Skip to content

Fixing ExpressRoute commandlets + new Set-AzureDedicatedCircuitBandwidth commandlet #202

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
Feb 27, 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 @@ -83,7 +83,7 @@
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.ExpressRoute, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.18.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.18.2-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -135,6 +135,7 @@
<Compile Include="DedicatedCircuits\GetAzureDedicatedCircuit.cs" />
<Compile Include="DedicatedCircuits\NewAzureDedicatedCircuit.cs" />
<Compile Include="DedicatedCircuits\RemoveAzureDedicatedCircuit.cs" />
<Compile Include="DedicatedCircuitBandwidths\SetAzureDedicatedCircuitBandwidth.cs" />
<Compile Include="ExpressRouteBaseCmdlet.cs" />
<Compile Include="ExpressRouteClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ----------------------------------------------------------------------------------
//
// 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 System;
using System.Management.Automation;
using Microsoft.WindowsAzure.Commands.ExpressRoute.Properties;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
using Management.ExpressRoute.Models;

[Cmdlet(VerbsCommon.Set, "AzureDedicatedCircuitBandwidth"), OutputType(typeof(AzureDedicatedCircuit))]
public class SetAzureDedicatedCircuitBandwidthCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key of Azure Dedicated Circuit to be removed")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Circuit Bandwidth")]
[ValidateNotNullOrEmpty]
public UInt32 Bandwidth { get; set; }

[Parameter(HelpMessage = "Do not confirm Azure Dedicated Circuit Update")]
public SwitchParameter Force { get; set; }

