Skip to content

Commit f27667f

Browse files
committed
Add Peering cmdlets
1 parent cfb8298 commit f27667f

File tree

5 files changed

+187
-4
lines changed

5 files changed

+187
-4
lines changed

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@
234234
<Compile Include="ExpressRouteCircuit\Authorization\NewAzureExpressRouteCircuitAuthorizationConfigCommand.cs" />
235235
<Compile Include="ExpressRouteCircuit\Authorization\RemoveAzureExpressRouteCircuitAuthorizationConfigCommand.cs" />
236236
<Compile Include="ExpressRouteCircuit\Authorization\SetAzureExpressRouteCircuitAuthorizationConfigCommand.cs" />
237+
<Compile Include="ExpressRouteCircuit\GetAzureExpressRouteCircuitArpTableCommand.cs" />
238+
<Compile Include="ExpressRouteCircuit\GetAzureExpressRouteCircuitRoutesTableCommand.cs" />
239+
<Compile Include="ExpressRouteCircuit\GetAzureExpressRouteCircuitStatsCommand.cs" />
237240
<Compile Include="ExpressRouteCircuit\GetAzureExpressRouteCircuitCommand.cs" />
238241
<Compile Include="ExpressRouteCircuit\NewAzureExpressRouteCircuitCommand.cs" />
239242
<Compile Include="ExpressRouteCircuit\Peering\AddAzureExpressRouteCircuitPeeringConfigCommand.cs" />

