Skip to content

Commit 8cda112

Browse files
committed
Merge pull request #36 from huangpf/d0701a
D0701a
2 parents 186b728 + cab244e commit 8cda112

File tree

22 files changed

+4151
-253
lines changed

22 files changed

+4151
-253
lines changed

src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
106106
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.2.0-preview\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
107107
</Reference>
108+
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
109+
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.0\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
110+
<Private>True</Private>
111+
</Reference>
108112
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
109113
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
110114
</Reference>
@@ -205,6 +209,9 @@
205209
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceManagementCloudExceptionTests.json">
206210
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
207211
</None>
212+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunStartAndStopMultipleVirtualMachinesTest.json">
213+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
214+
</None>
208215
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\TestGetAzureLocation.json">
209216
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
210217
</None>

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/ServiceManagementTests.ps1

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,68 @@ function Run-ServiceManagementCloudExceptionTests
6969
Assert-ThrowsLike { $st = Get-AzureService -ServiceName '*' } $compare;
7070
Assert-ThrowsLike { $st = Get-AzureVM -ServiceName '*' } $compare;
7171
Assert-ThrowsLike { $st = Get-AzureAffinityGroup -Name '*' } $compare;
72+
}
73+
74+
# Test Start/Stop-AzureVM for Multiple VMs
75+
function Run-StartAndStopMultipleVirtualMachinesTest
76+
{
77+
# Setup
78+
$location = Get-DefaultLocation;
79+
$imgName = Get-DefaultImage $location;
80+
81+
$storageName = 'pstest' + (getAssetName);
82+
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;
83+
84+
# Associate the new storage account with the current subscription
85+
Set-CurrentStorageAccountName $storageName;
86+
87+
$vmNameList = @("vm01", "vm02", "test04");
88+
$svcName = 'pstest' + (Get-CloudServiceName);
89+
$userName = "pstestuser";
90+
$password = "p@ssw0rd";
91+
92+
# Test
93+
New-AzureService -ServiceName $svcName -Location $location;
94+
95+
try
96+
{
97+
foreach ($vmName in $vmNameList)
98+
{
99+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername $userName -Password $password;
100+
}
101+
102+
# Get VM List
103+
$vmList = Get-AzureVM -ServiceName $svcName;
104+
105+
# Test Stop
106+
Stop-AzureVM -Force -ServiceName $svcName -Name $vmNameList[0];
107+
Stop-AzureVM -Force -ServiceName $svcName -Name $vmNameList[0],$vmNameList[1];
108+
Stop-AzureVM -Force -ServiceName $svcName -Name $vmNameList;
109+
Stop-AzureVM -Force -ServiceName $svcName -Name '*';
110+
Stop-AzureVM -Force -ServiceName $svcName -Name 'vm*';
111+
Stop-AzureVM -Force -ServiceName $svcName -Name 'vm*','test*';
112+
Stop-AzureVM -Force -ServiceName $svcName -VM $vmList[0];
113+
Stop-AzureVM -Force -ServiceName $svcName -VM $vmList[0],$vmList[1];
114+
Stop-AzureVM -Force -ServiceName $svcName -VM $vmList;
115+
116+
# Test Start
117+
Start-AzureVM -ServiceName $svcName -Name $vmNameList[0];
118+
Start-AzureVM -ServiceName $svcName -Name $vmNameList[0],$vmNameList[1];
119+
Start-AzureVM -ServiceName $svcName -Name $vmNameList;
120+
Start-AzureVM -ServiceName $svcName -Name '*';
121+
Start-AzureVM -ServiceName $svcName -Name 'vm*';
122+
Start-AzureVM -ServiceName $svcName -Name 'vm*','test*';
123+
Start-AzureVM -ServiceName $svcName -VM $vmList[0];
124+
Start-AzureVM -ServiceName $svcName -VM $vmList[0],$vmList[1];
125+
Start-AzureVM -ServiceName $svcName -VM $vmList;
126+
}
127+
catch
128+
{
129+
130+
}
131+
finally
132+
{
133+
# Cleanup
134+
Cleanup-CloudService $svcName;
135+
}
72136
}

src/Common/Commands.ScenarioTest/ServiceManagement/ScenarioTests.cs

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

15-
using Microsoft.Azure.Common.Authentication;
16-
using Microsoft.Azure.Test;
17-
using System.Collections.Generic;
18-
using System.IO;
19-
using System.Linq;
2015
using Xunit;
2116

