Skip to content

Commit 1ef4b32

Browse files
naveenchekurianton-evseev
authored andcommitted
Add support for ExpressRoutePort Identity and ExpressRoutePortLink MacSecConfiguration
1 parent f572d6c commit 1ef4b32

20 files changed

+2562
-4
lines changed

src/Network/Network.Test/ScenarioTests/ExpressRoutePortTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,13 @@ public void TestExpressRoutePortCRUDMinimalParameters()
3232
{
3333
TestRunner.RunTestScript(string.Format("Test-ExpressRoutePortCRUD"));
3434
}
35+
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
39+
public void TestExpressRoutePortIdentityCRUD()
40+
{
41+
TestRunner.RunTestScript("Test-ExpressRoutePortIdentityCRUD");
42+
}
3543
}
3644
}

src/Network/Network.Test/ScenarioTests/ExpressRoutePortTests.ps1

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,86 @@ function Test-ExpressRoutePortCRUD
105105
Clean-ResourceGroup $rgname
106106
}
107107
}
108+
109+
<#
110+
.SYNOPSIS
111+
Test creating new ExpressRoutePortIdentityCRUD
112+
#>
113+
function Test-ExpressRoutePortIdentityCRUD
114+
{
115+
# Setup
116+
$rgname = Get-ResourceGroupName
117+
$rglocation = Get-ProviderLocation ResourceManagement
118+
$rname = Get-ResourceName
119+
$identityName = Get-ResourceName
120+
$resourceTypeParent = "Microsoft.Network/expressRoutePorts"
121+
$location = Get-ProviderLocation $resourceTypeParent
122+
$peeringLocation = "Cheyenne-ERDirect"
123+
$encapsulation = "QinQ"
124+
$bandwidthInGbps = 100.0
125+
126+
try
127+
{
128+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation
129+
130+
# Create Managed Identity
131+
$identity = New-AzUserAssignedIdentity -Name $identityName -Location $rglocation -ResourceGroup $rgname
132+
133+
# ExpressRoutePort identity
134+
$expressRoutePortIdentity = New-AzExpressRoutePortIdentity -UserAssignedIdentity $identity.Id
135+
136+
# Create ExpressRoutePort
137+
$vExpressRoutePort = New-AzExpressRoutePort -Identity $expressRoutePortIdentity -ResourceGroupName $rgname -Name $rname -Location $location -PeeringLocation $peeringLocation -Encapsulation $encapsulation -BandwidthInGbps $bandwidthInGbps
138+
Assert-NotNull $vExpressRoutePort
139+
Assert-NotNull $(Get-AzExpressRoutePortIdentity -ExpressRoutePort $vExpressRoutePort)
140+
Assert-True { Check-CmdletReturnType "New-AzExpressRoutePort" $vExpressRoutePort }
141+
Assert-NotNull $vExpressRoutePort.Links
142+
Assert-True { $vExpressRoutePort.Links.Count -eq 2 }
143+
Assert-AreEqual $rname $vExpressRoutePort.Name
144+
145+
# Get ExpressRoutePort
146+
$vExpressRoutePort = Get-AzExpressRoutePort -ResourceGroupName $rgname -Name $rname
147+
Assert-NotNull $vExpressRoutePort
148+
Assert-True { Check-CmdletReturnType "Get-AzExpressRoutePort" $vExpressRoutePort }
149+
Assert-AreEqual $rname $vExpressRoutePort.Name
150+
151+
$vExpressRoutePort = Get-AzExpressRoutePort -ResourceGroupName "*"
152+
Assert-NotNull $vExpressRoutePort
153+
Assert-True {$vExpressRoutePort.Count -ge 0}
154+
155+
$vExpressRoutePort = Get-AzExpressRoutePort -Name "*"
156+
Assert-NotNull $vExpressRoutePort
157+
Assert-True {$vExpressRoutePort.Count -ge 0}
158+
159+
$vExpressRoutePort = Get-AzExpressRoutePort -ResourceGroupName "*" -Name "*"
160+
Assert-NotNull $vExpressRoutePort
161+
Assert-True {$vExpressRoutePort.Count -ge 0}
162+
163+
# Get ExpressRoutePort
164+
$vExpressRoutePort = Get-AzureRmExpressRoutePort -ResourceId $vExpressRoutePort.Id
165+
Assert-NotNull $vExpressRoutePort
166+
Assert-True { Check-CmdletReturnType "Get-AzureRmExpressRoutePort" $vExpressRoutePort }
167+
Assert-AreEqual $rname $vExpressRoutePort.Name
168+
169+
$vExpressRoutePorts = Get-AzureRmExpressRoutePort -ResourceGroupName $rgname
170+
Assert-NotNull $vExpressRoutePorts
171+
172+
$vExpressRoutePortsAll = Get-AzureRmExpressRoutePort
173+
Assert-NotNull $vExpressRoutePortsAll
174+
175+
# Remove Identity from ExpressRoutePort
176+
Remove-AzExpressRoutePortIdentity -ExpressRoutePort $vExpressRoutePort
177+
Assert-Null $(Get-AzExpressRoutePortIdentity -ExpressRoutePort $vExpressRoutePort)
178+
179+
# Remove ExpressRoutePort
180+
$removeExpressRoutePort = Remove-AzExpressRoutePort -ResourceGroupName $rgname -Name $rname -PassThru -Force
181+
Assert-AreEqual $true $removeExpressRoutePort
182+
}
183+
finally
184+
{
185+
# Cleanup
186+
Clean-ResourceGroup $rgname
187+
}
188+
}
189+
190+

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.ExpressRoutePortTests/TestExpressRoutePortIdentityCRUD.json

