Skip to content

Commit 34ce529

Browse files
committed
ServiceManagement BGP support
1 parent 2fe3530 commit 34ce529

9 files changed

+101
-12
lines changed

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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,18 @@ 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 = "Virtual network gateway BGP speaker's IP/BGP identifier")]
49+
public string BgpPeeringAddress { get; set; }
50+
51+
[Parameter(Position = 8, Mandatory = false, HelpMessage = "Weight for routes learned from this BGP speaker")]
52+
public int PeerWeight { get; set; }
53+
4554
public override void ExecuteCmdlet()
4655
{
47-
WriteObject(Client.CreateVirtualNetworkGateway(VNetName, GatewayName, GatewayType, GatewaySKU, Location, VnetId));
56+
WriteObject(Client.CreateVirtualNetworkGateway(VNetName, GatewayName, GatewayType, GatewaySKU, Location, VnetId, Asn, BgpPeeringAddress, PeerWeight));
4857
}
4958
}
5059
}

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 bool 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), 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: 36 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

@@ -1096,6 +1096,9 @@ public GetVirtualNetworkGatewayContext GetVirtualNetworkGateway(string gatewayId
10961096
VnetId = response.VnetId,
10971097
SubnetId = response.SubnetId,
10981098
EnableBgp = response.EnableBgp.ToString(),
1099+
Asn = response.BgpSettings.Asn,
1100+
BgpPeeringAddress = response.BgpSettings.BgpPeeringAddress,
1101+
PeerWeight = response.BgpSettings.PeerWeight,
10991102
};
11001103
PopulateOperationContext(response.RequestId, gatewayContext);
11011104

@@ -1123,6 +1126,7 @@ public GetVirtualNetworkGatewayConnectionContext GetVirtualNetworkGatewayConnect
11231126
GatewayConnectionType = response.GatewayConnectionType,
11241127
RoutingWeight = response.RoutingWeight,
11251128
SharedKey = response.SharedKey,
1129+
EnableBgp = response.EnableBgp.ToString(),
11261130
};
11271131
PopulateOperationContext(response.RequestId, gatewayContext);
11281132

@@ -1144,6 +1148,9 @@ public GetLocalNetworkGatewayContext GetLocalNetworkGateway(string gatewayId)
11441148
GatewayName = response.GatewayName,
11451149
IpAddress = response.IpAddress,
11461150
AddressSpace = response.AddressSpace.ToList(),
1151+
Asn = response.BgpSettings.Asn,
1152+
BgpPeeringAddress = response.BgpSettings.BgpPeeringAddress,
1153+
PeerWeight = response.BgpSettings.PeerWeight,
11471154
};
11481155
PopulateOperationContext(response.RequestId, gatewayContext);
11491156

@@ -1215,6 +1222,9 @@ public IEnumerable<GetLocalNetworkGatewayContext> ListLocalNetworkGateways()
12151222
GatewayName = localNetworkGateway.GatewayName,
12161223
IpAddress = localNetworkGateway.IpAddress,
12171224
AddressSpace = localNetworkGateway.AddressSpace.ToList(),
1225+
Asn = localNetworkGateway.BgpSettings.Asn,
1226+
BgpPeeringAddress = localNetworkGateway.BgpSettings.BgpPeeringAddress,
1227+
PeerWeight = localNetworkGateway.BgpSettings.PeerWeight,
12181228
};
12191229
});
12201230
PopulateOperationContext(response.RequestId, localNetworkGateways);
@@ -1249,7 +1259,8 @@ public SharedKeyContext GetSharedKeyV2(string gatewayId, string connectedentityI
12491259
return sharedKeyContext;
12501260
}
12511261

