Skip to content

Commit e05c2f0

Browse files
committed
Merge pull request #82 from huangpf/clu
Clu
2 parents 76f78e5 + 55ee202 commit e05c2f0

33 files changed

+3247
-4
lines changed

src/CLU/Microsoft.Azure.Commands.Compute/Common/ComputeAutoMapperProfile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ public static bool Initialize()
6868
protected override void Configure()
6969
{
7070
//Mapper.CreateMap<Microsoft.Azure.AzureOperationResponse, TO.PSOperation>();
71-
//Mapper.CreateMap<FROM.ComputeLongRunningOperationResponse, TO.PSComputeLongRunningOperation>();
71+
Mapper.CreateMap<FROM.VirtualMachineCaptureResult, TO.PSComputeLongRunningOperation>();
7272
//Mapper.CreateMap<FROM.DeleteOperationResponse, TO.PSComputeLongRunningOperation>();
7373

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

77-
//Mapper.CreateMap<FROM.VirtualMachine, TO.PSVirtualMachine>();
77+
Mapper.CreateMap<FROM.VirtualMachine, TO.PSVirtualMachine>();
7878
//Mapper.CreateMap<Microsoft.Azure.AzureOperationResponse, TO.PSVirtualMachine>();
7979

8080
Mapper.CreateMap<FROM.VirtualMachineSize, TO.PSVirtualMachineSize>();
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
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+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Compute.Common;
16+
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Management.Compute;
18+
using Microsoft.Azure.Management.Compute.Models;
19+
using System.Linq;
20+
using System.Management.Automation;
21+
22+
namespace Microsoft.Azure.Commands.Compute
23+
{
24+
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImage)]
25+
[OutputType(typeof(PSVirtualMachineExtensionImage))]
26+
[OutputType(typeof(PSVirtualMachineExtensionImageDetails))]
27+
public class GetAzureVMExtensionImageCommand : VirtualMachineExtensionImageBaseCmdlet
28+
{
29+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
30+
public string Location { get; set; }
31+
32+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
33+
public string PublisherName { get; set; }
34+
35+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
36+
public string Type { get; set; }
37+
38+
[Parameter, ValidateNotNullOrEmpty]
39+
public string FilterExpression { get; set; }
40+
41+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true)]
42+
public string Version { get; set; }
43+
44+
protected override void ProcessRecord()
45+
{
46+
base.ProcessRecord();
47+
48+
ExecuteClientAction(() =>
49+
{
50+
if (string.IsNullOrEmpty(this.Version))
51+
{
52+
// TODO, FilterExpression
53+
var result = this.VirtualMachineExtensionImageClient.ListVersions(Location.Canonicalize(), PublisherName, Type);
54+
55+
var images = from r in result
56+
select new PSVirtualMachineExtensionImage
57+
{
58+
Id = r.Id,
59+
Location = r.Location,
60+
Version = r.Name,
61+
PublisherName = this.PublisherName,
62+
Type = this.Type,
63+
FilterExpression = this.FilterExpression
64+
};
65+
66+
WriteObject(result, true);
67+
// TODO: Cannot Write the Result from Linq Select.
68+
//WriteObject(images, true);
69+
}
70+
else
71+
{
72+
var result = this.VirtualMachineExtensionImageClient.Get(Location.Canonicalize(), PublisherName, Type, Version);
73+
74+
var image = new PSVirtualMachineExtensionImageDetails
75+
{
76+
Id = result.Id,
77+
Location = result.Location,
78+
HandlerSchema = result.HandlerSchema,
79+
OperatingSystem = result.OperatingSystem,
80+
ComputeRole = result.ComputeRole,
81+
SupportsMultipleExtensions = result.SupportsMultipleExtensions,
82+
VMScaleSetEnabled = result.VmScaleSetEnabled,
83+
Version = result.Name,
84+
PublisherName = this.PublisherName,
85+
Type = this.Type,
86+
FilterExpression = this.FilterExpression
87+
};
88+
89+
WriteObject(image);
90+
}
91+
});
92+
}
93+
}
94+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
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+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Compute.Common;
16+
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Management.Compute;
18+
using Microsoft.Azure.Management.Compute.Models;
19+
using System.Linq;
20+
using System.Management.Automation;
21+
22+
namespace Microsoft.Azure.Commands.Compute
23+
{
24+
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImageType)]
25+
[OutputType(typeof(PSVirtualMachineExtensionImageType))]
26+
public class GetAzureVMExtensionImageTypeCommand : VirtualMachineExtensionImageBaseCmdlet
27+
{
28+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
29+
public string Location { get; set; }
30+
31+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true), ValidateNotNullOrEmpty]
32+
public string PublisherName { get; set; }
33+
34+
protected override void ProcessRecord()
35+
{
36+
base.ProcessRecord();
37+
38+
ExecuteClientAction(() =>
39+
{
40+
var result = this.VirtualMachineExtensionImageClient.ListTypes(Location.Canonicalize(), PublisherName);
41+
42+
var images = from r in result
43+
select new PSVirtualMachineExtensionImageType
44+
{
45+
Id = r.Id,
46+
Location = r.Location,
47+
Type = r.Name,
48+
PublisherName = this.PublisherName
49+
};
50+
51+
WriteObject(result, true);
52+
// TODO: Cannot Write the Result from Linq Select.
53+
//WriteObject(images, true);
54+
});
55+
}
56+
}
57+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
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+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Management.Compute;
16+
17+
namespace Microsoft.Azure.Commands.Compute
18+
{
19+
public abstract class VirtualMachineExtensionImageBaseCmdlet : ComputeClientBaseCmdlet
20+
{
21+
public IVirtualMachineExtensionImagesOperations VirtualMachineExtensionImageClient
22+
{
23+
get
24+
{
25+
return ComputeClient.ComputeManagementClient.VirtualMachineExtensionImages;
26+
}
27+
}
28+
}
29+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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 Newtonsoft.Json;
24+
using System.Collections.Generic;
25+
using System.Text.RegularExpressions;
26+
27+
namespace Microsoft.Azure.Commands.Compute.Models
28+
{
29+
public class PSVirtualMachine : PSOperation
30+
{
31+
// Gets or sets the property of 'ResourceGroupName'
32+
public string ResourceGroupName
33+
{
34+
get
35+
{
36+
if (string.IsNullOrEmpty(Id)) return null;
37+
Regex r = new Regex(@"(.*?)/resourcegroups/(?<rgname>\S+)/providers/(.*?)", RegexOptions.IgnoreCase);
38+
Match m = r.Match(Id);
39+
return m.Success ? m.Groups["rgname"].Value : null;
40+
}
41+
}
42+
43+
// Gets or sets the property of 'Id'
44+
public string Id { get; set; }
45+
46+
// Gets or sets the property of 'Name'
47+
public string Name { get; set; }
48+
49+
// Gets or sets the property of 'Type'
50+
public string Type { get; set; }
51+
52+
// Gets or sets the property of 'Location'
53+
public string Location { get; set; }
54+
55+
// Gets or sets the property of 'Tags'
56+
public IDictionary<string, string> Tags { get; set; }
57+
58+
[JsonIgnore]
59+
public string TagsText
60+
{
61+
get { return JsonConvert.SerializeObject(Tags, Formatting.Indented); }
62+
}
63+
64+
// Gets or sets the reference Id of the availailbity set to which this virtual machine belongs.
65+
public SubResource AvailabilitySetReference { get; set; }
66+
67+
[JsonIgnore]
68+
public string AvailabilitySetReferenceText
69+
{
70+
get { return JsonConvert.SerializeObject(AvailabilitySetReference, Formatting.Indented); }
71+
}
72+
73+
// Gets or sets the diagnostics profile.
74+
public DiagnosticsProfile DiagnosticsProfile { get; set; }
75+
76+
[JsonIgnore]
77+
public string DiagnosticsProfileText
78+
{
79+
get { return JsonConvert.SerializeObject(DiagnosticsProfile, Formatting.Indented); }
80+
}
81+
82+
// Gets the virtual machine child extension resources.
83+
public IList<VirtualMachineExtension> Extensions { get; set; }
84+
85+
[JsonIgnore]
86+
public string ExtensionsText
87+
{
88+
get { return JsonConvert.SerializeObject(Extensions, Formatting.Indented); }
89+
}
90+
91+
// Gets or sets the hardware profile.
92+
public HardwareProfile HardwareProfile { get; set; }
93+
94+
[JsonIgnore]
95+
public string HardwareProfileText
96+
{
97+
get { return JsonConvert.SerializeObject(HardwareProfile, Formatting.Indented); }
98+
}
99+
100+
// Gets the virtual machine instance view.
101+
public VirtualMachineInstanceView InstanceView { get; set; }
102+
103+
[JsonIgnore]
104+
public string InstanceViewText
105+
{
106+
get { return JsonConvert.SerializeObject(InstanceView, Formatting.Indented); }
107+
}
108+
109+
// Gets or sets the network profile.
110+
public NetworkProfile NetworkProfile { get; set; }
111+
112+
[JsonIgnore]
113+
public string NetworkProfileText
114+
{
115+
get { return JsonConvert.SerializeObject(NetworkProfile, Formatting.Indented); }
116+
}
117+
118+
// Gets or sets the OS profile.
119+
public OSProfile OSProfile { get; set; }
120+
121+
[JsonIgnore]
122+
public string OSProfileText
123+
{
124+
get { return JsonConvert.SerializeObject(OSProfile, Formatting.Indented); }
125+
}
126+
127+
// Gets or sets the purchase plan when deploying virtual machine from VM Marketplace images.
128+
public Plan Plan { get; set; }
129+
130+
[JsonIgnore]
131+
public string PlanText
132+
{
133+
get { return JsonConvert.SerializeObject(Plan, Formatting.Indented); }
134+
}
135+
136+
// Gets or sets the provisioning state, which only appears in the response.
137+
public string ProvisioningState { get; set; }
138+
139+
// Gets or sets the storage profile.
140+
public StorageProfile StorageProfile { get; set; }
141+
142+
[JsonIgnore]
143+
public string StorageProfileText
144+
{
145+
get { return JsonConvert.SerializeObject(StorageProfile, Formatting.Indented); }
146+
}
147+
148+
[JsonIgnore]
149+
public string[] DataDiskNames
150+
{
151+
get
152+
{
153+
if (this.StorageProfile == null) return null;
154+
var listStr = new List<string>();
155+
foreach (var item in StorageProfile.DataDisks)
156+
{
157+
listStr.Add(item.Name);
158+
}
159+
return listStr.ToArray();
160+
}
161+
}
162+
163+
[JsonIgnore]
164+
public string[] NetworkInterfaceIDs
165+
{
166+
get
167+
{
168+
if (this.NetworkProfile == null) return null;
169+
var listStr = new List<string>();
170+
foreach (var item in NetworkProfile.NetworkInterfaces)
171+
{
172+
listStr.Add(item.Id);
173+
}
174+
return listStr.ToArray();
175+
}
176+
}
177+
}
178+
}

src/CLU/Microsoft.Azure.Commands.Compute/Models/PSVirtualMachineExtensionImage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class PSVirtualMachineExtensionImageDetails : PSVirtualMachineExtensionIm
3636

3737
public string ComputeRole { get; set; }
3838

39-
public bool SupportsMultipleExtensions { get; set; }
39+
public bool? SupportsMultipleExtensions { get; set; }
4040

41-
public bool VMScaleSetEnabled { get; set; }
41+
public bool? VMScaleSetEnabled { get; set; }
4242
}
4343
}

0 commit comments

Comments
 (0)