Skip to content

Commit cab67c9

Browse files
committed
Address CRs
1 parent 5706468 commit cab67c9

File tree

11 files changed

+56
-192
lines changed

11 files changed

+56
-192
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function Test-VirtualMachineList
194194

195195
if ($s2 -ne $null)
196196
{
197-
Assert-True { $s2[0].ResourceGroupName -ne $null; }
197+
Assert-NotNull $s2[0].ResourceGroupName;
198198
}
199199

200200
Assert-ThrowsContains { $s3 = Get-AzureVM -NextLink "http://www.test.com/test"; } "Unexpected character"
@@ -633,8 +633,8 @@ function Test-VirtualMachinePIRv2
633633
$p.StorageProfile.SourceImage = $null;
634634
$imgRef = Get-DefaultCRPImage;
635635
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
636-
Assert-True { $p.ImageReference -ne $null };
637-
Assert-True { $p.SourceImageId -eq $null };
636+
Assert-NotNull $p.ImageReference;
637+
Assert-Null $p.SourceImageId;
638638

639639
# TODO: Remove Data Disks for now
640640
$p.StorageProfile.DataDisks = $null;

src/ResourceManager/Compute/Commands.Compute/AvailabilitySets/AvailabilitySetBaseCmdlet.cs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,8 @@
1818

1919
namespace Microsoft.Azure.Commands.Compute
2020
{
21-
public abstract class AvailabilitySetBaseCmdlet : AzurePSCmdlet
21+
public abstract class AvailabilitySetBaseCmdlet : ComputeClientBaseCmdlet
2222
{
23-
private ComputeClient computeClient;
24-
25-
public ComputeClient ComputeClient
26-
{
27-
get
28-
{
29-
if (computeClient == null)
30-
{
31-
computeClient = new ComputeClient(Profile.Context)
32-
{
33-
VerboseLogger = WriteVerboseWithTimestamp,
34-
ErrorLogger = WriteErrorWithTimestamp
35-
};
36-
}
37-
38-
return computeClient;
39-
}
40-
41-
set { computeClient = value; }
42-
}
43-
4423
public IAvailabilitySetOperations AvailabilitySetClient
4524
{
4625
get
@@ -65,10 +44,5 @@ public IAvailabilitySetOperations AvailabilitySetClient
6544
HelpMessage = "The resource name.")]
6645
[ValidateNotNullOrEmpty]
6746
public virtual string Name { get; set; }
68-
69-
public override void ExecuteCmdlet()
70-
{
71-
base.ExecuteCmdlet();
72-
}
7347
}
7448
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
<Compile Include="AvailabilitySets\GetAzureAvailabilitySetCommand.cs" />
141141
<Compile Include="AvailabilitySets\NewAzureAvailabilitySetCommand.cs" />
142142
<Compile Include="AvailabilitySets\AvailabilitySetBaseCmdlet.cs" />
143+
<Compile Include="Common\ComputeClientBaseCmdlet.cs" />
143144
<Compile Include="Common\ComputeClient.cs" />
144145
<Compile Include="ExtensionImages\GetAzureVMExtensionImageTypeCommand.cs" />
145146
<Compile Include="ExtensionImages\GetAzureVMExtensionImageCommand.cs" />

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using Microsoft.Azure.Management.Compute;
17-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
18-
using Microsoft.WindowsAzure.Commands.Common;
19-
using Microsoft.Azure.Common.Authentication.Models;
2015
using Microsoft.Azure.Common.Authentication;
16+
using Microsoft.Azure.Common.Authentication.Models;
17+
using Microsoft.Azure.Management.Compute;
18+
using System;
2119

2220
namespace Microsoft.Azure.Commands.Compute
2321
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.WindowsAzure.Commands.Utilities.Common;
16+
17+
namespace Microsoft.Azure.Commands.Compute
18+
{
19+
public abstract class ComputeClientBaseCmdlet : AzurePSCmdlet
20+
{
21+
private ComputeClient computeClient;
22+
23+
public ComputeClient ComputeClient
24+
{
25+
get
26+
{
27+
if (computeClient == null)
28+
{
29+
computeClient = new ComputeClient(Profile.Context)
30+
{
31+
VerboseLogger = WriteVerboseWithTimestamp,
32+
ErrorLogger = WriteErrorWithTimestamp
33+
};
34+
}
35+
36+
return computeClient;
37+
}
38+
39+
set { computeClient = value; }
40+
}
41+
}
42+
}

