Skip to content

Commit 858709c

Browse files
author
siddheshwar-more
committed
Changes to add DeleteChefConfig option for set chef extension
1 parent 0583743 commit 858709c

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/Chef/SetAzureVMChefExtension.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineChefExtensionCmdletB
9090
[ValidateNotNullOrEmpty]
9191
public SwitchParameter AutoUpdateChefClient { get; set; }
9292

93+
[Parameter(
94+
ValueFromPipelineByPropertyName = true,
95+
HelpMessage = "Delete the chef config files during update/uninstall extension. Default is false.")]
96+
[ValidateNotNullOrEmpty]
97+
public SwitchParameter DeleteChefConfig { get; set; }
98+
9399
[Parameter(
94100
Mandatory = true,
95101
ParameterSetName = LinuxParameterSetName,
@@ -160,6 +166,7 @@ private void SetPublicConfig()
160166
bool IsRunListEmpty = string.IsNullOrEmpty(this.RunList);
161167
bool IsBootstrapOptionsEmpty = string.IsNullOrEmpty(this.BootstrapOptions);
162168
string AutoUpdateChefClient = this.AutoUpdateChefClient.IsPresent ? "true" : "false";
169+
string DeleteChefConfig = this.DeleteChefConfig.IsPresent ? "true" : "false";
163170

164171
//Cases handled:
165172
// 1. When clientRb given by user and:
@@ -213,14 +220,16 @@ private void SetPublicConfig()
213220
{
214221
if (IsBootstrapOptionsEmpty)
215222
{
216-
this.PublicConfiguration = string.Format("{{{0},{1}}}",
223+
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
217224
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
225+
string.Format(DeleteChefConfigTemplate, DeleteChefConfig),
218226
string.Format(ClientRbTemplate, ClientConfig));
219227
}
220228
else
221229
{
222-
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
230+
this.PublicConfiguration = string.Format("{{{0},{1},{2},{3}}}",
223231
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
232+
string.Format(DeleteChefConfigTemplate, DeleteChefConfig),
224233
string.Format(ClientRbTemplate, ClientConfig),
225234
string.Format(BootStrapOptionsTemplate, this.BootstrapOptions));
226235
}
@@ -229,15 +238,17 @@ private void SetPublicConfig()
229238
{
230239
if (IsBootstrapOptionsEmpty)
231240
{
232-
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
241+
this.PublicConfiguration = string.Format("{{{0},{1},{2},{3}}}",
233242
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
243+
string.Format(DeleteChefConfigTemplate, DeleteChefConfig),
234244
string.Format(ClientRbTemplate, ClientConfig),
235245
string.Format(RunListTemplate, this.RunList));
236246
}
237247
else
238248
{
239-
this.PublicConfiguration = string.Format("{{{0},{1},{2},{3}}",
249+
this.PublicConfiguration = string.Format("{{{0},{1},{2},{3},{4}}",
240250
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
251+
string.Format(DeleteChefConfigTemplate, DeleteChefConfig),
241252
string.Format(ClientRbTemplate, ClientConfig),
242253
string.Format(RunListTemplate, this.RunList),
243254
string.Format(BootStrapOptionsTemplate, this.BootstrapOptions));

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/Chef/VirtualMachineChefExtensionCmdletBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class VirtualMachineChefExtensionCmdletBase : VirtualMachineExtensionCmdl
2323
protected const string LinuxExtensionName = "LinuxChefClient";
2424
protected const string PrivateConfigurationTemplate = "{{\"validation_key\":\"{0}\"}}";
2525
protected const string AutoUpdateTemplate = "\"autoUpdateClient\":\"{0}\"";
26+
protected const string DeleteChefConfigTemplate = "\"deleteChefConfig\":\"{0}\"";
2627
protected const string ClientRbTemplate = "\"client_rb\":\"{0}\"";
2728
protected const string BootStrapOptionsTemplate = "\"bootstrap_options\":{0}";
2829
protected const string RunListTemplate = "\"runlist\": \"\\\"{0}\\\"\"";

src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33690,6 +33690,17 @@ PS C:\> Get-AzureVM -ServiceName "ContosoService03" -Name "Con
3369033690
</dev:type>
3369133691
<dev:defaultValue></dev:defaultValue>
3369233692
</command:parameter>
33693+
<command:parameter required="false" variableLength="false" globbing="false" position="named">
33694+
<maml:name>DeleteChefConfig</maml:name>
33695+
<maml:description>
33696+
<maml:para>DeleteChefConfig Options determines whether Chef configuration files removed when Azure removes the Chef resource extension from the VM. This options is useful during extension update and uninstall process. Default is false</maml:para>
33697+
</maml:description>
33698+
<dev:type>
33699+
<maml:name>Boolean</maml:name>
33700+
<maml:uri/>
33701+
</dev:type>
33702+
<dev:defaultValue>false</dev:defaultValue>
33703+
</command:parameter>
3369333704
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
3369433705
<maml:name>BootstrapOptions</maml:name>
3369533706
<maml:description>

0 commit comments

Comments
 (0)