Skip to content

Commit b4d6868

Browse files
committed
Merge pull request Azure#1599 from dihan0604/dev
Bug fix for several APIs
2 parents b09051a + c41e822 commit b4d6868

File tree

4 files changed

+60
-11
lines changed

4 files changed

+60
-11
lines changed

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/BgpPeerings/RemoveAzureBGPPeering.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class RemoveAzureBGPPeeringCommand : ExpressRouteBaseCmdlet
2727
HelpMessage = "Service Key associated with the Azure BGP Peering to be removed")]
2828
public Guid ServiceKey { get; set; }
2929

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

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/DedicatedCircuitStats/GetAzureDedicatedCircuitPeeringArpInfo.cs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,40 @@
2020

2121
namespace Microsoft.WindowsAzure.Commands.ExpressRoute
2222
{
23+
using System.IO;
24+
using System.Net;
25+
using System.Text;
26+
using System.Xml;
27+
public class CommonParser
28+
{
29+
public static string parseResult(string url, StringBuilder sb)
30+
{
31+
var contents = new System.Net.WebClient().DownloadString(url);
32+
XmlDocument xmlDoc = new XmlDocument();
33+
xmlDoc.LoadXml(contents);
34+
bool firstLine = true;
35+
StringBuilder header = new StringBuilder();
36+
StringBuilder body = new StringBuilder();
37+
foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
38+
{
39+
foreach (XmlNode nodeChild in node.ChildNodes)
40+
{
41+
if (firstLine)
42+
{
43+
header.Append(string.Format("{0,20}", nodeChild.Name));
44+
}
45+
body.Append(string.Format("{0,20}", nodeChild.InnerText));
46+
}
47+
firstLine = false;
48+
body.AppendLine();
49+
}
50+
sb.AppendLine();
51+
sb.AppendLine(header.ToString());
52+
sb.AppendLine(body.ToString());
53+
return sb.ToString();
54+
}
55+
}
56+
2357
[Cmdlet(VerbsCommon.Get, "AzureDedicatedCircuitPeeringArpInfo"), OutputType(typeof(string), typeof(IEnumerable<string>))]
2458
public class GetAzureDedicatedCircuitPeeringArpInfoCommand : ExpressRouteBaseCmdlet
2559
{
@@ -33,13 +67,18 @@ public class GetAzureDedicatedCircuitPeeringArpInfoCommand : ExpressRouteBaseCmd
3367

3468
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
3569
HelpMessage = "Device Path: Primary or Secondary")]
36-
public DevicePath BgpPeeringDevicePath { get; set; }
70+
public DevicePath Path { get; set; }
3771

3872
public override void ExecuteCmdlet()
3973
{
40-
var arpInfo = ExpressRouteClient.GetAzureDedicatedCircuitPeeringArpInfo(ServiceKey, AccessType, BgpPeeringDevicePath);
41-
Console.WriteLine(arpInfo);
42-
WriteObject(arpInfo);
74+
var arpInfo = ExpressRouteClient.GetAzureDedicatedCircuitPeeringArpInfo(ServiceKey, AccessType, Path);
75+
// parse output to a more user-friendly output
76+
StringBuilder sb = new StringBuilder();
77+
sb.AppendLine("");
78+
sb.AppendLine("ARP Info:");
79+
WriteObject(CommonParser.parseResult(arpInfo, sb));
4380
}
81+
82+
4483
}
4584
}

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/DedicatedCircuitStats/GetAzureDedicatedCircuitPeeringRouteTableInfo.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace Microsoft.WindowsAzure.Commands.ExpressRoute
2222
{
23+
using System.Text;
24+
2325
[Cmdlet(VerbsCommon.Get, "AzureDedicatedCircuitPeeringRouteTableInfo"), OutputType(typeof(AzureDedicatedCircuitPeeringRouteTableInfo), typeof(IEnumerable<AzureDedicatedCircuitPeeringRouteTableInfo>))]
2426
public class GetAzureDedicatedCircuitPeeringRouteTableInfoCommand : ExpressRouteBaseCmdlet
2527
{
@@ -33,12 +35,15 @@ public class GetAzureDedicatedCircuitPeeringRouteTableInfoCommand : ExpressRoute
3335

3436
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
3537
HelpMessage = "Device Path: Primary or Secondary")]
36-
public DevicePath BgpPeeringDevicePath { get; set; }
38+
public DevicePath Path { get; set; }
3739

3840
public override void ExecuteCmdlet()
3941
{
40-
var arpInfo = ExpressRouteClient.GetAzureDedicatedCircuitPeeringRouteTableInfo(ServiceKey, AccessType, BgpPeeringDevicePath);
41-
WriteObject(arpInfo);
42+
var routeTable = ExpressRouteClient.GetAzureDedicatedCircuitPeeringRouteTableInfo(ServiceKey, AccessType, Path);
43+
StringBuilder sb = new StringBuilder();
44+
sb.AppendLine("");
45+
sb.AppendLine("Route Table Info:");
46+
WriteObject(CommonParser.parseResult(routeTable, sb));
4247
}
4348
}
4449

src/ServiceManagement/ExpressRoute/Commands.ExpressRoute/DedicatedCircuitStats/GetAzureDedicatedCircuitPeeringRouteTableSummary.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace Microsoft.WindowsAzure.Commands.ExpressRoute
2222
{
23+
using System.Text;
24+
2325
[Cmdlet(VerbsCommon.Get, "AzureDedicatedCircuitPeeringRouteTableSummary"), OutputType(typeof(AzureDedicatedCircuitPeeringRouteTableSummary), typeof(IEnumerable<AzureDedicatedCircuitPeeringRouteTableSummary>))]
2426
public class GetAzureDedicatedCircuitPeeringRouteTableSummaryCommand : ExpressRouteBaseCmdlet
2527
{
@@ -33,12 +35,15 @@ public class GetAzureDedicatedCircuitPeeringRouteTableSummaryCommand : ExpressRo
3335

3436
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true,
3537
HelpMessage = "Device Path: Primary or Secondary")]
36-
public DevicePath BgpPeeringDevicePath { get; set; }
38+
public DevicePath Path { get; set; }
3739

3840
public override void ExecuteCmdlet()
3941
{
40-
var arpInfo = ExpressRouteClient.GetAzureDedicatedCircuitPeeringRouteTableSummary(ServiceKey, AccessType, BgpPeeringDevicePath);
41-
WriteObject(arpInfo);
42+
var routeSummary = ExpressRouteClient.GetAzureDedicatedCircuitPeeringRouteTableSummary(ServiceKey, AccessType, Path);
43+
StringBuilder sb = new StringBuilder();
44+
sb.AppendLine("");
45+
sb.AppendLine("Route Table Summary:");
46+
WriteObject(CommonParser.parseResult(routeSummary, sb));
4247
}
4348
}
4449
}

0 commit comments

Comments
 (0)