Skip to content

Commit 6de00fc

Browse files
author
unknown
committed
Vipmobility powershell
1 parent da73cb5 commit 6de00fc

25 files changed

+520
-78
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,21 @@
5959
<SpecificVersion>False</SpecificVersion>
6060
<HintPath>..\..\..\packages\AutoMapper.3.1.1\lib\net40\AutoMapper.Net4.dll</HintPath>
6161
</Reference>
62-
<Reference Include="Hyak.Common">
63-
<HintPath>..\..\..\packages\Hyak.Common.1.0.1\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
62+
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
63+
<SpecificVersion>False</SpecificVersion>
64+
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
6465
</Reference>
65-
<Reference Include="Microsoft.Azure.Common">
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.dll</HintPath>
66+
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<SpecificVersion>False</SpecificVersion>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.2\lib\net45\Microsoft.Azure.Common.dll</HintPath>
6769
</Reference>
6870
<Reference Include="Microsoft.Azure.Common.Extensions, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6971
<SpecificVersion>False</SpecificVersion>
7072
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Extensions.0.14.0-preview\lib\net45\Microsoft.Azure.Common.Extensions.dll</HintPath>
7173
</Reference>
72-
<Reference Include="Microsoft.Azure.Common.NetFramework">
73-
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
74+
<Reference Include="Microsoft.Azure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
75+
<SpecificVersion>False</SpecificVersion>
76+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.2\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
7477
</Reference>
7578
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7679
<SpecificVersion>False</SpecificVersion>
@@ -116,7 +119,7 @@
116119
</Reference>
117120
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118121
<SpecificVersion>False</SpecificVersion>
119-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
122+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
120123
</Reference>
121124
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
122125
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/packages.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="AutoMapper" version="3.1.1" targetFramework="net45" />
4-
<package id="Hyak.Common" version="1.0.1" targetFramework="net45" />
5-
<package id="Microsoft.Azure.Common" version="2.0.1" targetFramework="net45" />
4+
<package id="Hyak.Common" version="1.0.2" targetFramework="net45" />
5+
<package id="Microsoft.Azure.Common" version="2.0.2" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Common.Extensions" version="0.14.0-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Resources" version="2.12.0-preview" targetFramework="net45" />
@@ -17,7 +17,7 @@
1717
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
1818
<package id="Microsoft.WindowsAzure.Management" version="4.0.1" targetFramework="net45" />
1919
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.0.0" targetFramework="net45" />
20-
<package id="Microsoft.WindowsAzure.Management.Network" version="6.0.0" targetFramework="net45" />
20+
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.2" targetFramework="net45" />
2121
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
2323
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@
5353
<SpecificVersion>False</SpecificVersion>
5454
<HintPath>..\..\..\packages\AutoMapper.3.1.1\lib\net40\AutoMapper.Net4.dll</HintPath>
5555
</Reference>
56-
<Reference Include="Hyak.Common">
57-
<HintPath>..\..\..\packages\Hyak.Common.1.0.1\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
56+
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
57+
<SpecificVersion>False</SpecificVersion>
58+
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
5859
</Reference>
59-
<Reference Include="Microsoft.Azure.Common">
60-
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.dll</HintPath>
60+
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
61+
<SpecificVersion>False</SpecificVersion>
62+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.2\lib\net45\Microsoft.Azure.Common.dll</HintPath>
6163
</Reference>
6264
<Reference Include="Microsoft.Azure.Common.Extensions">
6365
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Extensions.0.14.0-preview\lib\net45\Microsoft.Azure.Common.Extensions.dll</HintPath>
6466
</Reference>
65-
<Reference Include="Microsoft.Azure.Common.NetFramework">
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.1\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
67+
<Reference Include="Microsoft.Azure.Common.NetFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68+
<SpecificVersion>False</SpecificVersion>
69+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.0.2\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
6770
</Reference>
6871
<Reference Include="Microsoft.Azure.ResourceManager">
6972
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.12.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -107,8 +110,9 @@
107110
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
108111
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
109112
</Reference>
110-
<Reference Include="Microsoft.WindowsAzure.Management.Network">
111-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
113+
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
114+
<SpecificVersion>False</SpecificVersion>
115+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
112116
</Reference>
113117
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
114118
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
@@ -287,7 +291,9 @@
287291
<Compile Include="FunctionalTests\IaasCmdletInfo\AddAzureNetworkInterfaceConfigCmdletInfo.cs" />
288292
<Compile Include="FunctionalTests\NetworkCmdletInfo\GetAzureReservedIPCmdletInfo.cs" />
289293
<Compile Include="FunctionalTests\NetworkCmdletInfo\NewAzureReservedIPCmdletInfo.cs" />
294+
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPAssociationCmdletInfo.cs" />
290295
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPCmdletInfo.cs" />
296+
<Compile Include="FunctionalTests\NetworkCmdletInfo\SetAzureReservedIPAssociationCmdletInfo.cs" />
291297
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventBySlotCmdletInfo.cs" />
292298
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventCmdletInfo.cs" />
293299
<Compile Include="FunctionalTests\SubscriptionCmdletInfo\RemoveAzureSubscriptionCmdletInfo.cs" />

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/LocationBasedReservedIPTests.cs

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,161 @@ public void CreateReservedIPThenWindowsVM()
109109
}
110110
}
111111

