Skip to content

Clu #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2015
Merged

Clu #82

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public static bool Initialize()
protected override void Configure()
{
//Mapper.CreateMap<Microsoft.Azure.AzureOperationResponse, TO.PSOperation>();
//Mapper.CreateMap<FROM.ComputeLongRunningOperationResponse, TO.PSComputeLongRunningOperation>();
Mapper.CreateMap<FROM.VirtualMachineCaptureResult, TO.PSComputeLongRunningOperation>();
//Mapper.CreateMap<FROM.DeleteOperationResponse, TO.PSComputeLongRunningOperation>();

Mapper.CreateMap<FROM.AvailabilitySet, TO.PSAvailabilitySet>();
//Mapper.CreateMap<Microsoft.Azure.AzureOperationResponse, TO.PSAvailabilitySet>();

//Mapper.CreateMap<FROM.VirtualMachine, TO.PSVirtualMachine>();
Mapper.CreateMap<FROM.VirtualMachine, TO.PSVirtualMachine>();
//Mapper.CreateMap<Microsoft.Azure.AzureOperationResponse, TO.PSVirtualMachine>();

Mapper.CreateMap<FROM.VirtualMachineSize, TO.PSVirtualMachineSize>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Compute
{
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImage)]
[OutputType(typeof(PSVirtualMachineExtensionImage))]
[OutputType(typeof(PSVirtualMachineExtensionImageDetails))]
public class GetAzureVMExtensionImageCommand : VirtualMachineExtensionImageBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
public string Location { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
public string PublisherName { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
public string Type { get; set; }

[Parameter, ValidateNotNullOrEmpty]
public string FilterExpression { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true)]
public string Version { get; set; }

protected override void ProcessRecord()
{
base.ProcessRecord();

ExecuteClientAction(() =>
{
if (string.IsNullOrEmpty(this.Version))
{
// TODO, FilterExpression
var result = this.VirtualMachineExtensionImageClient.ListVersions(Location.Canonicalize(), PublisherName, Type);

var images = from r in result
select new PSVirtualMachineExtensionImage
{
Id = r.Id,
Location = r.Location,
Version = r.Name,
PublisherName = this.PublisherName,
Type = this.Type,
FilterExpression = this.FilterExpression
};

WriteObject(result, true);
// TODO: Cannot Write the Result from Linq Select.
//WriteObject(images, true);
}
else
{
var result = this.VirtualMachineExtensionImageClient.Get(Location.Canonicalize(), PublisherName, Type, Version);

var image = new PSVirtualMachineExtensionImageDetails
{
Id = result.Id,
Location = result.Location,
HandlerSchema = result.HandlerSchema,
OperatingSystem = result.OperatingSystem,
ComputeRole = result.ComputeRole,
SupportsMultipleExtensions = result.SupportsMultipleExtensions,
VMScaleSetEnabled = result.VmScaleSetEnabled,
Version = result.Name,
PublisherName = this.PublisherName,
Type = this.Type,
FilterExpression = this.FilterExpression
};

WriteObject(image);
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Compute
{
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImageType)]
[OutputType(typeof(PSVirtualMachineExtensionImageType))]
public class GetAzureVMExtensionImageTypeCommand : VirtualMachineExtensionImageBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
public string Location { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
public string PublisherName { get; set; }

protected override void ProcessRecord()
{
base.ProcessRecord();

ExecuteClientAction(() =>
{
var result = this.VirtualMachineExtensionImageClient.ListTypes(Location.Canonicalize(), PublisherName);

var images = from r in result
select new PSVirtualMachineExtensionImageType
{
Id = r.Id,
Location = r.Location,
Type = r.Name,
PublisherName = this.PublisherName
};

WriteObject(result, true);
// TODO: Cannot Write the Result from Linq Select.
//WriteObject(images, true);
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Management.Compute;

namespace Microsoft.Azure.Commands.Compute
{
public abstract class VirtualMachineExtensionImageBaseCmdlet : ComputeClientBaseCmdlet
{
public IVirtualMachineExtensionImagesOperations VirtualMachineExtensionImageClient
{
get
{
return ComputeClient.ComputeManagementClient.VirtualMachineExtensionImages;
}
}
}
}
178 changes: 178 additions & 0 deletions src/CLU/Microsoft.Azure.Commands.Compute/Models/PSVirtualMachine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using Microsoft.Azure.Management.Compute.Models;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Microsoft.Azure.Commands.Compute.Models
{
public class PSVirtualMachine : PSOperation
{
// Gets or sets the property of 'ResourceGroupName'
public string ResourceGroupName
{
get
{
if (string.IsNullOrEmpty(Id)) return null;
Regex r = new Regex(@"(.*?)/resourcegroups/(?<rgname>\S+)/providers/(.*?)", RegexOptions.IgnoreCase);
Match m = r.Match(Id);
return m.Success ? m.Groups["rgname"].Value : null;
}
}

// Gets or sets the property of 'Id'
public string Id { get; set; }

// Gets or sets the property of 'Name'
public string Name { get; set; }

// Gets or sets the property of 'Type'
public string Type { get; set; }

// Gets or sets the property of 'Location'
public string Location { get; set; }

// Gets or sets the property of 'Tags'
public IDictionary<string, string> Tags { get; set; }

[JsonIgnore]
public string TagsText
{
get { return JsonConvert.SerializeObject(Tags, Formatting.Indented); }
}

// Gets or sets the reference Id of the availailbity set to which this virtual machine belongs.
public SubResource AvailabilitySetReference { get; set; }

[JsonIgnore]
public string AvailabilitySetReferenceText
{
get { return JsonConvert.SerializeObject(AvailabilitySetReference, Formatting.Indented); }
}

// Gets or sets the diagnostics profile.
public DiagnosticsProfile DiagnosticsProfile { get; set; }

[JsonIgnore]
public string DiagnosticsProfileText
{
get { return JsonConvert.SerializeObject(DiagnosticsProfile, Formatting.Indented); }
}

// Gets the virtual machine child extension resources.
public IList<VirtualMachineExtension> Extensions { get; set; }

[JsonIgnore]
public string ExtensionsText
{
get { return JsonConvert.SerializeObject(Extensions, Formatting.Indented); }
}

// Gets or sets the hardware profile.
public HardwareProfile HardwareProfile { get; set; }

[JsonIgnore]
public string HardwareProfileText
{
get { return JsonConvert.SerializeObject(HardwareProfile, Formatting.Indented); }
}

// Gets the virtual machine instance view.
public VirtualMachineInstanceView InstanceView { get; set; }

[JsonIgnore]
public string InstanceViewText
{
get { return JsonConvert.SerializeObject(InstanceView, Formatting.Indented); }
}

// Gets or sets the network profile.
public NetworkProfile NetworkProfile { get; set; }

[JsonIgnore]
public string NetworkProfileText
{
get { return JsonConvert.SerializeObject(NetworkProfile, Formatting.Indented); }
}

// Gets or sets the OS profile.
public OSProfile OSProfile { get; set; }

[JsonIgnore]
public string OSProfileText
{
get { return JsonConvert.SerializeObject(OSProfile, Formatting.Indented); }
}

// Gets or sets the purchase plan when deploying virtual machine from VM Marketplace images.
public Plan Plan { get; set; }

[JsonIgnore]
public string PlanText
{
get { return JsonConvert.SerializeObject(Plan, Formatting.Indented); }
}

// Gets or sets the provisioning state, which only appears in the response.
public string ProvisioningState { get; set; }

// Gets or sets the storage profile.
public StorageProfile StorageProfile { get; set; }

[JsonIgnore]
public string StorageProfileText
{
get { return JsonConvert.SerializeObject(StorageProfile, Formatting.Indented); }
}

[JsonIgnore]
public string[] DataDiskNames
{
get
{
if (this.StorageProfile == null) return null;
var listStr = new List<string>();
foreach (var item in StorageProfile.DataDisks)
{
listStr.Add(item.Name);
}
return listStr.ToArray();
}
}

[JsonIgnore]
public string[] NetworkInterfaceIDs
{
get
{
if (this.NetworkProfile == null) return null;
var listStr = new List<string>();
foreach (var item in NetworkProfile.NetworkInterfaces)
{
listStr.Add(item.Id);
}
return listStr.ToArray();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class PSVirtualMachineExtensionImageDetails : PSVirtualMachineExtensionIm

public string ComputeRole { get; set; }

public bool SupportsMultipleExtensions { get; set; }
public bool? SupportsMultipleExtensions { get; set; }

public bool VMScaleSetEnabled { get; set; }
public bool? VMScaleSetEnabled { get; set; }
}
}
Loading