Skip to content

Commit e265b2f

Browse files
committed
update
1 parent 5585861 commit e265b2f

File tree

7 files changed

+343
-80
lines changed

7 files changed

+343
-80
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ function Test-VirtualMachineImageList
213213
try
214214
{
215215
$locStr = 'EastAsia';
216+
217+
# VM Images
216218
$s1 = Get-AzureVMImagePublisher -Location $locStr;
217219
Assert-NotNull $s1;
218220

@@ -229,7 +231,15 @@ function Test-VirtualMachineImageList
229231
Assert-ThrowsContains { $s5 = Get-AzureVMImage -Location $locStr -PublisherName $publisherName -Offer $offerName -Skus $skusName -FilterExpression $filter; } "was not found";
230232

231233
$version = '1.0.0';
232-
Assert-ThrowsContains { $s5 = Get-AzureVMImage -Location $locStr -PublisherName $publisherName -Offer $offerName -Skus $skusName -FilterExpression $filter -Version $version; } "was not found";
234+
Assert-ThrowsContains { $s6 = Get-AzureVMImage -Location $locStr -PublisherName $publisherName -Offer $offerName -Skus $skusName -FilterExpression $filter -Version $version; } "was not found";
235+
236+
# Extension Images
237+
$type = Get-ComputeTestResourceName;
238+
Assert-ThrowsContains { $s7 = Get-AzureVMExtensionImage -Location $locStr -PublisherName $publisherName -Type $type -FilterExpression $filter -Version $version; } "was not found";
239+
240+
Assert-ThrowsContains { $s8 = Get-AzureVMExtensionImageType -Location $locStr -PublisherName $publisherName; } "was not found";
241+
242+
Assert-ThrowsContains { $s9 = Get-AzureVMExtensionImageVersion -Location $locStr -PublisherName $publisherName -Type $type -FilterExpression $filter; } "was not found";
233243

234244
$passed = $true;
235245
}

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVirtualMachineImageList.json

Lines changed: 208 additions & 51 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
<Compile Include="AvailabilitySets\AvailabilitySetBaseCmdlet.cs" />
135135
<Compile Include="Common\ExtensionSettingBuilder.cs" />
136136
<Compile Include="Common\ComputeClient.cs" />
137+
<Compile Include="ExtensionImages\GetAzureVMExtensionImageTypeCommand.cs" />
138+
<Compile Include="ExtensionImages\GetAzureVMExtensionImageVersionCommand.cs" />
137139
<Compile Include="ExtensionImages\GetAzureVMExtensionImageCommand.cs" />
138140
<Compile Include="ExtensionImages\VirtualMachineExtensionImageBaseCmdlet.cs" />
139141
<Compile Include="Extension\SetAzureVMExtensionCommand.cs" />

src/ResourceManager/Compute/Commands.Compute/Common/ConstantStringTypes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public static class ProfileNouns
6666
public const string VirtualMachine = "AzureVM";
6767
public const string VirtualMachineExtension = "AzureVMExtension";
6868
public const string VirtualMachineExtensionImage = "AzureVMExtensionImage";
69+
public const string VirtualMachineExtensionImageVersion = "AzureVMExtensionImageVersion";
70+
public const string VirtualMachineExtensionImageType = "AzureVMExtensionImageType";
6971

7072
public const string AvailabilitySet = "AzureAvailabilitySet";
7173
public const string VirtualMachineConfig = "AzureVMConfig";

src/ResourceManager/Compute/Commands.Compute/ExtensionImages/GetAzureVMExtensionImageCommand.cs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,42 @@
1919

