diff --git a/src/ServiceManagement/Network/Commands.Network/Commands.ServiceManagement.Network.csproj b/src/ServiceManagement/Network/Commands.Network/Commands.ServiceManagement.Network.csproj index daa2f2b59827..60f92c80e56b 100644 --- a/src/ServiceManagement/Network/Commands.Network/Commands.ServiceManagement.Network.csproj +++ b/src/ServiceManagement/Network/Commands.Network/Commands.ServiceManagement.Network.csproj @@ -103,8 +103,8 @@ ..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.6.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll - False - ..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.4\lib\net40\Microsoft.WindowsAzure.Management.Network.dll + ..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.5\lib\net40\Microsoft.WindowsAzure.Management.Network.dll + True False diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetLocalNetworkGatewayContext.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetLocalNetworkGatewayContext.cs index 80084128bb8d..d617678f871b 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetLocalNetworkGatewayContext.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetLocalNetworkGatewayContext.cs @@ -27,5 +27,11 @@ public class GetLocalNetworkGatewayContext : ManagementOperationContext public string IpAddress { get; set; } public List AddressSpace { get; set; } + + public uint Asn { get; set; } + + public string BgpPeeringAddress { get; set; } + + public int PeerWeight { get; set; } } } \ No newline at end of file diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayConnectionContext.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayConnectionContext.cs index ffa54c0f15bd..01a61c6d6f15 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayConnectionContext.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayConnectionContext.cs @@ -31,5 +31,7 @@ public class GetVirtualNetworkGatewayConnectionContext : ManagementOperationCont public int RoutingWeight { get; set; } public string SharedKey { get; set; } + + public string EnableBgp { get; set; } } } \ No newline at end of file diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayContext.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayContext.cs index b1502786dfac..547b7dd2dc1b 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayContext.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/Model/GetVirtualNetworkGatewayContext.cs @@ -48,5 +48,11 @@ public class GetVirtualNetworkGatewayContext : ManagementOperationContext public string SubnetId { get; set; } public string EnableBgp { get; set; } + + public uint Asn { get; set; } + + public string BgpPeeringAddress { get; set; } + + public int PeerWeight { get; set; } } } \ No newline at end of file diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureLocalNetworkGateway.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureLocalNetworkGateway.cs index bd4f3be6b7d8..25f0f5797408 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureLocalNetworkGateway.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureLocalNetworkGateway.cs @@ -30,9 +30,18 @@ public class NewAzureLocalNetworkGateway : NetworkCmdletBase [Parameter(Position = 2, Mandatory = true, HelpMessage = "The virtual network gateway AddressSpace.")] public List AddressSpace { get; set; } + [Parameter(Position = 3, Mandatory = false, HelpMessage = "On-premise BGP speaker's ASN")] + public uint Asn { get; set; } + + [Parameter(Position = 4, Mandatory = false, HelpMessage = "On-premise BGP speaker's IP/BGP identifier")] + public string BgpPeeringAddress { get; set; } + + [Parameter(Position = 5, Mandatory = false, HelpMessage = "Weight for routes learned from this BGP speaker")] + public int PeerWeight { get; set; } + public override void ExecuteCmdlet() { - WriteObject(Client.CreateLocalNetworkGateway(GatewayName, IpAddress, AddressSpace)); + WriteObject(Client.CreateLocalNetworkGateway(GatewayName, IpAddress, AddressSpace, Asn, BgpPeeringAddress, PeerWeight)); } } } diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGateway.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGateway.cs index ca709e038de0..d6ab9fba96cb 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGateway.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGateway.cs @@ -42,9 +42,15 @@ public class NewAzureVirtualNetworkGatewayCommand : NetworkCmdletBase [ValidateNotNullOrEmpty] public string VnetId { get; set; } + [Parameter(Position = 6, Mandatory = false, HelpMessage = "Virtual network gateway BGP speaker's ASN")] + public uint Asn { get; set; } + + [Parameter(Position = 7, Mandatory = false, HelpMessage = "Weight for routes learned from this BGP speaker")] + public int PeerWeight { get; set; } + public override void ExecuteCmdlet() { - WriteObject(Client.CreateVirtualNetworkGateway(VNetName, GatewayName, GatewayType, GatewaySKU, Location, VnetId)); + WriteObject(Client.CreateVirtualNetworkGateway(VNetName, GatewayName, GatewayType, GatewaySKU, Location, VnetId, Asn, PeerWeight)); } } } diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGatewayConnection.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGatewayConnection.cs index 1b0f1bde19d6..630b17b4b932 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGatewayConnection.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/NewAzureVirtualNetworkGatewayConnection.cs @@ -47,9 +47,12 @@ public class NewAzureVirtualNetworkGatewayConnectionCommand : NetworkCmdletBase [ValidateNotNullOrEmpty] public string VirtualNetworkGatewayId { get; set; } + [Parameter(Position = 6, Mandatory = false, HelpMessage = "Whether to establish a BGP session over this connection")] + public string EnableBgp { get; set; } + public override void ExecuteCmdlet() { - WriteObject(Client.CreateVirtualNetworkGatewayConnection(ConnectedEntityId, GatewayConnectionName, GatewayConnectionType, RoutingWeight, SharedKey, Guid.Parse(VirtualNetworkGatewayId))); + WriteObject(Client.CreateVirtualNetworkGatewayConnection(ConnectedEntityId, GatewayConnectionName, GatewayConnectionType, RoutingWeight, SharedKey, Guid.Parse(VirtualNetworkGatewayId), bool.Parse(EnableBgp))); } } } diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureLocalNetworkGateway.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureLocalNetworkGateway.cs index 498e70abce46..716076e92b87 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureLocalNetworkGateway.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureLocalNetworkGateway.cs @@ -37,9 +37,27 @@ public List AddressSpace get; set; } + [Parameter(Position = 2, Mandatory = false, HelpMessage = "The local network gateway BGP speaker's ASN")] + public uint Asn + { + get; set; + } + + [Parameter(Position = 3, Mandatory = false, HelpMessage = "The local network gateway BGP speaker's IP/BGP identifier")] + public string BgpPeeringAddress + { + get; set; + } + + [Parameter(Position = 4, Mandatory = false, HelpMessage = "Weight for routes learned from local network gateway's BGP speaker")] + public int PeerWeight + { + get; set; + } + public override void ExecuteCmdlet() { - WriteObject(Client.UpdateLocalNetworkGateway(GatewayId, AddressSpace)); + WriteObject(Client.UpdateLocalNetworkGateway(GatewayId, AddressSpace, Asn, BgpPeeringAddress, PeerWeight)); } } } diff --git a/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureVirtualNetworkGatewayConnection.cs b/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureVirtualNetworkGatewayConnection.cs index 8d3312681186..fcac74d48433 100644 --- a/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureVirtualNetworkGatewayConnection.cs +++ b/src/ServiceManagement/Network/Commands.Network/Gateway/UpdateAzureVirtualNetworkGatewayConnection.cs @@ -54,9 +54,16 @@ public string SharedKey set; } + [Parameter(Position = 4, Mandatory = false, HelpMessage = "Whether to establish a BGP session over this connection")] + public bool EnableBgp + { + get; + set; + } + public override void ExecuteCmdlet() { - WriteObject(Client.UpdateVirtualNetworkGatewayConnection(GatewayId, ConnectedEntityId, RoutingWeight, SharedKey)); + WriteObject(Client.UpdateVirtualNetworkGatewayConnection(GatewayId, ConnectedEntityId, RoutingWeight, SharedKey, EnableBgp)); } } } diff --git a/src/ServiceManagement/Network/Commands.Network/NetworkClient.cs b/src/ServiceManagement/Network/Commands.Network/NetworkClient.cs index aa59e8b29dba..f7bc88190d3c 100644 --- a/src/ServiceManagement/Network/Commands.Network/NetworkClient.cs +++ b/src/ServiceManagement/Network/Commands.Network/NetworkClient.cs @@ -502,7 +502,7 @@ public VirtualNetworkGatewayContext GetGateway(string vnetName) State = (ProvisioningState)Enum.Parse(typeof(ProvisioningState), response.State, true), VIPAddress = response.VipAddress, DefaultSite = (response.DefaultSite != null ? response.DefaultSite.Name : null), - GatewaySKU = response.GatewaySKU, + GatewaySKU = response.GatewaySKU, }; PopulateOperationContext(response.RequestId, gatewayContext); @@ -1097,6 +1097,13 @@ public GetVirtualNetworkGatewayContext GetVirtualNetworkGateway(string gatewayId SubnetId = response.SubnetId, EnableBgp = response.EnableBgp.ToString(), }; + + if(response.BgpSettings != null) + { + gatewayContext.Asn = response.BgpSettings.Asn; + gatewayContext.BgpPeeringAddress = response.BgpSettings.BgpPeeringAddress; + gatewayContext.PeerWeight = response.BgpSettings.PeerWeight; + } PopulateOperationContext(response.RequestId, gatewayContext); return gatewayContext; @@ -1123,6 +1130,7 @@ public GetVirtualNetworkGatewayConnectionContext GetVirtualNetworkGatewayConnect GatewayConnectionType = response.GatewayConnectionType, RoutingWeight = response.RoutingWeight, SharedKey = response.SharedKey, + EnableBgp = response.EnableBgp.ToString(), }; PopulateOperationContext(response.RequestId, gatewayContext); @@ -1145,6 +1153,14 @@ public GetLocalNetworkGatewayContext GetLocalNetworkGateway(string gatewayId) IpAddress = response.IpAddress, AddressSpace = response.AddressSpace.ToList(), }; + + if(response.BgpSettings != null) + { + gatewayContext.Asn = response.BgpSettings.Asn; + gatewayContext.BgpPeeringAddress = response.BgpSettings.BgpPeeringAddress; + gatewayContext.PeerWeight = response.BgpSettings.PeerWeight; + } + PopulateOperationContext(response.RequestId, gatewayContext); return gatewayContext; @@ -1164,6 +1180,7 @@ public IEnumerable ListVirtualNetwork GatewayConnectionType = connection.GatewayConnectionType, RoutingWeight = connection.RoutingWeight, SharedKey = connection.SharedKey, + EnableBgp = connection.EnableBgp.ToString(), }; }); PopulateOperationContext(response.RequestId, connections); @@ -1195,6 +1212,9 @@ public IEnumerable ListVirtualNetworkGateways() VnetId = virtualNetworkGateway.VnetId, SubnetId = virtualNetworkGateway.SubnetId, EnableBgp = virtualNetworkGateway.EnableBgp.ToString(), + Asn = virtualNetworkGateway.BgpSettings != null ? virtualNetworkGateway.BgpSettings.Asn : 0, + BgpPeeringAddress = virtualNetworkGateway.BgpSettings != null ? virtualNetworkGateway.BgpSettings.BgpPeeringAddress : "", + PeerWeight = virtualNetworkGateway.BgpSettings != null ? virtualNetworkGateway.BgpSettings.PeerWeight : 0 }; }); PopulateOperationContext(response.RequestId, virtualNetworkGateways); @@ -1215,6 +1235,9 @@ public IEnumerable ListLocalNetworkGateways() GatewayName = localNetworkGateway.GatewayName, IpAddress = localNetworkGateway.IpAddress, AddressSpace = localNetworkGateway.AddressSpace.ToList(), + Asn = localNetworkGateway.BgpSettings.Asn, + BgpPeeringAddress = localNetworkGateway.BgpSettings.BgpPeeringAddress, + PeerWeight = localNetworkGateway.BgpSettings.PeerWeight, }; }); PopulateOperationContext(response.RequestId, localNetworkGateways); @@ -1249,7 +1272,8 @@ public SharedKeyContext GetSharedKeyV2(string gatewayId, string connectedentityI return sharedKeyContext; } - public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnetName, string gatewayName, string gatewayType, string gatewaySKU, string location, string vnetId) + public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnetName, string gatewayName, string gatewayType, string gatewaySKU, string location, string vnetId, + uint Asn, int PeerWeight) { VirtualNetworkGatewayCreateParameters parameters = new VirtualNetworkGatewayCreateParameters() { @@ -1258,13 +1282,18 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnet GatewayType = gatewayType, Location = location, VnetId = vnetId, + BgpSettings = (Asn > 0 || PeerWeight > 0)?new BgpSettings { + Asn = Asn, + BgpPeeringAddress = "", // We don't allow changing the gateway's BgpPeeringAddress + PeerWeight = PeerWeight + }:null, }; return client.Gateways.CreateVirtualNetworkGateway(vnetName, parameters); } public GatewayGetOperationStatusResponse CreateVirtualNetworkGatewayConnection(string connectedEntityId, string gatewayConnectionName, string gatewayConnectionType, - int routingWeight, string sharedKey, Guid virtualNetworkGatewayId) + int routingWeight, string sharedKey, Guid virtualNetworkGatewayId, bool EnableBgp) { GatewayConnectionCreateParameters parameters = new GatewayConnectionCreateParameters() { @@ -1273,19 +1302,26 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGatewayConnection(s GatewayConnectionType = gatewayConnectionType, VirtualNetworkGatewayId = virtualNetworkGatewayId, RoutingWeight = routingWeight, - SharedKey = sharedKey, + SharedKey = sharedKey, + EnableBgp = EnableBgp, }; return client.Gateways.CreateGatewayConnection(parameters); } - public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List addressSpace) + public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List addressSpace, + uint Asn, string BgpPeeringAddress, int PeerWeight) { LocalNetworkGatewayCreateParameters parameters = new LocalNetworkGatewayCreateParameters() { AddressSpace = addressSpace, GatewayName = gatewayName, IpAddress = ipAddress, + BgpSettings = Asn > 0? new BgpSettings { + Asn = Asn, + BgpPeeringAddress = BgpPeeringAddress, + PeerWeight = PeerWeight, + }:null, }; return client.Gateways.CreateLocalNetworkGateway(parameters); @@ -1340,21 +1376,27 @@ public GatewayGetOperationStatusResponse ResizeVirtualNetworkGateway(string gate return client.Gateways.ResizeVirtualNetworkGateway(gatewayId, parameters); } - public GatewayGetOperationStatusResponse UpdateVirtualNetworkGatewayConnection(string gatewayId, string connectedentityId, int routingWeight, string sharedKey) + public GatewayGetOperationStatusResponse UpdateVirtualNetworkGatewayConnection(string gatewayId, string connectedentityId, int routingWeight, string sharedKey, bool EnableBgp) { UpdateGatewayConnectionParameters parameters = new UpdateGatewayConnectionParameters() { RoutingWeight = routingWeight, SharedKey = sharedKey, + EnableBgp = EnableBgp, }; return client.Gateways.UpdateGatewayConnection(gatewayId, connectedentityId, parameters); } - public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List addressSpace) + public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List addressSpace, uint Asn, string BgpPeeringAddress, int PeerWeight) { UpdateLocalNetworkGatewayParameters parameters = new UpdateLocalNetworkGatewayParameters() { AddressSpace = addressSpace, + BgpSettings = (Asn > 0 || PeerWeight > 0 || ! string.IsNullOrEmpty(BgpPeeringAddress))?new BgpSettings { + Asn = Asn, + BgpPeeringAddress = BgpPeeringAddress, + PeerWeight = PeerWeight, + }:null, }; return client.Gateways.UpdateLocalNetworkGateway(gatewayId, parameters); diff --git a/src/ServiceManagement/Network/Commands.Network/packages.config b/src/ServiceManagement/Network/Commands.Network/packages.config index 1e0e6c7c3086..eea1f5bcb96b 100644 --- a/src/ServiceManagement/Network/Commands.Network/packages.config +++ b/src/ServiceManagement/Network/Commands.Network/packages.config @@ -18,8 +18,8 @@ - + - + \ No newline at end of file