Skip to content

BGP over IPsec ServiceManagement PS cmdlets #1890

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 9 commits into from
Mar 16, 2016
Merged
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 @@ -103,8 +103,8 @@
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.6.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.4\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.5\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ public class GetLocalNetworkGatewayContext : ManagementOperationContext
public string IpAddress { get; set; }

public List<string> AddressSpace { get; set; }

public uint Asn { get; set; }

public string BgpPeeringAddress { get; set; }

public int PeerWeight { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ public class GetVirtualNetworkGatewayConnectionContext : ManagementOperationCont
public int RoutingWeight { get; set; }

public string SharedKey { get; set; }

public string EnableBgp { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,18 @@ public class NewAzureLocalNetworkGateway : NetworkCmdletBase
[Parameter(Position = 2, Mandatory = true, HelpMessage = "The virtual network gateway AddressSpace.")]
public List<string> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,27 @@ public List<string> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
56 changes: 49 additions & 7 deletions src/ServiceManagement/Network/Commands.Network/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -1123,6 +1130,7 @@ public GetVirtualNetworkGatewayConnectionContext GetVirtualNetworkGatewayConnect
GatewayConnectionType = response.GatewayConnectionType,
RoutingWeight = response.RoutingWeight,
SharedKey = response.SharedKey,
EnableBgp = response.EnableBgp.ToString(),
};
PopulateOperationContext(response.RequestId, gatewayContext);

Expand All @@ -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;
Expand All @@ -1164,6 +1180,7 @@ public IEnumerable<GetVirtualNetworkGatewayConnectionContext> ListVirtualNetwork
GatewayConnectionType = connection.GatewayConnectionType,
RoutingWeight = connection.RoutingWeight,
SharedKey = connection.SharedKey,
EnableBgp = connection.EnableBgp.ToString(),
};
});
PopulateOperationContext(response.RequestId, connections);
Expand Down Expand Up @@ -1195,6 +1212,9 @@ public IEnumerable<GetVirtualNetworkGatewayContext> 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);
Expand All @@ -1215,6 +1235,9 @@ public IEnumerable<GetLocalNetworkGatewayContext> 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);
Expand Down Expand Up @@ -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()
{
Expand All @@ -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()
{
Expand All @@ -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<string> addressSpace)
public LocalNetworkGatewayCreateResponse CreateLocalNetworkGateway(string gatewayName, string ipAddress, List<string> 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);
Expand Down Expand Up @@ -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<string> addressSpace)
public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List<string> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.0.1-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="12.6.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="7.0.4" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="7.0.5" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="6.1.0" targetFramework="net45" />
</packages>
</packages>