Lines changed: 1735 additions & 0 deletions
Large diffs are not rendered by default.

src/Network/Network/Az.Network.psd1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
219219
'Get-AzExpressRoutePort', 'New-AzExpressRoutePort',
220220
'Get-AzExpressRoutePortLinkConfig', 'Remove-AzExpressRoutePort',
221221
'Set-AzExpressRoutePort', 'Get-AzExpressRoutePortsLocation',
222+
'Get-AzExpressRoutePortIdentity',
223+
'New-AzExpressRoutePortIdentity',
224+
'Remove-AzExpressRoutePortIdentity',
225+
'Set-AzExpressRoutePortIdentity',
222226
'Get-AzEffectiveNetworkSecurityGroup', 'Get-AzEffectiveRouteTable',
223227
'Add-AzNetworkInterfaceIpConfig', 'Get-AzNetworkInterfaceIpConfig',
224228
'New-AzNetworkInterfaceIpConfig',
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using MNM = Microsoft.Azure.Management.Network.Models;
20+
21+
namespace Microsoft.Azure.Commands.Network
22+
{
23+
public class AzureExpressRoutePortIdentityBase : NetworkBaseCmdlet
24+
{
25+
[Parameter(
26+
Mandatory = true,
27+
ValueFromPipelineByPropertyName = true,
28+
HelpMessage = "ResourceId of the user assigned identity to be assigned to ExpressRoutePort.")]
29+
[ValidateNotNullOrEmpty]
30+
[Alias("UserAssignedIdentity")]
31+
public string UserAssignedIdentityId { get; set; }
32+
33+
public override void ExecuteCmdlet()
34+
{
35+
base.ExecuteCmdlet();
36+
}
37+
38+
public PSManagedServiceIdentity NewObject()
39+
{
40+
var identity = new PSManagedServiceIdentity
41+
{
42+
Type = MNM.ResourceIdentityType.UserAssigned,
43+
UserAssignedIdentities = new Dictionary<string, PSManagedServiceIdentityUserAssignedIdentitiesValue>
44+
{
45+
{ this.UserAssignedIdentityId, new PSManagedServiceIdentityUserAssignedIdentitiesValue() }
46+
}
47+
};
48+
49+
return identity;
50+
}
51+
}
52+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Network.Models;
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.Network
19+
{
20+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortIdentity"), OutputType(typeof(PSManagedServiceIdentity))]
21+
public class GetAzureExpressRoutePortIdentityCommand : NetworkBaseCmdlet
22+
{
23+
[Parameter(
24+
Mandatory = true,
25+
ValueFromPipeline = true,
26+
HelpMessage = "The ExpressRoute Port")]
27+
public PSExpressRoutePort ExpressRoutePort { get; set; }
28+
29+
public override void ExecuteCmdlet()
30+
{
31+
base.ExecuteCmdlet();
32+
WriteObject(this.ExpressRoutePort.Identity, true);
33+
}
34+
}
35+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using Microsoft.Azure.Commands.Network.Models;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortIdentity"), OutputType(typeof(PSManagedServiceIdentity))]
22+
public class NewAzureExpressRoutePortIdentityCommand : AzureExpressRoutePortIdentityBase
23+
{
24+
public override void ExecuteCmdlet()
25+
{
26+
base.ExecuteCmdlet();
27+
WriteObject(this.NewObject());
28+
}
29+
}
30+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Network.Models;
17+
using System.Management.Automation;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortIdentity"), OutputType(typeof(PSExpressRoutePort))]
22+
public class RemoveAzureExpressRoutePortIdentityCommand : NetworkBaseCmdlet
23+
{
24+
[Parameter(
25+
Mandatory = true,
26+
ValueFromPipeline = true,
27+
HelpMessage = "The ExpressRoutePort")]
28+
public PSExpressRoutePort ExpressRoutePort { get; set; }
29+
30+
public override void ExecuteCmdlet()
31+
{
32+
if (this.ExpressRoutePort.Identity == null)
33+
{
34+
throw new ArgumentException("ExpressRoutePort doesn't have an identity assigned to it.");
35+
}
36+
37+
base.ExecuteCmdlet();
38+
this.ExpressRoutePort.Identity = null;
39+
WriteObject(this.ExpressRoutePort);
40+
}
41+
}
42+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections.Generic;
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.Network.Models;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortIdentity"), OutputType(typeof(PSExpressRoutePort))]
22+
public class SetExpressRoutePortIdentityCommand : AzureExpressRoutePortIdentityBase
23+
{
24+
[Parameter(
25+
Mandatory = true,
26+
ValueFromPipeline = true,
27+
HelpMessage = "The ExpressRoutePort")]
28+
public PSExpressRoutePort ExpressRoutePort { get; set; }
29+
public override void ExecuteCmdlet()
30+
{
31+
base.ExecuteCmdlet();
32+
this.ExpressRoutePort.Identity = this.NewObject();
33+
WriteObject(this.ExpressRoutePort);
34+
}
35+
}
36+
}

src/Network/Network/ExpressRoutePort/NewAzureRMExpressRoutePortCommand.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public partial class NewAzureRmExpressRoutePort : NetworkBaseCmdlet
109109
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
110110
public SwitchParameter AsJob { get; set; }
111111

112+
[Parameter(
113+
Mandatory = false,
114+
HelpMessage = "User Assigned Identity for reading MacSec configuration")]
115+
public PSManagedServiceIdentity Identity { get; set; }
116+
112117
public override void Execute()
113118
{
114119
base.Execute();
@@ -129,6 +134,11 @@ public override void Execute()
129134
Links = this.Link?.ToList(),
130135
};
131136

137+
if (this.Identity != null)
138+
{
139+
vExpressRoutePort.Identity = this.Identity;
140+
}
141+
132142
var vExpressRoutePortModel = NetworkResourceManagerProfile.Mapper.Map<MNM.ExpressRoutePort>(vExpressRoutePort);
133143
vExpressRoutePortModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);
134144
var present = true;

