Skip to content

Commit 2db4e3e

Browse files
Merge pull request #1943 from edsonarios/issue1937
Updated command - slcli account bandwidth-pools
2 parents 3817b53 + 770981b commit 2db4e3e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

SoftLayer/CLI/account/bandwidth_pools.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
def 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)

SoftLayer/managers/account.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ def get_bandwidth_pools(self, mask=None):
365365

366366
if mask is None:
367367
mask = """mask[totalBandwidthAllocated,locationGroup, id, name, projectedPublicBandwidthUsage,
368-
billingCyclePublicBandwidthUsage[amountOut,amountIn]]
368+
billingCyclePublicBandwidthUsage[amountOut,amountIn],
369+
billingItem[id,nextInvoiceTotalRecurringAmount],outboundPublicBandwidthUsage,serviceProviderId,bandwidthAllotmentTypeId,activeDetailCount]
369370
"""
370371

371372
return self.client.call('SoftLayer_Account', 'getBandwidthAllotments', mask=mask, iter=True)

0 commit comments

Comments
 (0)