1414def cli (env ):
1515 """Displays bandwidth pool information
1616
17- Similiar to https://cloud.ibm.com/classic/network/ bandwidth/vdr
17+ Similiar to https://cloud.ibm.com/classic- bandwidth/pools
1818 """
1919
2020 manager = AccountManager (env .client )
2121 items = manager .get_bandwidth_pools ()
2222
2323 table = formatting .Table ([
2424 "Id" ,
25- "Pool Name" ,
25+ "Name" ,
2626 "Region" ,
27- "Servers " ,
27+ "Devices " ,
2828 "Allocation" ,
2929 "Current Usage" ,
30- "Projected Usage"
30+ "Projected Usage" ,
31+ "Cost"
3132 ], title = "Bandwidth Pools" )
3233 table .align = 'l'
3334 for item in items :
@@ -36,8 +37,20 @@ def cli(env):
3637 region = utils .lookup (item , 'locationGroup' , 'name' )
3738 servers = manager .get_bandwidth_pool_counts (identifier = item .get ('id' ))
3839 allocation = "{} GB" .format (item .get ('totalBandwidthAllocated' , 0 ))
39- current = "{} GB" .format (utils .lookup (item , 'billingCyclePublicBandwidthUsage' , 'amountOut' ))
40+
41+ current = utils .lookup (item , 'billingCyclePublicBandwidthUsage' , 'amountOut' )
42+ if current is not None :
43+ current = "{} GB" .format (current )
44+ else :
45+ current = "0 GB"
46+
4047 projected = "{} GB" .format (item .get ('projectedPublicBandwidthUsage' , 0 ))
4148
42- table .add_row ([id_bandwidth , name , region , servers , allocation , current , projected ])
49+ cost = utils .lookup (item , 'billingItem' , 'nextInvoiceTotalRecurringAmount' )
50+ if cost is not None :
51+ cost = "${}" .format (cost )
52+ else :
53+ cost = "$0.0"
54+
55+ table .add_row ([id_bandwidth , name , region , servers , allocation , current , projected , cost ])
4356 env .fout (table )
0 commit comments