Skip to content

Commit

Permalink
[Express Route] IPv6 Global Reach Add/Set-AzExpressRouteCircuitConnec…
Browse files Browse the repository at this point in the history
…tion cmdlet changes. (#11501)

* Updated ChangeLog.md

* Added Set-Cmdlet

* Added Set/Add AzExpressRouteConnection Cmdlets

* Updated with review comments.

* ReNamed the new parameter from PeerAddressType to AddressPrefixType.

* Added Set/Add AzExpressRouteConnection Cmdlets

* Updated with review comments.

* Fixed Ipv6CircuitConnectionParameter

* Added help files for Express Route Circuit Connection Config

* Minor fixes

* Fixed indentation in Add-AzExpressRouteCircuitConnectionConfig.cs and updated help text in documentation.

* Addressed Review comments.

* Updated the help message

* Updated the help text.

* a. Added test cases
b. Incorporated review comments.

* Added Resources.Designer.cs for Add/SetAzureExpressRouteCircuitConnectionConfigCommand

* Minor updates to ChangeLog.md

* Fixed indentation

* Fixed online help/Set-AzExpressRouteCircuitConnectionConfig .md

* Fixed test case

* Fixing online help/Set-AzExpressRouteCircuitConnectionConfig .md

* removed online version from the file
  • Loading branch information
amwate authored Apr 6, 2020
1 parent ef6da90 commit ca93419
Show file tree
Hide file tree
Showing 18 changed files with 7,844 additions and 272 deletions.
16 changes: 16 additions & 0 deletions src/Network/Network.Test/ScenarioTests/ExpressRouteCircuitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ public void TestExpressRouteCircuitConnectionCRUD()
TestRunner.RunTestScript("Test-ExpressRouteCircuitConnectionCRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
public void TestExpressRouteCircuitConnectionIPv6CRUD()
{
TestRunner.RunTestScript("Test-ExpressRouteCircuitConnectionIPv6CRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
public void TestExpressRouteCircuitConnectionIPv6PrecreatedCRUD()
{
TestRunner.RunTestScript("Test-ExpressRouteCircuitConnectionIPv6PrecreatedCRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
Expand Down
950 changes: 698 additions & 252 deletions src/Network/Network.Test/ScenarioTests/ExpressRouteCircuitTests.ps1

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Network/Network/Az.Network.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
'Remove-AzDdosProtectionPlan',
'New-AzNetworkWatcherProtocolConfiguration',
'Add-AzExpressRouteCircuitConnectionConfig',
'Set-AzExpressRouteCircuitConnectionConfig',
'Get-AzExpressRouteCircuitConnectionConfig',
'Remove-AzExpressRouteCircuitConnectionConfig',
'New-AzServiceEndpointPolicy', 'Remove-AzServiceEndpointPolicy',
Expand Down
8 changes: 8 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

## Upcoming Release

* Add Support for IPv6 address family in ExpressRouteCircuitConnectionConfig (Global Reach)
- Added Cmdlet
- Set-AzExpressRouteCircuitConnectionConfig
- allows setting of all the existing properties including the IPv6CircuitConnectionProperties
-Updated Cmdlet
- Add-AzExpressRouteCircuitConnectionConfig
- Added another optional parameter AddressPrefixType to specify the address family of address prefix

## Version 2.4.0
* Updated cmdlets to allow cross-tenant VirtualHubVnetConnections
- `New-AzVirtualHubVnetConnection`
Expand Down
6 changes: 4 additions & 2 deletions src/Network/Network/Common/NetworkResourceManagerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ private static void Initialize()
cfg.CreateMap<CNM.PSPeering, MNM.ExpressRouteCircuitPeering>();
cfg.CreateMap<CNM.PSExpressRouteCircuitAuthorization, MNM.ExpressRouteCircuitAuthorization>();
cfg.CreateMap<CNM.PSExpressRouteCircuitConnection, MNM.ExpressRouteCircuitConnection>();
cfg.CreateMap<CNM.PSExpressRouteCircuitConnectionIPv6ConnectionConfig, MNM.Ipv6CircuitConnectionConfig>();

// MNM to CNM
cfg.CreateMap<MNM.ExpressRouteCircuit, CNM.PSExpressRouteCircuit>();
Expand All @@ -781,6 +782,7 @@ private static void Initialize()
cfg.CreateMap<CNM.PSExpressRouteCircuitRoutesTable, MNM.ExpressRouteCircuitRoutesTable>();
cfg.CreateMap<CNM.PSExpressRouteCircuitRoutesTableSummary, MNM.ExpressRouteCircuitRoutesTableSummary>();
cfg.CreateMap<MNM.ExpressRouteCircuitConnection, CNM.PSExpressRouteCircuitConnection>();
cfg.CreateMap<MNM.Ipv6CircuitConnectionConfig, CNM.PSExpressRouteCircuitConnectionIPv6ConnectionConfig>();

// ExpressRouteCircuitPeering
// CNM to MNM
Expand All @@ -796,10 +798,10 @@ private static void Initialize()
// Express Route Circuit Connection
// CNM to MNM
cfg.CreateMap<CNM.PSExpressRouteCircuitConnection, MNM.ExpressRouteCircuitConnection>();

// MNM to CNM
cfg.CreateMap<MNM.ExpressRouteCircuitConnection, CNM.PSExpressRouteCircuitConnection>();

// Peer Express Route Circuit Connection
// CNM to MNM
cfg.CreateMap<CNM.PSPeerExpressRouteCircuitConnection, MNM.PeerExpressRouteCircuitConnection>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,29 @@ public override void Execute()
{
base.Execute();

var circuitconnection = new PSExpressRouteCircuitConnection();

circuitconnection.Name = this.Name;
circuitconnection.AddressPrefix = this.AddressPrefix;

var peering =
this.ExpressRouteCircuit.Peerings.SingleOrDefault(
resource =>
string.Equals(resource.Name, "AzurePrivatePeering", System.StringComparison.CurrentCultureIgnoreCase));

if (peering == null)
{
throw new ArgumentException("Private Peering needs to be configured on the Express Route Circuit");
throw new ArgumentException(Properties.Resources.ExpressRoutePrivatePeeringNotFound);
}

var circuitconnection = peering.Connections.SingleOrDefault(
resource =>
string.Equals(resource.Name, Name, System.StringComparison.CurrentCultureIgnoreCase));

if (circuitconnection != null)
{
throw new ArgumentException(string.Format(Properties.Resources.ExpressRouteCircuitConnectionAlreadyAdded, Name));
}

circuitconnection = new PSExpressRouteCircuitConnection();

circuitconnection.Name = this.Name;

circuitconnection.ExpressRouteCircuitPeering = new PSResourceId();
circuitconnection.ExpressRouteCircuitPeering.Id = peering.Id;

Expand All @@ -69,6 +77,19 @@ public override void Execute()
circuitconnection.AuthorizationKey = this.AuthorizationKey;
}

if (this.AddressPrefixType == IPv6)
{
// Create new PSExpressRouteIPv6AddressPrefix()
var expressRouteIPv6AddressPrefix = new PSExpressRouteCircuitConnectionIPv6ConnectionConfig();
expressRouteIPv6AddressPrefix.AddressPrefix = AddressPrefix;
circuitconnection.IPv6CircuitConnectionConfig = expressRouteIPv6AddressPrefix;
}
else
{
// For IPv4
circuitconnection.AddressPrefix = this.AddressPrefix;
}

peering.Connections.Add(circuitconnection);

WriteObject(this.ExpressRouteCircuit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ public class AzureExpressRouteCircuitConnectionConfigBase : NetworkBaseCmdlet
[ValidateNotNullOrEmpty]
public string AddressPrefix { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Specify address family of the configured AddressPrefix. Valid values [IPv4|IPv6]")]
[ValidateSet(
IPv4,
IPv6,
IgnoreCase = true)]
public string AddressPrefixType { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Authorization Key to peer to circuit in another subscription")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Commands.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using System;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network {
[CmdletOutputBreakingChange(typeof(PSExpressRouteCircuit), DeprecatedOutputProperties = new[] { "AllowGlobalReach" })]
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRouteCircuitConnectionConfig", DefaultParameterSetName = "SetByResource", SupportsShouldProcess = true), OutputType(typeof(PSExpressRouteCircuit))]
public class SetAzureExpressRouteCircuitConnectionConfigCommand : AzureExpressRouteCircuitConnectionConfigBase
{
[Parameter(
Position = 0,
Mandatory = true,
HelpMessage = "The name of the Circuit Connection")]
[ValidateNotNullOrEmpty]
public override string Name { get; set; }

[Parameter(
Position = 1,
Mandatory = true,
ValueFromPipeline = true,
HelpMessage = "Express Route Circuit Peering initiating connection")]
[ValidateNotNullOrEmpty]
public PSExpressRouteCircuit ExpressRouteCircuit { get; set; }

public override void Execute()
{
base.Execute();

var peering = this.ExpressRouteCircuit.Peerings.SingleOrDefault(
resource =>
string.Equals(resource.Name, "AzurePrivatePeering", System.StringComparison.CurrentCultureIgnoreCase));

if (peering == null)
{
throw new ArgumentException(Properties.Resources.ExpressRoutePrivatePeeringNotFound);
}

var circuitconnection = peering.Connections.SingleOrDefault(
resource =>
string.Equals(resource.Name, Name, StringComparison.CurrentCultureIgnoreCase));

if (null == circuitconnection)
{
throw new ArgumentException(string.Format(Properties.Resources.ExpressRouteCircuitConnectionNotFound, Name));
}

circuitconnection.Name = this.Name;

if (null != peering.Id)
{
circuitconnection.ExpressRouteCircuitPeering.Id = peering.Id;
}

if (null != this.PeerExpressRouteCircuitPeering)
{
circuitconnection.PeerExpressRouteCircuitPeering.Id = this.PeerExpressRouteCircuitPeering;
}

if (!string.IsNullOrWhiteSpace(this.AuthorizationKey))
{
circuitconnection.AuthorizationKey = this.AuthorizationKey;
}

if (this.AddressPrefix != null)
{
if (this.AddressPrefixType == IPv6)
{
if (circuitconnection.IPv6CircuitConnectionConfig != null)
{
circuitconnection.IPv6CircuitConnectionConfig.AddressPrefix = this.AddressPrefix;
}
else
{
var ipv6AddressPrefix = new PSExpressRouteCircuitConnectionIPv6ConnectionConfig();
ipv6AddressPrefix.AddressPrefix = this.AddressPrefix;
circuitconnection.IPv6CircuitConnectionConfig = ipv6AddressPrefix;
}
}
else
{
circuitconnection.AddressPrefix = this.AddressPrefix;
}
}

WriteObject(this.ExpressRouteCircuit);
} // end of Execute()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public partial class PSExpressRouteCircuitConnection : PSChildResource
[JsonProperty(Order = 1)]
public PSResourceId PeerExpressRouteCircuitPeering { get; set; }

[JsonProperty(Order = 1)]
public PSExpressRouteCircuitConnectionIPv6ConnectionConfig IPv6CircuitConnectionConfig { get; set; }

[JsonIgnore]
public string ExpressRouteCircuitPeeringText
{
Expand All @@ -59,5 +62,11 @@ public string PeerExpressRouteCircuitPeeringText
{
get { return JsonConvert.SerializeObject(PeerExpressRouteCircuitPeering, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string IPv6CircuitConnectionConfigText
{
get { return JsonConvert.SerializeObject(IPv6CircuitConnectionConfig, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// 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.
//

namespace Microsoft.Azure.Commands.Network.Models
{
using Microsoft.Azure.Management.Network.Models;

using Newtonsoft.Json;
using WindowsAzure.Commands.Common.Attributes;

public class PSExpressRouteCircuitConnectionIPv6ConnectionConfig
{
[JsonProperty(Order = 1)]
[Ps1Xml(Target = ViewControl.Table)]
public string AddressPrefix { get; set; }

[JsonProperty(Order = 1)]
[Ps1Xml(Target = ViewControl.Table)]
public string CircuitConnectionStatus { get; set; }

}
}
5 changes: 3 additions & 2 deletions src/Network/Network/Network.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PsModuleName>Network</PsModuleName>
Expand All @@ -8,7 +8,8 @@

<PropertyGroup>
<RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<ApplicationIcon />
<Win32Resource />
</PropertyGroup>

<ItemGroup>
Expand Down
26 changes: 26 additions & 0 deletions src/Network/Network/Network.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -3732,6 +3732,32 @@
<Label>FirewallPolicy</Label>
<PropertyName>FirewallPolicy</PropertyName>
</ListItem>
<ListItem>
<Label>IPv6CircuitConnectionConfig</Label>
<PropertyName>IPv6CircuitConnectionConfigText</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
<View>
<Name>Microsoft.Azure.Commands.Network.Models.PSExpressRouteCircuitConnectionIPv6Prefix</Name>
<ViewSelectedBy>
<TypeName>Microsoft.Azure.Commands.Network.Models.PSExpressRouteCircuitConnectionIPv6Prefix</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<Label>AddressPrefix</Label>
<PropertyName>AddressPrefix</PropertyName>
</ListItem>
<ListItem>
<Label>CircuitConnectionStatus</Label>
<PropertyName>CircuitConnectionStatus</PropertyName>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
Expand Down
Loading

0 comments on commit ca93419

Please sign in to comment.