Skip to content

Commit 38da735

Browse files
committed
Merge pull request #11 from avijitgupta/dev
Vipmobility powershell
2 parents 74d4bd7 + eefbaaf commit 38da735

29 files changed

+670
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</Reference>
117117
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118118
<SpecificVersion>False</SpecificVersion>
119-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
119+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
120120
</Reference>
121121
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
122122
<SpecificVersion>False</SpecificVersion>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.2.0" targetFramework="net45" />
20-
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.1" 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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@
108108
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
109109
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
110110
</Reference>
111-
<Reference Include="Microsoft.WindowsAzure.Management.Network">
112-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
111+
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
112+
<SpecificVersion>False</SpecificVersion>
113+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
113114
</Reference>
114115
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
115116
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
@@ -288,7 +289,9 @@
288289
<Compile Include="FunctionalTests\IaasCmdletInfo\AddAzureNetworkInterfaceConfigCmdletInfo.cs" />
289290
<Compile Include="FunctionalTests\NetworkCmdletInfo\GetAzureReservedIPCmdletInfo.cs" />
290291
<Compile Include="FunctionalTests\NetworkCmdletInfo\NewAzureReservedIPCmdletInfo.cs" />
292+
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPAssociationCmdletInfo.cs" />
291293
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPCmdletInfo.cs" />
294+
<Compile Include="FunctionalTests\NetworkCmdletInfo\SetAzureReservedIPAssociationCmdletInfo.cs" />
292295
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventBySlotCmdletInfo.cs" />
293296
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventCmdletInfo.cs" />
294297
<Compile Include="FunctionalTests\SubscriptionCmdletInfo\RemoveAzureSubscriptionCmdletInfo.cs" />
@@ -419,6 +422,12 @@
419422
<None Include="AzureRTComplete_Full_Diff.playlist" />
420423
<None Include="AzureRTExtensions.playlist" />
421424
<None Include="AzureRTFull.playlist" />
425+
<None Include="Resources\HelloWorld_SDK20.cspkg">
426+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
427+
</None>
428+
<None Include="Resources\ServiceConfiguration.cscfg">
429+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
430+
</None>
422431
<None Include="MSSharedLibKey.snk" />
423432
<None Include="packages.config" />
424433
<None Include="Resources\affinityGroupData.csv" />

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

Lines changed: 269 additions & 2 deletions
Large diffs are not rendered by default.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
16+
using Microsoft.WindowsAzure.Management.Compute.Models;
1617

1718
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
1819
{
@@ -30,5 +31,13 @@ public NewAzureReservedIPCmdletInfo(string name, string location, string label)
3031
this.cmdletParams.Add(new CmdletParam("Label", label));
3132
}
3233
}
34+
35+
public NewAzureReservedIPCmdletInfo(string name, string location, string serviceName, string slot, string label): this(name, location, label)
36+
{
37+
this.cmdletName = Utilities.NewAzureReservedIPCmdletName;
38+
39+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
40+
this.cmdletParams.Add(new CmdletParam("Slot", slot));
41+
}
3342
}
3443
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.Model;
16+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
17+
18+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
19+
{
20+
class RemoveAzureReservedIPAssociationCmdletInfo : CmdletsInfo
21+
{
22+
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string slot, bool force)
23+
{
24+
this.cmdletName = Utilities.RemoveAzureReservedIPAssociationCmdletName;
25+
26+
this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
27+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
28+
this.cmdletParams.Add(new CmdletParam("Slot", slot));
29+
if (force)
30+
{
31+
this.cmdletParams.Add(new CmdletParam("Force"));
32+
}
33+
}
34+
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName)
35+
: this(reservedIpName, serviceName, DeploymentSlotType.Production, true)
36+
{
37+
}
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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.Model;
16+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
17+
18+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
19+
{
20+
public class SetAzureReservedIPAssociationCmdletInfo : CmdletsInfo
21+
{
22+
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string slot)
23+
{
24+
this.cmdletName = Utilities.SetAzureReservedIPAssociationCmdletName;
25+
26+
this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
27+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
28+
this.cmdletParams.Add(new CmdletParam("Slot", slot));
29+
}
30+
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName) : this(reservedIpName, serviceName, DeploymentSlotType.Production)
31+
{
32+
}
33+
34+
}
35+
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,21 @@ internal ManagementOperationContext NewAzureReservedIP(string name, string locat
861861
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, label));
862862
}
863863

