Skip to content

Commit 0fa1fc2

Browse files
authored
Merge pull request #4214 from vinayada1/ipv6
Ipv6
2 parents 4f97f10 + 226f979 commit 0fa1fc2

File tree

16 files changed

+224
-70
lines changed

16 files changed

+224
-70
lines changed

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,4 +645,4 @@
645645
</ItemGroup>
646646
<Copy SourceFiles="@(MarkdownFiles)" DestinationFolder="$(OutputPath)\help\" ContinueOnError="false" />
647647
</Target>
648-
</Project>
648+
</Project>

src/ResourceManager/Network/Commands.Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,4 @@ public static void Initialize()
448448
});
449449
}
450450
}
451-
}
451+
}

src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/Peering/AddAzureExpressRouteCircuitPeeringConfigCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public override void Execute()
6262
peering.SecondaryPeerAddressPrefix = this.SecondaryPeerAddressPrefix;
6363
peering.PeerASN = this.PeerASN;
6464
peering.VlanId = this.VlanId;
65-
65+
6666

6767
if (!string.IsNullOrEmpty(this.SharedKey))
6868
{

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/BgpPeerings/GetAzureBGPPeering.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public class GetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
2727
HelpMessage = "Service Key representing the Azure Circuit")]
2828
public Guid ServiceKey { get; set; }
2929

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

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/BgpPeerings/NewAzureBGPPeering.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,21 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
5858
public UInt32 VlanId { get; set; }
5959

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

65+
[Parameter(Mandatory = false, HelpMessage = "Bgp Peer Address Type: IPv4, IPv6")]
66+
[ValidateSet("IPv4", "IPv6")]
67+
[DefaultValue("IPv4")]
68+
public PeerAddressTypeValues PeerAddressType { get; set; }
69+
6470
public override void ExecuteCmdlet()
6571
{
66-
var route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn, PeerAsn,
67-
PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId, AccessType, SharedKey, Convert.ToUInt32(LegacyMode));
72+
AzureBgpPeering route = null;
73+
route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAddressType, AdvertisedPublicPrefixes, CustomerAsn, PeerAsn, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet,
74+
VlanId, AccessType, SharedKey, Convert.ToUInt32(LegacyMode));
75+
6876
WriteObject(route);
6977
}
7078
}
@@ -74,4 +82,10 @@ public enum LegacyMode
7482
False = 0,
7583
True = 1
7684
}
85+
86+
public enum PeerAddressTypeValues
87+
{
88+
IPv4 = 0,
89+
IPv6 = 1
90+
}
7791
}

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/BgpPeerings/RemoveAzureBGPPeering.cs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@
2020

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

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

35+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peer Address Type: IPv4, IPv6, All")]
36+
[ValidateSet("IPv4", "IPv6", "All")]
37+
[DefaultValue("IPv4")]
38+
public BgpPeerAddressType PeerAddressType { get; set; }
39+
3440
[Parameter(HelpMessage = "Do not confirm Azure BGP Peering deletion")]
3541
public SwitchParameter Force { get; set; }
3642

@@ -46,18 +52,35 @@ public override void ExecuteCmdlet()
4652
ServiceKey.ToString(),
4753
() =>
4854
{
49-
50-
if(!ExpressRouteClient.RemoveAzureBGPPeering(ServiceKey, AccessType))
55+
if (PeerAddressType == BgpPeerAddressType.All || AccessType != BgpPeeringAccessType.Microsoft)
5156
{
52-
throw new Exception(Resources.RemoveAzureBGPPeeringFailed);
57+
if (!ExpressRouteClient.RemoveAzureBGPPeering(ServiceKey, AccessType, BgpPeerAddressType.All))
58+
{
59+
throw new Exception(Resources.RemoveAzureBGPPeeringFailed);
60+
}
61+
else
62+
{
63+
WriteVerboseWithTimestamp(Resources.RemoveAzureBGPPeeringSucceeded, ServiceKey);
64+
if (PassThru.IsPresent)
65+
{
66+
WriteObject(true);
67+
}
68+
}
5369
}
5470
else
5571
{
56-
WriteVerboseWithTimestamp(Resources.RemoveAzureBGPPeeringSucceeded, ServiceKey);
57-
if (PassThru.IsPresent)
58-
{
59-
WriteObject(true);
60-
}
72+
if (!ExpressRouteClient.RemoveAzureBGPPeering(ServiceKey, AccessType, (BgpPeerAddressType)PeerAddressType))
73+
{
74+
throw new Exception(Resources.RemoveAzureBGPPeeringFailed);
75+
}
76+
else
77+
{
78+
WriteVerboseWithTimestamp(Resources.RemoveAzureBGPPeeringFailed, ServiceKey);
79+
if (PassThru.IsPresent)
80+
{
81+
WriteObject(true);
82+
}
83+
}
6184
}
6285
});
6386
}

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/BgpPeerings/SetAzureBGPPeering.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
3232
public string AdvertisedPublicPrefixes;
3333

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

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

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