2020
namespace Microsoft.Azure.Commands.Compute
2121
{
22-
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImage, DefaultParameterSetName = ListExtensionImageTypesParamSet)]
22+
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImage, DefaultParameterSetName = GetExtensionImageParamSet)]
2323
[OutputType(typeof(VirtualMachineExtensionImage))]
2424
public class GetAzureVMExtensionImageCommand : VirtualMachineExtensionImageBaseCmdlet
2525
{
26-
protected const string ListExtensionImageTypesParamSet = "ListExtensionImageTypesParamSet";
27-
protected const string ListExtensionImageVersionsParamSet = "ListExtensionImageVersionsParamSet";
26+
protected const string GetExtensionImageParamSet = "GetExtensionImageParamSet";
2827

2928
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
3029
public string Location { get; set; }
3130

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

34+
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
35+
public string Type { get; set; }
36+
3537
[Parameter, ValidateNotNullOrEmpty]
3638
public string FilterExpression { get; set; }
3739

3840
[Parameter, ValidateNotNullOrEmpty]
39-
public string Type { get; set; }
41+
public string Version { get; set; }
4042

4143
public override void ExecuteCmdlet()
4244
{
4345
base.ExecuteCmdlet();
4446

45-
if (this.ParameterSetName == ListExtensionImageTypesParamSet)
47+
var parameters = new VirtualMachineExtensionImageGetParameters
4648
{
47-
var parameters = new VirtualMachineExtensionImageListTypesParameters
48-
{
49-
Location = Location,
50-
Publishername = PublisherName
51-
};
52-
53-
var result = this.VirtualMachineExtensionImageClient.ListTypes(parameters);
54-
WriteObject(result);
55-
}
56-
else if (this.ParameterSetName == ListExtensionImageVersionsParamSet)
57-
{
58-
59-
var parameters = new VirtualMachineExtensionImageListVersionsParameters
60-
{
61-
Location = Location,
62-
Publishername = PublisherName,
63-
FilterExpression = FilterExpression,
64-
Type = Type
65-
};
66-
67-
var result = this.VirtualMachineExtensionImageClient.ListVersions(parameters);
68-
WriteObject(result);
69-
}
49+
Location = Location,
50+
Publishername = PublisherName,
51+
Type = Type,
52+
FilterExpression = FilterExpression,
53+
Version = Version
54+
};
55+
56+
var result = this.VirtualMachineExtensionImageClient.Get(parameters);
57+
WriteObject(result);
7058
}
7159
}
7260
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.Management.Compute;
17+
using Microsoft.Azure.Management.Compute.Models;
18+
using System.Management.Automation;
19+
20+
namespace Microsoft.Azure.Commands.Compute
21+
{
22+
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImageType, DefaultParameterSetName = ListExtensionImageTypeParamSet)]
23+
[OutputType(typeof(VirtualMachineImageResource))]
24+
public class GetAzureVMExtensionImageTypeCommand : VirtualMachineExtensionImageBaseCmdlet
25+
{
26+
protected const string ListExtensionImageTypeParamSet = "ListExtensionImageTypeParamSet";
27+
28+
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
29+
public string Location { get; set; }
30+
31+
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
32+
public string PublisherName { get; set; }
33+
34+
public override void ExecuteCmdlet()
35+
{
36+
base.ExecuteCmdlet();
37+
38+
var parameters = new VirtualMachineExtensionImageListTypesParameters
39+
{
40+
Location = Location,
41+
Publishername = PublisherName
42+
};
43+
44+
var result = this.VirtualMachineExtensionImageClient.ListTypes(parameters);
45+
WriteObject(result);
46+
}
47+
}
48+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.Management.Compute;
17+
using Microsoft.Azure.Management.Compute.Models;
18+
using System.Management.Automation;
19+
20+
namespace Microsoft.Azure.Commands.Compute
21+
{
22+
[Cmdlet(VerbsCommon.Get, ProfileNouns.VirtualMachineExtensionImageVersion, DefaultParameterSetName = ListExtensionImageVersionParamSet)]
23+
[OutputType(typeof(VirtualMachineImageResource))]
24+
public class GetAzureVMExtensionImageVersionCommand : VirtualMachineExtensionImageBaseCmdlet
25+
{
26+
protected const string ListExtensionImageVersionParamSet = "ListExtensionImageVersionParamSet";
27+
28+
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
29+
public string Location { get; set; }
30+
31+
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
32+
public string PublisherName { get; set; }
33+
34+
[Parameter(Mandatory = true), ValidateNotNullOrEmpty]
35+
public string Type { get; set; }
36+
37+
[Parameter, ValidateNotNullOrEmpty]
38+
public string FilterExpression { get; set; }
39+
40+
public override void ExecuteCmdlet()
41+
{
42+
base.ExecuteCmdlet();
43+
44+
var parameters = new VirtualMachineExtensionImageListVersionsParameters
45+
{
46+
Location = Location,
47+
Publishername = PublisherName,
48+
Type = Type,
49+
FilterExpression = FilterExpression
50+
};
51+
52+
var result = this.VirtualMachineExtensionImageClient.ListVersions(parameters);
53+
WriteObject(result);
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)