Skip to content

Commit 800d9a4

Browse files
committed
Auto-generator for helper cmdlets
1 parent 90e32e8 commit 800d9a4

27 files changed

+3474
-52
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -78,49 +78,31 @@ function Test-VirtualMachineScaleSet
7878
$stoaccount = Get-AzureRMStorageAccount -ResourceGroupName $rgname -Name $stoname;
7979

8080
# New VMSS Parameters
81-
$vmss = New-AzureComputeParameterObject -FullName Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSet;
82-
$vmss.Name = 'vmss' + $rgname;
83-
$vmss.Type = 'Microsoft.Compute/virtualMachineScaleSets';
84-
$vmss.Location = $loc;
85-
86-
$vmss.VirtualMachineProfile = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetVMProfile;
87-
$vmss.VirtualMachineProfile.ExtensionProfile = $null;
88-
$vmss.Sku = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetSku;
89-
$vmss.Sku.Capacity = 2;
90-
$vmss.Sku.Name = 'Standard_A0';
91-
$vmss.UpgradePolicy = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetUpgradePolicy;
92-
$vmss.UpgradePolicy.Mode = 'automatic';
93-
94-
$vmss.VirtualMachineProfile.NetworkProfile = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetNetworkProfile;
95-
$ipCfg = New-Object Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetIPConfiguration;
96-
$ipcfg.Name = 'test';
97-
$ipCfg.LoadBalancerBackendAddressPools = $null;
98-
$ipCfg.Subnet = New-Object Microsoft.Azure.Management.Compute.Models.ApiEntityReference;
99-
$ipCfg.Subnet.ReferenceUri = $subnetId;
100-
$netCfg = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetNetworkConfiguration;
101-
$netCfg.Name = 'test';
102-
$netCfg.Primary = $true;
103-
$netCfg.IPConfigurations.Add($ipCfg);
104-
$vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations.Add($netCfg);
105-
106-
$vmss.VirtualMachineProfile.OSProfile = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetOSProfile;
107-
$vmss.VirtualMachineProfile.OSProfile.ComputerNamePrefix = 'test';
108-
$vmss.VirtualMachineProfile.OSProfile.AdminUsername = 'Foo12';
109-
$vmss.VirtualMachineProfile.OSProfile.AdminPassword = "BaR@123" + $rgname;
110-
111-
$vmss.VirtualMachineProfile.StorageProfile = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetStorageProfile;
81+
$vmssName = 'vmss' + $rgname;
82+
$vmssType = 'Microsoft.Compute/virtualMachineScaleSets';
83+
84+
$adminUsername = 'Foo12';
85+
$adminPassword = "BaR@123" + $rgname;
86+
11287
$imgRef = Get-DefaultCRPImage -loc $loc;
113-
$vmss.VirtualMachineProfile.StorageProfile.ImageReference = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetImageReference;
114-
$vmss.VirtualMachineProfile.StorageProfile.ImageReference.Publisher = $imgRef.PublisherName;
115-
$vmss.VirtualMachineProfile.StorageProfile.ImageReference.Offer = $imgRef.Offer;
116-
$vmss.VirtualMachineProfile.StorageProfile.ImageReference.Sku = $imgRef.Skus;
117-
$vmss.VirtualMachineProfile.StorageProfile.ImageReference.Version = $imgRef.Version;
118-
$vmss.VirtualMachineProfile.StorageProfile.OSDisk = New-AzureComputeParameterObject -FriendlyName VirtualMachineScaleSetOSDisk;
119-
$vmss.VirtualMachineProfile.StorageProfile.OSDisk.Caching = 'None';
120-
$vmss.VirtualMachineProfile.StorageProfile.OSDisk.CreateOption = 'FromImage';
121-
$vmss.VirtualMachineProfile.StorageProfile.OSDisk.Name = 'test';
122-
$vhdContainer = "https://" + $stoname + ".blob.core.windows.net/" + $vmss.Name;
123-
$vmss.VirtualMachineProfile.StorageProfile.OSDisk.VirtualHardDiskContainers.Add($vhdContainer);
88+
$vhdContainer = "https://" + $stoname + ".blob.core.windows.net/" + $vmssName;
89+
90+
$aucComponentName="Microsoft-Windows-Shell-Setup";
91+
$aucPassName ="oobeSystem";
92+
$aucSetting = "AutoLogon";
93+
$aucContent = "<UserAccounts><AdministratorPassword><Value>password</Value><PlainText>true</PlainText></AdministratorPassword></UserAccounts>";
94+
95+
$ipCfg = New-AzureVmssIPConfigurationsConfig -Name 'test' -LoadBalancerBackendAddressPoolsReferenceUri $null -SubnetReferenceUri $subnetId;
96+
97+
$vmss = New-AzureVmssConfig -Name $vmssName -Type $vmssType -Location $loc `
98+
-SkuCapacity 2 -SkuName 'Standard_A0' -UpgradePolicyMode 'automatic' -NetworkInterfaceConfigurations $netCfg `
99+
| Add-AzureVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfigurations $ipCfg `
100+
| Set-AzureVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
101+
| Set-AzureVmssStorageProfile -Name 'test' -CreateOption 'FromImage' -Caching 'None' `
102+
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion $imgRef.Version `
103+
-ImageReferencePublisher $imgRef.PublisherName -VirtualHardDiskContainers $vhdContainer `
104+
| Add-AzureVmssAdditionalUnattendContent -ComponentName $aucComponentName -Content $aucContent -PassName $aucPassName -SettingName $aucSetting `
105+
| Remove-AzureVmssAdditionalUnattendContent -ComponentName $aucComponentName;
124106

125107
$st = New-AzureRmVmss -ResourceGroupName $rgname -VirtualMachineScaleSetCreateOrUpdateParameters $vmss;
126108

@@ -136,7 +118,6 @@ function Test-VirtualMachineScaleSet
136118

137119
$argList = New-AzureComputeArgumentList -MethodName VirtualMachineScaleSetListAll;
138120
$args = ($argList | select -ExpandProperty Value);
139-
#$vmssList = Invoke-AzureComputeMethod -MethodName VirtualMachineScaleSetListAll -ArgumentList $args;
140121
$vmssList = Get-AzureRmVmssAllList;
141122
Assert-True { ($vmssList.VirtualMachineScaleSets | select -ExpandProperty Name) -contains $vmss.Name };
142123
$output = $vmssList | Out-String;
@@ -165,7 +146,6 @@ function Test-VirtualMachineScaleSet
165146
$argList[2].Value = $rgname;
166147
$argList[4].Value = $vmss.Name;
167148
$args = ($argList | select -ExpandProperty Value);
168-
#$vmListResult = Invoke-AzureComputeMethod -MethodName VirtualMachineScaleSetVMList -ArgumentList $args;
169149
$vmListResult = Get-AzureRmVmssVMList -ResourceGroupName $rgname -VirtualMachineScaleSetName $vmss.Name;
170150
$output = $vmListResult | Out-String;
171151
Write-Verbose ($output);

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,39 @@
269269
<Compile Include="Generated\VirtualMachineScaleSetVM\VirtualMachineScaleSetVMPowerOffMethod.cs" />
270270
<Compile Include="Generated\VirtualMachineScaleSetVM\VirtualMachineScaleSetVMRestartMethod.cs" />
271271
<Compile Include="Generated\VirtualMachineScaleSetVM\VirtualMachineScaleSetVMStartMethod.cs" />
272+
<Compile Include="Generated\VirtualMachineScaleSet\Config\AddAzureVmssAdditionalUnattendContentCommand.cs">
273+
<SubType>Code</SubType>
274+
</Compile>
275+
<Compile Include="Generated\VirtualMachineScaleSet\Config\AddAzureVmssExtensionCommand.cs">
276+
<SubType>Code</SubType>
277+
</Compile>
278+
<Compile Include="Generated\VirtualMachineScaleSet\Config\AddAzureVmssListenerCommand.cs">
279+
<SubType>Code</SubType>
280+
</Compile>
281+
<Compile Include="Generated\VirtualMachineScaleSet\Config\AddAzureVmssNetworkInterfaceConfigurationCommand.cs">
282+
<SubType>Code</SubType>
283+
</Compile>
284+
<Compile Include="Generated\VirtualMachineScaleSet\Config\AddAzureVmssPublicKeyCommand.cs">
285+
<SubType>Code</SubType>
286+
</Compile>
287+
<Compile Include="Generated\VirtualMachineScaleSet\Config\AddAzureVmssSecretCommand.cs">
288+
<SubType>Code</SubType>
289+
</Compile>
290+
<Compile Include="Generated\VirtualMachineScaleSet\Config\NewAzureVmssConfigCommand.cs" />
291+
<Compile Include="Generated\VirtualMachineScaleSet\Config\NewAzureVmssIPConfigurationsConfigCommand.cs" />
292+
<Compile Include="Generated\VirtualMachineScaleSet\Config\NewAzureVmssVaultCertificatesConfigCommand.cs" />
293+
<Compile Include="Generated\VirtualMachineScaleSet\Config\RemoveAzureVmssAdditionalUnattendContentCommand.cs" />
294+
<Compile Include="Generated\VirtualMachineScaleSet\Config\RemoveAzureVmssExtensionCommand.cs" />
295+
<Compile Include="Generated\VirtualMachineScaleSet\Config\RemoveAzureVmssListenerCommand.cs" />
296+
<Compile Include="Generated\VirtualMachineScaleSet\Config\RemoveAzureVmssNetworkInterfaceConfigurationCommand.cs" />
297+
<Compile Include="Generated\VirtualMachineScaleSet\Config\RemoveAzureVmssPublicKeyCommand.cs" />
298+
<Compile Include="Generated\VirtualMachineScaleSet\Config\RemoveAzureVmssSecretCommand.cs" />
299+
<Compile Include="Generated\VirtualMachineScaleSet\Config\SetAzureVmssOSProfileCommand.cs">
300+
<SubType>Code</SubType>
301+
</Compile>
302+
<Compile Include="Generated\VirtualMachineScaleSet\Config\SetAzureVmssStorageProfileCommand.cs">
303+
<SubType>Code</SubType>
304+
</Compile>
272305
<Compile Include="Generated\VirtualMachineScaleSet\VirtualMachineScaleSetCreateOrUpdateMethod.cs" />
273306
<Compile Include="Generated\VirtualMachineScaleSet\VirtualMachineScaleSetDeallocateInstancesMethod.cs" />
274307
<Compile Include="Generated\VirtualMachineScaleSet\VirtualMachineScaleSetDeallocateMethod.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
//
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
22+
using Microsoft.Azure.Management.Compute.Models;
23+
using System;
24+
using System.Collections.Generic;
25+
using System.Linq;
26+
using System.Management.Automation;
27+
28+
namespace Microsoft.Azure.Commands.Compute.Automation
29+
{
30+
[Cmdlet("Add", "AzureVmssAdditionalUnattendContent")]
31+
[OutputType(typeof(VirtualMachineScaleSet))]
32+
public class AddAzureVmssAdditionalUnattendContentCommand : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet
33+
{
34+
[Parameter(
35+
Mandatory = false,
36+
Position = 0,
37+
ValueFromPipeline = true,
38+
ValueFromPipelineByPropertyName = true)]
39+
public VirtualMachineScaleSet VirtualMachineScaleSet { get; set; }
40+
41+
[Parameter(
42+
Mandatory = false,
43+
Position = 1,
44+
ValueFromPipelineByPropertyName = true)]
45+
public string ComponentName { get; set; }
46+
47+
[Parameter(
48+
Mandatory = false,
49+
Position = 2,
50+
ValueFromPipelineByPropertyName = true)]
51+
public string Content { get; set; }
52+
53+
[Parameter(
54+
Mandatory = false,
55+
Position = 3,
56+
ValueFromPipelineByPropertyName = true)]
57+
public string PassName { get; set; }
58+
59+
[Parameter(
60+
Mandatory = false,
61+
Position = 4,
62+
ValueFromPipelineByPropertyName = true)]
63+
public string SettingName { get; set; }
64+
65+
protected override void ProcessRecord()
66+
{
67+
68+
// VirtualMachineProfile
69+
if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
70+
{
71+
this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
72+
}
73+
74+
75+
// OSProfile
76+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile == null)
77+
{
78+
this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetOSProfile();
79+
}
80+
81+
82+
// WindowsConfiguration
83+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile.WindowsConfiguration == null)
84+
{
85+
this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile.WindowsConfiguration = new Microsoft.Azure.Management.Compute.Models.WindowsConfiguration();
86+
}
87+
88+
89+
// AdditionalUnattendContents
90+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile.WindowsConfiguration.AdditionalUnattendContents == null)
91+
{
92+
this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile.WindowsConfiguration.AdditionalUnattendContents = new List<Microsoft.Azure.Management.Compute.Models.AdditionalUnattendContent>();
93+
}
94+
95+
96+
var vAdditionalUnattendContents = new Microsoft.Azure.Management.Compute.Models.AdditionalUnattendContent();
97+
98+
vAdditionalUnattendContents.ComponentName = this.ComponentName;
99+
vAdditionalUnattendContents.Content = this.Content;
100+
vAdditionalUnattendContents.PassName = this.PassName;
101+
vAdditionalUnattendContents.SettingName = this.SettingName;
102+
this.VirtualMachineScaleSet.VirtualMachineProfile.OSProfile.WindowsConfiguration.AdditionalUnattendContents.Add(vAdditionalUnattendContents);
103+
WriteObject(this.VirtualMachineScaleSet);
104+
}
105+
}
106+
}
107+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
//
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
22+
using Microsoft.Azure.Management.Compute.Models;
23+
using System;
24+
using System.Collections.Generic;
25+
using System.Linq;
26+
using System.Management.Automation;
27+
28+
namespace Microsoft.Azure.Commands.Compute.Automation
29+
{
30+
[Cmdlet("Add", "AzureVmssExtension")]
31+
[OutputType(typeof(VirtualMachineScaleSet))]
32+
public class AddAzureVmssExtensionCommand : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet
33+
{
34+
[Parameter(
35+
Mandatory = false,
36+
Position = 0,
37+
ValueFromPipeline = true,
38+
ValueFromPipelineByPropertyName = true)]
39+
public VirtualMachineScaleSet VirtualMachineScaleSet { get; set; }
40+
41+
[Parameter(
42+
Mandatory = false,
43+
Position = 1,
44+
ValueFromPipelineByPropertyName = true)]
45+
public bool AutoUpgradeMinorVersion { get; set; }
46+
47+
[Parameter(
48+
Mandatory = false,
49+
Position = 2,
50+
ValueFromPipelineByPropertyName = true)]
51+
public string ExtensionType { get; set; }
52+
53+
[Parameter(
54+
Mandatory = false,
55+
Position = 3,
56+
ValueFromPipelineByPropertyName = true)]
57+
public string ProtectedSettings { get; set; }
58+
59+
[Parameter(
60+
Mandatory = false,
61+
Position = 4,
62+
ValueFromPipelineByPropertyName = true)]
63+
public string ProvisioningState { get; set; }
64+
65+
[Parameter(
66+
Mandatory = false,
67+
Position = 5,
68+
ValueFromPipelineByPropertyName = true)]
69+
public string Publisher { get; set; }
70+
71+
[Parameter(
72+
Mandatory = false,
73+
Position = 6,
74+
ValueFromPipelineByPropertyName = true)]
75+
public string Settings { get; set; }
76+
77+
[Parameter(
78+
Mandatory = false,
79+
Position = 7,
80+
ValueFromPipelineByPropertyName = true)]
81+
public string TypeHandlerVersion { get; set; }
82+
83+
[Parameter(
84+
Mandatory = false,
85+
Position = 8,
86+
ValueFromPipelineByPropertyName = true)]
87+
public string Id { get; set; }
88+
89+
[Parameter(
90+
Mandatory = false,
91+
Position = 9,
92+
ValueFromPipelineByPropertyName = true)]
93+
public string Name { get; set; }
94+
95+
[Parameter(
96+
Mandatory = false,
97+
Position = 10,
98+
ValueFromPipelineByPropertyName = true)]
99+
public string Type { get; set; }
100+
101+
[Parameter(
102+
Mandatory = false,
103+
Position = 11,
104+
ValueFromPipelineByPropertyName = true)]
105+
public string Location { get; set; }
106+
107+
[Parameter(
108+
Mandatory = false,
109+
Position = 12,
110+
ValueFromPipelineByPropertyName = true)]
111+
public IDictionary<string,string> Tags { get; set; }
112+
113+
protected override void ProcessRecord()
114+
{
115+
116+
// VirtualMachineProfile
117+
if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
118+
{
119+
this.VirtualMachineScaleSet.VirtualMachineProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetVMProfile();
120+
}
121+
122+
123+
// ExtensionProfile
124+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile == null)
125+
{
126+
this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtensionProfile();
127+
}
128+
129+
130+
// Extensions
131+
if (this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions == null)
132+
{
133+
this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions = new List<Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension>();
134+
}
135+
136+
137+
var vExtensions = new Microsoft.Azure.Management.Compute.Models.VirtualMachineScaleSetExtension();
138+
139+
vExtensions.AutoUpgradeMinorVersion = this.AutoUpgradeMinorVersion;
140+
vExtensions.ExtensionType = this.ExtensionType;
141+
vExtensions.ProtectedSettings = this.ProtectedSettings;
142+
vExtensions.ProvisioningState = this.ProvisioningState;
143+
vExtensions.Publisher = this.Publisher;
144+
vExtensions.Settings = this.Settings;
145+
vExtensions.TypeHandlerVersion = this.TypeHandlerVersion;
146+
vExtensions.Id = this.Id;
147+
vExtensions.Name = this.Name;
148+
vExtensions.Type = this.Type;
149+
vExtensions.Location = this.Location;
150+
vExtensions.Tags = this.Tags;
151+
this.VirtualMachineScaleSet.VirtualMachineProfile.ExtensionProfile.Extensions.Add(vExtensions);
152+
WriteObject(this.VirtualMachineScaleSet);
153+
}
154+
}
155+
}
156+

0 commit comments

Comments
 (0)