Skip to content

Commit c3bd04c

Browse files
author
Hovsep
committed
Merge pull request Azure#1890 from lamchester/chelamBgp
BGP over IPsec ServiceManagement PS cmdlets
2 parents f330472 + 6798aeb commit c3bd04c

11 files changed

+115
-16
lines changed

src/ServiceManagement/Network/Commands.Network/Commands.ServiceManagement.Network.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.6.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
104104
</Reference>
105105
<Reference Include="Microsoft.WindowsAzure.Management.Network">
106-
<SpecificVersion>False</SpecificVersion>
107-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.4\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
106+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.5\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
107+
<Private>True</Private>
108108
</Reference>
109109
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
110110
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetLocalNetworkGatewayContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ public class GetLocalNetworkGatewayContext : ManagementOperationContext
2727
public string IpAddress { get; set; }
2828

2929
public List<string> AddressSpace { get; set; }
30+
31+
public uint Asn { get; set; }
32+
33+
public string BgpPeeringAddress { get; set; }
34+
35+
public int PeerWeight { get; set; }
3036
}
3137
}

src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayConnectionContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ public class GetVirtualNetworkGatewayConnectionContext : ManagementOperationCont
3131
public int RoutingWeight { get; set; }
3232

3333
public string SharedKey { get; set; }
34+
35+
public string EnableBgp { get; set; }
3436
}
3537
}

src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,11 @@ public class GetVirtualNetworkGatewayContext : ManagementOperationContext
4848
public string SubnetId { get; set; }
4949

5050
public string EnableBgp { get; set; }
51+
52+
public uint Asn { get; set; }
53+
54+
public string BgpPeeringAddress { get; set; }
55+
56+
public int PeerWeight { get; set; }
5157
}
5258
}

src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureLocalNetworkGateway.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ public class NewAzureLocalNetworkGateway : NetworkCmdletBase
3030
[Parameter(Position = 2, Mandatory = true, HelpMessage = "The virtual network gateway AddressSpace.")]
3131
public List<string> AddressSpace { get; set; }
3232

33+
[Parameter(Position = 3, Mandatory = false, HelpMessage = "On-premise BGP speaker's ASN")]
34+
public uint Asn { get; set; }
35+
36+
[Parameter(Position = 4, Mandatory = false, HelpMessage = "On-premise BGP speaker's IP/BGP identifier")]
37+
public string BgpPeeringAddress { get; set; }
38+
39+
[Parameter(Position = 5, Mandatory = false, HelpMessage = "Weight for routes learned from this BGP speaker")]
40+
public int PeerWeight { get; set; }
41+
3342
public override void ExecuteCmdlet()
3443
{
35-
WriteObject(Client.CreateLocalNetworkGateway(GatewayName, IpAddress, AddressSpace));
44+
WriteObject(Client.CreateLocalNetworkGateway(GatewayName, IpAddress, AddressSpace, Asn, BgpPeeringAddress, PeerWeight));
3645
}
3746
}
3847
}

src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGateway.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ public class NewAzureVirtualNetworkGatewayCommand : NetworkCmdletBase
4242
[ValidateNotNullOrEmpty]
4343
public string VnetId { get; set; }
4444

45+
[Parameter(Position = 6, Mandatory = false, HelpMessage = "Virtual network gateway BGP speaker's ASN")]
46+
public uint Asn { get; set; }
47+
48+
[Parameter(Position = 7, Mandatory = false, HelpMessage = "Weight for routes learned from this BGP speaker")]
49+
public int PeerWeight { get; set; }
50+
4551
public override void ExecuteCmdlet()
4652
{
47-
WriteObject(Client.CreateVirtualNetworkGateway(VNetName, GatewayName, GatewayType, GatewaySKU, Location, VnetId));
53+
WriteObject(Client.CreateVirtualNetworkGateway(VNetName, GatewayName, GatewayType, GatewaySKU, Location, VnetId, Asn, PeerWeight));
4854
}
4955
}
5056
}

src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGatewayConnection.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ public class NewAzureVirtualNetworkGatewayConnectionCommand : NetworkCmdletBase
4747
[ValidateNotNullOrEmpty]
4848
public string VirtualNetworkGatewayId { get; set; }
4949

