1
1
using AutoMapper ;
2
2
using Microsoft . Azure . Commands . Compute . Common ;
3
3
using Microsoft . Azure . Commands . Compute . Models ;
4
- using Microsoft . Azure . Management . Compute ;
5
4
using Microsoft . Azure . Management . Compute . Models ;
6
- using System . Management . Automation ;
7
- using System . Text . RegularExpressions ;
8
- using System . Collections ;
9
- using System . Linq ;
10
5
using System ;
6
+ using System . Collections ;
11
7
using System . IO ;
8
+ using System . Linq ;
9
+ using System . Management . Automation ;
12
10
13
11
namespace Microsoft . Azure . Commands . Compute . Extension . Chef
14
12
{
@@ -31,10 +29,7 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineExtensionBaseCmdlet
31
29
private Hashtable privateConfiguration ;
32
30
33
31
private string PrivateConfigurationTemplate = "validation_key" ;
34
- private string AutoUpdateTemplate = "autoUpdateClient" ;
35
- private string DeleteChefConfigTemplate = "deleteChefConfig" ;
36
32
private string BootstrapVersionTemplate = "bootstrap_version" ;
37
- private string UninstallChefClientTemplate = "uninstallChefClient" ;
38
33
private string ClientRbTemplate = "client_rb" ;
39
34
private string BootStrapOptionsTemplate = "bootstrap_options" ;
40
35
private string RunListTemplate = "runlist" ;
@@ -117,30 +112,12 @@ public string TypeHandlerVersion
117
112
[ ValidateNotNullOrEmpty ]
118
113
public string OrganizationName { get ; set ; }
119
114
120
- [ Parameter (
121
- ValueFromPipelineByPropertyName = true ,
122
- HelpMessage = "Flag to opt for auto chef-client update. Chef-client update is false by default." ) ]
123
- [ ValidateNotNullOrEmpty ]
124
- public SwitchParameter AutoUpdateChefClient { get ; set ; }
125
-
126
- [ Parameter (
127
- ValueFromPipelineByPropertyName = true ,
128
- HelpMessage = "Delete the chef config files during update/uninstall extension. Default is false." ) ]
129
- [ ValidateNotNullOrEmpty ]
130
- public SwitchParameter DeleteChefConfig { get ; set ; }
131
-
132
115
[ Parameter (
133
116
ValueFromPipelineByPropertyName = true ,
134
117
HelpMessage = "Chef client version to be installed with the extension. Works for only linux." ) ]
135
118
[ ValidateNotNullOrEmpty ]
136
119
public string BootstrapVersion { get ; set ; }
137
120
138
- [ Parameter (
139
- ValueFromPipelineByPropertyName = true ,
140
- HelpMessage = "Uninstall Chef client during update/uninstall extension. Default is false." ) ]
141
- [ ValidateNotNullOrEmpty ]
142
- public SwitchParameter UninstallChefClient { get ; set ; }
143
-
144
121
[ Parameter (
145
122
Mandatory = true ,
146
123
ParameterSetName = LinuxParameterSetName ,
@@ -221,10 +198,7 @@ private Hashtable PublicConfiguration
221
198
bool IsValidationClientNameEmpty = string . IsNullOrEmpty ( this . ValidationClientName ) ;
222
199
bool IsRunListEmpty = string . IsNullOrEmpty ( this . RunList ) ;
223
200
bool IsBootstrapOptionsEmpty = string . IsNullOrEmpty ( this . BootstrapOptions ) ;
224
- string AutoUpdateChefClient = this . AutoUpdateChefClient . IsPresent ? "true" : "false" ;
225
- string DeleteChefConfig = this . DeleteChefConfig . IsPresent ? "true" : "false" ;
226
201
string BootstrapVersion = string . IsNullOrEmpty ( this . BootstrapVersion ) ? "" : this . BootstrapVersion ;
227
- string UninstallChefClient = this . UninstallChefClient . IsPresent ? "true" : "false" ;
228
202
229
203
//Cases handled:
230
204
// 1. When clientRb given by user and:
@@ -277,20 +251,14 @@ private Hashtable PublicConfiguration
277
251
if ( IsBootstrapOptionsEmpty )
278
252
{
279
253
var hashTable = new Hashtable ( ) ;
280
- hashTable . Add ( AutoUpdateTemplate , AutoUpdateChefClient ) ;
281
- hashTable . Add ( DeleteChefConfigTemplate , DeleteChefConfig ) ;
282
254
hashTable . Add ( BootstrapVersionTemplate , BootstrapVersion ) ;
283
- hashTable . Add ( UninstallChefClientTemplate , UninstallChefClient ) ;
284
255
hashTable . Add ( ClientRbTemplate , ClientConfig ) ;
285
256
this . publicConfiguration = hashTable ;
286
257
}
287
258
else
288
259
{
289
260
var hashTable = new Hashtable ( ) ;
290
- hashTable . Add ( AutoUpdateTemplate , AutoUpdateChefClient ) ;
291
- hashTable . Add ( DeleteChefConfigTemplate , DeleteChefConfig ) ;
292
261
hashTable . Add ( BootstrapVersionTemplate , BootstrapVersion ) ;
293
- hashTable . Add ( UninstallChefClientTemplate , UninstallChefClient ) ;
294
262
hashTable . Add ( ClientRbTemplate , ClientConfig ) ;
295
263
hashTable . Add ( BootStrapOptionsTemplate , this . BootstrapOptions ) ;
296
264
this . publicConfiguration = hashTable ;
@@ -301,25 +269,19 @@ private Hashtable PublicConfiguration
301
269
if ( IsBootstrapOptionsEmpty )
302
270
{
303
271
var hashTable = new Hashtable ( ) ;
304
- hashTable . Add ( AutoUpdateTemplate , AutoUpdateChefClient ) ;
305
- hashTable . Add ( DeleteChefConfigTemplate , DeleteChefConfig ) ;
306
272
hashTable . Add ( BootstrapVersionTemplate , BootstrapVersion ) ;
307
- hashTable . Add ( UninstallChefClientTemplate , UninstallChefClient ) ;
308
273
hashTable . Add ( ClientRbTemplate , ClientConfig ) ;
309
274
hashTable . Add ( RunListTemplate , this . RunList ) ;
310
275
this . publicConfiguration = hashTable ;
311
276
}
312
277
else
313
278
{
314
279
var hashTable = new Hashtable ( ) ;
315
- hashTable . Add ( AutoUpdateTemplate , AutoUpdateChefClient ) ;
316
- hashTable . Add ( DeleteChefConfigTemplate , DeleteChefConfig ) ;
317
280
hashTable . Add ( BootstrapVersionTemplate , BootstrapVersion ) ;
318
- hashTable . Add ( UninstallChefClientTemplate , UninstallChefClient ) ;
319
281
hashTable . Add ( ClientRbTemplate , ClientConfig ) ;
320
282
hashTable . Add ( RunListTemplate , this . RunList ) ;
321
283
hashTable . Add ( BootStrapOptionsTemplate , this . BootstrapOptions ) ;
322
- this . publicConfiguration = hashTable ;
284
+ this . publicConfiguration = hashTable ;
323
285
}
324
286
}
325
287
}
@@ -337,7 +299,7 @@ private Hashtable PrivateConfiguration
337
299
var hashTable = new Hashtable ( ) ;
338
300
hashTable . Add ( PrivateConfigurationTemplate , File . ReadAllText ( this . ValidationPem ) . TrimEnd ( '\r ' , '\n ' ) ) ;
339
301
this . privateConfiguration = hashTable ;
340
- }
302
+ }
341
303
342
304
return this . privateConfiguration ;
343
305
}
@@ -349,7 +311,7 @@ private void ExecuteCommand()
349
311
{
350
312
var parameters = new VirtualMachineExtension
351
313
{
352
- Location = this . Location ,
314
+ Location = this . Location ,
353
315
Settings = this . PublicConfiguration ,
354
316
ProtectedSettings = this . PrivateConfiguration ,
355
317
Publisher = ExtensionDefaultPublisher ,
@@ -415,7 +377,7 @@ private string GetLatestChefExtensionVersion()
415
377
}
416
378
417
379
private void ValidateParameters ( )
418
- {
380
+ {
419
381
bool IsClientRbEmpty = string . IsNullOrEmpty ( this . ClientRb ) ;
420
382
bool IsChefServerUrlEmpty = string . IsNullOrEmpty ( this . ChefServerUrl ) ;
421
383
bool IsValidationClientNameEmpty = string . IsNullOrEmpty ( this . ValidationClientName ) ;
0 commit comments