public override void ExecuteCmdlet()
{
ConfirmAction(
Force.IsPresent,
string.Format(Resources.SetAzureDedicatedCircuitBandwidthWarning, ServiceKey, Bandwidth),
Resources.SetAzureDedicatedCircuitBandwidthMessage,
ServiceKey,
() =>
{
var circuit = ExpressRouteClient.SetAzureDedicatedCircuitBandwidth(ServiceKey, Bandwidth);

WriteObject(circuit);

});
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Microsoft.WindowsAzure.Commands.ExpressRoute
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using Utilities.Common;
using Microsoft.Azure.Common.Authentication.Models;
Expand Down Expand Up @@ -61,14 +62,23 @@ public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessTyp
public AzureBgpPeering NewAzureBGPPeering(string serviceKey, UInt32 peerAsn, string primaryPeerSubnet,
string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null)
{
return Client.BorderGatewayProtocolPeerings.New(serviceKey, accessType, new BorderGatewayProtocolPeeringNewParameters()
var result = Client.BorderGatewayProtocolPeerings.New(serviceKey, accessType, new BorderGatewayProtocolPeeringNewParameters()
{
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId
}).BgpPeering;
});

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureBGPPeering(serviceKey, accessType);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public bool RemoveAzureBGPPeering(string serviceKey, BgpPeeringAccessType accessType)
Expand All @@ -81,15 +91,22 @@ public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey,
BgpPeeringAccessType accessType, UInt32 peerAsn, string primaryPeerSubnet,
string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
{
return
(Client.BorderGatewayProtocolPeerings.Update(serviceKey, accessType, new BorderGatewayProtocolPeeringUpdateParameters()
var result = Client.BorderGatewayProtocolPeerings.Update(serviceKey, accessType, new BorderGatewayProtocolPeeringUpdateParameters()
{
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
})).BgpPeering;
});
if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureBGPPeering(serviceKey, accessType);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public AzureDedicatedCircuit GetAzureDedicatedCircuit(string serviceKey)
Expand All @@ -100,20 +117,46 @@ public AzureDedicatedCircuit GetAzureDedicatedCircuit(string serviceKey)
public AzureDedicatedCircuit NewAzureDedicatedCircuit(string circuitName,
UInt32 bandwidth, string location, string serviceProviderName)
{
return (Client.DedicatedCircuits.New(new DedicatedCircuitNewParameters()
var result = Client.DedicatedCircuits.New(new DedicatedCircuitNewParameters()
{
Bandwidth = bandwidth,
CircuitName = circuitName,
Location = location,
ServiceProviderName = serviceProviderName
})).DedicatedCircuit;
});

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureDedicatedCircuit(result.Data);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public IEnumerable<AzureDedicatedCircuit> ListAzureDedicatedCircuit()
{
return (Client.DedicatedCircuits.List().DedicatedCircuits);
}

public AzureDedicatedCircuit SetAzureDedicatedCircuitBandwidth(string serviceKey, UInt32 bandwidth)
{
var result = Client.DedicatedCircuits.Update(serviceKey, (new DedicatedCircuitUpdateParameters()
{
Bandwidth = bandwidth
}));

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureDedicatedCircuit(serviceKey);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public bool RemoveAzureDedicatedCircuit(string serviceKey)
{
var result = Client.DedicatedCircuits.Remove(serviceKey);
Expand All @@ -127,7 +170,15 @@ public AzureDedicatedCircuitLink GetAzureDedicatedCircuitLink(string serviceKey,

public AzureDedicatedCircuitLink NewAzureDedicatedCircuitLink(string serviceKey, string vNetName)
{
return (Client.DedicatedCircuitLinks.New(serviceKey, vNetName)).DedicatedCircuitLink;
var result = Client.DedicatedCircuitLinks.New(serviceKey, vNetName);
if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureDedicatedCircuitLink(serviceKey, vNetName);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public IEnumerable<AzureDedicatedCircuitLink> ListAzureDedicatedCircuitLink(string serviceKey)
Expand All @@ -153,13 +204,31 @@ public AzureCrossConnection GetAzureCrossConnection(string serviceKey)

public AzureCrossConnection NewAzureCrossConnection(string serviceKey)
{
return (Client.CrossConnections.New(serviceKey)).CrossConnection;
var result = Client.CrossConnections.New(serviceKey);

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureCrossConnection(serviceKey);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public AzureCrossConnection SetAzureCrossConnection(string serviceKey,
CrossConnectionUpdateParameters parameters)
{
return (Client.CrossConnections.Update(serviceKey, parameters)).CrossConnection;
var result = Client.CrossConnections.Update(serviceKey, parameters);

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureCrossConnection(serviceKey);
}
else
{
throw new Exception(result.Error.ToString());
}
}

public IEnumerable<AzureCrossConnection> ListAzureCrossConnections()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<data name="RemoveAzureDedicatdCircuitWarning" xml:space="preserve">
<value>Are you sure you want to remove the Dedicated Circuit with service key '{0}'?</value>
</data>
<data name="SetAzureDedicatedCircuitBandwidthWarning" xml:space="preserve">
<value>Are you sure you want to update the bandwidth of the Dedicated Circuit with service key '{0}' to '{1}'?</value>
</data>
<data name="RemoveAzureDedicatedCircuitFailed" xml:space="preserve">
<value>Remove-AzureDedicatedCircuit Operation failed.</value>
</data>
Expand Down Expand Up @@ -180,6 +183,9 @@
<data name="RemoveAzureDedicatedCircuitMessage" xml:space="preserve">
<value>Removing Dedicated Circuit</value>
</data>
<data name="SetAzureDedicatedCircuitBandwidthMessage" xml:space="preserve">
<value>Updating Dedicated Circuit Bandwidth</value>
</data>
<data name="RemoveAzureDedicatedCircuitSucceeded" xml:space="preserve">
<value>Successfully removed Azure Dedicated Circuit with Service Key {0}.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.12.111071459" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.0.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.ExpressRoute" version="0.18.0-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.ExpressRoute" version="0.18.2-preview" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.9.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.ExpressRoute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.18.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.18.2-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.MediaServices">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.MediaServices.4.0.0\lib\net40\Microsoft.WindowsAzure.Management.MediaServices.dll</HintPath>
Expand Down
Loading