src/Network/Network/Generated/Models/PSExpressRouteLink.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,13 @@ public partial class PSExpressRouteLink : PSChildResource
5353
[JsonProperty(Order = 1)]
5454
[Ps1Xml(Target = ViewControl.Table)]
5555
public string ProvisioningState { get; set; }
56+
[JsonProperty(Order = 1)]
57+
public PSExpressRouteLinkMacSecConfig MacSecConfig { get; set; }
58+
59+
[JsonIgnore]
60+
public string MacSecConfigText
61+
{
62+
get { return JsonConvert.SerializeObject(MacSecConfig, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
63+
}
5664
}
5765
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// <auto-generated>
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
//
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
//
22+
// For documentation on code generator please visit
23+
// https://aka.ms/nrp-code-generation
24+
// Please contact [email protected] if you need to make changes to this file.
25+
// </auto-generated>
26+
27+
using Microsoft.WindowsAzure.Commands.Common.Attributes;
28+
using Newtonsoft.Json;
29+
30+
namespace Microsoft.Azure.Commands.Network.Models
31+
{
32+
public partial class PSExpressRouteLinkMacSecConfig
33+
{
34+
[JsonProperty(Order = 1)]
35+
[Ps1Xml(Target = ViewControl.Table)]
36+
public string CknSecretIdentifier { get; set; }
37+
[JsonProperty(Order = 1)]
38+
[Ps1Xml(Target = ViewControl.Table)]
39+
public string CakSecretIdentifier { get; set; }
40+
[JsonProperty(Order = 1)]
41+
[Ps1Xml(Target = ViewControl.Table)]
42+
public string Cipher { get; set; }
43+
}
44+
}

0 commit comments

Comments
 (0)