64+
[Parameter(Mandatory = false, HelpMessage = "Bgp Peer Address Type: IPv4, IPv6")]
65+
[ValidateSet("IPv4", "IPv6")]
66+
[DefaultValue("IPv4")]
67+
public PeerAddressTypeValues PeerAddressType { get; set; }
68+
6369
public override void ExecuteCmdlet()
6470
{
6571
try
6672
{
6773
var route = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);
68-
var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType, CustomerAsn,
69-
PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet, RoutingRegistryName,
70-
SecondaryPeerSubnet ?? route.SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
71-
SharedKey.Trim());
74+
75+
var advertisedPublicPrefixes = AdvertisedPublicPrefixes ?? ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.AdvertisedPublicPrefixes : route.AdvertisedPublicPrefixesIpv6);
76+
var routingRegistryName = RoutingRegistryName ?? ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.RoutingRegistryName : route.RoutingRegistryNameIpv6);
77+
var customerAsn = (CustomerAsn.HasValue) ? CustomerAsn.Value : ((PeerAddressType == PeerAddressTypeValues.IPv4) ? route.CustomerAutonomousSystemNumber : route.CustomerAutonomousSystemNumberIpv6);
78+
79+
var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, PeerAddressType, AccessType,
80+
advertisedPublicPrefixes, customerAsn, PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet,
81+
routingRegistryName, SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
82+
string.IsNullOrWhiteSpace(SharedKey) ? null : SharedKey.Trim());
83+
7284
WriteObject(updatedRoute, false);
7385
}
7486
catch
@@ -93,9 +105,8 @@ public override void ExecuteCmdlet()
93105
throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
94106
}
95107

96-
var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn,
97-
PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId.Value, AccessType,
98-
SharedKey);
108+
var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAddressType, AdvertisedPublicPrefixes, CustomerAsn.Value, PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet,
109+
VlanId.Value, AccessType, SharedKey);
99110
WriteObject(newRoute);
100111
}
101112
}

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/Commands.ExpressRoute.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
8989
</Reference>
9090
<Reference Include="Microsoft.WindowsAzure.Management.ExpressRoute">
91-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.21.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
91+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.ExpressRoute.0.23.0-preview\lib\net40\Microsoft.WindowsAzure.Management.ExpressRoute.dll</HintPath>
9292
<Private>True</Private>
9393
</Reference>
9494
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -194,4 +194,4 @@
194194
</ItemGroup>
195195
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
196196
<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')" />
197-
</Project>
197+
</Project>

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/ExpressRouteClient.cs

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,41 @@ public AzureBgpPeering GetAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType
7979
return Client.BorderGatewayProtocolPeerings.Get(serviceKey.ToString(), accessType).BgpPeering;
8080
}
8181