112+
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Test the cmdlets (Set-AzureReservedIPAssociation, New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
113+
public void CreateWindowsVMThenAssociateReservedIP()
114+
{
115+
try
116+
{
117+
string reservedIpName = Utilities.GetUniqueShortName("ResrvdIP");
118+
string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
119+
string dnsName = Utilities.GetUniqueShortName("Dns");
120+
string vmName = Utilities.GetUniqueShortName(vmNamePrefix);
121+
string deploymentName = Utilities.GetUniqueShortName("Depl");
122+
var input = new ReservedIPContext()
123+
{
124+
//Address = string.Empty,
125+
DeploymentName = string.Empty,
126+
Label = reservedIpLabel,
127+
InUse = false,
128+
Location = locationName,
129+
ReservedIPName = reservedIpName,
130+
State = "Created"
131+
};
132+
133+
// Reserve a new IP
134+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
135+
//Get the reserved ip and verify the reserved Ip properties.
136+
VerifyReservedIpNotInUse(input);
137+
// Create a new VM with the reserved ip.
138+
DnsServer dns = null;
139+
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
140+
Utilities.ExecuteAndLog(() =>
141+
{
142+
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
143+
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
144+
}, "Create a new windows azure vm without reserved ip.");
145+
146+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName, serviceName, serviceName); }, "Create a new Azure Reserved IP Association");
147+
148+
149+
VerifyReservedIpInUse(serviceName, input);
150+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
151+
VerifyReservedIpNotInUse(input);
152+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
153+
VerifyReservedIpRemoved(reservedIpName);
154+
pass = true;
155+
}
156+
catch (Exception ex)
157+
{
158+
pass = false;
159+
Console.WriteLine(ex.ToString());
160+
throw;
161+
}
162+
}
163+
164+
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Test the cmdlets (Remove-AzureReservedIPAssociation, New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
165+
public void CreateWindowsVMWithReservedIPThenDisassociateReservedIP()
166+
{
167+
try
168+
{
169+
string reservedIpName = Utilities.GetUniqueShortName("ResrvdIP");
170+
string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
171+
string dnsName = Utilities.GetUniqueShortName("Dns");
172+
string vmName = Utilities.GetUniqueShortName(vmNamePrefix);
173+
string deploymentName = Utilities.GetUniqueShortName("Depl");
174+
var input = new ReservedIPContext()
175+
{
176+
//Address = string.Empty,
177+
DeploymentName = string.Empty,
178+
Label = reservedIpLabel,
179+
InUse = false,
180+
Location = locationName,
181+
ReservedIPName = reservedIpName,
182+
State = "Created"
183+
};
184+
185+
// Reserve a new IP
186+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
187+
//Get the reserved ip and verify the reserved Ip properties.
188+
VerifyReservedIpNotInUse(input);
189+
// Create a new VM with the reserved ip.
190+
DnsServer dns = null;
191+
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
192+
Utilities.ExecuteAndLog(() =>
193+
{
194+
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
195+
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName, reservedIPName: reservedIpName);
196+
}, "Create a new windows azure vm with reserved ip.");
197+
198+
VerifyReservedIpInUse(serviceName, input);
199+
200+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, serviceName); }, "Remove an Azure Reserved IP Association");
201+
202+
VerifyReservedIpNotInUse(input);
203+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
204+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
205+
VerifyReservedIpRemoved(reservedIpName);
206+
pass = true;
207+
}
208+
catch (Exception ex)
209+
{
210+
pass = false;
211+
Console.WriteLine(ex.ToString());
212+
throw;
213+
}
214+
}
215+
216+
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Test the cmdlets (New-AzureReservedIP, Remove-AzureReservedIPAssociation, Get-AzureReservedIP,Remove-AzureReservedIP)")]
217+
public void CreateWindowsVMThenReservedExistingIP()
218+
{
219+
try
220+
{
221+
string reservedIpName = Utilities.GetUniqueShortName("ResrvdIP");
222+
string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
223+
string dnsName = Utilities.GetUniqueShortName("Dns");
224+
string vmName = Utilities.GetUniqueShortName(vmNamePrefix);
225+
string deploymentName = Utilities.GetUniqueShortName("Depl");
226+
var input = new ReservedIPContext()
227+
{
228+
//Address = string.Empty,
229+
DeploymentName = string.Empty,
230+
Label = reservedIpLabel,
231+
InUse = false,
232+
Location = locationName,
233+
ReservedIPName = reservedIpName,
234+
State = "Created"
235+
};
236+
237+
// Create a new VM with the reserved ip.
238+
DnsServer dns = null;
239+
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
240+
Utilities.ExecuteAndLog(() =>
241+
{
242+
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
243+
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
244+
}, "Create a new windows azure vm without reserved ip.");
245+
246+
// Reserve an existing IP
247+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, serviceName, serviceName, reservedIpLabel), "Reserve existing deployment IP");
248+
249+
VerifyReservedIpInUse(serviceName, input);
250+
251+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, serviceName); }, "Remove an Azure Reserved IP Association");
252+
253+
VerifyReservedIpNotInUse(input);
254+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
255+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
256+
VerifyReservedIpRemoved(reservedIpName);
257+
pass = true;
258+
}
259+
catch (Exception ex)
260+
{
261+
pass = false;
262+
Console.WriteLine(ex.ToString());
263+
throw;
264+
}
265+
}
266+
112267
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("hylee"), Description("Test the cmdlets (New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
113268
public void CreateReservedIPThenLinuxVM()
114269
{

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/NetworkCmdletInfo/NewAzureReservedIPCmdletInfo.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,13 @@ public NewAzureReservedIPCmdletInfo(string name, string location, string label)
3030
this.cmdletParams.Add(new CmdletParam("Label", label));
3131
}
3232
}
33+
34+
public NewAzureReservedIPCmdletInfo(string name, string location, string serviceName, string deploymentName, string label): this(name, location, label)
35+
{
36+
this.cmdletName = Utilities.NewAzureReservedIPCmdletName;
37+
38+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
39+
this.cmdletParams.Add(new CmdletParam("DeploymentName", deploymentName));
40+
}
3341
}
3442
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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.ServiceManagement.Test.FunctionalTests.PowershellCore;
16+
17+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
18+
{
19+
class RemoveAzureReservedIPAssociationCmdletInfo : CmdletsInfo
20+
{
21+
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string deploymentName)
22+
{
23+
this.cmdletName = Utilities.RemoveAzureReservedIPAssociationCmdletName;
24+
25+
this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
26+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
27+
this.cmdletParams.Add(new CmdletParam("DeploymentName", deploymentName));
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)