Skip to content

Ipv6 #4214

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 8 commits into from
Jun 29, 2017
Merged

Ipv6 #4214

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 @@ -645,4 +645,4 @@
</ItemGroup>
<Copy SourceFiles="@(MarkdownFiles)" DestinationFolder="$(OutputPath)\help\" ContinueOnError="false" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,4 @@ public static void Initialize()
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Execute()
peering.SecondaryPeerAddressPrefix = this.SecondaryPeerAddressPrefix;
peering.PeerASN = this.PeerASN;
peering.VlanId = this.VlanId;


if (!string.IsNullOrEmpty(this.SharedKey))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public class GetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
HelpMessage = "Service Key representing the Azure Circuit")]
public Guid ServiceKey { 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")]
[ValidateSet("Microsoft", "Public", "Private")]
[DefaultValue("Private")]
public BgpPeeringAccessType AccessType { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,21 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
public UInt32 VlanId { get; set; }

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

[Parameter(Mandatory = false, HelpMessage = "Bgp Peer Address Type: IPv4, IPv6")]
[ValidateSet("IPv4", "IPv6")]
[DefaultValue("IPv4")]
public PeerAddressTypeValues PeerAddressType { get; set; }

public override void ExecuteCmdlet()
{
var route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn, PeerAsn,
PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId, AccessType, SharedKey, Convert.ToUInt32(LegacyMode));
AzureBgpPeering route = null;
route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAddressType, AdvertisedPublicPrefixes, CustomerAsn, PeerAsn, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet,
VlanId, AccessType, SharedKey, Convert.ToUInt32(LegacyMode));

WriteObject(route);
}
}
Expand All @@ -74,4 +82,10 @@ public enum LegacyMode
False = 0,
True = 1
}

public enum PeerAddressTypeValues
{
IPv4 = 0,
IPv6 = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
[Cmdlet(VerbsCommon.Remove, "AzureBGPPeering"),OutputType(typeof(bool))]
[Cmdlet(VerbsCommon.Remove, "AzureBGPPeering", SupportsShouldProcess = true), OutputType(typeof(bool))]
public class RemoveAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key associated with the Azure BGP Peering to be removed")]
public Guid ServiceKey { get; set; }

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

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peer Address Type: IPv4, IPv6, All")]
[ValidateSet("IPv4", "IPv6", "All")]
[DefaultValue("IPv4")]
public BgpPeerAddressType PeerAddressType { get; set; }

[Parameter(HelpMessage = "Do not confirm Azure BGP Peering deletion")]
public SwitchParameter Force { get; set; }

Expand All @@ -46,18 +52,35 @@ public override void ExecuteCmdlet()
ServiceKey.ToString(),
() =>
{

if(!ExpressRouteClient.RemoveAzureBGPPeering(ServiceKey, AccessType))
if (PeerAddressType == BgpPeerAddressType.All || AccessType != BgpPeeringAccessType.Microsoft)
{
throw new Exception(Resources.RemoveAzureBGPPeeringFailed);
if (!ExpressRouteClient.RemoveAzureBGPPeering(ServiceKey, AccessType, BgpPeerAddressType.All))
{
throw new Exception(Resources.RemoveAzureBGPPeeringFailed);
}
else
{
WriteVerboseWithTimestamp(Resources.RemoveAzureBGPPeeringSucceeded, ServiceKey);
if (PassThru.IsPresent)
{
WriteObject(true);
}
}
}
else
{
WriteVerboseWithTimestamp(Resources.RemoveAzureBGPPeeringSucceeded, ServiceKey);
if (PassThru.IsPresent)
{
WriteObject(true);
}
if (!ExpressRouteClient.RemoveAzureBGPPeering(ServiceKey, AccessType, (BgpPeerAddressType)PeerAddressType))
{
throw new Exception(Resources.RemoveAzureBGPPeeringFailed);
}
else
{
WriteVerboseWithTimestamp(Resources.RemoveAzureBGPPeeringFailed, ServiceKey);
if (PassThru.IsPresent)
{
WriteObject(true);
}
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
public string AdvertisedPublicPrefixes;

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

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Peer Asn")]
Expand All @@ -57,18 +57,30 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
public UInt32? VlanId { get; set; }

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

[Parameter(Mandatory = false, HelpMessage = "Bgp Peer Address Type: IPv4, IPv6")]
[ValidateSet("IPv4", "IPv6")]
[DefaultValue("IPv4")]
public PeerAddressTypeValues PeerAddressType { get; set; }

public override void ExecuteCmdlet()
{
try
{
var route = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);
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.Trim());

var advertisedPublicPrefixes = AdvertisedPublicPrefixes ?? ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.AdvertisedPublicPrefixes : route.AdvertisedPublicPrefixesIpv6);
var routingRegistryName = RoutingRegistryName ?? ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.RoutingRegistryName : route.RoutingRegistryNameIpv6);
var customerAsn = (CustomerAsn.HasValue) ? CustomerAsn.Value : ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.CustomerAutonomousSystemNumber : route.CustomerAutonomousSystemNumberIpv6);

var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, PeerAddressType, AccessType,
advertisedPublicPrefixes, customerAsn, PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet,
routingRegistryName, SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
string.IsNullOrWhiteSpace(SharedKey) ? null : SharedKey.Trim());

