Skip to content

Added AzureCrossConnection commandlets, and updated others to latest expressroute APIs #345

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

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,9 @@
<Component Id="cmpBE209ED6509A7E857FD9F9078051DC6A" Guid="*">
<File Id="fil96FD7FA0CBEE96E0C0239408CD5651A9" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.WindowsAzure.Common.NetFramework.dll" />
</Component>
<Component Id="cmpD7A9F76B2346156CA8F83F41A302B714" Guid="*">
<File Id="fil0218D7505353104A9DB742A55A839351" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.WindowsAzure.Management.dll" />
</Component>
<Component Id="cmp4D3E383B38EF4392E70E981B7CA033D7" Guid="*">
<File Id="fil3D6B846AC421D38C5A9CB40A58B058B6" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\RecoveryServices\Microsoft.WindowsAzure.Management.SiteRecovery.dll" />
</Component>
Expand Down Expand Up @@ -3275,6 +3278,7 @@
<ComponentRef Id="cmp8CDB44BA783FF24C94CDFC5D12066BB1" />
<ComponentRef Id="cmpA0A697DEB7822A0EC30F3D359EE930A6" />
<ComponentRef Id="cmpBE209ED6509A7E857FD9F9078051DC6A" />
<ComponentRef Id="cmpD7A9F76B2346156CA8F83F41A302B714" />
<ComponentRef Id="cmp4D3E383B38EF4392E70E981B7CA033D7" />
<ComponentRef Id="cmp50D44814DFFEA762A53D9DEDCE48F689" />
<ComponentRef Id="cmp439E7C155DEEFC3877653E4ED11F66AC" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Advertised Public Prefixes")]
[ValidateNotNullOrEmpty]
public string AdvertisedPublicPrefixes { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Customer AS number")]
public UInt32 CustomerAsn { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Peer Asn")]
public UInt32 PeerAsn { get; set; }
Expand All @@ -35,6 +42,9 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string PrimaryPeerSubnet { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Routing Registry Name for Prefix Validation")]
public string RoutingRegistryName { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Secondary Peer Subnet")]
[ValidateNotNullOrEmpty]
public string SecondaryPeerSubnet { get; set; }
Expand All @@ -46,14 +56,14 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Vlan Id")]
public UInt32 VlanId { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peering Access Type: Public or Private")]
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peering Access Type: Microsoft, Public or Private")]
[DefaultValue("Private")]
public BgpPeeringAccessType AccessType { get; set; }

public override void ExecuteCmdlet()
{
var route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAsn, PrimaryPeerSubnet,
SecondaryPeerSubnet, VlanId, AccessType, SharedKey);
var route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn, PeerAsn,
PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId, AccessType, SharedKey);
WriteObject(route);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
using ServiceManagement.Model;

[Cmdlet(VerbsCommon.Set, "AzureBGPPeering"), OutputType(typeof(AzureBgpPeering))]
public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
{
Expand All @@ -28,6 +30,13 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Advertised Public Prefixes")]
[ValidateNotNullOrEmpty]
public string AdvertisedPublicPrefixes;

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Customer AS number")]
public UInt32 CustomerAsn { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Peer Asn")]
public UInt32? PeerAsn { get; set; }
Expand All @@ -36,6 +45,9 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string PrimaryPeerSubnet { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Routing Registry Name for Prefix Validation")]
public string RoutingRegistryName { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Secondary Peer Subnet")]
[ValidateNotNullOrEmpty]
public string SecondaryPeerSubnet { get; set; }
Expand All @@ -47,7 +59,7 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Vlan Id")]
public UInt32? VlanId { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peering Access Type: Public or Private")]
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peering Access Type: Microsoft, Public or Private")]
[DefaultValue("Private")]
public BgpPeeringAccessType AccessType { get; set; }

Expand All @@ -56,8 +68,8 @@ public override void ExecuteCmdlet()
try
{
var route = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);
var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType,
PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet,
var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType, CustomerAsn,
PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet, RoutingRegistryName,
SecondaryPeerSubnet ?? route.SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
SharedKey);
WriteObject(updatedRoute, false);
Expand All @@ -84,8 +96,9 @@ public override void ExecuteCmdlet()
throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
}

var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAsn.Value, PrimaryPeerSubnet,
SecondaryPeerSubnet, VlanId.Value, AccessType, SharedKey);
var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn,
PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId.Value, AccessType,
SharedKey);
WriteObject(newRoute);
}
}
Expand Down
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.2-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.18.3-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 @@ -122,6 +122,9 @@
<Compile Include="BgpPeerings\NewAzureBGPPeering.cs" />
<Compile Include="BgpPeerings\RemoveAzureBGPPeering.cs" />
<Compile Include="BgpPeerings\SetAzureBGPPeering.cs" />
<Compile Include="CrossConnections\GetAzureCrossConnection.cs" />
<Compile Include="CrossConnections\NewAzureCrossConnections.cs" />
<Compile Include="CrossConnections\SetAzureCrossConnection.cs" />
<Compile Include="DedicatedCircuitLinkAuthorizationMicrosoftIds\NewAzureDedicatedCircuitLinkAuthorizationMicrosoftIds.cs" />
<Compile Include="DedicatedCircuitLinkAuthorizationMicrosoftIds\RemoveAzureDedicatedCircuitLinkAuthorizationMicrosoftIds.cs" />
<Compile Include="DedicatedCircuitLinkAuthorizations\GetAzureDedicatedCircuitLinkAuthorization.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.Collections.Generic;
using System.Management.Automation;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
[Cmdlet(VerbsCommon.Get, "AzureCrossConnection"), OutputType(typeof(AzureCrossConnection), typeof(IEnumerable<AzureCrossConnection>))]
public class GetAzureCrossConnectionCommand : ExpressRouteBaseCmdlet
{
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key representing the Dedicated Circuit")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

public override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(ServiceKey))
{
GetByServiceKey();
}
else
{
GetNoServiceKey();
}
}

private void GetByServiceKey()
{
var crossConnection = ExpressRouteClient.GetAzureCrossConnection(ServiceKey);
WriteObject(crossConnection);
}

private void GetNoServiceKey()
{
var crossConnections = ExpressRouteClient.ListAzureCrossConnections();
WriteObject(crossConnections, true);
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ----------------------------------------------------------------------------------
//
// 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;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
[Cmdlet(VerbsCommon.New, "AzureCrossConnection"), OutputType(typeof(AzureCrossConnection))]
public class NewAzureCrossConnectionCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Dedicated Circuit Service Key")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(HelpMessage = "Do not confirm Azure Cross Connection creation")]
public SwitchParameter Force { get; set; }

public override void ExecuteCmdlet()
{
ConfirmAction(
Force.IsPresent,
string.Format(Resources.NewAzureCrossConnectionWarning, ServiceKey),
string.Format(Resources.NewAzureCrossConnectionMessage, ServiceKey),
ServiceKey,
() =>
{
var crossConnection = ExpressRouteClient.NewAzureCrossConnection(ServiceKey);
WriteVerboseWithTimestamp(Resources.NewAzureCrossConnectionSucceeded);
WriteObject(crossConnection);
});

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// ----------------------------------------------------------------------------------
//
// 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.ComponentModel;
using System.Management.Automation;
using Microsoft.WindowsAzure.Commands.ExpressRoute.Properties;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
using ServiceManagement.Model;

[Cmdlet(VerbsCommon.Set, "AzureCrossConnection"), OutputType(typeof(AzureCrossConnection))]
public class SetAzureCrossConnectionCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Service Key representing Azure Circuit for which BGP peering needs to be created/modified")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Notification Operation to perform. NotifyCrossConnectionProvisioned or NotifyCrossConnectionNotProvisioned")]
[ValidateNotNullOrEmpty]
public UpdateCrossConnectionOperation Operation { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Provisioning Error Message")]
public string ProvisioningError { get; set; }

public override void ExecuteCmdlet()
{
var crossConnection = ExpressRouteClient.SetAzureCrossConnection(ServiceKey,
new CrossConnectionUpdateParameters() {Operation = Operation, ProvisioningError = ProvisioningError});
WriteObject(crossConnection);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessTyp
return Client.BorderGatewayProtocolPeerings.Get(serviceKey, accessType).BgpPeering;
}

public AzureBgpPeering NewAzureBGPPeering(string serviceKey, UInt32 peerAsn, string primaryPeerSubnet,
string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null)
public AzureBgpPeering NewAzureBGPPeering(string serviceKey, string advertisedPublicPrefixes, UInt32 customerAsn,
UInt32 peerAsn, string primaryPeerSubnet, string routingRegistryName, string secondaryPeerSubnet,
UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null)
{
var result = Client.BorderGatewayProtocolPeerings.New(serviceKey, accessType, new BorderGatewayProtocolPeeringNewParameters()
{
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
CustomerAutonomousSystemNumber = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
RoutingRegistryName = routingRegistryName,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId
Expand All @@ -87,14 +91,19 @@ public bool RemoveAzureBGPPeering(string serviceKey, BgpPeeringAccessType access
return result.HttpStatusCode.Equals(HttpStatusCode.OK);
}

public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey,
BgpPeeringAccessType accessType, UInt32 peerAsn, string primaryPeerSubnet,
string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey,
BgpPeeringAccessType accessType, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet,
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)



{
var result = Client.BorderGatewayProtocolPeerings.Update(serviceKey, accessType, new BorderGatewayProtocolPeeringUpdateParameters()
{
CustomerAutonomousSystemNumber = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
RoutingRegistryName = routingRegistryName,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
Expand Down Expand Up @@ -144,7 +153,7 @@ public AzureDedicatedCircuit SetAzureDedicatedCircuitBandwidth(string serviceKey
{
var result = Client.DedicatedCircuits.Update(serviceKey, (new DedicatedCircuitUpdateParameters()
{
Bandwidth = bandwidth
Bandwidth = bandwidth.ToString()
}));

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
Expand Down Expand Up @@ -298,5 +307,6 @@ public bool RemoveAzureDedicatedCircuitLinkAuthorizationMicrosoftIds(string serv
});
return result.StatusCode.Equals(HttpStatusCode.OK);
}

}
}
Loading