Skip to content

Commit d43920c

Browse files
author
siddheshwar-more
committed
AutoUpdateClient option added to set-azurevmchefextension cmdlet
1 parent 04137b7 commit d43920c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineChefExtensionCmdletB
7676
[ValidateNotNullOrEmpty]
7777
public string OrganizationName { get; set; }
7878

79+
[Parameter(
80+
ValueFromPipelineByPropertyName = true,
81+
HelpMessage = "Flag to opt for auto chef-client update. Chef-client update is false by default.")]
82+
[ValidateNotNullOrEmpty]
83+
public SwitchParameter EnableAutoUpdateClient { get; set; }
84+
7985
[Parameter(
8086
Mandatory = true,
8187
ParameterSetName = LinuxParameterSetName,
@@ -141,6 +147,7 @@ private void SetPublicConfig()
141147
bool IsChefServerUrlEmpty = string.IsNullOrEmpty(this.ChefServerUrl);
142148
bool IsValidationClientNameEmpty = string.IsNullOrEmpty(this.ValidationClientName);
143149
bool IsRunListEmpty = string.IsNullOrEmpty(this.RunList);
150+
string AutoUpdateClient = this.EnableAutoUpdateClient.IsPresent ? "true" : "false";
144151

145152
//Cases handled:
146153
// 1. When clientRb given by user and:
@@ -192,14 +199,16 @@ private void SetPublicConfig()
192199

193200
if (IsRunListEmpty)
194201
{
195-
this.PublicConfiguration = string.Format("{{{0}}}",
202+
this.PublicConfiguration = string.Format("{{{0},{1}}}",
203+
string.Format(AutoUpdateTemplate, AutoUpdateClient),
196204
string.Format(ClientRbTemplate, ClientConfig));
197205
}
198206
else
199207
{
200-
this.PublicConfiguration = string.Format("{{{0},{1}}}",
201-
string.Format(ClientRbTemplate, ClientConfig),
202-
string.Format(RunListTemplate, this.RunList));
208+
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
209+
string.Format(AutoUpdateTemplate, AutoUpdateClient),
210+
string.Format(ClientRbTemplate, ClientConfig),
211+
string.Format(RunListTemplate, this.RunList));
203212
}
204213
}
205214

@@ -223,4 +232,4 @@ protected override void ProcessRecord()
223232
ExecuteCommand();
224233
}
225234
}
226-
}
235+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class VirtualMachineChefExtensionCmdletBase : VirtualMachineExtensionCmdl
2222
protected const string ExtensionDefaultName = "ChefClient";
2323
protected const string LinuxExtensionName = "LinuxChefClient";
2424
protected const string PrivateConfigurationTemplate = "{{\"validation_key\":\"{0}\"}}";
25+
protected const string AutoUpdateTemplate = "\"autoUpdateClient\":\"{0}\"";
2526
protected const string ClientRbTemplate = "\"client_rb\":\"{0}\"";
2627
protected const string RunListTemplate = "\"runlist\": \"\\\"{0}\\\"\"";
2728

@@ -44,4 +45,4 @@ protected string GetPlatformSpecificExtensionName()
4445
else { return null; }
4546
}
4647
}
47-
}
48+
}

0 commit comments

Comments
 (0)