Skip to content

New CrossConnection commandlets and additional parameters to BgpPeering commandlets #403

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 11 commits into from
Jun 9, 2015
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
7 changes: 3 additions & 4 deletions setup/azurepowershell.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30110.0
MinimumVisualStudioVersion = 10.0.40219.1

Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "azurepowershell", "azurepowershell.wixproj", "{36D6E303-E057-4963-A093-C7AAE0FD92B3}"
ProjectSection(ProjectDependencies) = postProject
{EA5BD11B-10B3-433D-A250-92AE76669D8D} = {EA5BD11B-10B3-433D-A250-92AE76669D8D}
Expand All @@ -15,10 +16,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{36D6E303-E057-4963-A093-C7AAE0FD92B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36D6E303-E057-4963-A093-C7AAE0FD92B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36D6E303-E057-4963-A093-C7AAE0FD92B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36D6E303-E057-4963-A093-C7AAE0FD92B3}.Release|Any CPU.Build.0 = Release|Any CPU
{36D6E303-E057-4963-A093-C7AAE0FD92B3}.Debug|Any CPU.ActiveCfg = Debug|x86
{36D6E303-E057-4963-A093-C7AAE0FD92B3}.Release|Any CPU.ActiveCfg = Release|x86
{EA5BD11B-10B3-433D-A250-92AE76669D8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA5BD11B-10B3-433D-A250-92AE76669D8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA5BD11B-10B3-433D-A250-92AE76669D8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,24 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

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

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

[Cmdlet(VerbsCommon.Get, "AzureAuthorizedDedicatedCircuit"), OutputType(typeof(AzureAuthorizedDedicatedCircuit), typeof(IEnumerable<AzureAuthorizedDedicatedCircuit>))]
public class GetAzureAuthorizedDedicatedCircuitCommand : ExpressRouteBaseCmdlet
{
[Parameter(Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key representing the Dedicated Circuit")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }
public Guid ServiceKey { get; set; }

public override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(ServiceKey))
if (ServiceKey != Guid.Empty)
{
GetByServiceKey();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
using System.ComponentModel;
using System.Management.Automation;
using Microsoft.WindowsAzure.Management.ExpressRoute.Models;
using System;

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{

[Cmdlet(VerbsCommon.Get, "AzureBGPPeering"), OutputType(typeof(AzureBgpPeering))]
public class GetAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key representing the Azure Circuit")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }
public Guid ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peering Access Type: Public or Private")]
[DefaultValue("Private")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ namespace Microsoft.WindowsAzure.Commands.ExpressRoute
public class NewAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Service Key representing Azure Circuit for which BGP peering needs to be created/modified")]
[ValidateGuid]
public Guid ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Advertised Public Prefixes")]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }
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")]
Expand All @@ -35,6 +40,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 +54,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 @@ -25,9 +25,7 @@ public class RemoveAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
HelpMessage = "Service Key associated with the Azure BGP Peering to be removed")]
[ValidateGuid]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }
public Guid ServiceKey { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Bgp Peering Access Type: Public or Private")]
[DefaultValue("Private")]
Expand All @@ -45,7 +43,7 @@ public override void ExecuteCmdlet()
Force.IsPresent,
string.Format(Resources.RemoveAzureBGPPeeringWarning, ServiceKey),
Resources.RemoveAzureBGPPeeringMessage,
ServiceKey,
ServiceKey.ToString(),
() =>
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@

namespace Microsoft.WindowsAzure.Commands.ExpressRoute
{

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

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Advertised Public Prefixes")]
[ValidateNotNullOrEmpty]
public string ServiceKey { get; set; }
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")]
Expand All @@ -36,6 +42,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 +56,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 +65,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 +93,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 All @@ -144,7 +147,6 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Model\ValidateGuid.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="ExpressRoute.psd1">
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
{
using System;

[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")]
public Guid ServiceKey { get; set; }

public override void ExecuteCmdlet()
{
if(ServiceKey != Guid.Empty)
{
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,48 @@
// ----------------------------------------------------------------------------------
//
// 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")]
public Guid 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.ToString(),
() =>
{
var crossConnection = ExpressRouteClient.NewAzureCrossConnection(ServiceKey);
WriteVerboseWithTimestamp(Resources.NewAzureCrossConnectionSucceeded);
WriteObject(crossConnection);
});

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ----------------------------------------------------------------------------------
//
// 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")]
public Guid 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);
}
}
}
}
Loading