@@ -22,27 +22,33 @@ def cli(env, identifier):
2222 table .align ['value' ] = 'l'
2323 table .add_row (['Id' , bandwidths ['id' ]])
2424 table .add_row (['Name' , bandwidths ['name' ]])
25- table .add_row (['Create Date' , bandwidths [ 'createDate' ] ])
25+ table .add_row (['Create Date' , utils . clean_time ( bandwidths . get ( 'createDate' ), '%Y-%m-%d' ) ])
2626 current = "{} GB" .format (utils .lookup (bandwidths , 'billingCyclePublicBandwidthUsage' , 'amountOut' ))
27+ if current is None :
28+ current = '-'
2729 table .add_row (['Current Usage' , current ])
2830 projected = "{} GB" .format (bandwidths .get ('projectedPublicBandwidthUsage' , 0 ))
31+ if projected is None :
32+ projected = '-'
2933 table .add_row (['Projected Usage' , projected ])
3034 inbound = "{} GB" .format (bandwidths .get ('inboundPublicBandwidthUsage' , 0 ))
35+ if inbound is None :
36+ inbound = '-'
3137 table .add_row (['Inbound Usage' , inbound ])
3238 if bandwidths ['hardware' ] != []:
3339 table .add_row (['hardware' , _bw_table (bandwidths ['hardware' ])])
3440 else :
35- table .add_row (['hardware' , 'not found ' ])
41+ table .add_row (['hardware' , 'Not Found ' ])
3642
3743 if bandwidths ['virtualGuests' ] != []:
3844 table .add_row (['virtualGuests' , _virtual_table (bandwidths ['virtualGuests' ])])
3945 else :
4046 table .add_row (['virtualGuests' , 'Not Found' ])
4147
4248 if bandwidths ['bareMetalInstances' ] != []:
43- table .add_row (['Netscale ' , _bw_table (bandwidths ['bareMetalInstances' ])])
49+ table .add_row (['Netscaler ' , _bw_table (bandwidths ['bareMetalInstances' ])])
4450 else :
45- table .add_row (['Netscale ' , 'Not Found' ])
51+ table .add_row (['Netscaler ' , 'Not Found' ])
4652
4753 env .fout (table )
4854
@@ -51,9 +57,11 @@ def _bw_table(bw_data):
5157 """Generates a bandwidth useage table"""
5258 table_data = formatting .Table (['Id' , 'HostName' , "IP Address" , 'Amount' , "Current Usage" ])
5359 for bw_point in bw_data :
54- amount = "{} GB" .format (utils .lookup (bw_point , 'bandwidthAllotmentDetail' , 'allocation' , 'amountOut ' ))
60+ amount = "{} GB" .format (utils .lookup (bw_point , 'bandwidthAllotmentDetail' , 'allocation' , 'amount ' ))
5561 current = "{} GB" .format (bw_point .get ('outboundBandwidthUsage' , 0 ))
56- ip_address = bw_point ['primaryIpAddress' ]
62+ ip_address = bw_point .get ('primaryIpAddress' )
63+ if ip_address is None :
64+ ip_address = '-'
5765 table_data .add_row ([bw_point ['id' ], bw_point ['fullyQualifiedDomainName' ], ip_address , amount , current ])
5866 return [table_data ]
5967
@@ -62,8 +70,10 @@ def _virtual_table(bw_data):
6270 """Generates a virtual bandwidth usage table"""
6371 table_data = formatting .Table (['Id' , 'HostName' , "IP Address" , 'Amount' , "Current Usage" ])
6472 for bw_point in bw_data :
65- amount = "{} GB" .format (utils .lookup (bw_point , 'bandwidthAllotmentDetail' , 'allocation' , 'amountOut ' ))
73+ amount = "{} GB" .format (utils .lookup (bw_point , 'bandwidthAllotmentDetail' , 'allocation' , 'amount ' ))
6674 current = "{} GB" .format (bw_point .get ('outboundBandwidthUsage' , 0 ))
67- ip_address = bw_point ['primaryIpAddress' ]
75+ ip_address = bw_point .get ('primaryIpAddress' )
76+ if ip_address is None :
77+ ip_address = '-'
6878 table_data .add_row ([bw_point ['id' ], bw_point ['fullyQualifiedDomainName' ], ip_address , amount , current ])
6979 return [table_data ]
0 commit comments