Skip to content

Commit

Permalink
fix tox tool and fix the some problems
Browse files Browse the repository at this point in the history
  • Loading branch information
caberos authored and caberos committed Feb 14, 2022
1 parent 43b33de commit 6f85906
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions SoftLayer/CLI/account/bandwidth_pools_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,33 @@ def cli(env, identifier):
table.align['value'] = 'l'
table.add_row(['Id', bandwidths['id']])
table.add_row(['Name', bandwidths['name']])
table.add_row(['Create Date', bandwidths['createDate']])
table.add_row(['Create Date', utils.clean_time(bandwidths.get('createDate'), '%Y-%m-%d')])
current = "{} GB".format(utils.lookup(bandwidths, 'billingCyclePublicBandwidthUsage', 'amountOut'))
if current is None:
current = '-'
table.add_row(['Current Usage', current])
projected = "{} GB".format(bandwidths.get('projectedPublicBandwidthUsage', 0))
if projected is None:
projected = '-'
table.add_row(['Projected Usage', projected])
inbound = "{} GB".format(bandwidths.get('inboundPublicBandwidthUsage', 0))
if inbound is None:
inbound = '-'
table.add_row(['Inbound Usage', inbound])
if bandwidths['hardware'] != []:
table.add_row(['hardware', _bw_table(bandwidths['hardware'])])
else:
table.add_row(['hardware', 'not found'])
table.add_row(['hardware', 'Not Found'])

if bandwidths['virtualGuests'] != []:
table.add_row(['virtualGuests', _virtual_table(bandwidths['virtualGuests'])])
else:
table.add_row(['virtualGuests', 'Not Found'])

if bandwidths['bareMetalInstances'] != []:
table.add_row(['Netscale', _bw_table(bandwidths['bareMetalInstances'])])
table.add_row(['Netscaler', _bw_table(bandwidths['bareMetalInstances'])])
else:
table.add_row(['Netscale', 'Not Found'])
table.add_row(['Netscaler', 'Not Found'])

env.fout(table)

Expand All @@ -51,9 +57,11 @@ def _bw_table(bw_data):
"""Generates a bandwidth useage table"""
table_data = formatting.Table(['Id', 'HostName', "IP Address", 'Amount', "Current Usage"])
for bw_point in bw_data:
amount = "{} GB".format(utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amountOut'))
amount = "{} GB".format(utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amount'))
current = "{} GB".format(bw_point.get('outboundBandwidthUsage', 0))
ip_address = bw_point['primaryIpAddress']
ip_address = bw_point.get('primaryIpAddress')
if ip_address is None:
ip_address = '-'
table_data.add_row([bw_point['id'], bw_point['fullyQualifiedDomainName'], ip_address, amount, current])
return [table_data]

Expand All @@ -62,8 +70,10 @@ def _virtual_table(bw_data):
"""Generates a virtual bandwidth usage table"""
table_data = formatting.Table(['Id', 'HostName', "IP Address", 'Amount', "Current Usage"])
for bw_point in bw_data:
amount = "{} GB".format(utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amountOut'))
amount = "{} GB".format(utils.lookup(bw_point, 'bandwidthAllotmentDetail', 'allocation', 'amount'))
current = "{} GB".format(bw_point.get('outboundBandwidthUsage', 0))
ip_address = bw_point['primaryIpAddress']
ip_address = bw_point.get('primaryIpAddress')
if ip_address is None:
ip_address = '-'
table_data.add_row([bw_point['id'], bw_point['fullyQualifiedDomainName'], ip_address, amount, current])
return [table_data]

0 comments on commit 6f85906

Please sign in to comment.