WriteObject(updatedRoute, false);
}
catch
Expand All @@ -93,9 +105,8 @@ public override void ExecuteCmdlet()
throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
}

var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn,
PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId.Value, AccessType,
SharedKey);
var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAddressType, AdvertisedPublicPrefixes, CustomerAsn.Value, 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 @@ -88,7 +88,7 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.ExpressRoute">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.21.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.23.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand Down Expand Up @@ -194,4 +194,4 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,41 @@ public AzureBgpPeering GetAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType
return Client.BorderGatewayProtocolPeerings.Get(serviceKey.ToString(), accessType).BgpPeering;
}

public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn,string primaryPeerSubnet,
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null, UInt32 legacyMode = 0)
{
var result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters()
{
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
CustomerAutonomousSystemNumber = customerAsn,
LegacyMode = legacyMode,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
RoutingRegistryName = routingRegistryName,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
});
public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, PeerAddressTypeValues peerAddressType, string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet, string routingRegistryName, string secondaryPeerSubnet,
UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null, UInt32 legacyMode = 0)
{
ExpressRouteOperationStatusResponse result = null;

if (peerAddressType == PeerAddressTypeValues.IPv4)
{
result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters()
{
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
LegacyMode = legacyMode,
CustomerAutonomousSystemNumber = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
RoutingRegistryName = routingRegistryName,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
});
}
else
{
result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters()
{
AdvertisedPublicPrefixesIpv6 = advertisedPublicPrefixes,
LegacyMode = legacyMode,
CustomerAutonomousSystemNumberIpv6 = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnetIpv6 = primaryPeerSubnet,
RoutingRegistryNameIpv6 = routingRegistryName,
SecondaryPeerSubnetIpv6 = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
});
}

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
Expand All @@ -105,18 +125,22 @@ public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, string advertisedPubl
}
}

public bool RemoveAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType)
public bool RemoveAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType, BgpPeerAddressType peerAddressType)
{
var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey.ToString(), accessType);
var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey.ToString(), accessType, peerAddressType);
return result.HttpStatusCode.Equals(HttpStatusCode.OK);
}

public AzureBgpPeering UpdateAzureBGPPeering(Guid serviceKey,
BgpPeeringAccessType accessType, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet,
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
public AzureBgpPeering UpdateAzureBGPPeering(Guid serviceKey, PeerAddressTypeValues peerAddressType, BgpPeeringAccessType accessType,
string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet, string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
{
var result = Client.BorderGatewayProtocolPeerings.Update(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringUpdateParameters()
ExpressRouteOperationStatusResponse result = null;

if (peerAddressType == PeerAddressTypeValues.IPv4)
{
result = Client.BorderGatewayProtocolPeerings.Update(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringUpdateParameters()
{
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
CustomerAutonomousSystemNumber = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
Expand All @@ -125,6 +149,22 @@ public AzureBgpPeering UpdateAzureBGPPeering(Guid serviceKey,
SharedKey = sharedKey,
VirtualLanId = vlanId,
});
}
else
{
result = Client.BorderGatewayProtocolPeerings.Update(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringUpdateParameters()
{
AdvertisedPublicPrefixesIpv6 = advertisedPublicPrefixes,
CustomerAutonomousSystemNumberIpv6 = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnetIpv6 = primaryPeerSubnet,
RoutingRegistryNameIpv6 = routingRegistryName,
SecondaryPeerSubnetIpv6 = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
});
}

if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
{
return GetAzureBGPPeering(serviceKey, accessType);
Expand Down
Loading