Skip to content

#5532005 Fix stats API when access type is not given #1587

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 1 commit into from
Jan 6, 2016
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,15 @@ public override void ExecuteCmdlet()
SecondaryBytesIn = (ulong)0,
SecondaryBytesOut = (ulong)0
};
AzureBgpPeering peering= ExpressRouteClient.GetAzureBGPPeering(ServiceKey, BgpPeeringAccessType.Private);
if (peering != null)
{
stats = compute(stats, ServiceKey, BgpPeeringAccessType.Private);
}
peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, BgpPeeringAccessType.Public);
if (peering != null)
{
stats = compute(stats, ServiceKey, BgpPeeringAccessType.Public);
}
peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, BgpPeeringAccessType.Microsoft);
if (peering != null)
{
stats = compute(stats, ServiceKey, BgpPeeringAccessType.Microsoft);
}
stats = compute(stats, ServiceKey, BgpPeeringAccessType.Private);
stats = compute(stats, ServiceKey, BgpPeeringAccessType.Public);
stats = compute(stats, ServiceKey, BgpPeeringAccessType.Microsoft);

WriteObject(stats);

}
BgpPeeringAccessType type;
if (BgpPeeringAccessType.TryParse(AccessType, out type))
if (BgpPeeringAccessType.TryParse(AccessType, true, out type))
{
var stats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(ServiceKey, type);
WriteObject(stats);
Expand All @@ -72,12 +61,24 @@ public override void ExecuteCmdlet()

private AzureDedicatedCircuitStats compute(AzureDedicatedCircuitStats stats, Guid key, BgpPeeringAccessType type)
{
var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key,type);
stats.PrimaryBytesIn += tempstats.PrimaryBytesIn;
stats.PrimaryBytesOut += tempstats.PrimaryBytesOut;
stats.SecondaryBytesIn += tempstats.SecondaryBytesIn;
stats.SecondaryBytesOut += tempstats.SecondaryBytesOut;
return stats;
try
{
AzureBgpPeering peering = ExpressRouteClient.GetAzureBGPPeering(ServiceKey, type);
if (peering != null)
{
var tempstats = ExpressRouteClient.GetAzureDedicatedCircuitStatsInfo(key, type);
stats.PrimaryBytesIn += tempstats.PrimaryBytesIn;
stats.PrimaryBytesOut += tempstats.PrimaryBytesOut;
stats.SecondaryBytesIn += tempstats.SecondaryBytesIn;
stats.SecondaryBytesOut += tempstats.SecondaryBytesOut;
}
return stats;
}
catch
{
// The cirucit might not have corresponding peering
return stats;
}
}
}
}