Skip to content

Commit

Permalink
imagename case insensetive
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Nov 29, 2017
1 parent b5d723f commit dba029c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.ResourceManager.Models;
using System;

namespace Microsoft.Azure.Commands.Common.Strategies.Network
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ public abstract class ComputeClientBaseCmdlet : Microsoft.Azure.Commands.Resourc
{
protected const string VirtualMachineExtensionType = "Microsoft.Compute/virtualMachines/extensions";

protected override bool IsUsageMetricEnabled
{
get { return true; }
}
protected override bool IsUsageMetricEnabled => true;

private ComputeClient computeClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ public ProgressReportType(Cmdlet cmdlet)
public void Report<TModel>(ResourceConfig<TModel> config, double progress)
where TModel : class
{

}
/*
=> _Cmdlet.WriteVerbose(
Expand All @@ -231,9 +230,11 @@ public void StrategyExecuteCmdlet()
// get image
var image = Images
.Instance
.Select(osAndMap =>
new { OsType = osAndMap.Key, Image = osAndMap.Value.GetOrNull(ImageName) })
.First(osAndImage => osAndImage.Image != null);
.SelectMany(osAndMap => osAndMap
.Value
.Where(nameAndImage => nameAndImage.Key.ToLower() == ImageName.ToLower())
.Select(nameAndImage => new { OsType = osAndMap.Key, Image = nameAndImage.Value }))
.FirstOrDefault();

OpenPorts = OpenPorts
?? (image.OsType == "Windows" ? new[] { 3389, 5985 } : new[] { 22 });
Expand All @@ -258,6 +259,7 @@ public void StrategyExecuteCmdlet()
adminPassword: new NetworkCredential(string.Empty, Credential.Password).Password,
image: image.Image);

// get state
var client = new Client(DefaultProfile.DefaultContext);
var current = virtualMachine
.GetStateAsync(client, new CancellationToken())
Expand All @@ -273,8 +275,10 @@ public void StrategyExecuteCmdlet()
}
}

// create target state
var target = virtualMachine.GetTargetState(current, client.SubscriptionId, Location);

// apply target state
var result = virtualMachine
.UpdateStateAsync(
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ public abstract class VirtualMachineBaseCmdlet : ComputeClientBaseCmdlet
{
protected const InstanceViewTypes InstanceViewExpand = InstanceViewTypes.InstanceView;

public IVirtualMachinesOperations VirtualMachineClient
{
get
{
return ComputeClient.ComputeManagementClient.VirtualMachines;
}
}
public IVirtualMachinesOperations VirtualMachineClient
=> ComputeClient.ComputeManagementClient.VirtualMachines;

public static string FormatObject(Object obj)
{
Expand Down

0 comments on commit dba029c

Please sign in to comment.