Merge lp:~bteleaga/gwacl/windowsgwacl into lp:gwacl
- windowsgwacl
- Merge into trunk
Proposed by
Bogdan Teleaga
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | 244 |
Merged at revision: | 244 |
Proposed branch: | lp:~bteleaga/gwacl/windowsgwacl |
Merge into: | lp:gwacl |
Prerequisite: | lp:~axwalk/gwacl/gwacl-update-version |
Diff against target: |
546 lines (+346/-27) 4 files modified
helpers_apiobjects_test.go (+66/-2) management_base_test.go (+1/-1) xmlobjects.go (+140/-10) xmlobjects_test.go (+139/-14) |
To merge this branch: | bzr merge lp:~bteleaga/gwacl/windowsgwacl |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Wilkins (community) | Approve | ||
Review via email: mp+266090@code.launchpad.net |
Commit message
This is a patch directly on top of https:/
It adds some XML that will basically mean windows VM's can now be launched and resource extensions can be defined. New role and configuration set types have been defined.
Description of the change
This is a patch directly on top of https:/
It adds some XML that will basically mean windows VM's can now be launched and resource extensions can be defined. New role and configuration set types have been defined.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'helpers_apiobjects_test.go' |
2 | --- helpers_apiobjects_test.go 2014-12-02 00:36:45 +0000 |
3 | +++ helpers_apiobjects_test.go 2015-07-28 13:15:20 +0000 |
4 | @@ -48,6 +48,25 @@ |
5 | return NewLinuxProvisioningConfigurationSet(hostname, username, password, customdata, disableSSH) |
6 | } |
7 | |
8 | +func makeWindowsProvisioningConfiguration() *ConfigurationSet { |
9 | + ComputerName := MakeRandomString(10) |
10 | + Password := MakeRandomString(10) |
11 | + AdminUsername := MakeRandomString(10) |
12 | + TimeZone := MakeRandomString(10) |
13 | + AdditionalUnattendContent := MakeRandomString(10) |
14 | + CustomData := MakeRandomString(10) |
15 | + EnableAutomaticUpdates := BoolToString(MakeRandomBool()) |
16 | + |
17 | + StoreLocation := MakeRandomString(10) |
18 | + StoreName := MakeRandomString(10) |
19 | + Thumbprint := MakeRandomString(10) |
20 | + CertSettings := []CertificateSetting{CertificateSetting{StoreLocation, StoreName, Thumbprint}} |
21 | + |
22 | + WinRMListener := &WinRMListener{WinRMProtocolHTTP, Thumbprint} |
23 | + |
24 | + return NewWindowsProvisioningConfigurationSet(ComputerName, Password, EnableAutomaticUpdates, TimeZone, CertSettings, WinRMListener, AdminUsername, AdditionalUnattendContent, CustomData) |
25 | +} |
26 | + |
27 | func makeOSVirtualHardDisk() *OSVirtualHardDisk { |
28 | HostCaching := BoolToString(MakeRandomBool()) |
29 | DiskLabel := MakeRandomString(10) |
30 | @@ -63,7 +82,7 @@ |
31 | SourceImageName: SourceImageName} |
32 | } |
33 | |
34 | -func makeRole() *Role { |
35 | +func makeLinuxRole() *Role { |
36 | RoleSize := "ExtraSmall" |
37 | RoleName := MakeRandomString(10) |
38 | RoleType := "PersistentVMRole" |
39 | @@ -77,6 +96,51 @@ |
40 | ConfigurationSets: configset} |
41 | } |
42 | |
43 | +func makeWindowsRole() *Role { |
44 | + RoleSize := "ExtraSmall" |
45 | + RoleName := MakeRandomString(10) |
46 | + RoleType := "PersistentVMRole" |
47 | + config := makeWindowsProvisioningConfiguration() |
48 | + configset := []ConfigurationSet{*config} |
49 | + provisionGuestAgent := BoolToString(MakeRandomBool()) |
50 | + resourceReference := makeWindowsResourceExtensionReference() |
51 | + |
52 | + return &Role{ |
53 | + RoleSize: RoleSize, |
54 | + RoleName: RoleName, |
55 | + RoleType: RoleType, |
56 | + ConfigurationSets: configset, |
57 | + ProvisionGuestAgent: provisionGuestAgent, |
58 | + ResourceExtensionReferences: &[]ResourceExtensionReference{*resourceReference}, |
59 | + } |
60 | +} |
61 | + |
62 | +func makeWindowsResourceExtensionReference() *ResourceExtensionReference { |
63 | + refName := MakeRandomString(10) |
64 | + publisher := MakeRandomString(10) |
65 | + name := MakeRandomString(10) |
66 | + version := MakeRandomString(10) |
67 | + state := MakeRandomString(10) |
68 | + |
69 | + param1 := makeWindowsResourceExtensionParameter(true) |
70 | + param2 := makeWindowsResourceExtensionParameter(false) |
71 | + |
72 | + return NewResourceExtensionReference(refName, publisher, name, version, state, |
73 | + []ResourceExtensionParameter{*param1, *param2}) |
74 | +} |
75 | + |
76 | +func makeWindowsResourceExtensionParameter(private bool) *ResourceExtensionParameter { |
77 | + key := MakeRandomString(10) |
78 | + value := MakeRandomString(10) |
79 | + var paramType ResourceExtensionParameterType |
80 | + if private { |
81 | + paramType = ResourceExtensionParameterTypePrivate |
82 | + } else { |
83 | + paramType = ResourceExtensionParameterTypePublic |
84 | + } |
85 | + return NewResourceExtensionParameter(key, value, paramType) |
86 | +} |
87 | + |
88 | func makeDnsServer() *DnsServer { |
89 | name := MakeRandomString(10) |
90 | address := MakeRandomString(10) |
91 | @@ -91,7 +155,7 @@ |
92 | DeploymentSlot := "Staging" |
93 | Label := MakeRandomString(10) |
94 | VirtualNetworkName := MakeRandomString(10) |
95 | - role := makeRole() |
96 | + role := makeLinuxRole() |
97 | RoleList := []Role{*role} |
98 | Dns := []DnsServer{*makeDnsServer()} |
99 | |
100 | |
101 | === modified file 'management_base_test.go' |
102 | --- management_base_test.go 2015-07-28 13:15:20 +0000 |
103 | +++ management_base_test.go 2015-07-28 13:15:20 +0000 |
104 | @@ -706,7 +706,7 @@ |
105 | serviceName := "serviceName" |
106 | configurationSet := NewLinuxProvisioningConfigurationSet("testHostname12345", "test", "test123#@!", "user-data", "false") |
107 | vhd := NewOSVirtualHardDisk("hostCaching", "diskLabel", "diskName", "http://mediaLink", "sourceImageName", "os") |
108 | - role := NewRole("ExtraSmall", "test-role-123", vhd, []ConfigurationSet{*configurationSet}) |
109 | + role := NewLinuxRole("ExtraSmall", "test-role-123", vhd, []ConfigurationSet{*configurationSet}) |
110 | deployment := NewDeploymentForCreateVMDeployment("test-machine-name", "Staging", "testLabel", []Role{*role}, "testNetwork") |
111 | err := api.AddDeployment(deployment, serviceName) |
112 | |
113 | |
114 | === modified file 'xmlobjects.go' |
115 | --- xmlobjects.go 2015-07-28 13:15:20 +0000 |
116 | +++ xmlobjects.go 2015-07-28 13:15:20 +0000 |
117 | @@ -35,13 +35,37 @@ |
118 | return string(out), nil |
119 | } |
120 | |
121 | +// CertificateSetting specifies the parameters for the certificate which to |
122 | +// provision to the new Virtual Machine. |
123 | +type CertificateSetting struct { |
124 | + StoreLocation string |
125 | + StoreName string |
126 | + Thumbprint string |
127 | +} |
128 | + |
129 | +// WinRMListener specifies the protocol and certificate information for a WinRM |
130 | +// listener. |
131 | +type WinRMListener struct { |
132 | + Protocol WinRMProtocol |
133 | + CertificateThumbprint string `xml:",omitempty"` |
134 | +} |
135 | + |
136 | +type WinRMProtocol string |
137 | + |
138 | +// Enum values for WinRMProtocol |
139 | +const ( |
140 | + WinRMProtocolHTTP WinRMProtocol = "Http" |
141 | + WinRMProtocolHTTPS WinRMProtocol = "Https" |
142 | +) |
143 | + |
144 | // |
145 | // ConfigurationSet bits |
146 | // |
147 | |
148 | const ( |
149 | - CONFIG_SET_LINUX_PROVISIONING = "LinuxProvisioningConfiguration" |
150 | - CONFIG_SET_NETWORK = "NetworkConfiguration" |
151 | + CONFIG_SET_LINUX_PROVISIONING = "LinuxProvisioningConfiguration" |
152 | + CONFIG_SET_WINDOWS_PROVISIONING = "WindowsProvisioningConfiguration" |
153 | + CONFIG_SET_NETWORK = "NetworkConfiguration" |
154 | ) |
155 | |
156 | // A ConfigurationSet object can be different things depending on its 'type'. |
157 | @@ -55,9 +79,19 @@ |
158 | Hostname string `xml:"HostName,omitempty"` |
159 | Username string `xml:"UserName,omitempty"` |
160 | Password string `xml:"UserPassword,omitempty"` |
161 | - CustomData string `xml:"CustomData,omitempty"` |
162 | DisableSSHPasswordAuthentication string `xml:"DisableSshPasswordAuthentication,omitempty"` |
163 | |
164 | + // WindowsProvisioningConfiguration fields. |
165 | + ComputerName string `xml:"ComputerName,omitempty"` |
166 | + AdminPassword string `xml:"AdminPassword,omitempty"` |
167 | + EnableAutomaticUpdates string `xml:"EnableAutomaticUpdates,omitempty"` |
168 | + TimeZone string `xml:"TimeZone,omitempty"` |
169 | + StoredCertificateSettings []CertificateSetting `xml:"StoredCertificateSettings,omitempty"` |
170 | + WinRMListeners *WinRMListener `xml:"WinRM>Listeners>Listener,omitempty"` |
171 | + AdminUsername string `xml:"AdminUsername,omitempty"` |
172 | + AdditionalUnattendContent string `xml:"AdditionalUnattendContent,omitempty"` |
173 | + |
174 | + CustomData string `xml:"CustomData,omitempty"` |
175 | // NetworkConfiguration fields. |
176 | // We use slice pointers to work around a Go bug: |
177 | // https://code.google.com/p/go/issues/detail?id=4168 |
178 | @@ -98,6 +132,24 @@ |
179 | } |
180 | } |
181 | |
182 | +func NewWindowsProvisioningConfigurationSet( |
183 | + ComputerName, AdminPassword, EnableAutomaticUpdates string, TimeZone string, |
184 | + StoredCertificateSettings []CertificateSetting, WinRMListeners *WinRMListener, |
185 | + AdminUsername, AdditionalUnattendContent, CustomData string) *ConfigurationSet { |
186 | + return &ConfigurationSet{ |
187 | + ConfigurationSetType: CONFIG_SET_WINDOWS_PROVISIONING, |
188 | + ComputerName: ComputerName, |
189 | + AdminPassword: AdminPassword, |
190 | + EnableAutomaticUpdates: EnableAutomaticUpdates, |
191 | + TimeZone: TimeZone, |
192 | + StoredCertificateSettings: StoredCertificateSettings, |
193 | + WinRMListeners: WinRMListeners, |
194 | + AdminUsername: AdminUsername, |
195 | + CustomData: CustomData, |
196 | + AdditionalUnattendContent: AdditionalUnattendContent, |
197 | + } |
198 | +} |
199 | + |
200 | // NewNetworkConfiguration creates a ConfigurationSet of type "NetworkConfiguration". |
201 | func NewNetworkConfigurationSet( |
202 | inputEndpoints []InputEndpoint, subnetNames []string) *ConfigurationSet { |
203 | @@ -333,6 +385,69 @@ |
204 | return fmt.Sprintf("http://%s.blob.core.windows.net/%s", StorageName, StoragePath) |
205 | } |
206 | |
207 | +// ResourceExtensionReference contains a collection of resource extensions that |
208 | +// are to be installed on the Virtual Machine. The VM Agent must be installed on |
209 | +// the Virtual Machine to install resource extensions. For more information, see |
210 | +// Manage Extensions: |
211 | +// |
212 | +// https://msdn.microsoft.com/en-us/library/dn606311.aspx. |
213 | +type ResourceExtensionReference struct { |
214 | + ReferenceName string `xml:"ReferenceName"` |
215 | + Publisher string `xml:"Publisher"` |
216 | + Name string `xml:"Name"` |
217 | + Version string `xml:"Version"` |
218 | + ParameterValues []ResourceExtensionParameter `xml:"ResourceExtensionParameterValues>ResourceExtensionParameterValue,omitempty"` |
219 | + State string `xml:"State,omitempty"` |
220 | +} |
221 | + |
222 | +func (r *ResourceExtensionReference) Serialize() (string, error) { |
223 | + return toxml(r) |
224 | +} |
225 | + |
226 | +func NewResourceExtensionReference( |
227 | + ReferenceName, Publisher, Name, Version, State string, |
228 | + ParameterValues []ResourceExtensionParameter, |
229 | +) *ResourceExtensionReference { |
230 | + return &ResourceExtensionReference{ |
231 | + ReferenceName: ReferenceName, |
232 | + Publisher: Publisher, |
233 | + Name: Name, |
234 | + Version: Version, |
235 | + ParameterValues: ParameterValues, |
236 | + State: State, |
237 | + } |
238 | +} |
239 | + |
240 | +// ResourceExtensionParameter specifies the key, value, and type of a parameter that is passed to the |
241 | +// resource extension when it is installed. |
242 | +type ResourceExtensionParameter struct { |
243 | + Key string |
244 | + Value string |
245 | + Type ResourceExtensionParameterType // If this value is set to Private, the parameter will not be returned by Get Deployment (). |
246 | +} |
247 | + |
248 | +type ResourceExtensionParameterType string |
249 | + |
250 | +// Enum values for ResourceExtensionParameterType |
251 | +const ( |
252 | + ResourceExtensionParameterTypePublic ResourceExtensionParameterType = "Public" |
253 | + ResourceExtensionParameterTypePrivate ResourceExtensionParameterType = "Private" |
254 | +) |
255 | + |
256 | +func (r *ResourceExtensionParameter) Serialize() (string, error) { |
257 | + return toxml(r) |
258 | +} |
259 | + |
260 | +func NewResourceExtensionParameter( |
261 | + Key, Value string, Type ResourceExtensionParameterType, |
262 | +) *ResourceExtensionParameter { |
263 | + return &ResourceExtensionParameter{ |
264 | + Key: Key, |
265 | + Value: Value, |
266 | + Type: Type, |
267 | + } |
268 | +} |
269 | + |
270 | type Role struct { |
271 | XMLNS string `xml:"xmlns,attr,omitempty"` |
272 | RoleName string `xml:"RoleName"` |
273 | @@ -341,12 +456,13 @@ |
274 | MediaLocation string `xml:"MediaLocation,omitempty"` |
275 | ConfigurationSets []ConfigurationSet `xml:"ConfigurationSets>ConfigurationSet"` |
276 | // TODO(axw) ResourceExtensionReferences |
277 | - AvailabilitySetName string `xml:"AvailabilitySetName,omitempty"` |
278 | - DataVirtualHardDisks *[]DataVirtualHardDisk `xml:"DataVirtualHardDisks>DataVirtualHardDisk,omitempty"` |
279 | - OSVirtualHardDisk *OSVirtualHardDisk `xml:"OSVirtualHardDisk,omitempty"` |
280 | - RoleSize string `xml:"RoleSize"` |
281 | - ProvisionGuestAgent bool `xml:"ProvisionGuestAgent,omitempty"` |
282 | - DefaultWinRmCertificateThumbprint string `xml:"DefaultWinRmCertificateThumbprint,omitempty"` |
283 | + ResourceExtensionReferences *[]ResourceExtensionReference `xml:"ResourceExtensionReferences>ResourceExtensionReference,omitempty"` |
284 | + AvailabilitySetName string `xml:"AvailabilitySetName,omitempty"` |
285 | + DataVirtualHardDisks *[]DataVirtualHardDisk `xml:"DataVirtualHardDisks>DataVirtualHardDisk,omitempty"` |
286 | + OSVirtualHardDisk *OSVirtualHardDisk `xml:"OSVirtualHardDisk,omitempty"` |
287 | + RoleSize string `xml:"RoleSize"` |
288 | + ProvisionGuestAgent string `xml:"ProvisionGuestAgent,omitempty"` |
289 | + DefaultWinRmCertificateThumbprint string `xml:"DefaultWinRmCertificateThumbprint,omitempty"` |
290 | // TODO(axw) VMImageInput |
291 | } |
292 | |
293 | @@ -358,7 +474,7 @@ |
294 | return toxml(c) |
295 | } |
296 | |
297 | -func NewRole(RoleSize, RoleName string, vhd *OSVirtualHardDisk, ConfigurationSets []ConfigurationSet) *Role { |
298 | +func newRole(RoleSize, RoleName string, vhd *OSVirtualHardDisk, ConfigurationSets []ConfigurationSet) *Role { |
299 | return &Role{ |
300 | RoleSize: RoleSize, |
301 | RoleName: RoleName, |
302 | @@ -368,6 +484,20 @@ |
303 | } |
304 | } |
305 | |
306 | +func NewLinuxRole(RoleSize, RoleName string, vhd *OSVirtualHardDisk, ConfigurationSets []ConfigurationSet) *Role { |
307 | + return newRole(RoleSize, RoleName, vhd, ConfigurationSets) |
308 | +} |
309 | + |
310 | +func NewWindowsRole( |
311 | + RoleSize, RoleName string, vhd *OSVirtualHardDisk, ConfigurationSets []ConfigurationSet, |
312 | + ResourceExtensionReferences *[]ResourceExtensionReference, ProvisionGuestAgent string, |
313 | +) *Role { |
314 | + role := newRole(RoleSize, RoleName, vhd, ConfigurationSets) |
315 | + role.ResourceExtensionReferences = ResourceExtensionReferences |
316 | + role.ProvisionGuestAgent = ProvisionGuestAgent |
317 | + return role |
318 | +} |
319 | + |
320 | // |
321 | // DnsServer bits |
322 | // |
323 | |
324 | === modified file 'xmlobjects_test.go' |
325 | --- xmlobjects_test.go 2015-07-28 13:15:20 +0000 |
326 | +++ xmlobjects_test.go 2015-07-28 13:15:20 +0000 |
327 | @@ -22,7 +22,7 @@ |
328 | // Tests for Marshallers |
329 | // |
330 | |
331 | -func (suite *xmlSuite) TestConfigurationSet(c *C) { |
332 | +func (suite *xmlSuite) TestLinuxConfigurationSet(c *C) { |
333 | config := makeLinuxProvisioningConfiguration() |
334 | |
335 | xml, err := config.Serialize() |
336 | @@ -33,12 +33,52 @@ |
337 | <HostName>%s</HostName> |
338 | <UserName>%s</UserName> |
339 | <UserPassword>%s</UserPassword> |
340 | - <CustomData>%s</CustomData> |
341 | <DisableSshPasswordAuthentication>%v</DisableSshPasswordAuthentication> |
342 | + <CustomData>%s</CustomData> |
343 | </ConfigurationSet>`) |
344 | expected := fmt.Sprintf(template, config.Hostname, config.Username, |
345 | - config.Password, config.CustomData, |
346 | - config.DisableSSHPasswordAuthentication) |
347 | + config.Password, config.DisableSSHPasswordAuthentication, |
348 | + config.CustomData) |
349 | + c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected)) |
350 | +} |
351 | + |
352 | +func (suite *xmlSuite) TestWindowsConfigurationSet(c *C) { |
353 | + config := makeWindowsProvisioningConfiguration() |
354 | + |
355 | + xml, err := config.Serialize() |
356 | + c.Assert(err, IsNil) |
357 | + template := dedent.Dedent(` |
358 | + <ConfigurationSet> |
359 | + <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType> |
360 | + <ComputerName>%s</ComputerName> |
361 | + <AdminPassword>%s</AdminPassword> |
362 | + <EnableAutomaticUpdates>%s</EnableAutomaticUpdates> |
363 | + <TimeZone>%v</TimeZone> |
364 | + <StoredCertificateSettings> |
365 | + <StoreLocation>%s</StoreLocation> |
366 | + <StoreName>%s</StoreName> |
367 | + <Thumbprint>%s</Thumbprint> |
368 | + </StoredCertificateSettings> |
369 | + <WinRM> |
370 | + <Listeners> |
371 | + <Listener> |
372 | + <Protocol>%s</Protocol> |
373 | + <CertificateThumbprint>%s</CertificateThumbprint> |
374 | + </Listener> |
375 | + </Listeners> |
376 | + </WinRM> |
377 | + <AdminUsername>%s</AdminUsername> |
378 | + <AdditionalUnattendContent>%s</AdditionalUnattendContent> |
379 | + <CustomData>%s</CustomData> |
380 | + </ConfigurationSet>`) |
381 | + expected := fmt.Sprintf(template, config.ComputerName, config.AdminPassword, |
382 | + config.EnableAutomaticUpdates, config.TimeZone, |
383 | + config.StoredCertificateSettings[0].StoreLocation, |
384 | + config.StoredCertificateSettings[0].StoreName, |
385 | + config.StoredCertificateSettings[0].Thumbprint, |
386 | + config.WinRMListeners.Protocol, config.WinRMListeners.CertificateThumbprint, |
387 | + config.AdminUsername, config.AdditionalUnattendContent, |
388 | + config.CustomData) |
389 | c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected)) |
390 | } |
391 | |
392 | @@ -146,8 +186,8 @@ |
393 | c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected)) |
394 | } |
395 | |
396 | -func (suite *xmlSuite) TestRole(c *C) { |
397 | - role := makeRole() |
398 | +func (suite *xmlSuite) TestLinuxRole(c *C) { |
399 | + role := makeLinuxRole() |
400 | config := role.ConfigurationSets[0] |
401 | |
402 | xml, err := role.Serialize() |
403 | @@ -162,16 +202,101 @@ |
404 | <HostName>%s</HostName> |
405 | <UserName>%s</UserName> |
406 | <UserPassword>%s</UserPassword> |
407 | - <CustomData>%s</CustomData> |
408 | <DisableSshPasswordAuthentication>%v</DisableSshPasswordAuthentication> |
409 | + <CustomData>%s</CustomData> |
410 | </ConfigurationSet> |
411 | </ConfigurationSets> |
412 | <RoleSize>%s</RoleSize> |
413 | </Role>`) |
414 | expected := fmt.Sprintf(template, role.RoleName, |
415 | config.ConfigurationSetType, config.Hostname, config.Username, |
416 | - config.Password, config.CustomData, |
417 | - config.DisableSSHPasswordAuthentication, role.RoleSize) |
418 | + config.Password, config.DisableSSHPasswordAuthentication, |
419 | + config.CustomData, role.RoleSize) |
420 | + c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected)) |
421 | +} |
422 | + |
423 | +func (suite *xmlSuite) TestWindowsRole(c *C) { |
424 | + role := makeWindowsRole() |
425 | + config := role.ConfigurationSets[0] |
426 | + resources := role.ResourceExtensionReferences |
427 | + resource := (*resources)[0] |
428 | + |
429 | + xml, err := role.Serialize() |
430 | + c.Assert(err, IsNil) |
431 | + template := dedent.Dedent(` |
432 | + <Role> |
433 | + <RoleName>%s</RoleName> |
434 | + <RoleType>PersistentVMRole</RoleType> |
435 | + <ConfigurationSets> |
436 | + <ConfigurationSet> |
437 | + <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType> |
438 | + <ComputerName>%s</ComputerName> |
439 | + <AdminPassword>%s</AdminPassword> |
440 | + <EnableAutomaticUpdates>%s</EnableAutomaticUpdates> |
441 | + <TimeZone>%v</TimeZone> |
442 | + <StoredCertificateSettings> |
443 | + <StoreLocation>%s</StoreLocation> |
444 | + <StoreName>%s</StoreName> |
445 | + <Thumbprint>%s</Thumbprint> |
446 | + </StoredCertificateSettings> |
447 | + <WinRM> |
448 | + <Listeners> |
449 | + <Listener> |
450 | + <Protocol>%s</Protocol> |
451 | + <CertificateThumbprint>%s</CertificateThumbprint> |
452 | + </Listener> |
453 | + </Listeners> |
454 | + </WinRM> |
455 | + <AdminUsername>%s</AdminUsername> |
456 | + <AdditionalUnattendContent>%s</AdditionalUnattendContent> |
457 | + <CustomData>%s</CustomData> |
458 | + </ConfigurationSet> |
459 | + </ConfigurationSets> |
460 | + <ResourceExtensionReferences> |
461 | + <ResourceExtensionReference> |
462 | + <ReferenceName>%s</ReferenceName> |
463 | + <Publisher>%s</Publisher> |
464 | + <Name>%s</Name> |
465 | + <Version>%s</Version> |
466 | + <ResourceExtensionParameterValues> |
467 | + <ResourceExtensionParameterValue> |
468 | + <Key>%s</Key> |
469 | + <Value>%s</Value> |
470 | + <Type>%s</Type> |
471 | + </ResourceExtensionParameterValue> |
472 | + <ResourceExtensionParameterValue> |
473 | + <Key>%s</Key> |
474 | + <Value>%s</Value> |
475 | + <Type>%s</Type> |
476 | + </ResourceExtensionParameterValue> |
477 | + </ResourceExtensionParameterValues> |
478 | + <State>%s</State> |
479 | + </ResourceExtensionReference> |
480 | + </ResourceExtensionReferences> |
481 | + <RoleSize>%s</RoleSize> |
482 | + <ProvisionGuestAgent>%s</ProvisionGuestAgent> |
483 | + </Role>`) |
484 | + expected := fmt.Sprintf(template, role.RoleName, |
485 | + config.ComputerName, config.AdminPassword, |
486 | + config.EnableAutomaticUpdates, config.TimeZone, |
487 | + config.StoredCertificateSettings[0].StoreLocation, |
488 | + config.StoredCertificateSettings[0].StoreName, |
489 | + config.StoredCertificateSettings[0].Thumbprint, |
490 | + config.WinRMListeners.Protocol, config.WinRMListeners.CertificateThumbprint, |
491 | + config.AdminUsername, config.AdditionalUnattendContent, |
492 | + config.CustomData, |
493 | + resource.ReferenceName, resource.Publisher, resource.Name, |
494 | + resource.Version, |
495 | + resource.ParameterValues[0].Key, |
496 | + resource.ParameterValues[0].Value, |
497 | + resource.ParameterValues[0].Type, |
498 | + resource.ParameterValues[1].Key, |
499 | + resource.ParameterValues[1].Value, |
500 | + resource.ParameterValues[1].Type, |
501 | + resource.State, |
502 | + role.RoleSize, |
503 | + role.ProvisionGuestAgent, |
504 | + ) |
505 | c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected)) |
506 | } |
507 | |
508 | @@ -712,8 +837,8 @@ |
509 | <HostName>%s</HostName> |
510 | <UserName>%s</UserName> |
511 | <UserPassword>%s</UserPassword> |
512 | + <DisableSshPasswordAuthentication>%v</DisableSshPasswordAuthentication> |
513 | <CustomData>%s</CustomData> |
514 | - <DisableSshPasswordAuthentication>%v</DisableSshPasswordAuthentication> |
515 | </ConfigurationSet> |
516 | </ConfigurationSets> |
517 | <RoleSize>%s</RoleSize> |
518 | @@ -733,8 +858,8 @@ |
519 | expected := fmt.Sprintf(template, deployment.Name, |
520 | deployment.DeploymentSlot, deployment.Label, |
521 | role.RoleName, config.ConfigurationSetType, config.Hostname, |
522 | - config.Username, config.Password, config.CustomData, |
523 | - config.DisableSSHPasswordAuthentication, role.RoleSize, |
524 | + config.Username, config.Password, config.DisableSSHPasswordAuthentication, |
525 | + config.CustomData, role.RoleSize, |
526 | deployment.VirtualNetworkName, dns.Name, dns.Address) |
527 | c.Check(strings.TrimSpace(xml), Equals, strings.TrimSpace(expected)) |
528 | } |
529 | @@ -1034,7 +1159,7 @@ |
530 | deploymentSlot := "staging" |
531 | label := "deploymentLabel" |
532 | vhd := NewOSVirtualHardDisk("hostCaching", "diskLabel", "diskName", "mediaLink", "sourceImageName", "os") |
533 | - roles := []Role{*NewRole("size", "name", vhd, []ConfigurationSet{})} |
534 | + roles := []Role{*NewLinuxRole("size", "name", vhd, []ConfigurationSet{})} |
535 | virtualNetworkName := "network" |
536 | |
537 | deployment := NewDeploymentForCreateVMDeployment(name, deploymentSlot, label, roles, virtualNetworkName) |
538 | @@ -1305,7 +1430,7 @@ |
539 | configset := []ConfigurationSet{*config} |
540 | vhd := NewOSVirtualHardDisk("hostCaching", "diskLabel", "diskName", "mediaLink", "sourceImageName", "os") |
541 | |
542 | - role := NewRole(rolesize, rolename, vhd, configset) |
543 | + role := NewLinuxRole(rolesize, rolename, vhd, configset) |
544 | c.Check(role.RoleSize, Equals, rolesize) |
545 | c.Check(role.RoleName, Equals, rolename) |
546 | c.Check(role.ConfigurationSets, DeepEquals, configset) |
LGTM