Skip to content

Commit 0bddd80

Browse files
Revert VMSS.
1 parent 8c5d5f8 commit 0bddd80

File tree

1 file changed

+13
-173
lines changed

1 file changed

+13
-173
lines changed

src/ResourceManager/Compute/Commands.Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 13 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// Changes to this file may cause incorrect behavior and will be lost if the
2020
// code is regenerated.
2121

22-
using Microsoft.Azure.Commands.Common.Strategies.Compute;
2322
using Microsoft.Azure.Commands.Compute.Automation.Models;
2423
using Microsoft.Azure.Management.Compute;
2524
using Microsoft.Azure.Management.Compute.Models;
@@ -29,15 +28,6 @@
2928
using System.Collections.Generic;
3029
using System.Linq;
3130
using System.Management.Automation;
32-
using Microsoft.Azure.Commands.Common.Strategies;
33-
using Microsoft.Azure.Commands.Common.Strategies.ResourceManager;
34-
using System.Threading;
35-
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
36-
using Microsoft.Azure.Commands.Common.Strategies.Network;
37-
using Microsoft.Azure.Commands.Compute.Common;
38-
using System.Net;
39-
using Microsoft.Azure.Commands.Compute.Strategies;
40-
using System.Threading.Tasks;
4131

4232
namespace Microsoft.Azure.Commands.Compute.Automation
4333
{
@@ -126,114 +116,23 @@ protected PSArgument[] CreateVirtualMachineScaleSetCreateOrUpdateParameters()
126116
[OutputType(typeof(PSVirtualMachineScaleSet))]
127117
public partial class NewAzureRmVmss : ComputeAutomationBaseCmdlet
128118
{
129-
public const string SimpleParameterSet = "SimpleParameterSet";
130-
131119
public override void ExecuteCmdlet()
132120
{
133-
switch (ParameterSetName)
121+
ExecuteClientAction(() =>
134122
{
135-
case SimpleParameterSet:
136-
this.StartAndWait(SimpleParameterSetExecuteCmdlet);
137-
break;
138-
default:
139-
ExecuteClientAction(() =>
140-
{
141-
if (ShouldProcess(this.VMScaleSetName, VerbsCommon.New))
142-
{
143-
string resourceGroupName = this.ResourceGroupName;
144-
string vmScaleSetName = this.VMScaleSetName;
145-
VirtualMachineScaleSet parameters = new VirtualMachineScaleSet();
146-
ComputeAutomationAutoMapperProfile.Mapper.Map<PSVirtualMachineScaleSet, VirtualMachineScaleSet>(this.VirtualMachineScaleSet, parameters);
147-
148-
var result = VirtualMachineScaleSetsClient.CreateOrUpdate(resourceGroupName, vmScaleSetName, parameters);
149-
var psObject = new PSVirtualMachineScaleSet();
150-
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineScaleSet, PSVirtualMachineScaleSet>(result, psObject);
151-
WriteObject(psObject);
152-
}
153-
});
154-
break;
155-
}
156-
}
157-
158-
async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
159-
{
160-
ResourceGroupName = ResourceGroupName ?? VMScaleSetName;
161-
VirtualNetworkName = VirtualNetworkName ?? VMScaleSetName;
162-
SubnetName = SubnetName ?? VMScaleSetName;
163-
PublicIpAddressName = PublicIpAddressName ?? VMScaleSetName;
164-
DomainNameLabel = DomainNameLabel ?? (VMScaleSetName + ResourceGroupName).ToLower();
165-
SecurityGroupName = SecurityGroupName ?? VMScaleSetName;
166-
LoadBalancerName = LoadBalancerName ?? VMScaleSetName;
167-
168-
// get image
169-
var image = Images
170-
.Instance
171-
.Select(osAndMap =>
172-
new { OsType = osAndMap.Key, Image = osAndMap.Value.GetOrNull(ImageName) })
173-
.First(osAndImage => osAndImage.Image != null);
174-
175-
BackendPorts = BackendPorts
176-
?? (image.OsType == "Windows" ? new[] { 3389, 5985 } : new[] { 22 });
177-
178-
var resourceGroup = ResourceGroupStrategy.CreateResourceGroupConfig(ResourceGroupName);
179-
180-
var publicIpAddress = resourceGroup.CreatePublicIPAddressConfig(
181-
name: PublicIpAddressName,
182-
domainNameLabel: DomainNameLabel,
183-
allocationMethod: AllocationMethod);
184-
185-
var loadBalancer = resourceGroup.CreateLoadBalancerConfig(
186-
name: LoadBalancerName);
187-
188-
var virtualNetwork = resourceGroup.CreateVirtualNetworkConfig(
189-
name: VirtualNetworkName, addressPrefix: VnetAddressPrefix);
190-
191-
var subnet = virtualNetwork.CreateSubnet(SubnetName, SubnetAddressPrefix);
192-
193-
/*
194-
var networkSecurityGroup = resourceGroup.CreateNetworkSecurityGroupConfig(
195-
name: SecurityGroupName,
196-
openPorts: OpenPorts);
197-
198-
var networkInterface = resourceGroup.CreateNetworkInterfaceConfig(
199-
Name, subnet, publicIpAddress, networkSecurityGroup);*/
200-
201-
var virtualMachineScaleSet = resourceGroup.CreateVirtualMachineScaleSetConfig(
202-
name: VMScaleSetName,
203-
adminUsername: Credential.UserName,
204-
adminPassword: new NetworkCredential(string.Empty, Credential.Password).Password,
205-
image: image.Image);
206-
207-
var client = new Client(DefaultProfile.DefaultContext);
208-
209-
var current = virtualMachineScaleSet
210-
.GetStateAsync(client, new CancellationToken())
211-
.GetAwaiter()
212-
.GetResult();
213-
214-
if (Location == null)
215-
{
216-
Location = current.GetLocation(virtualMachineScaleSet);
217-
if (Location == null)
123+
if (ShouldProcess(this.VMScaleSetName, VerbsCommon.New))
218124
{
219-
Location = "eastus";
125+
string resourceGroupName = this.ResourceGroupName;
126+
string vmScaleSetName = this.VMScaleSetName;
127+
VirtualMachineScaleSet parameters = new VirtualMachineScaleSet();
128+
ComputeAutomationAutoMapperProfile.Mapper.Map<PSVirtualMachineScaleSet, VirtualMachineScaleSet>(this.VirtualMachineScaleSet, parameters);
129+
130+
var result = VirtualMachineScaleSetsClient.CreateOrUpdate(resourceGroupName, vmScaleSetName, parameters);
131+
var psObject = new PSVirtualMachineScaleSet();
132+
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineScaleSet, PSVirtualMachineScaleSet>(result, psObject);
133+
WriteObject(psObject);
220134
}
221-
}
222-
223-
var target = virtualMachineScaleSet.GetTargetState(current, client.SubscriptionId, Location);
224-
225-
if (ShouldProcess(VMScaleSetName, VerbsCommon.New))
226-
{
227-
var result = await virtualMachineScaleSet
228-
.UpdateStateAsync(
229-
client,
230-
target,
231-
new CancellationToken(),
232-
new ShouldProcess(asyncCmdlet),
233-
new ProgressReport(asyncCmdlet));
234-
235-
asyncCmdlet.WriteObject(result);
236-
}
135+
});
237136
}
238137

239138
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
@@ -247,9 +146,6 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
247146
ValueFromPipeline = false)]
248147
[AllowNull]
249148
[ResourceManager.Common.ArgumentCompleters.ResourceGroupCompleter()]
250-
[Parameter(
251-
ParameterSetName = SimpleParameterSet,
252-
Mandatory = false)]
253149
public string ResourceGroupName { get; set; }
254150