50+
[Parameter(Position = 6, Mandatory = false, HelpMessage = "Whether to establish a BGP session over this connection")]
51+
public string EnableBgp { get; set; }
52+
5053
public override void ExecuteCmdlet()
5154
{
52-
WriteObject(Client.CreateVirtualNetworkGatewayConnection(ConnectedEntityId, GatewayConnectionName, GatewayConnectionType, RoutingWeight, SharedKey, Guid.Parse(VirtualNetworkGatewayId)));
55+
WriteObject(Client.CreateVirtualNetworkGatewayConnection(ConnectedEntityId, GatewayConnectionName, GatewayConnectionType, RoutingWeight, SharedKey, Guid.Parse(VirtualNetworkGatewayId), bool.Parse(EnableBgp)));
5356
}
5457
}
5558
}

src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureLocalNetworkGateway.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,27 @@ public List<string> AddressSpace
3737
get; set;
3838
}
3939

40+
[Parameter(Position = 2, Mandatory = false, HelpMessage = "The local network gateway BGP speaker's ASN")]
41+
public uint Asn
42+
{
43+
get; set;
44+
}
45+
46+
[Parameter(Position = 3, Mandatory = false, HelpMessage = "The local network gateway BGP speaker's IP/BGP identifier")]
47+
public string BgpPeeringAddress
48+
{
49+
get; set;
50+
}
51+
52+
[Parameter(Position = 4, Mandatory = false, HelpMessage = "Weight for routes learned from local network gateway's BGP speaker")]
53+
public int PeerWeight
54+
{
55+
get; set;
56+
}
57+
4058
public override void ExecuteCmdlet()
4159
{
42-
WriteObject(Client.UpdateLocalNetworkGateway(GatewayId, AddressSpace));
60+
WriteObject(Client.UpdateLocalNetworkGateway(GatewayId, AddressSpace, Asn, BgpPeeringAddress, PeerWeight));
4361
}
4462
}
4563
}

src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureVirtualNetworkGatewayConnection.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,16 @@ public string SharedKey
5454
set;
5555
}
5656

57+
[Parameter(Position = 4, Mandatory = false, HelpMessage = "Whether to establish a BGP session over this connection")]
58+
public bool EnableBgp
59+
{
60+
get;
61+
set;
62+
}
63+
5764
public override void ExecuteCmdlet()
5865
{
59-
WriteObject(Client.UpdateVirtualNetworkGatewayConnection(GatewayId, ConnectedEntityId, RoutingWeight, SharedKey));
66+
WriteObject(Client.UpdateVirtualNetworkGatewayConnection(GatewayId, ConnectedEntityId, RoutingWeight, SharedKey, EnableBgp));
6067
}
6168
}
6269
}

src/ServiceManagement/Network/Commands.Network/NetworkClient.cs

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ public VirtualNetworkGatewayContext GetGateway(string vnetName)
502502
State = (ProvisioningState)Enum.Parse(typeof(ProvisioningState), response.State, true),
503503
VIPAddress = response.VipAddress,
504504
DefaultSite = (response.DefaultSite != null ? response.DefaultSite.Name : null),
505-
GatewaySKU = response.GatewaySKU,
505+
GatewaySKU = response.GatewaySKU,
506506
};
507507
PopulateOperationContext(response.RequestId, gatewayContext);
508508

@@ -1097,6 +1097,13 @@ public GetVirtualNetworkGatewayContext GetVirtualNetworkGateway(string gatewayId
10971097
SubnetId = response.SubnetId,
10981098
EnableBgp = response.EnableBgp.ToString(),
10991099
};
1100+
1101+
if(response.BgpSettings != null)
1102+
{
1103+
gatewayContext.Asn = response.BgpSettings.Asn;
1104+
gatewayContext.BgpPeeringAddress = response.BgpSettings.BgpPeeringAddress;
1105+
gatewayContext.PeerWeight = response.BgpSettings.PeerWeight;
1106+
}
11001107
PopulateOperationContext(response.RequestId, gatewayContext);
11011108

11021109
return gatewayContext;
@@ -1123,6 +1130,7 @@ public GetVirtualNetworkGatewayConnectionContext GetVirtualNetworkGatewayConnect
11231130
GatewayConnectionType = response.GatewayConnectionType,
11241131
RoutingWeight = response.RoutingWeight,
11251132
SharedKey = response.SharedKey,
1133+
EnableBgp = response.EnableBgp.ToString(),
11261134
};
11271135
PopulateOperationContext(response.RequestId, gatewayContext);
11281136