src/ResourceManager/Compute/Commands.Compute/Extension/VirtualMachineExtensionBaseCmdlet.cs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,14 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Management.Compute;
16-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1716
using System.Management.Automation;
1817

1918
namespace Microsoft.Azure.Commands.Compute
2019
{
21-
public abstract class VirtualMachineExtensionBaseCmdlet : AzurePSCmdlet
20+
public abstract class VirtualMachineExtensionBaseCmdlet : ComputeClientBaseCmdlet
2221
{
2322
protected const string VirtualMachineExtensionType = "Microsoft.Compute/virtualMachines/extensions";
2423

25-
private ComputeClient computeClient;
26-
27-
public ComputeClient ComputeClient
28-
{
29-
get
30-
{
31-
if (computeClient == null)
32-
{
33-
computeClient = new ComputeClient(Profile.Context)
34-
{
35-
VerboseLogger = WriteVerboseWithTimestamp,
36-
ErrorLogger = WriteErrorWithTimestamp
37-
};
38-
}
39-
40-
return computeClient;
41-
}
42-
43-
set { computeClient = value; }
44-
}
45-
4624
public IVirtualMachineExtensionOperations VirtualMachineExtensionClient
4725
{
4826
get
@@ -76,10 +54,5 @@ public IVirtualMachineExtensionOperations VirtualMachineExtensionClient
7654
HelpMessage = "The extension name.")]
7755
[ValidateNotNullOrEmpty]
7856
public virtual string Name { get; set; }
79-
80-
public override void ExecuteCmdlet()
81-
{
82-
base.ExecuteCmdlet();
83-
}
8457
}
8558
}

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,11 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Management.Compute;
16-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1716