864+
internal ManagementOperationContext NewAzureReservedIP(string name, string location, string serviceName, string label = null, string slot = SM.DeploymentSlotType.Production)
865+
{
866+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, serviceName, slot, label));
867+
}
868+
869+
internal ManagementOperationContext SetAzureReservedIPAssociation(string reservedIpName, string serviceName, string slot = SM.DeploymentSlotType.Production)
870+
{
871+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new SetAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, slot));
872+
}
873+
874+
internal ManagementOperationContext RemoveAzureReservedIPAssociation(string reservedIpName, string serviceName, bool force, string slot = SM.DeploymentSlotType.Production)
875+
{
876+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new RemoveAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, slot, force));
877+
}
878+
864879
internal Collection<SM.ReservedIPContext> GetAzureReservedIP(string name = null)
865880
{
866881
return RunPSCmdletAndReturnAll<SM.ReservedIPContext>(new GetAzureReservedIPCmdletInfo(name));

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,21 @@ private static string GetServiceManagementUrl(string publishSettingsFile)
143143
XDocument psf = XDocument.Load(publishSettingsFile);
144144
XElement pubData = psf.Descendants().FirstOrDefault();
145145
XElement pubProfile = pubData.Elements().ToList()[0];
146-
return pubProfile.Attribute("Url").Value;
146+
XAttribute urlattr = pubProfile.Attribute("Url");
147+
string url = string.Empty;
148+
if (urlattr != null)
149+
{
150+
url = urlattr.Value;
151+
}
152+
else
153+
{
154+
var subscriptions = pubProfile.Elements("Subscription").ToList();
155+
if (subscriptions.Any())
156+
{
157+
url = subscriptions[0].Attribute("ServiceManagementUrl").Value;
158+
}
159+
}
160+
return url;
147161
}
148162
catch
149163
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ internal class Utilities
137137
public const string NewAzureReservedIPCmdletName = "New-AzureReservedIP";
138138
public const string GetAzureReservedIPCmdletName = "Get-AzureReservedIP";
139139
public const string RemoveAzureReservedIPCmdletName = "Remove-AzureReservedIP";
140+
public const string SetAzureReservedIPAssociationCmdletName = "Set-AzureReservedIPAssociation";
141+
public const string RemoveAzureReservedIPAssociationCmdletName = "Remove-AzureReservedIPAssociation";
140142

141143
// AzureRole & AzureRoleInstnace
142144
public const string GetAzureRoleCmdletName = "Get-AzureRole";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-16"?>
2+
<ServiceConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" serviceName="HelloWorld" osFamily="2" osVersion="*" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
3+
<Role name="HelloWorld_WebRole">
4+
<ConfigurationSettings>
5+
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=samplesa;AccountKey=1VtQsFrdpGyY8bKCC2WF74B1lV9fBpPtxZbBj6apwFNLCm/sYTlsrCmps9TgBMykw5NiGGGwngYUzhvpECUXUQ==" />
6+
</ConfigurationSettings>
7+
<Instances count="1" />
8+
</Role>
9+
<NetworkConfiguration>
10+
<AddressAssignments>
11+
<InstanceAddress roleName="HelloWorld_WebRole">
12+
<PublicIPs>
13+
<PublicIP name="PublicIP1"/>
14+
</PublicIPs>
15+
</InstanceAddress>
16+
</AddressAssignments>
17+
</NetworkConfiguration>
18+
</ServiceConfiguration>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.2.0" targetFramework="net45" />
20-
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.1" 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="Moq" version="4.2.1402.2112" targetFramework="net45" />
2323
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
</Reference>
119119
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
120120
<SpecificVersion>False</SpecificVersion>
121-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
121+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
122122
</Reference>
123123
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
124124
<SpecificVersion>False</SpecificVersion>
@@ -248,11 +248,13 @@
248248
<Compile Include="IaaS\Network\RemoveAzureNetworkSecurityGroupConfig.cs" />
249249
<Compile Include="IaaS\Network\RemoveAzurePublicIP.cs" />
250250
<Compile Include="IaaS\Network\GetAzurePublicIP.cs" />
251+
<Compile Include="IaaS\Network\RemoveAzureReservedIPAssociation.cs" />
251252
<Compile Include="IaaS\Network\SetAzureDns.cs" />
252253
<Compile Include="IaaS\Network\SetAzureInternalLoadBalancer.cs" />
253254
<Compile Include="IaaS\Network\SetAzureNetworkSecurityGroupConfig.cs" />
254255
<Compile Include="IaaS\Network\SetAzureNetworkInterfaceConfig.cs" />
255256
<Compile Include="IaaS\Network\SetAzurePublicIP.cs" />
257+
<Compile Include="IaaS\Network\SetAzureReservedIPAssociation.cs" />
256258
<Compile Include="Model\DeploymentRebootEventContext.cs" />
257259
<Compile Include="Model\InternalLoadBalancerSetting.cs" />
258260
<Compile Include="Model\InternalLoadBalancerContext.cs" />

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

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
using Microsoft.WindowsAzure.Commands.Utilities.Common;
1818
using Microsoft.WindowsAzure.Management.Network.Models;
1919
using Microsoft.WindowsAzure.Management.Network;
20+
using Microsoft.WindowsAzure.Management.Compute;
21+
using Microsoft.WindowsAzure.Management.Compute.Models;
22+
using System;
2023

