Merge lp:~wallyworld/gwacl/azure-management-api-change into lp:gwacl
- azure-management-api-change
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ian Booth | ||||
Approved revision: | 230 | ||||
Merged at revision: | 227 | ||||
Proposed branch: | lp:~wallyworld/gwacl/azure-management-api-change | ||||
Merge into: | lp:gwacl | ||||
Diff against target: |
410 lines (+54/-50) 4 files modified
management_base.go (+22/-18) management_base_test.go (+30/-30) xmlobjects.go (+1/-1) xmlobjects_test.go (+1/-1) |
||||
To merge this branch: | bzr merge lp:~wallyworld/gwacl/azure-management-api-change | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julian Edwards (community) | Approve | ||
Review via email: mp+193368@code.launchpad.net |
Commit message
Azure now requires certain requests to the management api to have an updated version number in the header. Such changes are supposed to be backwards compatible but msft failed not to break existing applications. This branch includes the new api version. It also base64 encodes customdata sent with the request, as this also appears to have changed from underneath us.
With these changes, juju bootstrap now completes and the bootstrap instance spins up. Previously it would have errored part way through bootstrap. There still may be an issue with cloud-init completing properly but if this is the case, it appears to be a separate issue and I'd like to land this branch to allow others with Azure credentials to help debug.
Description of the change
Azure now requires certain requests to the management api to have an updated version number in the header. Such changes are supposed to be backwards compatible but msft failed not to break existing applications. This branch includes the new api version. It also base64 encodes customdata sent with the request, as this also appears to have changed from underneath us.
With these changes, juju bootstrap now completes and the bootstrap instance spins up. Previously it would have errored part way through bootstrap. There still may be an issue with cloud-init completing properly but if this is the case, it appears to be a separate issue and I'd like to land this branch to allow others with Azure credentials to help debug.
Julian Edwards (julian-edwards) wrote : | # |
Julian Edwards (julian-edwards) wrote : | # |
453 - customdata := MakeRandomStrin
454 + customdata := "customdata"
455 + base64EncodedCu
I'd feel better if you kept this random and calculated the expected base64 encoding.
Everything else looks cool.
Preview Diff
1 | === modified file 'management_base.go' | |||
2 | --- management_base.go 2013-08-09 14:59:50 +0000 | |||
3 | +++ management_base.go 2013-10-31 04:14:10 +0000 | |||
4 | @@ -11,6 +11,10 @@ | |||
5 | 11 | "time" | 11 | "time" |
6 | 12 | ) | 12 | ) |
7 | 13 | 13 | ||
8 | 14 | // Note: each API call is required to include a version string in the request header. | ||
9 | 15 | // These may often be the same string, but need to be kept as strings rather than being | ||
10 | 16 | // pulled out and replaced with a constant, each API call may be individually changed. | ||
11 | 17 | |||
12 | 14 | type ManagementAPI struct { | 18 | type ManagementAPI struct { |
13 | 15 | session *x509Session | 19 | session *x509Session |
14 | 16 | // The interval used when polling the server. | 20 | // The interval used when polling the server. |
15 | @@ -124,7 +128,7 @@ | |||
16 | 124 | // HostedService objects. | 128 | // HostedService objects. |
17 | 125 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460781.aspx | 129 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460781.aspx |
18 | 126 | func (api *ManagementAPI) ListHostedServices() ([]HostedServiceDescriptor, error) { | 130 | func (api *ManagementAPI) ListHostedServices() ([]HostedServiceDescriptor, error) { |
20 | 127 | res, err := api.session.get("services/hostedservices", "2012-03-01") | 131 | res, err := api.session.get("services/hostedservices", "2013-10-01") |
21 | 128 | if err != nil { | 132 | if err != nil { |
22 | 129 | return nil, err | 133 | return nil, err |
23 | 130 | } | 134 | } |
24 | @@ -144,7 +148,7 @@ | |||
25 | 144 | if err != nil { | 148 | if err != nil { |
26 | 145 | return err | 149 | return err |
27 | 146 | } | 150 | } |
29 | 147 | response, err := api.session.put(URI, "2012-03-01", []byte(body), "application/xml") | 151 | response, err := api.session.put(URI, "2013-10-01", []byte(body), "application/xml") |
30 | 148 | if err != nil { | 152 | if err != nil { |
31 | 149 | return err | 153 | return err |
32 | 150 | } | 154 | } |
33 | @@ -155,7 +159,7 @@ | |||
34 | 155 | // management API. | 159 | // management API. |
35 | 156 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460806.aspx | 160 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460806.aspx |
36 | 157 | func (api *ManagementAPI) GetHostedServiceProperties( | 161 | func (api *ManagementAPI) GetHostedServiceProperties( |
38 | 158 | serviceName string, embedDetail bool) (*HostedService, error) { | 162 | serviceName string, embedDetail bool) (*HostedService, error) { |
39 | 159 | checkPathComponents(serviceName) | 163 | checkPathComponents(serviceName) |
40 | 160 | URI := "services/hostedservices/" + serviceName + "?embed-detail=" | 164 | URI := "services/hostedservices/" + serviceName + "?embed-detail=" |
41 | 161 | switch embedDetail { | 165 | switch embedDetail { |
42 | @@ -164,7 +168,7 @@ | |||
43 | 164 | case false: | 168 | case false: |
44 | 165 | URI += "false" | 169 | URI += "false" |
45 | 166 | } | 170 | } |
47 | 167 | res, err := api.session.get(URI, "2012-03-01") | 171 | res, err := api.session.get(URI, "2013-10-01") |
48 | 168 | if err != nil { | 172 | if err != nil { |
49 | 169 | return nil, err | 173 | return nil, err |
50 | 170 | } | 174 | } |
51 | @@ -184,7 +188,7 @@ | |||
52 | 184 | if err != nil { | 188 | if err != nil { |
53 | 185 | return err | 189 | return err |
54 | 186 | } | 190 | } |
56 | 187 | response, err := api.session.post(URI, "2012-03-01", []byte(body), "application/xml") | 191 | response, err := api.session.post(URI, "2013-10-01", []byte(body), "application/xml") |
57 | 188 | if err != nil { | 192 | if err != nil { |
58 | 189 | return err | 193 | return err |
59 | 190 | } | 194 | } |
60 | @@ -199,7 +203,7 @@ | |||
61 | 199 | func (api *ManagementAPI) CheckHostedServiceNameAvailability(name string) error { | 203 | func (api *ManagementAPI) CheckHostedServiceNameAvailability(name string) error { |
62 | 200 | var err error | 204 | var err error |
63 | 201 | response, err := api.session.get( | 205 | response, err := api.session.get( |
65 | 202 | "services/hostedservices/operations/isavailable/"+name, "2012-03-01") | 206 | "services/hostedservices/operations/isavailable/"+name, "2013-10-01") |
66 | 203 | if err != nil { | 207 | if err != nil { |
67 | 204 | return err | 208 | return err |
68 | 205 | } | 209 | } |
69 | @@ -240,7 +244,7 @@ | |||
70 | 240 | if err != nil { | 244 | if err != nil { |
71 | 241 | return err | 245 | return err |
72 | 242 | } | 246 | } |
74 | 243 | response, err := api.session.post(URI, "2012-03-01", []byte(body), "application/xml") | 247 | response, err := api.session.post(URI, "2013-10-01", []byte(body), "application/xml") |
75 | 244 | if err != nil { | 248 | if err != nil { |
76 | 245 | return err | 249 | return err |
77 | 246 | } | 250 | } |
78 | @@ -251,7 +255,7 @@ | |||
79 | 251 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx | 255 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx |
80 | 252 | func (api *ManagementAPI) DeleteDeployment(serviceName string, deploymentName string) error { | 256 | func (api *ManagementAPI) DeleteDeployment(serviceName string, deploymentName string) error { |
81 | 253 | path := "services/hostedservices/" + serviceName + "/deployments/" + deploymentName | 257 | path := "services/hostedservices/" + serviceName + "/deployments/" + deploymentName |
83 | 254 | response, err := api.session.delete(path, "2012-03-01") | 258 | response, err := api.session.delete(path, "2013-10-01") |
84 | 255 | if err != nil { | 259 | if err != nil { |
85 | 256 | if IsNotFoundError(err) { | 260 | if IsNotFoundError(err) { |
86 | 257 | return nil | 261 | return nil |
87 | @@ -273,7 +277,7 @@ | |||
88 | 273 | checkPathComponents(request.ServiceName) | 277 | checkPathComponents(request.ServiceName) |
89 | 274 | checkPathComponents(request.DeploymentName) | 278 | checkPathComponents(request.DeploymentName) |
90 | 275 | path := "services/hostedservices/" + request.ServiceName + "/deployments/" + request.DeploymentName | 279 | path := "services/hostedservices/" + request.ServiceName + "/deployments/" + request.DeploymentName |
92 | 276 | response, err := api.session.get(path, "2012-03-01") | 280 | response, err := api.session.get(path, "2013-10-01") |
93 | 277 | if err != nil { | 281 | if err != nil { |
94 | 278 | return nil, err | 282 | return nil, err |
95 | 279 | } | 283 | } |
96 | @@ -298,7 +302,7 @@ | |||
97 | 298 | if err != nil { | 302 | if err != nil { |
98 | 299 | return err | 303 | return err |
99 | 300 | } | 304 | } |
101 | 301 | response, err := api.session.post(uri, "2012-03-01", []byte(body), "application/xml") | 305 | response, err := api.session.post(uri, "2013-10-01", []byte(body), "application/xml") |
102 | 302 | if err != nil { | 306 | if err != nil { |
103 | 303 | return err | 307 | return err |
104 | 304 | } | 308 | } |
105 | @@ -395,7 +399,7 @@ | |||
106 | 395 | func (api *ManagementAPI) StartRole(request *StartRoleRequest) error { | 399 | func (api *ManagementAPI) StartRole(request *StartRoleRequest) error { |
107 | 396 | return api.performRoleOperation( | 400 | return api.performRoleOperation( |
108 | 397 | request.ServiceName, request.DeploymentName, request.RoleName, | 401 | request.ServiceName, request.DeploymentName, request.RoleName, |
110 | 398 | "2012-03-01", startRoleOperation) | 402 | "2013-10-01", startRoleOperation) |
111 | 399 | } | 403 | } |
112 | 400 | 404 | ||
113 | 401 | type RestartRoleRequest performRoleOperationRequest | 405 | type RestartRoleRequest performRoleOperationRequest |
114 | @@ -405,7 +409,7 @@ | |||
115 | 405 | func (api *ManagementAPI) RestartRole(request *RestartRoleRequest) error { | 409 | func (api *ManagementAPI) RestartRole(request *RestartRoleRequest) error { |
116 | 406 | return api.performRoleOperation( | 410 | return api.performRoleOperation( |
117 | 407 | request.ServiceName, request.DeploymentName, request.RoleName, | 411 | request.ServiceName, request.DeploymentName, request.RoleName, |
119 | 408 | "2012-03-01", restartRoleOperation) | 412 | "2013-10-01", restartRoleOperation) |
120 | 409 | } | 413 | } |
121 | 410 | 414 | ||
122 | 411 | type ShutdownRoleRequest performRoleOperationRequest | 415 | type ShutdownRoleRequest performRoleOperationRequest |
123 | @@ -415,7 +419,7 @@ | |||
124 | 415 | func (api *ManagementAPI) ShutdownRole(request *ShutdownRoleRequest) error { | 419 | func (api *ManagementAPI) ShutdownRole(request *ShutdownRoleRequest) error { |
125 | 416 | return api.performRoleOperation( | 420 | return api.performRoleOperation( |
126 | 417 | request.ServiceName, request.DeploymentName, request.RoleName, | 421 | request.ServiceName, request.DeploymentName, request.RoleName, |
128 | 418 | "2012-03-01", shutdownRoleOperation) | 422 | "2013-10-01", shutdownRoleOperation) |
129 | 419 | } | 423 | } |
130 | 420 | 424 | ||
131 | 421 | type GetRoleRequest performRoleOperationRequest | 425 | type GetRoleRequest performRoleOperationRequest |
132 | @@ -428,7 +432,7 @@ | |||
133 | 428 | url := ("services/hostedservices/" + request.ServiceName + | 432 | url := ("services/hostedservices/" + request.ServiceName + |
134 | 429 | "/deployments/" + request.DeploymentName + "/roles/" + | 433 | "/deployments/" + request.DeploymentName + "/roles/" + |
135 | 430 | request.RoleName) | 434 | request.RoleName) |
137 | 431 | response, err := api.session.get(url, "2012-03-01") | 435 | response, err := api.session.get(url, "2013-10-01") |
138 | 432 | if err != nil { | 436 | if err != nil { |
139 | 433 | return nil, err | 437 | return nil, err |
140 | 434 | } | 438 | } |
141 | @@ -463,7 +467,7 @@ | |||
142 | 463 | if err != nil { | 467 | if err != nil { |
143 | 464 | return err | 468 | return err |
144 | 465 | } | 469 | } |
146 | 466 | response, err := api.session.put(url, "2012-03-01", []byte(role), "application/xml") | 470 | response, err := api.session.put(url, "2013-10-01", []byte(role), "application/xml") |
147 | 467 | if err != nil { | 471 | if err != nil { |
148 | 468 | return err | 472 | return err |
149 | 469 | } | 473 | } |
150 | @@ -483,7 +487,7 @@ | |||
151 | 483 | if err != nil { | 487 | if err != nil { |
152 | 484 | return err | 488 | return err |
153 | 485 | } | 489 | } |
155 | 486 | response, err := api.session.post(url, "2012-03-01", []byte(body), "application/xml") | 490 | response, err := api.session.post(url, "2013-10-01", []byte(body), "application/xml") |
156 | 487 | if err != nil { | 491 | if err != nil { |
157 | 488 | return err | 492 | return err |
158 | 489 | } | 493 | } |
159 | @@ -536,7 +540,7 @@ | |||
160 | 536 | // be nil. | 540 | // be nil. |
161 | 537 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157196.aspx | 541 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157196.aspx |
162 | 538 | func (api *ManagementAPI) GetNetworkConfiguration() (*NetworkConfiguration, error) { | 542 | func (api *ManagementAPI) GetNetworkConfiguration() (*NetworkConfiguration, error) { |
164 | 539 | response, err := api.session.get("services/networking/media", "2012-03-01") | 543 | response, err := api.session.get("services/networking/media", "2013-10-01") |
165 | 540 | if err != nil { | 544 | if err != nil { |
166 | 541 | if IsNotFoundError(err) { | 545 | if IsNotFoundError(err) { |
167 | 542 | return nil, nil | 546 | return nil, nil |
168 | @@ -561,7 +565,7 @@ | |||
169 | 561 | return err | 565 | return err |
170 | 562 | } | 566 | } |
171 | 563 | response, err := api.session.put( | 567 | response, err := api.session.put( |
173 | 564 | "services/networking/media", "2012-03-01", []byte(body), | 568 | "services/networking/media", "2013-10-01", []byte(body), |
174 | 565 | "application/octet-stream") | 569 | "application/octet-stream") |
175 | 566 | if err != nil { | 570 | if err != nil { |
176 | 567 | return err | 571 | return err |
177 | 568 | 572 | ||
178 | === modified file 'management_base_test.go' | |||
179 | --- management_base_test.go 2013-08-28 00:13:04 +0000 | |||
180 | +++ management_base_test.go 2013-10-31 04:14:10 +0000 | |||
181 | @@ -412,7 +412,7 @@ | |||
182 | 412 | 412 | ||
183 | 413 | c.Assert(err, IsNil) | 413 | c.Assert(err, IsNil) |
184 | 414 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices" | 414 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices" |
186 | 415 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", nil, "GET") | 415 | checkOneRequest(c, &recordedRequests, expectedURL, "2013-10-01", nil, "GET") |
187 | 416 | c.Assert(descriptors[0].URL, Equals, url) | 416 | c.Assert(descriptors[0].URL, Equals, url) |
188 | 417 | } | 417 | } |
189 | 418 | 418 | ||
190 | @@ -442,7 +442,7 @@ | |||
191 | 442 | 442 | ||
192 | 443 | c.Assert(err, IsNil) | 443 | c.Assert(err, IsNil) |
193 | 444 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + serviceName | 444 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + serviceName |
195 | 445 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", requestPayload, "PUT") | 445 | checkOneRequest(c, &recordedRequests, expectedURL, "2013-10-01", requestPayload, "PUT") |
196 | 446 | } | 446 | } |
197 | 447 | 447 | ||
198 | 448 | func assertGetHostedServicePropertiesRequest(c *C, api *ManagementAPI, serviceName string, embedDetail bool, httpRequest *X509Request) { | 448 | func assertGetHostedServicePropertiesRequest(c *C, api *ManagementAPI, serviceName string, embedDetail bool, httpRequest *X509Request) { |
199 | @@ -454,7 +454,7 @@ | |||
200 | 454 | } | 454 | } |
201 | 455 | expectedURL := fmt.Sprintf("%s%s/services/hostedservices/%s?%s", defaultManagement, | 455 | expectedURL := fmt.Sprintf("%s%s/services/hostedservices/%s?%s", defaultManagement, |
202 | 456 | api.session.subscriptionId, serviceName, query) | 456 | api.session.subscriptionId, serviceName, query) |
204 | 457 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") | 457 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", nil, "GET") |
205 | 458 | } | 458 | } |
206 | 459 | 459 | ||
207 | 460 | func (suite *managementBaseAPISuite) TestGetHostedServiceProperties_withoutDetails(c *C) { | 460 | func (suite *managementBaseAPISuite) TestGetHostedServiceProperties_withoutDetails(c *C) { |
208 | @@ -563,7 +563,7 @@ | |||
209 | 563 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices" | 563 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices" |
210 | 564 | expectedPayload, err := marshalXML(createHostedService) | 564 | expectedPayload, err := marshalXML(createHostedService) |
211 | 565 | c.Assert(err, IsNil) | 565 | c.Assert(err, IsNil) |
213 | 566 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") | 566 | checkOneRequest(c, recordedRequests, expectedURL, "2013-10-01", expectedPayload, "POST") |
214 | 567 | } | 567 | } |
215 | 568 | 568 | ||
216 | 569 | func makeAvailabilityResponse(result, reason string) string { | 569 | func makeAvailabilityResponse(result, reason string) string { |
217 | @@ -591,8 +591,8 @@ | |||
218 | 591 | 591 | ||
219 | 592 | c.Assert(err, IsNil) | 592 | c.Assert(err, IsNil) |
220 | 593 | expectedURL := (defaultManagement + api.session.subscriptionId + | 593 | expectedURL := (defaultManagement + api.session.subscriptionId + |
223 | 594 | "/services/hostedservices/operations/isavailable/" + serviceName) | 594 | "/services/hostedservices/operations/isavailable/" + serviceName) |
224 | 595 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", nil, "GET") | 595 | checkOneRequest(c, &recordedRequests, expectedURL, "2013-10-01", nil, "GET") |
225 | 596 | } | 596 | } |
226 | 597 | 597 | ||
227 | 598 | func (*managementBaseAPISuite) TestAddHostedServiceWithBadName(c *C) { | 598 | func (*managementBaseAPISuite) TestAddHostedServiceWithBadName(c *C) { |
228 | @@ -613,8 +613,8 @@ | |||
229 | 613 | c.Assert(err, ErrorMatches, reason) | 613 | c.Assert(err, ErrorMatches, reason) |
230 | 614 | c.Check(recordedRequests, HasLen, 1) | 614 | c.Check(recordedRequests, HasLen, 1) |
231 | 615 | expectedURL := (defaultManagement + api.session.subscriptionId + | 615 | expectedURL := (defaultManagement + api.session.subscriptionId + |
234 | 616 | "/services/hostedservices/operations/isavailable/" + serviceName) | 616 | "/services/hostedservices/operations/isavailable/" + serviceName) |
235 | 617 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", nil, "GET") | 617 | checkOneRequest(c, &recordedRequests, expectedURL, "2013-10-01", nil, "GET") |
236 | 618 | } | 618 | } |
237 | 619 | 619 | ||
238 | 620 | func (*managementBaseAPISuite) TestAddHostedServiceWithServerError(c *C) { | 620 | func (*managementBaseAPISuite) TestAddHostedServiceWithServerError(c *C) { |
239 | @@ -689,14 +689,14 @@ | |||
240 | 689 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + serviceName + "/deployments" | 689 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + serviceName + "/deployments" |
241 | 690 | expectedPayload, err := marshalXML(deployment) | 690 | expectedPayload, err := marshalXML(deployment) |
242 | 691 | c.Assert(err, IsNil) | 691 | c.Assert(err, IsNil) |
244 | 692 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") | 692 | checkOneRequest(c, recordedRequests, expectedURL, "2013-10-01", expectedPayload, "POST") |
245 | 693 | } | 693 | } |
246 | 694 | 694 | ||
247 | 695 | func assertDeleteDeploymentRequest(c *C, api *ManagementAPI, hostedServiceName, deploymentName string, httpRequest *X509Request) { | 695 | func assertDeleteDeploymentRequest(c *C, api *ManagementAPI, hostedServiceName, deploymentName string, httpRequest *X509Request) { |
248 | 696 | expectedURL := fmt.Sprintf( | 696 | expectedURL := fmt.Sprintf( |
249 | 697 | "%s%s/services/hostedservices/%s/deployments/%s", defaultManagement, | 697 | "%s%s/services/hostedservices/%s/deployments/%s", defaultManagement, |
250 | 698 | api.session.subscriptionId, hostedServiceName, deploymentName) | 698 | api.session.subscriptionId, hostedServiceName, deploymentName) |
252 | 699 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "DELETE") | 699 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", nil, "DELETE") |
253 | 700 | } | 700 | } |
254 | 701 | 701 | ||
255 | 702 | func (suite *managementBaseAPISuite) TestDeleteDeployment(c *C) { | 702 | func (suite *managementBaseAPISuite) TestDeleteDeployment(c *C) { |
256 | @@ -795,7 +795,7 @@ | |||
257 | 795 | expectedURL := fmt.Sprintf( | 795 | expectedURL := fmt.Sprintf( |
258 | 796 | "%s%s/services/hostedservices/%s/deployments/%s", defaultManagement, | 796 | "%s%s/services/hostedservices/%s/deployments/%s", defaultManagement, |
259 | 797 | api.session.subscriptionId, request.ServiceName, request.DeploymentName) | 797 | api.session.subscriptionId, request.ServiceName, request.DeploymentName) |
261 | 798 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") | 798 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", nil, "GET") |
262 | 799 | } | 799 | } |
263 | 800 | 800 | ||
264 | 801 | func (suite *managementBaseAPISuite) TestGetDeployment(c *C) { | 801 | func (suite *managementBaseAPISuite) TestGetDeployment(c *C) { |
265 | @@ -838,7 +838,7 @@ | |||
266 | 838 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/storageservices" | 838 | expectedURL := defaultManagement + api.session.subscriptionId + "/services/storageservices" |
267 | 839 | expectedPayload, err := marshalXML(cssi) | 839 | expectedPayload, err := marshalXML(cssi) |
268 | 840 | c.Assert(err, IsNil) | 840 | c.Assert(err, IsNil) |
270 | 841 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") | 841 | checkOneRequest(c, &recordedRequests, expectedURL, "2013-10-01", expectedPayload, "POST") |
271 | 842 | } | 842 | } |
272 | 843 | 843 | ||
273 | 844 | func (suite *managementBaseAPISuite) TestDeleteStorageAccount(c *C) { | 844 | func (suite *managementBaseAPISuite) TestDeleteStorageAccount(c *C) { |
274 | @@ -967,11 +967,11 @@ | |||
275 | 967 | err := api.StartRole(request) | 967 | err := api.StartRole(request) |
276 | 968 | c.Assert(err, IsNil) | 968 | c.Assert(err, IsNil) |
277 | 969 | expectedURL := (defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + | 969 | expectedURL := (defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + |
280 | 970 | request.ServiceName + "/deployments/" + request.DeploymentName + "/roleinstances/" + | 970 | request.ServiceName + "/deployments/" + request.DeploymentName + "/roleinstances/" + |
281 | 971 | request.RoleName + "/Operations") | 971 | request.RoleName + "/Operations") |
282 | 972 | expectedPayload, err := marshalXML(startRoleOperation) | 972 | expectedPayload, err := marshalXML(startRoleOperation) |
283 | 973 | c.Assert(err, IsNil) | 973 | c.Assert(err, IsNil) |
285 | 974 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") | 974 | checkOneRequest(c, recordedRequests, expectedURL, "2013-10-01", expectedPayload, "POST") |
286 | 975 | } | 975 | } |
287 | 976 | 976 | ||
288 | 977 | func (suite *managementBaseAPISuite) TestRestartRole(c *C) { | 977 | func (suite *managementBaseAPISuite) TestRestartRole(c *C) { |
289 | @@ -981,11 +981,11 @@ | |||
290 | 981 | err := api.RestartRole(request) | 981 | err := api.RestartRole(request) |
291 | 982 | c.Assert(err, IsNil) | 982 | c.Assert(err, IsNil) |
292 | 983 | expectedURL := (defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + | 983 | expectedURL := (defaultManagement + api.session.subscriptionId + "/services/hostedservices/" + |
295 | 984 | request.ServiceName + "/deployments/" + request.DeploymentName + "/roleinstances/" + | 984 | request.ServiceName + "/deployments/" + request.DeploymentName + "/roleinstances/" + |
296 | 985 | request.RoleName + "/Operations") | 985 | request.RoleName + "/Operations") |
297 | 986 | expectedPayload, err := marshalXML(restartRoleOperation) | 986 | expectedPayload, err := marshalXML(restartRoleOperation) |
298 | 987 | c.Assert(err, IsNil) | 987 | c.Assert(err, IsNil) |
300 | 988 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") | 988 | checkOneRequest(c, recordedRequests, expectedURL, "2013-10-01", expectedPayload, "POST") |
301 | 989 | } | 989 | } |
302 | 990 | 990 | ||
303 | 991 | func assertShutdownRoleRequest(c *C, api *ManagementAPI, request *ShutdownRoleRequest, httpRequest *X509Request) { | 991 | func assertShutdownRoleRequest(c *C, api *ManagementAPI, request *ShutdownRoleRequest, httpRequest *X509Request) { |
304 | @@ -995,7 +995,7 @@ | |||
305 | 995 | request.DeploymentName, request.RoleName) | 995 | request.DeploymentName, request.RoleName) |
306 | 996 | expectedPayload, err := marshalXML(shutdownRoleOperation) | 996 | expectedPayload, err := marshalXML(shutdownRoleOperation) |
307 | 997 | c.Assert(err, IsNil) | 997 | c.Assert(err, IsNil) |
309 | 998 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", expectedPayload, "POST") | 998 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", expectedPayload, "POST") |
310 | 999 | } | 999 | } |
311 | 1000 | 1000 | ||
312 | 1001 | func (suite *managementBaseAPISuite) TestShutdownRole(c *C) { | 1001 | func (suite *managementBaseAPISuite) TestShutdownRole(c *C) { |
313 | @@ -1010,9 +1010,9 @@ | |||
314 | 1010 | 1010 | ||
315 | 1011 | func assertGetRoleRequest(c *C, api *ManagementAPI, httpRequest *X509Request, serviceName, deploymentName, roleName string) { | 1011 | func assertGetRoleRequest(c *C, api *ManagementAPI, httpRequest *X509Request, serviceName, deploymentName, roleName string) { |
316 | 1012 | expectedURL := (defaultManagement + api.session.subscriptionId + | 1012 | expectedURL := (defaultManagement + api.session.subscriptionId + |
320 | 1013 | "/services/hostedservices/" + | 1013 | "/services/hostedservices/" + |
321 | 1014 | serviceName + "/deployments/" + deploymentName + "/roles/" + roleName) | 1014 | serviceName + "/deployments/" + deploymentName + "/roles/" + roleName) |
322 | 1015 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") | 1015 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", nil, "GET") |
323 | 1016 | } | 1016 | } |
324 | 1017 | 1017 | ||
325 | 1018 | func (suite *managementBaseAPISuite) TestGetRole(c *C) { | 1018 | func (suite *managementBaseAPISuite) TestGetRole(c *C) { |
326 | @@ -1038,10 +1038,10 @@ | |||
327 | 1038 | 1038 | ||
328 | 1039 | func assertUpdateRoleRequest(c *C, api *ManagementAPI, httpRequest *X509Request, serviceName, deploymentName, roleName, expectedXML string) { | 1039 | func assertUpdateRoleRequest(c *C, api *ManagementAPI, httpRequest *X509Request, serviceName, deploymentName, roleName, expectedXML string) { |
329 | 1040 | expectedURL := (defaultManagement + api.session.subscriptionId + | 1040 | expectedURL := (defaultManagement + api.session.subscriptionId + |
332 | 1041 | "/services/hostedservices/" + | 1041 | "/services/hostedservices/" + |
333 | 1042 | serviceName + "/deployments/" + deploymentName + "/roles/" + roleName) | 1042 | serviceName + "/deployments/" + deploymentName + "/roles/" + roleName) |
334 | 1043 | checkRequest( | 1043 | checkRequest( |
336 | 1044 | c, httpRequest, expectedURL, "2012-03-01", []byte(expectedXML), "PUT") | 1044 | c, httpRequest, expectedURL, "2013-10-01", []byte(expectedXML), "PUT") |
337 | 1045 | c.Assert(httpRequest.ContentType, Equals, "application/xml") | 1045 | c.Assert(httpRequest.ContentType, Equals, "application/xml") |
338 | 1046 | } | 1046 | } |
339 | 1047 | 1047 | ||
340 | @@ -1126,7 +1126,7 @@ | |||
341 | 1126 | 1126 | ||
342 | 1127 | expectedURL := defaultManagement + api.session.subscriptionId + "/affinitygroups" | 1127 | expectedURL := defaultManagement + api.session.subscriptionId + "/affinitygroups" |
343 | 1128 | expectedBody, _ := cag.Serialize() | 1128 | expectedBody, _ := cag.Serialize() |
345 | 1129 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", []byte(expectedBody), "POST") | 1129 | checkOneRequest(c, &recordedRequests, expectedURL, "2013-10-01", []byte(expectedBody), "POST") |
346 | 1130 | } | 1130 | } |
347 | 1131 | 1131 | ||
348 | 1132 | func (suite *managementBaseAPISuite) TestUpdateAffinityGroup(c *C) { | 1132 | func (suite *managementBaseAPISuite) TestUpdateAffinityGroup(c *C) { |
349 | @@ -1145,7 +1145,7 @@ | |||
350 | 1145 | c.Assert(err, IsNil) | 1145 | c.Assert(err, IsNil) |
351 | 1146 | 1146 | ||
352 | 1147 | expectedURL := (defaultManagement + api.session.subscriptionId + | 1147 | expectedURL := (defaultManagement + api.session.subscriptionId + |
354 | 1148 | "/affinitygroups/" + request.Name) | 1148 | "/affinitygroups/" + request.Name) |
355 | 1149 | expectedBody, _ := uag.Serialize() | 1149 | expectedBody, _ := uag.Serialize() |
356 | 1150 | checkOneRequest(c, &recordedRequests, expectedURL, "2011-02-25", []byte(expectedBody), "PUT") | 1150 | checkOneRequest(c, &recordedRequests, expectedURL, "2011-02-25", []byte(expectedBody), "PUT") |
357 | 1151 | } | 1151 | } |
358 | @@ -1164,7 +1164,7 @@ | |||
359 | 1164 | c.Assert(err, IsNil) | 1164 | c.Assert(err, IsNil) |
360 | 1165 | 1165 | ||
361 | 1166 | expectedURL := (defaultManagement + api.session.subscriptionId + | 1166 | expectedURL := (defaultManagement + api.session.subscriptionId + |
363 | 1167 | "/affinitygroups/" + request.Name) | 1167 | "/affinitygroups/" + request.Name) |
364 | 1168 | checkOneRequest(c, &recordedRequests, expectedURL, "2011-02-25", nil, "DELETE") | 1168 | checkOneRequest(c, &recordedRequests, expectedURL, "2011-02-25", nil, "DELETE") |
365 | 1169 | } | 1169 | } |
366 | 1170 | 1170 | ||
367 | @@ -1232,7 +1232,7 @@ | |||
368 | 1232 | expectedURL := fmt.Sprintf( | 1232 | expectedURL := fmt.Sprintf( |
369 | 1233 | "%s%s/services/networking/media", defaultManagement, | 1233 | "%s%s/services/networking/media", defaultManagement, |
370 | 1234 | api.session.subscriptionId) | 1234 | api.session.subscriptionId) |
372 | 1235 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") | 1235 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", nil, "GET") |
373 | 1236 | } | 1236 | } |
374 | 1237 | 1237 | ||
375 | 1238 | func (suite *managementBaseAPISuite) TestGetNetworkConfiguration(c *C) { | 1238 | func (suite *managementBaseAPISuite) TestGetNetworkConfiguration(c *C) { |
376 | @@ -1271,7 +1271,7 @@ | |||
377 | 1271 | expectedURL := fmt.Sprintf( | 1271 | expectedURL := fmt.Sprintf( |
378 | 1272 | "%s%s/services/networking/media", defaultManagement, | 1272 | "%s%s/services/networking/media", defaultManagement, |
379 | 1273 | api.session.subscriptionId) | 1273 | api.session.subscriptionId) |
381 | 1274 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", body, "PUT") | 1274 | checkRequest(c, httpRequest, expectedURL, "2013-10-01", body, "PUT") |
382 | 1275 | // Azure chokes when the content type is text/xml or similar. | 1275 | // Azure chokes when the content type is text/xml or similar. |
383 | 1276 | c.Assert(httpRequest.ContentType, Equals, "application/octet-stream") | 1276 | c.Assert(httpRequest.ContentType, Equals, "application/octet-stream") |
384 | 1277 | } | 1277 | } |
385 | 1278 | 1278 | ||
386 | === modified file 'xmlobjects.go' | |||
387 | --- xmlobjects.go 2013-07-25 22:02:41 +0000 | |||
388 | +++ xmlobjects.go 2013-10-31 04:14:10 +0000 | |||
389 | @@ -89,7 +89,7 @@ | |||
390 | 89 | Hostname: Hostname, | 89 | Hostname: Hostname, |
391 | 90 | Username: Username, | 90 | Username: Username, |
392 | 91 | Password: Password, | 91 | Password: Password, |
394 | 92 | CustomData: CustomData, | 92 | CustomData: base64.StdEncoding.EncodeToString([]byte(CustomData)), |
395 | 93 | DisableSSHPasswordAuthentication: DisableSSHPasswordAuthentication, | 93 | DisableSSHPasswordAuthentication: DisableSSHPasswordAuthentication, |
396 | 94 | } | 94 | } |
397 | 95 | } | 95 | } |
398 | 96 | 96 | ||
399 | === modified file 'xmlobjects_test.go' | |||
400 | --- xmlobjects_test.go 2013-07-25 22:02:41 +0000 | |||
401 | +++ xmlobjects_test.go 2013-10-31 04:14:10 +0000 | |||
402 | @@ -1322,7 +1322,7 @@ | |||
403 | 1322 | c.Check(config.Hostname, Equals, hostname) | 1322 | c.Check(config.Hostname, Equals, hostname) |
404 | 1323 | c.Check(config.Username, Equals, username) | 1323 | c.Check(config.Username, Equals, username) |
405 | 1324 | c.Check(config.Password, Equals, password) | 1324 | c.Check(config.Password, Equals, password) |
407 | 1325 | c.Check(config.CustomData, Equals, customdata) | 1325 | c.Check(config.CustomData, Equals, base64.StdEncoding.EncodeToString([]byte(customdata))) |
408 | 1326 | c.Check(config.DisableSSHPasswordAuthentication, Equals, disablessh) | 1326 | c.Check(config.DisableSSHPasswordAuthentication, Equals, disablessh) |
409 | 1327 | c.Check(config.ConfigurationSetType, Equals, "LinuxProvisioningConfiguration") | 1327 | c.Check(config.ConfigurationSetType, Equals, "LinuxProvisioningConfiguration") |
410 | 1328 | } | 1328 | } |
<bigjools> wallyworld_: first comment - pease remove the factored version numbers
<wallyworld_> why?
<bigjools> I previously had someone stop doing that - each api request is separately versioned and if you factor it you will introduce subtle bugs
<wallyworld_> it kinda sucks having them all copied and pasted in the code
<bigjools> yes - but it needs to be done
<wallyworld_> ok then
<bigjools> I rooted out at least 3 bugs last time I unfactored it