2217
namespace Microsoft.WindowsAzure.Commands.ScenarioTest
2318
{
2419
public partial class ServiceManagementTests
2520
{
21+
[Fact]
22+
[Trait(Category.Service, Category.ServiceManagement)]
23+
[Trait(Category.AcceptanceType, Category.CheckIn)]
24+
[Trait(Category.AcceptanceType, Category.BVT)]
25+
public void TestGetAzureVM()
26+
{
27+
this.RunPowerShellTest("Test-GetAzureVM");
28+
}
29+
2630
[Fact]
2731
[Trait(Category.Service, Category.ServiceManagement)]
2832
[Trait(Category.AcceptanceType, Category.CheckIn)]
@@ -40,5 +44,14 @@ public void RunServiceManagementCloudExceptionTests()
4044
{
4145
this.RunPowerShellTest("Run-ServiceManagementCloudExceptionTests");
4246
}
47+
48+
[Fact]
49+
[Trait(Category.Service, Category.ServiceManagement)]
50+
[Trait(Category.AcceptanceType, Category.CheckIn)]
51+
[Trait(Category.AcceptanceType, Category.BVT)]
52+
public void RunStartAndStopMultipleVirtualMachinesTest()
53+
{
54+
this.RunPowerShellTest("Run-StartAndStopMultipleVirtualMachinesTest");
55+
}
4356
}
4457
}

src/Common/Commands.ScenarioTest/ServiceManagement/ServiceManagementTests.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,33 @@
1414

1515
using Microsoft.Azure.Common.Authentication;
1616
using Microsoft.Azure.Test;
17+
using Microsoft.WindowsAzure.Management;
18+
using Microsoft.WindowsAzure.Management.Compute;
19+
using Microsoft.WindowsAzure.Management.Network;
20+
using Microsoft.WindowsAzure.Management.Storage;
1721
using System.Collections.Generic;
1822
using System.IO;
1923
using System.Linq;
20-
using Xunit;
2124

2225
namespace Microsoft.WindowsAzure.Commands.ScenarioTest
2326
{
2427
public partial class ServiceManagementTests
2528
{
2629
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper();
2730

28-
[Fact]
29-
[Trait(Category.AcceptanceType, Category.CheckIn)]
30-
public void TestGetAzureVM()
31-
{
32-
this.RunPowerShellTest("Test-GetAzureVM");
33-
}
34-
3531
protected void SetupManagementClients()
3632
{
37-
helper.SetupSomeOfManagementClients();
33+
var rdfeTestFactory = new RDFETestEnvironmentFactory();
34+
var managementClient = TestBase.GetServiceClient<ManagementClient>(rdfeTestFactory);
35+
var computeClient = TestBase.GetServiceClient<ComputeManagementClient>(rdfeTestFactory);
36+
var networkClient = TestBase.GetServiceClient<NetworkManagementClient>(rdfeTestFactory);
37+
var storageClient = TestBase.GetServiceClient<StorageManagementClient>(rdfeTestFactory);
38+
39+
helper.SetupSomeOfManagementClients(
40+
managementClient,
41+
computeClient,
42+
networkClient,
43+
storageClient);
3844
}
3945

4046
protected void RunPowerShellTest(params string[] scripts)

src/Common/Commands.ScenarioTest/SessionRecords/Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests/RunStartAndStopMultipleVirtualMachinesTest.json

Lines changed: 3937 additions & 0 deletions
Large diffs are not rendered by default.

src/Common/Commands.ScenarioTest/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
1919
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management.Compute" version="12.2.0-preview" targetFramework="net45" />
21+
<package id="Microsoft.WindowsAzure.Management.Network" version="7.0.0" targetFramework="net45" />
2122
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
2223
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.4.2-prerelease" targetFramework="net45" />
2324
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />

src/ServiceManagement/Compute/Commands.ServiceManagement/Commands.ServiceManagement.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248
<Compile Include="IaaS\Network\RemoveAzurePublicIP.cs" />
249249
<Compile Include="IaaS\Network\GetAzurePublicIP.cs" />
250250
<Compile Include="IaaS\Network\RemoveAzureReservedIPAssociation.cs" />
251+
<Compile Include="IaaS\Network\RemoveAzureVirtualIP.cs" />
251252
<Compile Include="IaaS\Network\SetAzureDns.cs" />
252253
<Compile Include="IaaS\Network\SetAzureInternalLoadBalancer.cs" />
253254
<Compile Include="IaaS\Network\SetAzureNetworkSecurityGroupConfig.cs" />
@@ -309,7 +310,6 @@
309310
<DesignTime>True</DesignTime>
310311
<DependentUpon>Resources.resx</DependentUpon>
311312
</Compile>
312-
<Compile Include="RemoveAzureVirtualIP.cs" />
313313
<Compile Include="RoleSizes\GetAzureRoleSize.cs" />
314314
<Compile Include="ServiceManagementProfile.cs" />
315315
<Compile Include="AffinityGroups\SetAzureAffinityGroup.cs" />

src/ServiceManagement/Compute/Commands.ServiceManagement/Extensions/Common/BaseAzureServiceExtensionCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ protected DeploymentGetResponse GetDeployment(string slot)
280280
{
281281
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
282282
{
283-
this.WriteExceptionDetails(ex);
283+
WriteExceptionError(ex);
284284
}
285285
}
286286
});