@@ -1145,6 +1153,14 @@ public GetLocalNetworkGatewayContext GetLocalNetworkGateway(string gatewayId)
11451153
IpAddress = response.IpAddress,
11461154
AddressSpace = response.AddressSpace.ToList(),
11471155
};
1156+
1157+
if(response.BgpSettings != null)
1158+
{
1159+
gatewayContext.Asn = response.BgpSettings.Asn;
1160+
gatewayContext.BgpPeeringAddress = response.BgpSettings.BgpPeeringAddress;
1161+
gatewayContext.PeerWeight = response.BgpSettings.PeerWeight;
1162+
}
1163+
11481164
PopulateOperationContext(response.RequestId, gatewayContext);
11491165

11501166
return gatewayContext;
@@ -1164,6 +1180,7 @@ public IEnumerable<GetVirtualNetworkGatewayConnectionContext> ListVirtualNetwork
11641180
GatewayConnectionType = connection.GatewayConnectionType,
11651181
RoutingWeight = connection.RoutingWeight,
11661182
SharedKey = connection.SharedKey,
1183+
EnableBgp = connection.EnableBgp.ToString(),
11671184
};
11681185
});
11691186
PopulateOperationContext(response.RequestId, connections);
@@ -1195,6 +1212,9 @@ public IEnumerable<GetVirtualNetworkGatewayContext> ListVirtualNetworkGateways()
11951212
VnetId = virtualNetworkGateway.VnetId,
11961213
SubnetId = virtualNetworkGateway.SubnetId,
11971214
EnableBgp = virtualNetworkGateway.EnableBgp.ToString(),
1215+
Asn = virtualNetworkGateway.BgpSettings != null ? virtualNetworkGateway.BgpSettings.Asn : 0,
1216+
BgpPeeringAddress = virtualNetworkGateway.BgpSettings != null ? virtualNetworkGateway.BgpSettings.BgpPeeringAddress : "",
1217+
PeerWeight = virtualNetworkGateway.BgpSettings != null ? virtualNetworkGateway.BgpSettings.PeerWeight : 0
11981218
};
11991219
});
12001220
PopulateOperationContext(response.RequestId, virtualNetworkGateways);
@@ -1215,6 +1235,9 @@ public IEnumerable<GetLocalNetworkGatewayContext> ListLocalNetworkGateways()
12151235
GatewayName = localNetworkGateway.GatewayName,
12161236
IpAddress = localNetworkGateway.IpAddress,
12171237
AddressSpace = localNetworkGateway.AddressSpace.ToList(),
1238+
Asn = localNetworkGateway.BgpSettings.Asn,
1239+
BgpPeeringAddress = localNetworkGateway.BgpSettings.BgpPeeringAddress,
1240+
PeerWeight = localNetworkGateway.BgpSettings.PeerWeight,
12181241
};
12191242
});
12201243
PopulateOperationContext(response.RequestId, localNetworkGateways);
@@ -1249,7 +1272,8 @@ public SharedKeyContext GetSharedKeyV2(string gatewayId, string connectedentityI
12491272
return sharedKeyContext;
12501273
}
12511274

1252-
public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnetName, string gatewayName, string gatewayType, string gatewaySKU, string location, string vnetId)
1275+
public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnetName, string gatewayName, string gatewayType, string gatewaySKU, string location, string vnetId,
1276+
uint Asn, int PeerWeight)
12531277
{
12541278
VirtualNetworkGatewayCreateParameters parameters = new VirtualNetworkGatewayCreateParameters()
12551279
{
@@ -1258,13 +1282,18 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnet
12581282
GatewayType = gatewayType,
12591283
Location = location,
12601284
VnetId = vnetId,
1285+
BgpSettings = (Asn > 0 || PeerWeight > 0)?new BgpSettings {
1286+
Asn = Asn,
1287+
BgpPeeringAddress = "", // We don't allow changing the gateway's BgpPeeringAddress
1288+
PeerWeight = PeerWeight
1289+
}:null,
12611290
};
12621291

12631292
return client.Gateways.CreateVirtualNetworkGateway(vnetName, parameters);
12641293
}
12651294