1817
namespace Microsoft.Azure.Commands.Compute
1918
{
20-
public abstract class VirtualMachineExtensionImageBaseCmdlet : AzurePSCmdlet
19+
public abstract class VirtualMachineExtensionImageBaseCmdlet : ComputeClientBaseCmdlet
2120
{
22-
private ComputeClient computeClient;
23-
24-
public ComputeClient ComputeClient
25-
{
26-
get
27-
{
28-
if (computeClient == null)
29-
{
30-
computeClient = new ComputeClient(Profile.Context)
31-
{
32-
VerboseLogger = WriteVerboseWithTimestamp,
33-
ErrorLogger = WriteErrorWithTimestamp
34-
};
35-
}
36-
37-
return computeClient;
38-
}
39-
40-
set { computeClient = value; }
41-
}
42-
4321
public IVirtualMachineExtensionImageOperations VirtualMachineExtensionImageClient
4422
{
4523
get

src/ResourceManager/Compute/Commands.Compute/Images/VirtualMachineImageBaseCmdlet.cs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,11 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Management.Compute;
16-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1716

1817
namespace Microsoft.Azure.Commands.Compute
1918
{
20-
public abstract class VirtualMachineImageBaseCmdlet : AzurePSCmdlet
19+
public abstract class VirtualMachineImageBaseCmdlet : ComputeClientBaseCmdlet
2120
{
22-
private ComputeClient computeClient;
23-
24-
public ComputeClient ComputeClient
25-
{
26-
get
27-
{
28-
if (computeClient == null)
29-
{
30-
computeClient = new ComputeClient(Profile.Context)
31-
{
32-
VerboseLogger = WriteVerboseWithTimestamp,
33-
ErrorLogger = WriteErrorWithTimestamp
34-
};
35-
}
36-
37-
return computeClient;
38-
}
39-
40-
set { computeClient = value; }
41-
}
42-
4321
public IVirtualMachineImageOperations VirtualMachineImageClient
4422
{
4523
get

src/ResourceManager/Compute/Commands.Compute/Usage/VirtualMachineUsageBaseCmdlet.cs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,17 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Management.Compute;
16-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1716

1817
namespace Microsoft.Azure.Commands.Compute
1918
{
20-
public abstract class VirtualMachineUsageBaseCmdlet : AzurePSCmdlet
19+
public abstract class VirtualMachineUsageBaseCmdlet : ComputeClientBaseCmdlet
2120
{
22-
private ComputeClient computeClient;
23-
24-
public ComputeClient ComputeClient
25-
{
26-
get
27-
{
28-
if (computeClient == null)
29-
{
30-
computeClient = new ComputeClient(Profile.Context)
31-
{
32-
VerboseLogger = WriteVerboseWithTimestamp,
33-
ErrorLogger = WriteErrorWithTimestamp
34-
};
35-
}
36-
37-
return computeClient;
38-
}
39-
40-
set { computeClient = value; }
41-
}
42-
4321
public IUsageOperations UsageClient
4422
{
4523
get
4624
{
4725
return ComputeClient.ComputeManagementClient.Usage;
4826
}
4927
}
50-
51-
public override void ExecuteCmdlet()
52-
{
53-
base.ExecuteCmdlet();
54-
}
5528
}
5629
}

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/VirtualMachineBaseCmdlet.cs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,8 @@
1919

2020
namespace Microsoft.Azure.Commands.Compute
2121
{
22-
public abstract class VirtualMachineBaseCmdlet : AzurePSCmdlet
22+
public abstract class VirtualMachineBaseCmdlet : ComputeClientBaseCmdlet
2323
{
24-
private ComputeClient computeClient;
25-
26-
public ComputeClient ComputeClient
27-
{
28-
get
29-
{
30-
if (computeClient == null)
31-
{
32-
computeClient = new ComputeClient(Profile.Context)
33-
{
34-
VerboseLogger = WriteVerboseWithTimestamp,
35-
ErrorLogger = WriteErrorWithTimestamp
36-
};
37-
}
38-
39-
return computeClient;
40-
}
41-
42-
set { computeClient = value; }
43-
}
44-
4524
public IVirtualMachineOperations VirtualMachineClient
4625
{
4726
get
@@ -66,10 +45,5 @@ public IVirtualMachineOperations VirtualMachineClient
6645
HelpMessage = "The resource name.")]
6746
[ValidateNotNullOrEmpty]
6847
public virtual string Name { get; set; }
69-
70-
public override void ExecuteCmdlet()
71-
{
72-
base.ExecuteCmdlet();
73-
}
7448
}
7549
}

src/ResourceManager/Compute/Commands.Compute/VirtualMachineSizes/VirtualMachineSizeBaseCmdlet.cs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,11 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Management.Compute;
16-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1716

1817
namespace Microsoft.Azure.Commands.Compute
1918
{
20-
public abstract class VirtualMachineSizeBaseCmdlet : AzurePSCmdlet
19+
public abstract class VirtualMachineSizeBaseCmdlet : ComputeClientBaseCmdlet
2120
{
22-
private ComputeClient computeClient;
23-
24-
public ComputeClient ComputeClient
25-
{
26-
get
27-
{
28-
if (computeClient == null)
29-
{
30-
computeClient = new ComputeClient(Profile.Context)
31-
{
32-
VerboseLogger = WriteVerboseWithTimestamp,
33-
ErrorLogger = WriteErrorWithTimestamp
34-
};
35-
}
36-
37-
return computeClient;
38-
}
39-
40-
set { computeClient = value; }
41-
}
42-
4321
public IVirtualMachineSizeOperations VirtualMachineSizeClient
4422
{
4523
get
@@ -63,10 +41,5 @@ public IAvailabilitySetOperations AvailabilitySetClient
6341
return ComputeClient.ComputeManagementClient.AvailabilitySets;
6442
}
6543
}
66-
67-
public override void ExecuteCmdlet()
68-
{
69-
base.ExecuteCmdlet();
70-
}
7144
}
7245
}

0 commit comments

Comments
 (0)