src/ServiceManagement/Compute/Commands.ServiceManagement/HostedServices/GetAzureRole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private DeploymentGetResponse GetCurrentDeployment(out OperationStatusResponse o
163163

164164
DeploymentGetResponse deploymentGetResponse = null;
165165
InvokeInOperationContext(() => deploymentGetResponse = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slot));
166-
operation = GetOperationNewSM(deploymentGetResponse.RequestId);
166+
operation = GetOperation(deploymentGetResponse.RequestId);
167167

168168
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
169169

src/ServiceManagement/Compute/Commands.ServiceManagement/HostedServices/NewAzureDeployment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public virtual void NewPaaSDeploymentProcess()
170170
{
171171
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
172172
{
173-
this.WriteExceptionDetails(ex);
173+
WriteExceptionError(ex);
174174
}
175175
}
176176

@@ -225,7 +225,7 @@ public virtual void NewPaaSDeploymentProcess()
225225
}
226226
catch (CloudException ex)
227227
{
228-
this.WriteExceptionDetails(ex);
228+
WriteExceptionError(ex);
229229
}
230230
});
231231
}
@@ -249,7 +249,7 @@ private void AssertNoPersistenVmRoleExistsInDeployment(string slot)
249249
{
250250
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
251251
{
252-
this.WriteExceptionDetails(ex);
252+
WriteExceptionError(ex);
253253
}
254254
}
255255
});

src/ServiceManagement/Compute/Commands.ServiceManagement/HostedServices/SetAzureDeployment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void ExecuteCommand()
175175
{
176176
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
177177
{
178-
this.WriteExceptionDetails(ex);
178+
WriteExceptionError(ex);
179179
}
180180
}
181181

@@ -263,7 +263,7 @@ public void ExecuteCommand()
263263
}
264264
catch (CloudException ex)
265265
{
266-
this.WriteExceptionDetails(ex);
266+
WriteExceptionError(ex);
267267
}
268268
});
269269
}

src/ServiceManagement/Compute/Commands.ServiceManagement/HostedServices/SetAzureRole.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private DeploymentGetResponse GetCurrentDeployment(out OperationStatusResponse o
110110

111111
WriteVerboseWithTimestamp(Resources.GetDeploymentBeginOperation);
112112
DeploymentGetResponse deploymentGetResponse = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slot);
113-
operation = GetOperationNewSM(deploymentGetResponse.RequestId);
113+
operation = GetOperation(deploymentGetResponse.RequestId);
114114
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
115115

116116
return deploymentGetResponse;

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/GetAzureVMDscExtensionStatus.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ internal void GetCurrentDeployment()
150150
return;
151151

152152
CurrentDeploymentNewSM = ComputeClient.Deployments.GetBySlot(Service, NSM.DeploymentSlot.Production);
153-
GetDeploymentOperationNewSM = GetOperationNewSM(CurrentDeploymentNewSM.RequestId);
153+
GetDeploymentOperationNewSM = GetOperation(CurrentDeploymentNewSM.RequestId);
154154
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
155155
}
156156
catch (CloudException ex)

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/IaaSDeploymentManagementCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected virtual void ExecuteCommand()
6868
try
6969
{
7070
CurrentDeploymentNewSM = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, DeploymentSlot.Production);
71-
GetDeploymentOperationNewSM = GetOperationNewSM(CurrentDeploymentNewSM.RequestId);
71+
GetDeploymentOperationNewSM = GetOperation(CurrentDeploymentNewSM.RequestId);
7272
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
7373
}
7474
catch (CloudException ex)

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Network/GetAzureVNetConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public VirtualNetworkConfigContext GetVirtualNetworkConfigProcess()
4848
WriteVerboseWithTimestamp(string.Format(Resources.AzureVNetConfigBeginOperation, CommandRuntime.ToString()));
4949

