Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -27,6 +27,13 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Advertised Public Prefixes")]
[ValidateNotNullOrEmpty]
public string AdvertisedPublicPrefixes { get; set; }

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

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Peer Asn")]
public UInt32 PeerAsn { get; set; }
Expand All @@ -35,6 +42,9 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string PrimaryPeerSubnet { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Routing Registry Name for Prefix Validation")]
public string RoutingRegistryName { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Secondary Peer Subnet")]
[ValidateNotNullOrEmpty]
public string SecondaryPeerSubnet { get; set; }
Expand All @@ -46,14 +56,14 @@ public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Vlan Id")]
public UInt32 VlanId { get; set; }

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

public override void ExecuteCmdlet()
{
var route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAsn, PrimaryPeerSubnet,
SecondaryPeerSubnet, VlanId, AccessType, SharedKey);
var route = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn, PeerAsn,
PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId, AccessType, SharedKey);
WriteObject(route);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{

[Cmdlet(VerbsCommon.Set, "AzureBGPPeering"), OutputType(typeof(AzureBgpPeering))]
public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
{
Expand All @@ -28,6 +29,13 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Advertised Public Prefixes")]
[ValidateNotNullOrEmpty]
public string AdvertisedPublicPrefixes;

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

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Peer Asn")]
public UInt32? PeerAsn { get; set; }
Expand All @@ -36,6 +44,9 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[ValidateNotNullOrEmpty]
public string PrimaryPeerSubnet { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Routing Registry Name for Prefix Validation")]
public string RoutingRegistryName { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Secondary Peer Subnet")]
[ValidateNotNullOrEmpty]
public string SecondaryPeerSubnet { get; set; }
Expand All @@ -47,7 +58,7 @@ public class SetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Vlan Id")]
public UInt32? VlanId { get; set; }

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

Expand All @@ -56,8 +67,8 @@ public override void ExecuteCmdlet()
try
{
var route = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, AccessType);
var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType,
PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet,
var updatedRoute = ExpressRouteClient.UpdateAzureBGPPeering(ServiceKey, AccessType, CustomerAsn,
PeerAsn.HasValue ? PeerAsn.Value : route.PeerAsn, PrimaryPeerSubnet ?? route.PrimaryPeerSubnet, RoutingRegistryName,
SecondaryPeerSubnet ?? route.SecondaryPeerSubnet, VlanId.HasValue ? VlanId.Value : route.VlanId,
SharedKey);
WriteObject(updatedRoute, false);
Expand All @@ -84,8 +95,9 @@ public override void ExecuteCmdlet()
throw new ArgumentException(Resources.SecondaryPeerSubnetRequired);
}

var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, PeerAsn.Value, PrimaryPeerSubnet,
SecondaryPeerSubnet, VlanId.Value, AccessType, SharedKey);
var newRoute = ExpressRouteClient.NewAzureBGPPeering(ServiceKey, AdvertisedPublicPrefixes, CustomerAsn,
PeerAsn.Value, PrimaryPeerSubnet, RoutingRegistryName, SecondaryPeerSubnet, VlanId.Value, AccessType,
SharedKey);
WriteObject(newRoute);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
<Compile Include="BgpPeerings\NewAzureBGPPeering.cs" />
<Compile Include="BgpPeerings\RemoveAzureBGPPeering.cs" />
<Compile Include="BgpPeerings\SetAzureBGPPeering.cs" />
<Compile Include="CrossConnections\GetAzureCrossConnection.cs" />
<Compile Include="CrossConnections\NewAzureCrossConnections.cs" />
<Compile Include="CrossConnections\SetAzureCrossConnection.cs" />
<Compile Include="DedicatedCircuitLinkAuthorizationMicrosoftIds\NewAzureDedicatedCircuitLinkAuthorizationMicrosoftIds.cs" />
<Compile Include="DedicatedCircuitLinkAuthorizationMicrosoftIds\RemoveAzureDedicatedCircuitLinkAuthorizationMicrosoftIds.cs" />
<Compile Include="DedicatedCircuitLinkAuthorizations\GetAzureDedicatedCircuitLinkAuthorization.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------


using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
[Cmdlet(VerbsCommon.Get, "AzureCrossConnection"), OutputType(typeof(AzureCrossConnection), typeof(IEnumerable<AzureCrossConnection>))]
public class GetAzureCrossConnectionCommand : ExpressRouteBaseCmdlet
{
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key representing the Dedicated Circuit")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may consider making this of type Guid

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed throughout


public override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(ServiceKey))
{
GetByServiceKey();
}
else
{
GetNoServiceKey();
}
}

private void GetByServiceKey()
{
var crossConnection = ExpressRouteClient.GetAzureCrossConnection(ServiceKey);
WriteObject(crossConnection);
}

private void GetNoServiceKey()
{
var crossConnections = ExpressRouteClient.ListAzureCrossConnections();
WriteObject(crossConnections, true);
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Management.Automation;
using Microsoft.WindowsAzure.Commands.ExpressRoute.Properties;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{
[Cmdlet(VerbsCommon.New, "AzureCrossConnection"), OutputType(typeof(AzureCrossConnection))]
public class NewAzureCrossConnectionCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Dedicated Circuit Service Key")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(HelpMessage = "Do not confirm Azure Cross Connection creation")]
public SwitchParameter Force { get; set; }

public override void ExecuteCmdlet()
{
ConfirmAction(
Force.IsPresent,
string.Format(Resources.NewAzureCrossConnectionWarning, ServiceKey),
string.Format(Resources.NewAzureCrossConnectionMessage, ServiceKey),
ServiceKey,
() =>
{
var crossConnection = ExpressRouteClient.NewAzureCrossConnection(ServiceKey);
WriteVerboseWithTimestamp(Resources.NewAzureCrossConnectionSucceeded);
WriteObject(crossConnection);
});

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Management.Automation;
using Microsoft.WindowsAzure.Commands.ExpressRoute.Properties;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{

[Cmdlet(VerbsCommon.Set, "AzureCrossConnection"), OutputType(typeof(AzureCrossConnection))]
public class SetAzureCrossConnectionCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Service Key representing Azure Circuit for which BGP peering needs to be created/modified")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }

[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Notification Operation to perform. NotifyCrossConnectionProvisioned or NotifyCrossConnectionNotProvisioned")]
[ValidateNotNullOrEmpty]
public UpdateCrossConnectionOperation Operation { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Provisioning Error Message")]
public string ProvisioningError { get; set; }

[Parameter(Mandatory = false)]
public SwitchParameter PassThru { get; set; }

public override void ExecuteCmdlet()
{
var crossConnection = ExpressRouteClient.SetAzureCrossConnection(ServiceKey,
new CrossConnectionUpdateParameters() {Operation = Operation, ProvisioningError = ProvisioningError});
if(PassThru.IsPresent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix alignment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

{
WriteObject(crossConnection);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ public AzureBgpPeering GetAzureBGPPeering(string serviceKey, BgpPeeringAccessTyp
return Client.BorderGatewayProtocolPeerings.Get(serviceKey, accessType).BgpPeering;
}

public AzureBgpPeering NewAzureBGPPeering(string serviceKey, UInt32 peerAsn, string primaryPeerSubnet,
string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null)
public AzureBgpPeering NewAzureBGPPeering(string serviceKey, string advertisedPublicPrefixes, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet,
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, BgpPeeringAccessType accessType, string sharedKey = null)
{
var result = Client.BorderGatewayProtocolPeerings.New(serviceKey, accessType, new BorderGatewayProtocolPeeringNewParameters()
{
AdvertisedPublicPrefixes = advertisedPublicPrefixes,
CustomerAutonomousSystemNumber = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
RoutingRegistryName = routingRegistryName,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId
Expand All @@ -88,13 +91,15 @@ public bool RemoveAzureBGPPeering(string serviceKey, BgpPeeringAccessType access
}

public AzureBgpPeering UpdateAzureBGPPeering(string serviceKey,
BgpPeeringAccessType accessType, UInt32 peerAsn, string primaryPeerSubnet,
string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
BgpPeeringAccessType accessType, UInt32 customerAsn, UInt32 peerAsn, string primaryPeerSubnet,
string routingRegistryName, string secondaryPeerSubnet, UInt32 vlanId, string sharedKey)
{
var result = Client.BorderGatewayProtocolPeerings.Update(serviceKey, accessType, new BorderGatewayProtocolPeeringUpdateParameters()
{
CustomerAutonomousSystemNumber = customerAsn,
PeerAutonomousSystemNumber = peerAsn,
PrimaryPeerSubnet = primaryPeerSubnet,
RoutingRegistryName = routingRegistryName,
SecondaryPeerSubnet = secondaryPeerSubnet,
SharedKey = sharedKey,
VirtualLanId = vlanId,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,13 @@
<data name="VlanIdRequired" xml:space="preserve">
<value>A value for the VLan Id has to be provided.</value>
</data>
<data name="NewAzureCrossConnectionMessage" xml:space="preserve">
<value>Provisioning Cross Connection for service key {0}</value>
</data>
<data name="NewAzureCrossConnectionSucceeded" xml:space="preserve">
<value>Successfully provisioned cross connection</value>
</data>
<data name="NewAzureCrossConnectionWarning" xml:space="preserve">
<value>Are you sure you want to provision a cross connection for service key {0}?</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="app.config" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove app.config from csproj file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

<None Include="MSSharedLibKey.snk" />
<Content Include="Resources\MyWebTemplateFolder\web.cloud.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down