82-
public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn,string primaryPeerSubnet,
83-
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null, UInt32 legacyMode = 0)
84-
{
85-
var result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters()
86-
{
87-
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
88-
CustomerAutonomousSystemNumber = customerAsn,
89-
LegacyMode = legacyMode,
90-
PeerAutonomousSystemNumber = peerAsn,
91-
PrimaryPeerSubnet = primaryPeerSubnet,
92-
RoutingRegistryName = routingRegistryName,
93-
SecondaryPeerSubnet = secondaryPeerSubnet,
94-
SharedKey = sharedKey,
95-
VirtualLanId = vlanId,
96-
});
82+
public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, PeerAddressTypeValues peerAddressType, string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet, string routingRegistryName, string secondaryPeerSubnet,
83+
UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null, UInt32 legacyMode = 0)
84+
{
85+
ExpressRouteOperationStatusResponse result = null;
86+
87+
if (peerAddressType == PeerAddressTypeValues.IPv4)
88+
{
89+
result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters()
90+
{
91+
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
92+
LegacyMode = legacyMode,
93+
CustomerAutonomousSystemNumber = customerAsn,
94+
PeerAutonomousSystemNumber = peerAsn,
95+
PrimaryPeerSubnet = primaryPeerSubnet,
96+
RoutingRegistryName = routingRegistryName,
97+
SecondaryPeerSubnet = secondaryPeerSubnet,
98+
SharedKey = sharedKey,
99+
VirtualLanId = vlanId,
100+
});
101+
}
102+
else
103+
{
104+
result = Client.BorderGatewayProtocolPeerings.New(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringNewParameters()
105+
{
106+
AdvertisedPublicPrefixesIpv6 = advertisedPublicPrefixes,
107+
LegacyMode = legacyMode,
108+
CustomerAutonomousSystemNumberIpv6 = customerAsn,
109+
PeerAutonomousSystemNumber = peerAsn,
110+
PrimaryPeerSubnetIpv6 = primaryPeerSubnet,
111+
RoutingRegistryNameIpv6 = routingRegistryName,
112+
SecondaryPeerSubnetIpv6 = secondaryPeerSubnet,
113+
SharedKey = sharedKey,
114+
VirtualLanId = vlanId,
115+
});
116+
}
97117

98118
if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
99119
{
@@ -105,18 +125,22 @@ public AzureBgpPeering NewAzureBGPPeering(Guid serviceKey, string advertisedPubl
105125
}
106126
}
107127

108-
public bool RemoveAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType)
128+
public bool RemoveAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType, BgpPeerAddressType peerAddressType)
109129
{
110-
var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey.ToString(), accessType);
130+
var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey.ToString(), accessType, peerAddressType);
111131
return result.HttpStatusCode.Equals(HttpStatusCode.OK);
112132
}
113133

114-
public AzureBgpPeering UpdateAzureBGPPeering(Guid serviceKey,
115-
BgpPeeringAccessType accessType, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet,
116-
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
134+
public AzureBgpPeering UpdateAzureBGPPeering(Guid serviceKey, PeerAddressTypeValues peerAddressType, BgpPeeringAccessType accessType,
135+
string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet, string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
117136
{
118-
var result = Client.BorderGatewayProtocolPeerings.Update(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringUpdateParameters()
137+
ExpressRouteOperationStatusResponse result = null;
138+
139+
if (peerAddressType == PeerAddressTypeValues.IPv4)
140+
{
141+
result = Client.BorderGatewayProtocolPeerings.Update(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringUpdateParameters()
119142
{
143+
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
120144
CustomerAutonomousSystemNumber = customerAsn,
121145
PeerAutonomousSystemNumber = peerAsn,
122146
PrimaryPeerSubnet = primaryPeerSubnet,
@@ -125,6 +149,22 @@ public AzureBgpPeering UpdateAzureBGPPeering(Guid serviceKey,
125149
SharedKey = sharedKey,
126150
VirtualLanId = vlanId,
127151
});
152+
}
153+
else
154+
{
155+
result = Client.BorderGatewayProtocolPeerings.Update(serviceKey.ToString(), accessType, new BorderGatewayProtocolPeeringUpdateParameters()
156+
{
157+
AdvertisedPublicPrefixesIpv6 = advertisedPublicPrefixes,
158+
CustomerAutonomousSystemNumberIpv6 = customerAsn,
159+
PeerAutonomousSystemNumber = peerAsn,
160+
PrimaryPeerSubnetIpv6 = primaryPeerSubnet,
161+
RoutingRegistryNameIpv6 = routingRegistryName,
162+
SecondaryPeerSubnetIpv6 = secondaryPeerSubnet,
163+
SharedKey = sharedKey,
164+
VirtualLanId = vlanId,
165+
});
166+
}
167+
128168
if (result.HttpStatusCode.Equals(HttpStatusCode.OK))
129169
{
130170
return GetAzureBGPPeering(serviceKey, accessType);

0 commit comments

Comments
 (0)