2124
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS
2225
{
@@ -39,7 +42,7 @@ public string ReservedIPName
3942

4043
[Parameter(Mandatory = false, Position = 1, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveNewIPParamSet, HelpMessage = "Reserved IP Label.")]
4144
[Parameter(Mandatory = false, Position = 3, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPUsingSlotParamSet, HelpMessage = "Reserved IP Label.")]
42-
[Parameter(Mandatory = false, Position = 2, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Reserved IP Label.")]
45+
[Parameter(Mandatory = false, Position = 1, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Reserved IP Label.")]
4346
[ValidateNotNullOrEmpty]
4447
public string Label
4548
{
@@ -49,17 +52,46 @@ public string Label
4952

5053
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveNewIPParamSet, HelpMessage = "Location Name.")]
5154
[Parameter(Mandatory = true, Position = 4, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPUsingSlotParamSet, HelpMessage = "Location Name.")]
52-
[Parameter(Mandatory = true, Position = 3, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Location Name.")]
55+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Location Name.")]
5356
[ValidateNotNullOrEmpty]
5457
public string Location
5558
{
5659
get;
5760
set;
5861
}
5962

63+
[Parameter(Mandatory = true, Position = 3, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Service Name.")]
64+
[ValidateNotNullOrEmpty]
65+
public string ServiceName
66+
{
67+
get;
68+
set;
69+
}
70+
71+
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Deployment slot [Staging | Production].")]
72+
[ValidateSet(Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DeploymentSlotType.Staging, Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DeploymentSlotType.Production, IgnoreCase = true)]
73+
public string Slot
74+
{
75+
get;
76+
set;
77+
}
78+
6079
protected override void OnProcessRecord()
6180
{
6281
ServiceManagementProfile.Initialize();
82+
string deploymentName = string.Empty;
83+
84+
if (!string.IsNullOrEmpty(this.ServiceName))
85+
{
86+
var slotType = string.IsNullOrEmpty(this.Slot) ?
87+
DeploymentSlot.Production :
88+
(DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true);
89+
90+
91+
deploymentName = this.ComputeClient.Deployments.GetBySlot(
92+
this.ServiceName,
93+
slotType).Name;
94+
}
6395

6496
ExecuteClientActionNewSM(
6597
null,
@@ -70,7 +102,9 @@ protected override void OnProcessRecord()
70102
{
71103
Name = this.ReservedIPName,
72104
Label = this.Label,
73-
Location = this.Location
105+
Location = this.Location,
106+
ServiceName = this.ServiceName,
107+
DeploymentName = deploymentName
74108
};
75109

76110
return this.NetworkClient.ReservedIPs.Create(parameters);

0 commit comments

Comments
 (0)