Skip to content
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

Updated command - slcli account bandwidth-pools #1943

Merged
merged 1 commit into from May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 19 additions & 6 deletions SoftLayer/CLI/account/bandwidth_pools.py
Expand Up @@ -14,20 +14,21 @@
def cli(env):
"""Displays bandwidth pool information

Similiar to https://cloud.ibm.com/classic/network/bandwidth/vdr
Similiar to https://cloud.ibm.com/classic-bandwidth/pools
"""

manager = AccountManager(env.client)
items = manager.get_bandwidth_pools()

table = formatting.Table([
"Id",
"Pool Name",
"Name",
"Region",
"Servers",
"Devices",
"Allocation",
"Current Usage",
"Projected Usage"
"Projected Usage",
"Cost"
], title="Bandwidth Pools")
table.align = 'l'
for item in items:
Expand All @@ -36,8 +37,20 @@ def cli(env):
region = utils.lookup(item, 'locationGroup', 'name')
servers = manager.get_bandwidth_pool_counts(identifier=item.get('id'))
allocation = "{} GB".format(item.get('totalBandwidthAllocated', 0))
current = "{} GB".format(utils.lookup(item, 'billingCyclePublicBandwidthUsage', 'amountOut'))

current = utils.lookup(item, 'billingCyclePublicBandwidthUsage', 'amountOut')
if current is not None:
current = "{} GB".format(current)
else:
current = "0 GB"

projected = "{} GB".format(item.get('projectedPublicBandwidthUsage', 0))

table.add_row([id_bandwidth, name, region, servers, allocation, current, projected])
cost = utils.lookup(item, 'billingItem', 'nextInvoiceTotalRecurringAmount')
if cost is not None:
cost = "${}".format(cost)
else:
cost = "$0.0"

table.add_row([id_bandwidth, name, region, servers, allocation, current, projected, cost])
env.fout(table)
3 changes: 2 additions & 1 deletion SoftLayer/managers/account.py
Expand Up @@ -358,7 +358,8 @@ def get_bandwidth_pools(self, mask=None):

if mask is None:
mask = """mask[totalBandwidthAllocated,locationGroup, id, name, projectedPublicBandwidthUsage,
billingCyclePublicBandwidthUsage[amountOut,amountIn]]
billingCyclePublicBandwidthUsage[amountOut,amountIn],
billingItem[id,nextInvoiceTotalRecurringAmount],outboundPublicBandwidthUsage,serviceProviderId,bandwidthAllotmentTypeId,activeDetailCount]
"""

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