255151
[Parameter(
@@ -260,9 +156,6 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
260156
ValueFromPipeline = false)]
261157
[Alias("Name")]
262158
[AllowNull]
263-
[Parameter(
264-
ParameterSetName = SimpleParameterSet,
265-
Mandatory = true)]
266159
public string VMScaleSetName { get; set; }
267160

268161
[Parameter(
@@ -273,58 +166,5 @@ async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)
273166
ValueFromPipeline = true)]
274167
[AllowNull]
275168
public PSVirtualMachineScaleSet VirtualMachineScaleSet { get; set; }
276-
277-
// SimpleParameterSet
278-
279-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = true)]
280-
public string ImageName { get; set; } //= "Win2016Datacenter";
281-
282-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = true)]
283-
public PSCredential Credential { get; set; }
284-
285-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
286-
public int InstanceCount { get; set; } = 2;
287-
288-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
289-
public string VirtualNetworkName { get; set; }
290-
291-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
292-
public string SubnetName { get; set; }
293-
294-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
295-
public string PublicIpAddressName { get; set; }
296-
297-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
298-
public string DomainNameLabel { get; set; }
299-
300-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
301-
public string SecurityGroupName { get; set; }
302-
303-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
304-
public string LoadBalancerName { get; set; }
305-
306-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
307-
public int[] BackendPorts { get; set; }
308-
309-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
310-
[LocationCompleter]
311-
public string Location { get; set; }
312-
313-
// this corresponds to VmSku in the Azure CLI
314-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
315-
public string VmSize { get; set; } = "Standard_DS1_v2";
316-
317-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
318-
public UpgradeMode UpgradePolicyMode { get; set; }
319-
320-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
321-
[ValidateSet("Static", "Dynamic")]
322-
public string AllocationMethod { get; set; } = "Static";
323-
324-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
325-
public string VnetAddressPrefix { get; set; } = "192.168.0.0/16";
326-
327-
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
328-
public string SubnetAddressPrefix { get; set; } = "192.168.1.0/24";
329169
}
330-
}
170+
}

0 commit comments

Comments
 (0)