Skip to content

Commit 2e7ac4a

Browse files
#1575 fixed some style and output issues
1 parent c93fa57 commit 2e7ac4a

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

SoftLayer/CLI/account/bandwidth_pools.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@
77
from SoftLayer.managers.account import AccountManager as AccountManager
88
from SoftLayer import utils
99

10-
from pprint import pprint as pp
1110

1211
@click.command()
1312
@environment.pass_env
1413
def cli(env):
15-
"""Lists billing items with some other useful information.
14+
"""Displays bandwidth pool information
1615
17-
Similiar to https://cloud.ibm.com/billing/billing-items
16+
Similiar to https://cloud.ibm.com/classic/network/bandwidth/vdr
1817
"""
1918

2019
manager = AccountManager(env.client)
2120
items = manager.get_bandwidth_pools()
22-
# table = item_table(items)
23-
pp(items)
21+
2422
table = formatting.Table([
2523
"Pool Name",
2624
"Region",
@@ -35,9 +33,9 @@ def cli(env):
3533
name = item.get('name')
3634
region = utils.lookup(item, 'locationGroup', 'name')
3735
servers = manager.get_bandwidth_pool_counts(identifier=item.get('id'))
38-
allocation = item.get('totalBandwidthAllocated', 0)
39-
current = item.get('billingCyclePublicUsageTotal', 0)
40-
projected = item.get('projectedPublicBandwidthUsage', 0)
36+
allocation = "{} GB".format(item.get('totalBandwidthAllocated', 0))
37+
current = "{} GB".format(utils.lookup(item, 'billingCyclePublicBandwidthUsage', 'amountOut'))
38+
projected = "{} GB".format(item.get('projectedPublicBandwidthUsage', 0))
4139

42-
table.add_row([name, region, servers, allocation, current, projected,])
40+
table.add_row([name, region, servers, allocation, current, projected])
4341
env.fout(table)

SoftLayer/CLI/report/bandwidth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from SoftLayer.CLI import formatting
1010
from SoftLayer import utils
1111

12-
from pprint import pprint as pp
1312

1413
# pylint: disable=unused-argument
1514
def _validate_datetime(ctx, param, value):

SoftLayer/managers/account.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,18 +331,22 @@ def get_bandwidth_pools(self, mask=None):
331331
"""Gets all the bandwidth pools on an account"""
332332

333333
if mask is None:
334-
mask = """mask[totalBandwidthAllocated,locationGroup, id, name, billingCyclePublicUsageTotal,
335-
projectedPublicBandwidthUsage]
334+
mask = """mask[totalBandwidthAllocated,locationGroup, id, name, projectedPublicBandwidthUsage,
335+
billingCyclePublicBandwidthUsage[amountOut,amountIn]]
336336
"""
337337

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

340340
def get_bandwidth_pool_counts(self, identifier):
341-
"""Gets a count of all servers in a bandwidth pool"""
341+
"""Gets a count of all servers in a bandwidth pool
342+
343+
Getting the server counts individually is significantly faster than pulling them in
344+
with the get_bandwidth_pools api call.
345+
"""
342346
mask = "mask[id, bareMetalInstanceCount, hardwareCount, virtualGuestCount]"
343347
counts = self.client.call('SoftLayer_Network_Bandwidth_Version1_Allotment', 'getObject',
344348
id=identifier, mask=mask)
345349
total = counts.get('bareMetalInstanceCount', 0) + \
346-
counts.get('hardwareCount', 0) + \
347-
counts.get('virtualGuestCount', 0)
348-
return total
350+
counts.get('hardwareCount', 0) + \
351+
counts.get('virtualGuestCount', 0)
352+
return total

0 commit comments

Comments
 (0)