Skip to content

Vipmobility powershell #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="System.Spatial" version="5.6.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.2.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
Expand Down Expand Up @@ -288,7 +289,9 @@
<Compile Include="FunctionalTests\IaasCmdletInfo\AddAzureNetworkInterfaceConfigCmdletInfo.cs" />
<Compile Include="FunctionalTests\NetworkCmdletInfo\GetAzureReservedIPCmdletInfo.cs" />
<Compile Include="FunctionalTests\NetworkCmdletInfo\NewAzureReservedIPCmdletInfo.cs" />
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPAssociationCmdletInfo.cs" />
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPCmdletInfo.cs" />
<Compile Include="FunctionalTests\NetworkCmdletInfo\SetAzureReservedIPAssociationCmdletInfo.cs" />
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventBySlotCmdletInfo.cs" />
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventCmdletInfo.cs" />
<Compile Include="FunctionalTests\SubscriptionCmdletInfo\RemoveAzureSubscriptionCmdletInfo.cs" />
Expand Down Expand Up @@ -419,6 +422,12 @@
<None Include="AzureRTComplete_Full_Diff.playlist" />
<None Include="AzureRTExtensions.playlist" />
<None Include="AzureRTFull.playlist" />
<None Include="Resources\HelloWorld_SDK20.cspkg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\ServiceConfiguration.cscfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="Resources\affinityGroupData.csv" />
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
using Microsoft.WindowsAzure.Management.Compute.Models;

namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
{
Expand All @@ -30,5 +31,13 @@ public NewAzureReservedIPCmdletInfo(string name, string location, string label)
this.cmdletParams.Add(new CmdletParam("Label", label));
}
}

public NewAzureReservedIPCmdletInfo(string name, string location, string serviceName, string slot, string label): this(name, location, label)
{
this.cmdletName = Utilities.NewAzureReservedIPCmdletName;

this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
this.cmdletParams.Add(new CmdletParam("Slot", slot));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;

namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
{
class RemoveAzureReservedIPAssociationCmdletInfo : CmdletsInfo
{
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string slot, bool force)
{
this.cmdletName = Utilities.RemoveAzureReservedIPAssociationCmdletName;

this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
this.cmdletParams.Add(new CmdletParam("Slot", slot));
if (force)
{
this.cmdletParams.Add(new CmdletParam("Force"));
}
}
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName)
: this(reservedIpName, serviceName, DeploymentSlotType.Production, true)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;

namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
{
public class SetAzureReservedIPAssociationCmdletInfo : CmdletsInfo
{
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string slot)
{
this.cmdletName = Utilities.SetAzureReservedIPAssociationCmdletName;

this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
this.cmdletParams.Add(new CmdletParam("Slot", slot));
}
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName) : this(reservedIpName, serviceName, DeploymentSlotType.Production)
{
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,21 @@ internal ManagementOperationContext NewAzureReservedIP(string name, string locat
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, label));
}

internal ManagementOperationContext NewAzureReservedIP(string name, string location, string serviceName, string label = null, string slot = SM.DeploymentSlotType.Production)
{
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, serviceName, slot, label));
}

internal ManagementOperationContext SetAzureReservedIPAssociation(string reservedIpName, string serviceName, string slot = SM.DeploymentSlotType.Production)
{
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new SetAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, slot));
}

internal ManagementOperationContext RemoveAzureReservedIPAssociation(string reservedIpName, string serviceName, bool force, string slot = SM.DeploymentSlotType.Production)
{
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new RemoveAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, slot, force));
}