5050
var netcfg = this.NetworkClient.Networks.GetConfiguration();
51-
var operation = GetOperationNewSM(netcfg.RequestId);
51+
var operation = GetOperation(netcfg.RequestId);
5252

5353
WriteVerboseWithTimestamp(string.Format(Resources.AzureVNetConfigCompletedOperation, CommandRuntime.ToString()));
5454

@@ -81,7 +81,7 @@ public VirtualNetworkConfigContext GetVirtualNetworkConfigProcess()
8181
}
8282
else
8383
{
84-
this.WriteExceptionDetails(ex);
84+
WriteExceptionError(ex);
8585
}
8686
}
8787
});

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Network/GetAzureVNetSite.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public IEnumerable<VirtualNetworkSiteContext> GetVirtualNetworkSiteProcess()
6060
}
6161
}
6262

63-
var operation = GetOperationNewSM(response.RequestId);
63+
var operation = GetOperation(response.RequestId);
6464
WriteVerboseWithTimestamp(string.Format(Resources.AzureVNetSiteCompletedOperation, CommandRuntime.ToString()));
6565
result = sites.Select(site => ContextFactory<NetworkListResponse.VirtualNetworkSite, VirtualNetworkSiteContext>(site, operation));
6666
}
@@ -72,7 +72,7 @@ public IEnumerable<VirtualNetworkSiteContext> GetVirtualNetworkSiteProcess()
7272
}
7373
else
7474
{
75-
this.WriteExceptionDetails(ex);
75+
WriteExceptionError(ex);
7676
}
7777
}
7878
});

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Network/RemoveAzureVirtualIP.cs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,48 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
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+
using System.Management.Automation;
15+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
16+
using Microsoft.WindowsAzure.Management.Network;
17+
using Microsoft.WindowsAzure.Management.Compute;
18+
using Microsoft.WindowsAzure.Management.Compute.Models;
19+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Properties;
620

721
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS
822
{
9-
using System.Management.Automation;
10-
using Microsoft.WindowsAzure.Commands.Utilities.Common;
11-
using Microsoft.WindowsAzure.Management.Network;
12-
using Microsoft.WindowsAzure.Management.Compute;
13-
using Microsoft.WindowsAzure.Management.Compute.Models;
14-
15-
1623
[Cmdlet(VerbsCommon.Remove, "AzureVirtualIP"), OutputType(typeof(ManagementOperationContext))]
1724
public class RemoveAzureVirtualIP : ServiceManagementBaseCmdlet
1825
{
1926
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = false)]
2027
[ValidateNotNullOrEmpty]
21-
public string VirtualIPName { get; set; }
28+
public string ServiceName { get; set; }
2229

2330
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = false)]
2431
[ValidateNotNullOrEmpty]
25-
public string ServiceName { get; set; }
32+
public string VirtualIPName { get; set; }
33+
34+
[Parameter(Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Do not confirm removal of Virtual IP")]
35+
public SwitchParameter Force { get; set; }
2636

2737
public override void ExecuteCmdlet()
38+
{
39+
if (this.Force.IsPresent || this.ShouldContinue(Resources.VirtualIPWillBeRemoved, Resources.RemoveVirtualIP))
40+
{
41+
this.ProcessRemoveAzureVirtualIP();
42+
}
43+
}
44+
45+
public void ProcessRemoveAzureVirtualIP()
2846
{
2947
ServiceManagementProfile.Initialize();
3048

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/PersistentVMs/GetAzureRemoteDesktopFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected override void ExecuteCommand()
7979
}
8080
}
8181

82-
var operation = GetOperationNewSM(desktopFileResponse.RequestId);
82+
var operation = GetOperation(desktopFileResponse.RequestId);
8383

8484
WriteVerboseWithTimestamp(string.Format(Resources.AzureRemoteDesktopCompletedOperation, CommandRuntime));
8585

0 commit comments

Comments
 (0)