Skip to content

Commit 0ba136c

Browse files
author
siddheshwar-more
committed
Added changes to support bootstrap options for chef extension
1 parent 09581f4 commit 0ba136c

File tree

3 files changed

+75
-9
lines changed

3 files changed

+75
-9
lines changed

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

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public class SetAzureVMChefExtensionCommand : VirtualMachineChefExtensionCmdletB
5353
[ValidateNotNullOrEmpty]
5454
public string ClientRb { get; set; }
5555

56+
[Parameter(
57+
ValueFromPipelineByPropertyName = true,
58+
HelpMessage = "The Chef Client bootstrap options in JSON format.")]
59+
[ValidateNotNullOrEmpty]
60+
public string BootstrapOptions { get; set; }
61+
5662
[Parameter(
5763
ValueFromPipelineByPropertyName = true,
5864
HelpMessage = "The Chef Server Node Runlist.")]
@@ -152,6 +158,7 @@ private void SetPublicConfig()
152158
bool IsChefServerUrlEmpty = string.IsNullOrEmpty(this.ChefServerUrl);
153159
bool IsValidationClientNameEmpty = string.IsNullOrEmpty(this.ValidationClientName);
154160
bool IsRunListEmpty = string.IsNullOrEmpty(this.RunList);
161+
bool IsBootstrapOptionsEmpty = string.IsNullOrEmpty(this.BootstrapOptions);
155162
string AutoUpdateChefClient = this.AutoUpdateChefClient.IsPresent ? "true" : "false";
156163

157164
//Cases handled:
@@ -204,17 +211,39 @@ private void SetPublicConfig()
204211

205212
if (IsRunListEmpty)
206213
{
207-
this.PublicConfiguration = string.Format("{{{0},{1}}}",
208-
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
209-
string.Format(ClientRbTemplate, ClientConfig));
214+
if (IsBootstrapOptionsEmpty)
215+
{
216+
this.PublicConfiguration = string.Format("{{{0},{1}}}",
217+
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
218+
string.Format(ClientRbTemplate, ClientConfig));
219+
}
220+
else
221+
{
222+
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
223+
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
224+
string.Format(ClientRbTemplate, ClientConfig),
225+
string.Format(BootStrapOptionsTemplate, this.BootstrapOptions));
226+
}
210227
}
211228
else
212229
{
213-
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
214-
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
215-
string.Format(ClientRbTemplate, ClientConfig),
216-
string.Format(RunListTemplate, this.RunList));
230+
if (IsBootstrapOptionsEmpty)
231+
{
232+
this.PublicConfiguration = string.Format("{{{0},{1},{2}}}",
233+
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
234+
string.Format(ClientRbTemplate, ClientConfig),
235+
string.Format(RunListTemplate, this.RunList));
236+
}
237+
else
238+
{
239+
this.PublicConfiguration = string.Format("{{{0},{1},{2},{3}}",
240+
string.Format(AutoUpdateTemplate, AutoUpdateChefClient),
241+
string.Format(ClientRbTemplate, ClientConfig),
242+
string.Format(RunListTemplate, this.RunList),
243+
string.Format(BootStrapOptionsTemplate, this.BootstrapOptions));
244+
}
217245
}
246+
218247
}
219248

220249
protected override void ValidateParameters()

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

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

2930
public VirtualMachineChefExtensionCmdletBase()

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33690,6 +33690,18 @@ 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" pipelineInput="true (ByPropertyName)" position="named">
33694+
<maml:name>BootstrapOptions</maml:name>
33695+
<maml:description>
33696+
<maml:para>Bootstrap Options in JSON Format</maml:para>
33697+
</maml:description>
33698+
<command:parameterValue required="false" variableLength="false">BootstrapOptions</command:parameterValue>
33699+
<dev:type>
33700+
<maml:name>String</maml:name>
33701+
<maml:uri/>
33702+
</dev:type>
33703+
<dev:defaultValue></dev:defaultValue>
33704+
</command:parameter>
3369333705
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
3369433706
<maml:name>ValidationClientName</maml:name>
3369533707
<maml:description>
@@ -33822,14 +33834,38 @@ PS C:\&gt; Get-AzureVM -ServiceName &quot;ContosoService03&quot; -Name &quot;Con
3382233834
</command:commandLine>
3382333835
</command:commandLines>
3382433836
</command:example>
33825-
3382633837
<command:example>
3382733838
<maml:title>
3382833839
-------------------------- EXAMPLE 2 --------------------------
3382933840
</maml:title>
3383033841
<maml:introduction>
3383133842
<maml:para>C:\PS&gt;</maml:para>
3383233843
</maml:introduction>
33844+
<dev:code>
33845+
Set-AzureVMChefExtension -VM $vm -ValidationPem "C:\\myorg-validator.pem" -BootstrapOptions '{"chef_node_name":"your_node_name","chef_server_url":"https://api.opscode.com/organizations/some-org", "validation_client_name":"some-org-validator"}' -RunList "apache" -Windows;
33846+
</dev:code>
33847+
<dev:remarks>
33848+
<maml:para>Description</maml:para>
33849+
<maml:para>-----------</maml:para>
33850+
<maml:para>This cmdlet adds the Chef extension to a windows VM.</maml:para>
33851+
<maml:para>When the VM comes up, it will be bootstrapped with Chef and have apache running on it, while bootstraping it will refer 'BootstrapOptions' specified in JSON format.</maml:para>
33852+
<maml:para></maml:para>
33853+
<maml:para></maml:para>
33854+
<maml:para></maml:para>
33855+
</dev:remarks>
33856+
<command:commandLines>
33857+
<command:commandLine>
33858+
<command:commandText></command:commandText>
33859+
</command:commandLine>
33860+
</command:commandLines>
33861+
</command:example>
33862+
<command:example>
33863+
<maml:title>
33864+
-------------------------- EXAMPLE 3 --------------------------
33865+
</maml:title>
33866+
<maml:introduction>
33867+
<maml:para>C:\PS&gt;</maml:para>
33868+
</maml:introduction>
3383333869
<dev:code>
3383433870
Set-AzureVMChefExtension -VM $vm -ValidationPem "C:\\myorg-validator.pem" -ChefServerUrl "http://ipaddress:port" -ValidationClientName "myorg-validator" -RunList "apache, git" -Windows;
3383533871
</dev:code>
@@ -33851,7 +33887,7 @@ PS C:\&gt; Get-AzureVM -ServiceName &quot;ContosoService03&quot; -Name &quot;Con
3385133887

3385233888
<command:example>
3385333889
<maml:title>
33854-
-------------------------- EXAMPLE 3 --------------------------
33890+
-------------------------- EXAMPLE 4 --------------------------
3385533891
</maml:title>
3385633892
<maml:introduction>
3385733893
<maml:para>C:\PS&gt;</maml:para>

0 commit comments

Comments
 (0)