internal Collection<SM.ReservedIPContext> GetAzureReservedIP(string name = null)
{
return RunPSCmdletAndReturnAll<SM.ReservedIPContext>(new GetAzureReservedIPCmdletInfo(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,21 @@ private static string GetServiceManagementUrl(string publishSettingsFile)
XDocument psf = XDocument.Load(publishSettingsFile);
XElement pubData = psf.Descendants().FirstOrDefault();
XElement pubProfile = pubData.Elements().ToList()[0];
return pubProfile.Attribute("Url").Value;
XAttribute urlattr = pubProfile.Attribute("Url");
string url = string.Empty;
if (urlattr != null)
{
url = urlattr.Value;
}
else
{
var subscriptions = pubProfile.Elements("Subscription").ToList();
if (subscriptions.Any())
{
url = subscriptions[0].Attribute("ServiceManagementUrl").Value;
}
}
return url;
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ internal class Utilities
public const string NewAzureReservedIPCmdletName = "New-AzureReservedIP";
public const string GetAzureReservedIPCmdletName = "Get-AzureReservedIP";
public const string RemoveAzureReservedIPCmdletName = "Remove-AzureReservedIP";
public const string SetAzureReservedIPAssociationCmdletName = "Set-AzureReservedIPAssociation";
public const string RemoveAzureReservedIPAssociationCmdletName = "Remove-AzureReservedIPAssociation";

// AzureRole & AzureRoleInstnace
public const string GetAzureRoleCmdletName = "Get-AzureRole";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-16"?>
<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">
<Role name="HelloWorld_WebRole">
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=samplesa;AccountKey=1VtQsFrdpGyY8bKCC2WF74B1lV9fBpPtxZbBj6apwFNLCm/sYTlsrCmps9TgBMykw5NiGGGwngYUzhvpECUXUQ==" />
</ConfigurationSettings>
<Instances count="1" />
</Role>
<NetworkConfiguration>
<AddressAssignments>
<InstanceAddress roleName="HelloWorld_WebRole">
<PublicIPs>
<PublicIP name="PublicIP1"/>
</PublicIPs>
</InstanceAddress>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="9.2.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="6.1.2" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.0.0" targetFramework="net45" />
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.1\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.6.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -248,11 +248,13 @@
<Compile Include="IaaS\Network\RemoveAzureNetworkSecurityGroupConfig.cs" />
<Compile Include="IaaS\Network\RemoveAzurePublicIP.cs" />
<Compile Include="IaaS\Network\GetAzurePublicIP.cs" />
<Compile Include="IaaS\Network\RemoveAzureReservedIPAssociation.cs" />
<Compile Include="IaaS\Network\SetAzureDns.cs" />
<Compile Include="IaaS\Network\SetAzureInternalLoadBalancer.cs" />
<Compile Include="IaaS\Network\SetAzureNetworkSecurityGroupConfig.cs" />
<Compile Include="IaaS\Network\SetAzureNetworkInterfaceConfig.cs" />
<Compile Include="IaaS\Network\SetAzurePublicIP.cs" />
<Compile Include="IaaS\Network\SetAzureReservedIPAssociation.cs" />
<Compile Include="Model\DeploymentRebootEventContext.cs" />
<Compile Include="Model\InternalLoadBalancerSetting.cs" />
<Compile Include="Model\InternalLoadBalancerContext.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.WindowsAzure.Management.Network.Models;
using Microsoft.WindowsAzure.Management.Network;
using Microsoft.WindowsAzure.Management.Compute;
using Microsoft.WindowsAzure.Management.Compute.Models;
using System;

namespace Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS
{
Expand All @@ -39,7 +42,7 @@ public string ReservedIPName

[Parameter(Mandatory = false, Position = 1, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveNewIPParamSet, HelpMessage = "Reserved IP Label.")]
[Parameter(Mandatory = false, Position = 3, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPUsingSlotParamSet, HelpMessage = "Reserved IP Label.")]
[Parameter(Mandatory = false, Position = 2, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Reserved IP Label.")]
[Parameter(Mandatory = false, Position = 1, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Reserved IP Label.")]
[ValidateNotNullOrEmpty]
public string Label
{
Expand All @@ -49,17 +52,46 @@ public string Label

[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveNewIPParamSet, HelpMessage = "Location Name.")]
[Parameter(Mandatory = true, Position = 4, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPUsingSlotParamSet, HelpMessage = "Location Name.")]
[Parameter(Mandatory = true, Position = 3, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Location Name.")]
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Location Name.")]
[ValidateNotNullOrEmpty]
public string Location
{
get;
set;
}

[Parameter(Mandatory = true, Position = 3, ValueFromPipelineByPropertyName = true, ParameterSetName = ReserveInUseIPParamSet, HelpMessage = "Service Name.")]
[ValidateNotNullOrEmpty]
public string ServiceName
{
get;
set;
}

[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Deployment slot [Staging | Production].")]
[ValidateSet(Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DeploymentSlotType.Staging, Microsoft.WindowsAzure.Commands.ServiceManagement.Model.DeploymentSlotType.Production, IgnoreCase = true)]
public string Slot
{
get;
set;
}

protected override void OnProcessRecord()
{
ServiceManagementProfile.Initialize();
string deploymentName = string.Empty;

if (!string.IsNullOrEmpty(this.ServiceName))
{
var slotType = string.IsNullOrEmpty(this.Slot) ?
DeploymentSlot.Production :
(DeploymentSlot)Enum.Parse(typeof(DeploymentSlot), this.Slot, true);


deploymentName = this.ComputeClient.Deployments.GetBySlot(
this.ServiceName,
slotType).Name;
}

ExecuteClientActionNewSM(
null,
Expand All @@ -70,7 +102,9 @@ protected override void OnProcessRecord()
{
Name = this.ReservedIPName,
Label = this.Label,
Location = this.Location
Location = this.Location,
ServiceName = this.ServiceName,
DeploymentName = deploymentName
};

return this.NetworkClient.ReservedIPs.Create(parameters);
Expand Down
Loading