12661295
public GatewayGetOperationStatusResponse CreateVirtualNetworkGatewayConnection(string connectedEntityId, string gatewayConnectionName, string gatewayConnectionType,
1267-
int routingWeight, string sharedKey, Guid virtualNetworkGatewayId)
1296+
int routingWeight, string sharedKey, Guid virtualNetworkGatewayId, bool EnableBgp)
12681297
{
12691298
GatewayConnectionCreateParameters parameters = new GatewayConnectionCreateParameters()
12701299
{
@@ -1273,19 +1302,26 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGatewayConnection(s
12731302
GatewayConnectionType = gatewayConnectionType,
12741303
VirtualNetworkGatewayId = virtualNetworkGatewayId,
12751304
RoutingWeight = routingWeight,
1276-
SharedKey = sharedKey,
1305+
SharedKey = sharedKey,
1306+
EnableBgp = EnableBgp,
12771307
};
12781308

12791309
return client.Gateways.CreateGatewayConnection(parameters);
12801310
}
12811311

1282-
public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List<string> addressSpace)
1312+
public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List<string> addressSpace,
1313+
uint Asn, string BgpPeeringAddress, int PeerWeight)
12831314
{
12841315
LocalNetworkGatewayCreateParameters parameters = new LocalNetworkGatewayCreateParameters()
12851316
{
12861317
AddressSpace = addressSpace,
12871318
GatewayName = gatewayName,
12881319
IpAddress = ipAddress,
1320+
BgpSettings = Asn > 0? new BgpSettings {
1321+
Asn = Asn,
1322+
BgpPeeringAddress = BgpPeeringAddress,
1323+
PeerWeight = PeerWeight,
1324+
}:null,
12891325
};
12901326

12911327
return client.Gateways.CreateLocalNetworkGateway(parameters);
@@ -1340,21 +1376,27 @@ public GatewayGetOperationStatusResponse ResizeVirtualNetworkGateway(string gate
13401376
return client.Gateways.ResizeVirtualNetworkGateway(gatewayId, parameters);
13411377
}
13421378

1343-
public GatewayGetOperationStatusResponse UpdateVirtualNetworkGatewayConnection(string gatewayId, string connectedentityId, int routingWeight, string sharedKey)
1379+
public GatewayGetOperationStatusResponse UpdateVirtualNetworkGatewayConnection(string gatewayId, string connectedentityId, int routingWeight, string sharedKey, bool EnableBgp)
13441380
{
13451381
UpdateGatewayConnectionParameters parameters = new UpdateGatewayConnectionParameters()
13461382
{
13471383
RoutingWeight = routingWeight,
13481384
SharedKey = sharedKey,
1385+
EnableBgp = EnableBgp,
13491386
};
13501387
return client.Gateways.UpdateGatewayConnection(gatewayId, connectedentityId, parameters);
13511388
}
13521389

1353-
public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List<string> addressSpace)
1390+
public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List<string> addressSpace, uint Asn, string BgpPeeringAddress, int PeerWeight)
13541391
{
13551392
UpdateLocalNetworkGatewayParameters parameters = new UpdateLocalNetworkGatewayParameters()
13561393
{
13571394
AddressSpace = addressSpace,
1395+
BgpSettings = (Asn > 0 || PeerWeight > 0 || ! string.IsNullOrEmpty(BgpPeeringAddress))?new BgpSettings {
1396+
Asn = Asn,
1397+
BgpPeeringAddress = BgpPeeringAddress,
1398+
PeerWeight = PeerWeight,
1399+
}:null,
13581400
};
13591401

13601402
return client.Gateways.UpdateLocalNetworkGateway(gatewayId, parameters);

src/ServiceManagement/Network/Commands.Network/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.0.1-preview" targetFramework="net45" />
1919
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.Management.Compute" version="12.6.0" targetFramework="net45" />
21-
<package id="Microsoft.WindowsAzure.Management.Network" version="7.0.4" targetFramework="net45" />
21+
<package id="Microsoft.WindowsAzure.Management.Network" version="7.0.5" targetFramework="net45" />
2222
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
2323
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
2424
<package id="WindowsAzure.Storage" version="6.1.0" targetFramework="net45" />
25-
</packages>
25+
</packages>

0 commit comments

Comments
 (0)