1252-
public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnetName, string gatewayName, string gatewayType, string gatewaySKU, string location, string vnetId)
1262+
public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnetName, string gatewayName, string gatewayType, string gatewaySKU, string location, string vnetId,
1263+
uint Asn, string BgpPeeringAddress, int PeerWeight)
12531264
{
12541265
VirtualNetworkGatewayCreateParameters parameters = new VirtualNetworkGatewayCreateParameters()
12551266
{
@@ -1258,13 +1269,18 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnet
12581269
GatewayType = gatewayType,
12591270
Location = location,
12601271
VnetId = vnetId,
1272+
BgpSettings = Asn > 0?new BgpSettings {
1273+
Asn = Asn,
1274+
BgpPeeringAddress = BgpPeeringAddress,
1275+
PeerWeight = PeerWeight
1276+
}:null,
12611277
};
12621278

12631279
return client.Gateways.CreateVirtualNetworkGateway(vnetName, parameters);
12641280
}
12651281

12661282
public GatewayGetOperationStatusResponse CreateVirtualNetworkGatewayConnection(string connectedEntityId, string gatewayConnectionName, string gatewayConnectionType,
1267-
int routingWeight, string sharedKey, Guid virtualNetworkGatewayId)
1283+
int routingWeight, string sharedKey, Guid virtualNetworkGatewayId, bool EnableBgp)
12681284
{
12691285
GatewayConnectionCreateParameters parameters = new GatewayConnectionCreateParameters()
12701286
{
@@ -1273,19 +1289,26 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGatewayConnection(s
12731289
GatewayConnectionType = gatewayConnectionType,
12741290
VirtualNetworkGatewayId = virtualNetworkGatewayId,
12751291
RoutingWeight = routingWeight,
1276-
SharedKey = sharedKey,
1292+
SharedKey = sharedKey,
1293+
EnableBgp = EnableBgp,
12771294
};
12781295

12791296
return client.Gateways.CreateGatewayConnection(parameters);
12801297
}
12811298

1282-
public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List<string> addressSpace)
1299+
public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List<string> addressSpace,
1300+
uint Asn, string BgpPeeringAddress, int PeerWeight)
12831301
{
12841302
LocalNetworkGatewayCreateParameters parameters = new LocalNetworkGatewayCreateParameters()
12851303
{
12861304
AddressSpace = addressSpace,
12871305
GatewayName = gatewayName,
12881306
IpAddress = ipAddress,
1307+
BgpSettings = Asn > 0? new BgpSettings {
1308+
Asn = Asn,
1309+
BgpPeeringAddress = BgpPeeringAddress,
1310+
PeerWeight = PeerWeight,
1311+
}:null,
12891312
};
12901313

12911314
return client.Gateways.CreateLocalNetworkGateway(parameters);
@@ -1340,21 +1363,27 @@ public GatewayGetOperationStatusResponse ResizeVirtualNetworkGateway(string gate
13401363
return client.Gateways.ResizeVirtualNetworkGateway(gatewayId, parameters);
13411364
}
13421365

1343-
public GatewayGetOperationStatusResponse UpdateVirtualNetworkGatewayConnection(string gatewayId, string connectedentityId, int routingWeight, string sharedKey)
1366+
public GatewayGetOperationStatusResponse UpdateVirtualNetworkGatewayConnection(string gatewayId, string connectedentityId, int routingWeight, string sharedKey, bool EnableBgp)
13441367
{
13451368
UpdateGatewayConnectionParameters parameters = new UpdateGatewayConnectionParameters()
13461369
{
13471370
RoutingWeight = routingWeight,
13481371
SharedKey = sharedKey,
1372+
EnableBgp = EnableBgp,
13491373
};
13501374
return client.Gateways.UpdateGatewayConnection(gatewayId, connectedentityId, parameters);
13511375
}
13521376

1353-
public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List<string> addressSpace)
1377+
public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List<string> addressSpace, uint Asn, string BgpPeeringAddress, int PeerWeight)
13541378
{
13551379
UpdateLocalNetworkGatewayParameters parameters = new UpdateLocalNetworkGatewayParameters()
13561380
{
13571381
AddressSpace = addressSpace,
1382+
BgpSettings = Asn > 0?new BgpSettings {
1383+
Asn = Asn,
1384+
BgpPeeringAddress = BgpPeeringAddress,
1385+
PeerWeight = PeerWeight,
1386+
}:null,
13581387
};
13591388

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

0 commit comments

Comments
 (0)