Merge lp:~axwalk/gwacl/add-delete-role into lp:gwacl
- add-delete-role
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~axwalk/gwacl/add-delete-role |
Merge into: | lp:gwacl |
Diff against target: |
505 lines (+212/-53) 9 files modified
example/management/run.go (+2/-3) management.go (+1/-3) management_base.go (+51/-0) management_base_test.go (+71/-1) management_test.go (+6/-10) x509dispatcher.go (+14/-2) x509dispatcher_test.go (+25/-0) xmlobjects.go (+19/-21) xmlobjects_test.go (+23/-13) |
To merge this branch: | bzr merge lp:~axwalk/gwacl/add-delete-role |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
GWACL Hackers | Pending | ||
Review via email: mp+210120@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-03-10.
Commit message
Description of the change
Introduce AddRole, DeleteRole; add missing Role fields
Two more management service API methods are added: AddRole
and DeleteRole (operating on deployments). These are
required when working with Availability Sets, where a role
must be added to an existing Cloud Service.
PersistentVMRole has been changed to be an alias for Role,
which has been expanded to include missing fields.
PersistentVMRole continues to have its own serialisation
methods, so it gets the correct XML tag name and namespace.
Roles can only have a single OS disk, so I've changed the
signature of NewRole to reflect this. Roles may have
additional data disks.
- 234. By Andrew Wilkins
-
Fix copy and paste error
Unmerged revisions
Preview Diff
1 | === modified file 'example/management/run.go' |
2 | --- example/management/run.go 2013-10-31 08:10:35 +0000 |
3 | +++ example/management/run.go 2014-03-10 04:06:20 +0000 |
4 | @@ -214,9 +214,8 @@ |
5 | diskLabel := makeRandomIdentifier("gwacl", 64) |
6 | vhd := gwacl.NewOSVirtualHardDisk("", diskLabel, diskName, mediaLink, sourceImageName, "Linux") |
7 | roleName := gwacl.MakeRandomRoleName("gwaclrole") |
8 | - role := gwacl.NewRole("ExtraSmall", roleName, |
9 | - []gwacl.ConfigurationSet{*linuxConfigurationSet, *networkConfigurationSet}, |
10 | - []gwacl.OSVirtualHardDisk{*vhd}) |
11 | + role := gwacl.NewRole("ExtraSmall", roleName, vhd, |
12 | + []gwacl.ConfigurationSet{*linuxConfigurationSet, *networkConfigurationSet}) |
13 | machineName := makeRandomIdentifier("gwaclmachine", 20) |
14 | deployment := gwacl.NewDeploymentForCreateVMDeployment( |
15 | machineName, "Production", machineName, []gwacl.Role{*role}, virtualNetworkName) |
16 | |
17 | === modified file 'management.go' |
18 | --- management.go 2013-08-28 00:13:04 +0000 |
19 | +++ management.go 2014-03-10 04:06:20 +0000 |
20 | @@ -140,9 +140,7 @@ |
21 | // 1. Get the list of the VM disks. |
22 | diskNameMap := make(map[string]bool) |
23 | for _, role := range deployment.RoleList { |
24 | - for _, osVHD := range role.OSVirtualHardDisk { |
25 | - diskNameMap[osVHD.DiskName] = true |
26 | - } |
27 | + diskNameMap[role.OSVirtualHardDisk.DiskName] = true |
28 | } |
29 | // 2. Delete deployment. This will delete all the role instances inside |
30 | // this deployment as a side effect. |
31 | |
32 | === modified file 'management_base.go' |
33 | --- management_base.go 2013-10-31 04:16:38 +0000 |
34 | +++ management_base.go 2014-03-10 04:06:20 +0000 |
35 | @@ -474,6 +474,57 @@ |
36 | return api.blockUntilCompleted(response) |
37 | } |
38 | |
39 | +type DeleteRoleRequest struct { |
40 | + ServiceName string |
41 | + DeploymentName string |
42 | + RoleName string |
43 | + DeleteMedia bool |
44 | +} |
45 | + |
46 | +// DeleteRole deletes a named Role from within the specified Cloud Service |
47 | +// and Deployment. |
48 | +// See http://msdn.microsoft.com/en-us/library/windowsazure/jj157187.aspx |
49 | +func (api *ManagementAPI) DeleteRole(request *DeleteRoleRequest) error { |
50 | + checkPathComponents(request.ServiceName, request.DeploymentName, request.RoleName) |
51 | + url := ("services/hostedservices/" + request.ServiceName + |
52 | + "/deployments/" + request.DeploymentName + "/roles/" + request.RoleName) |
53 | + if request.DeleteMedia { |
54 | + url = addURLQueryParams(url, "comp", "media") |
55 | + } |
56 | + response, err := api.session.delete(url, "2013-08-01") |
57 | + if err != nil { |
58 | + if IsNotFoundError(err) { |
59 | + return nil |
60 | + } |
61 | + return err |
62 | + } |
63 | + return api.blockUntilCompleted(response) |
64 | +} |
65 | + |
66 | +type AddRoleRequest struct { |
67 | + ServiceName string |
68 | + DeploymentName string |
69 | + PersistentVMRole *PersistentVMRole |
70 | +} |
71 | + |
72 | +// AddRole creates a new Role within the specified Cloud Service |
73 | +// and Deployment. |
74 | +// See http://msdn.microsoft.com/en-us/library/windowsazure/jj157187.aspx |
75 | +func (api *ManagementAPI) AddRole(request *AddRoleRequest) error { |
76 | + checkPathComponents(request.ServiceName, request.DeploymentName) |
77 | + url := ("services/hostedservices/" + request.ServiceName + |
78 | + "/deployments/" + request.DeploymentName + "/roles") |
79 | + role, err := request.PersistentVMRole.Serialize() |
80 | + if err != nil { |
81 | + return err |
82 | + } |
83 | + response, err := api.session.post(url, "2013-10-01", []byte(role), "application/xml") |
84 | + if err != nil { |
85 | + return err |
86 | + } |
87 | + return api.blockUntilCompleted(response) |
88 | +} |
89 | + |
90 | type CreateAffinityGroupRequest struct { |
91 | CreateAffinityGroup *CreateAffinityGroup |
92 | } |
93 | |
94 | === modified file 'management_base_test.go' |
95 | --- management_base_test.go 2013-10-31 04:16:38 +0000 |
96 | +++ management_base_test.go 2014-03-10 04:06:20 +0000 |
97 | @@ -681,7 +681,7 @@ |
98 | serviceName := "serviceName" |
99 | configurationSet := NewLinuxProvisioningConfigurationSet("testHostname12345", "test", "test123#@!", "user-data", "false") |
100 | vhd := NewOSVirtualHardDisk("hostCaching", "diskLabel", "diskName", "http://mediaLink", "sourceImageName", "os") |
101 | - role := NewRole("ExtraSmall", "test-role-123", []ConfigurationSet{*configurationSet}, []OSVirtualHardDisk{*vhd}) |
102 | + role := NewRole("ExtraSmall", "test-role-123", vhd, []ConfigurationSet{*configurationSet}) |
103 | deployment := NewDeploymentForCreateVMDeployment("test-machine-name", "Staging", "testLabel", []Role{*role}, "testNetwork") |
104 | err := api.AddDeployment(deployment, serviceName) |
105 | |
106 | @@ -1109,6 +1109,76 @@ |
107 | c.Check(recordedRequests[1].URL, Matches, ".*/operations/foobar") |
108 | } |
109 | |
110 | +func assertDeleteRoleRequest(c *C, api *ManagementAPI, httpRequest *X509Request, serviceName, deploymentName, roleName string, deleteMedia bool) { |
111 | + expectedURL := (defaultManagement + api.session.subscriptionId + |
112 | + "/services/hostedservices/" + |
113 | + serviceName + "/deployments/" + deploymentName + "/roles/" + roleName) |
114 | + if deleteMedia { |
115 | + expectedURL += "?comp=media" |
116 | + } |
117 | + checkRequest( |
118 | + c, httpRequest, expectedURL, "2013-08-01", nil, "DELETE") |
119 | +} |
120 | + |
121 | +func (suite *managementBaseAPISuite) TestDeleteRole(c *C) { |
122 | + suite.testDeleteRole(c, false) |
123 | +} |
124 | + |
125 | +func (suite *managementBaseAPISuite) TestDeleteRoleDeleteMedia(c *C) { |
126 | + suite.testDeleteRole(c, true) |
127 | +} |
128 | + |
129 | +func (suite *managementBaseAPISuite) testDeleteRole(c *C, deleteMedia bool) { |
130 | + api := makeAPI(c) |
131 | + request := &DeleteRoleRequest{ |
132 | + ServiceName: "serviceName", |
133 | + DeploymentName: "deploymentName", |
134 | + RoleName: "roleName", |
135 | + DeleteMedia: deleteMedia, |
136 | + } |
137 | + rigFixedResponseDispatcher(&x509Response{StatusCode: http.StatusOK}) |
138 | + recordedRequests := make([]*X509Request, 0) |
139 | + rigRecordingDispatcher(&recordedRequests) |
140 | + |
141 | + err := api.DeleteRole(request) |
142 | + c.Assert(err, IsNil) |
143 | + assertDeleteRoleRequest( |
144 | + c, api, recordedRequests[0], request.ServiceName, |
145 | + request.DeploymentName, request.RoleName, deleteMedia) |
146 | +} |
147 | + |
148 | +func assertAddRoleRequest(c *C, api *ManagementAPI, httpRequest *X509Request, serviceName, deploymentName, expectedXML string) { |
149 | + expectedURL := (defaultManagement + api.session.subscriptionId + |
150 | + "/services/hostedservices/" + |
151 | + serviceName + "/deployments/" + deploymentName + "/roles") |
152 | + checkRequest( |
153 | + c, httpRequest, expectedURL, "2013-10-01", []byte(expectedXML), "POST") |
154 | + c.Assert(httpRequest.ContentType, Equals, "application/xml") |
155 | +} |
156 | + |
157 | +func (suite *managementBaseAPISuite) TestAddRole(c *C) { |
158 | + api := makeAPI(c) |
159 | + request := &UpdateRoleRequest{ |
160 | + ServiceName: "serviceName", |
161 | + DeploymentName: "deploymentName", |
162 | + PersistentVMRole: &PersistentVMRole{ |
163 | + RoleName: "newRoleNamePerhaps", |
164 | + }, |
165 | + } |
166 | + rigFixedResponseDispatcher(&x509Response{StatusCode: http.StatusOK}) |
167 | + recordedRequests := make([]*X509Request, 0) |
168 | + rigRecordingDispatcher(&recordedRequests) |
169 | + |
170 | + err := api.UpdateRole(request) |
171 | + c.Assert(err, IsNil) |
172 | + |
173 | + expectedXML, err := request.PersistentVMRole.Serialize() |
174 | + c.Assert(err, IsNil) |
175 | + assertUpdateRoleRequest( |
176 | + c, api, recordedRequests[0], request.ServiceName, |
177 | + request.DeploymentName, request.RoleName, expectedXML) |
178 | +} |
179 | + |
180 | func (suite *managementBaseAPISuite) TestCreateAffinityGroup(c *C) { |
181 | api := makeAPI(c) |
182 | cag := NewCreateAffinityGroup( |
183 | |
184 | === modified file 'management_test.go' |
185 | --- management_test.go 2013-08-28 00:13:04 +0000 |
186 | +++ management_test.go 2014-03-10 04:06:20 +0000 |
187 | @@ -265,10 +265,8 @@ |
188 | return &Deployment{ |
189 | RoleInstanceList: makeNamedRoleInstances("one", "two"), |
190 | RoleList: []Role{ |
191 | - {OSVirtualHardDisk: []OSVirtualHardDisk{ |
192 | - {DiskName: "disk1"}, {DiskName: "disk2"}}}, |
193 | - {OSVirtualHardDisk: []OSVirtualHardDisk{ |
194 | - {DiskName: "disk1"}, {DiskName: "disk3"}}}, |
195 | + {OSVirtualHardDisk: &OSVirtualHardDisk{DiskName: "disk1"}}, |
196 | + {OSVirtualHardDisk: &OSVirtualHardDisk{DiskName: "disk2"}}, |
197 | }, |
198 | } |
199 | } |
200 | @@ -292,14 +290,13 @@ |
201 | } |
202 | err := api.DestroyDeployment(request) |
203 | c.Assert(err, IsNil) |
204 | - c.Check(record, HasLen, 5) |
205 | + c.Check(record, HasLen, 4) |
206 | assertGetDeploymentRequest(c, api, &GetDeploymentRequest{ |
207 | request.ServiceName, request.DeploymentName}, record[0]) |
208 | assertDeleteDeploymentRequest(c, api, request.ServiceName, |
209 | request.DeploymentName, record[1]) |
210 | assertDeleteDiskRequest(c, api, "disk1", record[2], true) |
211 | assertDeleteDiskRequest(c, api, "disk2", record[3], true) |
212 | - assertDeleteDiskRequest(c, api, "disk3", record[4], true) |
213 | } |
214 | |
215 | func (suite *suiteDestroyDeployment) TestOkayWhenDeploymentNotFound(c *C) { |
216 | @@ -338,14 +335,13 @@ |
217 | } |
218 | err := api.DestroyDeployment(request) |
219 | c.Assert(err, IsNil) |
220 | - c.Check(record, HasLen, 5) |
221 | + c.Check(record, HasLen, 4) |
222 | assertGetDeploymentRequest(c, api, &GetDeploymentRequest{ |
223 | request.ServiceName, request.DeploymentName}, record[0]) |
224 | assertDeleteDeploymentRequest(c, api, request.ServiceName, |
225 | request.DeploymentName, record[1]) |
226 | assertDeleteDiskRequest(c, api, "disk1", record[2], true) |
227 | assertDeleteDiskRequest(c, api, "disk2", record[3], true) |
228 | - assertDeleteDiskRequest(c, api, "disk3", record[4], true) |
229 | } |
230 | |
231 | func (suite *suiteDestroyDeployment) TestFailsGettingDeployment(c *C) { |
232 | @@ -393,7 +389,7 @@ |
233 | exampleDeployment := suite.makeExampleDeployment() |
234 | responses = append(responses, makeOKXMLResponse(c, exampleDeployment)...) |
235 | // For deleting disks. |
236 | - responses = append(responses, exampleOkayResponse, exampleOkayResponse, exampleOkayResponse) |
237 | + responses = append(responses, exampleOkayResponse, exampleOkayResponse) |
238 | // For other requests. |
239 | responses = append(responses, exampleFailResponse) |
240 | record := []*X509Request{} |
241 | @@ -407,7 +403,7 @@ |
242 | err := api.DestroyDeployment(request) |
243 | c.Assert(err, NotNil) |
244 | c.Check(err, ErrorMatches, "DELETE request failed [(]500: Internal Server Error[)]") |
245 | - c.Check(record, HasLen, 5) |
246 | + c.Check(record, HasLen, 4) |
247 | } |
248 | |
249 | type suiteDestroyHostedService struct{} |
250 | |
251 | === modified file 'x509dispatcher.go' |
252 | --- x509dispatcher.go 2014-02-05 04:46:09 +0000 |
253 | +++ x509dispatcher.go 2014-03-10 04:06:20 +0000 |
254 | @@ -6,7 +6,7 @@ |
255 | import ( |
256 | "bytes" |
257 | "fmt" |
258 | - "io/ioutil" |
259 | + "io" |
260 | "launchpad.net/gwacl/fork/http" |
261 | . "launchpad.net/gwacl/logging" |
262 | "net/url" |
263 | @@ -70,6 +70,17 @@ |
264 | Header http.Header |
265 | } |
266 | |
267 | +// rewindCloser returns an io.ReadCloser that seeks back |
268 | +// to the beginning of the reader upong Close being called. |
269 | +type rewindCloser struct { |
270 | + io.ReadSeeker |
271 | +} |
272 | + |
273 | +func (c rewindCloser) Close() error { |
274 | + _, err := c.Seek(0, 0) |
275 | + return err |
276 | +} |
277 | + |
278 | func performX509Request(session *x509Session, request *X509Request) (*x509Response, error) { |
279 | response := &x509Response{} |
280 | |
281 | @@ -78,11 +89,12 @@ |
282 | Debugf("Request body:\n%s", request.Payload) |
283 | } |
284 | |
285 | - bodyReader := ioutil.NopCloser(bytes.NewReader(request.Payload)) |
286 | + bodyReader := rewindCloser{bytes.NewReader(request.Payload)} |
287 | httpRequest, err := http.NewRequest(request.Method, request.URL, bodyReader) |
288 | if err != nil { |
289 | return nil, err |
290 | } |
291 | + httpRequest.ContentLength = int64(len(request.Payload)) |
292 | httpRequest.Header.Set("Content-Type", request.ContentType) |
293 | httpRequest.Header.Set("x-ms-version", request.APIVersion) |
294 | retrier := session.retryPolicy.getForkedHttpRetrier(session.client) |
295 | |
296 | === modified file 'x509dispatcher_test.go' |
297 | --- x509dispatcher_test.go 2014-02-05 04:46:09 +0000 |
298 | +++ x509dispatcher_test.go 2014-03-10 04:06:20 +0000 |
299 | @@ -219,6 +219,31 @@ |
300 | } |
301 | } |
302 | |
303 | +func (*x509DispatcherSuite) TestRedirectRewindsBody(c *C) { |
304 | + httpRequests := make(chan *Request, 2) |
305 | + serverConflict := makeRecordingHTTPServer(httpRequests, http.StatusConflict, nil, nil) |
306 | + defer serverConflict.Close() |
307 | + redirPath := "/else/where" |
308 | + responseHeaders := make(http.Header) |
309 | + responseHeaders.Set("Location", serverConflict.URL+redirPath) |
310 | + serverRedir := makeRecordingHTTPServer(httpRequests, http.StatusTemporaryRedirect, nil, responseHeaders) |
311 | + defer serverRedir.Close() |
312 | + session, err := newX509Session("subscriptionid", "", "West US", NoRetryPolicy) |
313 | + c.Assert(err, IsNil) |
314 | + path := "/foo/bar" |
315 | + version := "test-version" |
316 | + content := []byte("ponies") |
317 | + contentType := "text/plain" |
318 | + |
319 | + request := newX509RequestPOST(serverRedir.URL+path, version, content, contentType) |
320 | + response, err := performX509Request(session, request) |
321 | + c.Assert(err, IsNil) |
322 | + c.Assert(response.StatusCode, Equals, http.StatusConflict) |
323 | + c.Assert(httpRequests, HasLen, 2) |
324 | + c.Assert((<-httpRequests).BodyContent, DeepEquals, content) |
325 | + c.Assert((<-httpRequests).BodyContent, DeepEquals, content) |
326 | +} |
327 | + |
328 | func (*x509DispatcherSuite) TestRequestsLimitRedirects(c *C) { |
329 | httpRequests := make(chan *Request, 10) |
330 | serverRedir := makeRecordingHTTPServer(httpRequests, http.StatusTemporaryRedirect, nil, nil) |
331 | |
332 | === modified file 'xmlobjects.go' |
333 | --- xmlobjects.go 2013-10-31 07:59:14 +0000 |
334 | +++ xmlobjects.go 2014-03-10 04:06:20 +0000 |
335 | @@ -109,7 +109,7 @@ |
336 | // |
337 | |
338 | type LoadBalancerProbe struct { |
339 | - Path string `xml:"Path"` |
340 | + Path string `xml:"Path,omitempty"` |
341 | Port int `xml:"Port"` // Not uint16; see https://bugs.launchpad.net/juju-core/+bug/1201880 |
342 | Protocol string `xml:"Protocol"` |
343 | } |
344 | @@ -310,11 +310,16 @@ |
345 | } |
346 | |
347 | type Role struct { |
348 | - RoleName string `xml:"RoleName"` |
349 | - RoleType string `xml:"RoleType"` // Always "PersistentVMRole" |
350 | - ConfigurationSets []ConfigurationSet `xml:"ConfigurationSets>ConfigurationSet"` |
351 | - OSVirtualHardDisk []OSVirtualHardDisk `xml:"OSVirtualHardDisk"` |
352 | - RoleSize string `xml:"RoleSize"` |
353 | + XMLNS string `xml:"xmlns,attr,omitempty"` |
354 | + RoleName string `xml:"RoleName"` |
355 | + OsVersion string `xml:"OsVersion,omitempty"` |
356 | + RoleType string `xml:"RoleType"` // Always "PersistentVMRole" |
357 | + ConfigurationSets []ConfigurationSet `xml:"ConfigurationSets>ConfigurationSet"` |
358 | + AvailabilitySetName string `xml:"AvailabilitySetName,omitempty"` |
359 | + DataVirtualHardDisks *[]DataVirtualHardDisk `xml:"DataVirtualHardDisks>DataVirtualHardDisk,omitempty"` |
360 | + OSVirtualHardDisk *OSVirtualHardDisk `xml:"OSVirtualHardDisk,omitempty"` |
361 | + RoleSize string `xml:"RoleSize"` |
362 | + DefaultWinRmCertificateThumbprint string `xml:"DefaultWinRmCertificateThumbprint,omitempty"` |
363 | } |
364 | |
365 | // |
366 | @@ -325,14 +330,13 @@ |
367 | return toxml(c) |
368 | } |
369 | |
370 | -func NewRole(RoleSize string, RoleName string, |
371 | - ConfigurationSets []ConfigurationSet, vhds []OSVirtualHardDisk) *Role { |
372 | +func NewRole(RoleSize, RoleName string, vhd *OSVirtualHardDisk, ConfigurationSets []ConfigurationSet) *Role { |
373 | return &Role{ |
374 | RoleSize: RoleSize, |
375 | RoleName: RoleName, |
376 | RoleType: "PersistentVMRole", |
377 | ConfigurationSets: ConfigurationSets, |
378 | - OSVirtualHardDisk: vhds, |
379 | + OSVirtualHardDisk: vhd, |
380 | } |
381 | } |
382 | |
383 | @@ -600,24 +604,18 @@ |
384 | // |
385 | // PersistentVMRole, as used by GetRole, UpdateRole, etc. |
386 | // |
387 | -type PersistentVMRole struct { |
388 | - XMLNS string `xml:"xmlns,attr"` |
389 | - RoleName string `xml:"RoleName"` |
390 | - OsVersion string `xml:"OsVersion"` |
391 | - RoleType string `xml:"RoleType"` // Always PersistentVMRole |
392 | - ConfigurationSets []ConfigurationSet `xml:"ConfigurationSets>ConfigurationSet"` |
393 | - AvailabilitySetName string `xml:"AvailabilitySetName"` |
394 | - DataVirtualHardDisks *[]DataVirtualHardDisk `xml:"DataVirtualHardDisks>DataVirtualHardDisk,omitempty"` |
395 | - OSVirtualHardDisk OSVirtualHardDisk `xml:"OSVirtualHardDisk"` |
396 | - RoleSize string `xml:"RoleSize"` |
397 | - DefaultWinRmCertificateThumbprint string `xml:"DefaultWinRmCertificateThumbprint"` |
398 | -} |
399 | +type PersistentVMRole Role |
400 | |
401 | func (role *PersistentVMRole) Deserialize(data []byte) error { |
402 | return xml.Unmarshal(data, role) |
403 | } |
404 | |
405 | func (role *PersistentVMRole) Serialize() (string, error) { |
406 | + if role.XMLNS == "" { |
407 | + clone := *role |
408 | + clone.XMLNS = XMLNS |
409 | + role = &clone |
410 | + } |
411 | return toxml(role) |
412 | } |
413 | |
414 | |
415 | === modified file 'xmlobjects_test.go' |
416 | --- xmlobjects_test.go 2013-10-31 07:59:14 +0000 |
417 | +++ xmlobjects_test.go 2014-03-10 04:06:20 +0000 |
418 | @@ -291,7 +291,7 @@ |
419 | MediaLink: "path-to-vhd", |
420 | }, |
421 | }, |
422 | - OSVirtualHardDisk: OSVirtualHardDisk{ |
423 | + OSVirtualHardDisk: &OSVirtualHardDisk{ |
424 | HostCaching: "host-caching-mode-of-os-disk", |
425 | DiskName: "name-of-os-disk", |
426 | MediaLink: "path-to-vhd", |
427 | @@ -360,7 +360,7 @@ |
428 | MediaLink: "path-to-vhd", |
429 | }, |
430 | }, |
431 | - OSVirtualHardDisk: OSVirtualHardDisk{ |
432 | + OSVirtualHardDisk: &OSVirtualHardDisk{ |
433 | HostCaching: "host-caching-mode-of-os-disk", |
434 | DiskName: "name-of-os-disk", |
435 | MediaLink: "path-to-vhd", |
436 | @@ -922,7 +922,8 @@ |
437 | UpgradeDomainCount: "number-of-upgrade-domains-in-deployment", |
438 | RoleList: []Role{ |
439 | { |
440 | - RoleName: "name-of-role", |
441 | + RoleName: "name-of-role", |
442 | + OsVersion: "operating-system-version", |
443 | ConfigurationSets: []ConfigurationSet{ |
444 | { |
445 | ConfigurationSetType: "LinuxProvisioningConfiguration", |
446 | @@ -931,8 +932,9 @@ |
447 | }, |
448 | }, |
449 | { |
450 | - RoleName: "name-of-role", |
451 | - RoleType: "PersistentVMRole", |
452 | + RoleName: "name-of-role", |
453 | + OsVersion: "operating-system-version", |
454 | + RoleType: "PersistentVMRole", |
455 | ConfigurationSets: []ConfigurationSet{ |
456 | { |
457 | ConfigurationSetType: CONFIG_SET_NETWORK, |
458 | @@ -947,15 +949,23 @@ |
459 | SubnetNames: &[]string{"name-of-subnet"}, |
460 | }, |
461 | }, |
462 | - OSVirtualHardDisk: []OSVirtualHardDisk{ |
463 | + AvailabilitySetName: "name-of-availability-set", |
464 | + DataVirtualHardDisks: &[]DataVirtualHardDisk{ |
465 | { |
466 | - HostCaching: "host-caching-mode-of-os-disk", |
467 | - DiskName: "name-of-os-disk", |
468 | - MediaLink: "path-to-vhd", |
469 | - SourceImageName: "image-used-to-create-os-disk", |
470 | - OS: "operating-system-on-os-disk", |
471 | + HostCaching: "host-caching-mode-of-data-disk", |
472 | + DiskName: "name-of-data-disk", |
473 | + LUN: "logical-unit-number-of-data-disk", |
474 | + LogicalDiskSizeInGB: "size-of-data-disk", |
475 | + MediaLink: "path-to-vhd", |
476 | }, |
477 | }, |
478 | + OSVirtualHardDisk: &OSVirtualHardDisk{ |
479 | + HostCaching: "host-caching-mode-of-os-disk", |
480 | + DiskName: "name-of-os-disk", |
481 | + MediaLink: "path-to-vhd", |
482 | + SourceImageName: "image-used-to-create-os-disk", |
483 | + OS: "operating-system-on-os-disk", |
484 | + }, |
485 | RoleSize: "size-of-instance", |
486 | }, |
487 | }, |
488 | @@ -1030,7 +1040,7 @@ |
489 | deploymentSlot := "staging" |
490 | label := "deploymentLabel" |
491 | vhd := NewOSVirtualHardDisk("hostCaching", "diskLabel", "diskName", "mediaLink", "sourceImageName", "os") |
492 | - roles := []Role{*NewRole("size", "name", []ConfigurationSet{}, []OSVirtualHardDisk{*vhd})} |
493 | + roles := []Role{*NewRole("size", "name", vhd, []ConfigurationSet{})} |
494 | virtualNetworkName := "network" |
495 | |
496 | deployment := NewDeploymentForCreateVMDeployment(name, deploymentSlot, label, roles, virtualNetworkName) |
497 | @@ -1303,7 +1313,7 @@ |
498 | configset := []ConfigurationSet{*config} |
499 | vhd := NewOSVirtualHardDisk("hostCaching", "diskLabel", "diskName", "mediaLink", "sourceImageName", "os") |
500 | |
501 | - role := NewRole(rolesize, rolename, configset, []OSVirtualHardDisk{*vhd}) |
502 | + role := NewRole(rolesize, rolename, vhd, configset) |
503 | c.Check(role.RoleSize, Equals, rolesize) |
504 | c.Check(role.RoleName, Equals, rolename) |
505 | c.Check(role.ConfigurationSets, DeepEquals, configset) |