1212@click .argument ('identifier' )
1313@environment .pass_env
1414def cli (env , identifier ):
15- """Get bandwidth about a VLAN ."""
15+ """Get bandwidth pool details ."""
1616
1717 manager = AccountManager (env .client )
1818 bandwidths = manager .getBandwidthDetail (identifier )
@@ -23,9 +23,12 @@ def cli(env, identifier):
2323 table .add_row (['Id' , bandwidths ['id' ]])
2424 table .add_row (['Name' , bandwidths ['name' ]])
2525 table .add_row (['Create Date' , bandwidths ['createDate' ]])
26- table .add_row (['Current Usage' , bandwidths ['billingCyclePublicBandwidthUsage' ]['amountOut' ]])
27- table .add_row (['Projected Usage' , bandwidths ['projectedPublicBandwidthUsage' ]])
28- table .add_row (['Inbound Usage' , bandwidths ['inboundPublicBandwidthUsage' ]])
26+ current = "{} GB" .format (bandwidths ['billingCyclePublicBandwidthUsage' ]['amountOut' ], 0 )
27+ table .add_row (['Current Usage' , current ])
28+ projected = "{} GB" .format (bandwidths .get ('projectedPublicBandwidthUsage' , 0 ))
29+ table .add_row (['Projected Usage' , projected ])
30+ inbound = "{} GB" .format (bandwidths .get ('inboundPublicBandwidthUsage' , 0 ))
31+ table .add_row (['Inbound Usage' , inbound ])
2932 if bandwidths ['hardware' ] != []:
3033 table .add_row (['hardware' , _bw_table (bandwidths ['hardware' ])])
3134 else :
@@ -48,8 +51,8 @@ def _bw_table(bw_data):
4851 """Generates a bandwidth useage table"""
4952 table_data = formatting .Table (['Id' , 'HostName' , "IP Address" , 'Amount' , "Current Usage" ])
5053 for bw_point in bw_data :
51- amount = bw_point [ 'bandwidthAllotmentDetail' ][ 'allocation' ][ 'amount' ]
52- current = utils .lookup (bw_point , 'outboundBandwidthUsage' )
54+ amount = "{} GB" . format ( utils . lookup ( bw_point , 'bandwidthAllotmentDetail' , 'allocation' , 'amountOut' ), 0 )
55+ current = "{} GB" . format ( utils .lookup (bw_point , 'outboundBandwidthUsage' ), 0 )
5356 ip_address = bw_point ['primaryIpAddress' ]
5457 table_data .add_row ([bw_point ['id' ], bw_point ['fullyQualifiedDomainName' ], ip_address , amount , current ])
5558 return [table_data ]
@@ -59,8 +62,8 @@ def _virtual_table(bw_data):
5962 """Generates a virtual bandwidth usage table"""
6063 table_data = formatting .Table (['Id' , 'HostName' , "IP Address" , 'Amount' , "Current Usage" ])
6164 for bw_point in bw_data :
62- amount = bw_point [ 'bandwidthAllotmentDetail' ][ 'allocation' ][ 'amount' ]
63- current = utils .lookup (bw_point , 'outboundPublicBandwidthUsage' )
65+ amount = "{} GB" . format ( utils . lookup ( bw_point , 'bandwidthAllotmentDetail' , 'allocation' , 'amountOut' ), 0 )
66+ current = "{} GB" . format ( utils .lookup (bw_point , 'outboundBandwidthUsage' ), 0 )
6467 ip_address = bw_point ['primaryIpAddress' ]
6568 table_data .add_row ([bw_point ['id' ], bw_point ['fullyQualifiedDomainName' ], ip_address , amount , current ])
6669 return [table_data ]
0 commit comments