src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/ExpressRouteCircuitBaseCmdlet.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public PSExpressRouteCircuit GetExpressRouteCircuit(string resourceGroupName, st
5858
{
5959
var circuitGetResponse = this.ExpressRouteCircuitClient.Get(resourceGroupName, name);
6060

61-
var ExpressRouteCircuit = Mapper.Map<PSExpressRouteCircuit>(circuitGetResponse.ExpressRouteCircuit);
62-
ExpressRouteCircuit.ResourceGroupName = resourceGroupName;
61+
var expressRouteCircuit = Mapper.Map<PSExpressRouteCircuit>(circuitGetResponse.ExpressRouteCircuit);
62+
expressRouteCircuit.ResourceGroupName = resourceGroupName;
6363

64-
ExpressRouteCircuit.Tag =
64+
expressRouteCircuit.Tag =
6565
TagsConversionHelper.CreateTagHashtable(circuitGetResponse.ExpressRouteCircuit.Tags);
6666

67-
return ExpressRouteCircuit;
67+
return expressRouteCircuit;
6868
}
6969

7070
public PSExpressRouteCircuit ToPsExpressRouteCircuit(ExpressRouteCircuit circuit)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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.Management.Network;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using MNM = Microsoft.Azure.Management.Network.Models;
20+
21+
namespace Microsoft.Azure.Commands.Network
22+
{
23+
using AutoMapper;
24+
25+
[Cmdlet(VerbsCommon.Get, "AzureRmExpressRouteCircuitStArpTable"), OutputType(typeof(PSExpressRouteCircuitArpTable))]
26+
public class GetAzureExpressRouteCircuitArpTableCommand : ExpressRouteCircuitBaseCmdlet
27+
{
28+
[Alias("ResourceName")]
29+
[Parameter(
30+
Mandatory = true,
31+
ValueFromPipelineByPropertyName = true,
32+
HelpMessage = "The resource name.")]
33+
[ValidateNotNullOrEmpty]
34+
public virtual string Name { get; set; }
35+
36+
[Parameter(
37+
Mandatory = true,
38+
ValueFromPipelineByPropertyName = true,
39+
HelpMessage = "The resource group name.")]
40+
[ValidateNotNullOrEmpty]
41+
public virtual string ResourceGroupName { get; set; }
42+
43+
protected override void ProcessRecord()
44+
{
45+
base.ProcessRecord();
46+
47+
var circuitArpTableGetResponse = this.ExpressRouteCircuitClient.ListArpTable(this.ResourceGroupName, this.Name);
48+
49+
var psCircuitArpTables = new List<PSExpressRouteCircuitArpTable>();
50+
51+
foreach (var circuitArpTable in circuitArpTableGetResponse.ArpTable)
52+
{
53+
var psArpTable = Mapper.Map<PSExpressRouteCircuitArpTable>(circuitArpTable);
54+
psCircuitArpTables.Add(psArpTable);
55+
}
56+
57+
WriteObject(psCircuitArpTables, true);
58+
}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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.Management.Network;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using MNM = Microsoft.Azure.Management.Network.Models;
20+
21+
namespace Microsoft.Azure.Commands.Network
22+
{
23+
using AutoMapper;
24+
25+
[Cmdlet(VerbsCommon.Get, "AzureRmExpressRouteCircuitStRoutesTable"), OutputType(typeof(PSExpressRouteCircuitRoutesTable))]
26+
public class GetAzureExpressRouteCircuitRoutesTableCommand : ExpressRouteCircuitBaseCmdlet
27+
{
28+
[Alias("ResourceName")]
29+
[Parameter(
30+
Mandatory = true,
31+
ValueFromPipelineByPropertyName = true,
32+
HelpMessage = "The resource name.")]
33+
[ValidateNotNullOrEmpty]
34+
public virtual string Name { get; set; }
35+
36+
[Parameter(
37+
Mandatory = true,
38+
ValueFromPipelineByPropertyName = true,
39+
HelpMessage = "The resource group name.")]
40+
[ValidateNotNullOrEmpty]
41+
public virtual string ResourceGroupName { get; set; }
42+
43+
protected override void ProcessRecord()
44+
{
45+
base.ProcessRecord();
46+
47+
var circuitRoutesTableGetResponse = this.ExpressRouteCircuitClient.ListRoutesTable(this.ResourceGroupName, this.Name);
48+
49+
var psCircuitRoutesTables = new List<PSExpressRouteCircuitRoutesTable>();
50+
51+
foreach (var circuitRoutesTable in circuitRoutesTableGetResponse.RoutesTable)
52+
{
53+
var psRoutesTable = Mapper.Map<PSExpressRouteCircuitRoutesTable>(circuitRoutesTable);
54+
psCircuitRoutesTables.Add(psRoutesTable);
55+
}
56+
57+
WriteObject(psCircuitRoutesTables, true);
58+
}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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.Management.Network;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using MNM = Microsoft.Azure.Management.Network.Models;
20+
21+
namespace Microsoft.Azure.Commands.Network
22+
{
23+
using AutoMapper;
24+
25+
[Cmdlet(VerbsCommon.Get, "AzureRmExpressRouteCircuitStats"), OutputType(typeof(PSPeeringStats))]
26+
public class GetAzureExpressRouteCircuitStatsCommand : ExpressRouteCircuitBaseCmdlet
27+
{
28+
[Alias("ResourceName")]
29+
[Parameter(
30+
Mandatory = true,
31+
ValueFromPipelineByPropertyName = true,
32+
HelpMessage = "The resource name.")]
33+
[ValidateNotNullOrEmpty]
34+
public virtual string Name { get; set; }
35+
36+
[Parameter(
37+
Mandatory = true,
38+
ValueFromPipelineByPropertyName = true,
39+
HelpMessage = "The resource group name.")]
40+
[ValidateNotNullOrEmpty]
41+
public virtual string ResourceGroupName { get; set; }
42+
43+
protected override void ProcessRecord()
44+
{
45+
base.ProcessRecord();
46+
47+
var circuitStatsGetResponse = this.ExpressRouteCircuitClient.ListStats(this.ResourceGroupName, this.Name);
48+
49+
var psCircuitStats = new List<PSPeeringStats>();
50+
51+
foreach (var stats in circuitStatsGetResponse.Stats)
52+
{
53+
var psStats = Mapper.Map<PSPeeringStats>(stats);
54+
psCircuitStats.Add(psStats);
55+
}
56+
57+
WriteObject(psCircuitStats, true);
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)