Skip to content

Commit e89e151

Browse files
caberoscaberos
authored andcommitted
fix the team code review comments
1 parent 0d4bea2 commit e89e151

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

SoftLayer/CLI/block/options.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import SoftLayer
77
from SoftLayer.CLI.command import SLCommand
88
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import exceptions
910
from SoftLayer.CLI import formatting
1011

1112
PACKAGE_STORAGE = 759
@@ -24,30 +25,29 @@ def cli(env, prices, location=None):
2425
items = order_manager.get_items(PACKAGE_STORAGE)
2526
datacenters = order_manager.get_regions(PACKAGE_STORAGE, location)
2627

28+
tables = []
2729
network = SoftLayer.NetworkManager(env.client)
28-
2930
pods = network.get_closed_pods()
3031

31-
iops_table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
32-
snapshot_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
33-
storage_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Storage')
34-
tables = []
35-
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
36-
37-
for datacenter in datacenters:
38-
closure = []
39-
for pod in pods:
40-
if datacenter['location']['location']['name'] in str(pod['name']):
41-
closure.append(pod['name'])
42-
43-
notes = '-'
44-
if len(closure) > 0:
45-
notes = 'closed soon: %s' % (', '.join(closure))
46-
datacenter_table.add_row([datacenter['location']['locationId'],
47-
datacenter.get('description'),
48-
datacenter['keyname'], notes])
49-
50-
tables.append(datacenter_table)
32+
if datacenters != []:
33+
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
34+
35+
for datacenter in datacenters:
36+
closure = []
37+
for pod in pods:
38+
if datacenter['location']['location']['name'] in str(pod['name']):
39+
closure.append(pod['name'])
40+
41+
notes = '-'
42+
if len(closure) > 0:
43+
notes = 'closed soon: %s' % (', '.join(closure))
44+
datacenter_table.add_row([datacenter['location']['locationId'],
45+
datacenter.get('description'),
46+
datacenter['keyname'], notes])
47+
tables.append(datacenter_table)
48+
else:
49+
raise exceptions.CLIAbort('Location does not exit.')
50+
5151
tables.append(_block_ios_get_table(items, prices))
5252
tables.append(_block_storage_table(items, prices))
5353
tables.append(_block_snapshot_get_table(items, prices))

SoftLayer/CLI/file/options.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import SoftLayer
77
from SoftLayer.CLI.command import SLCommand
88
from SoftLayer.CLI import environment
9+
from SoftLayer.CLI import exceptions
910
from SoftLayer.CLI import formatting
1011

1112
PACKAGE_STORAGE = 759
@@ -29,25 +30,25 @@ def cli(env, prices, location=None):
2930

3031
pods = network.get_closed_pods()
3132

32-
iops_table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS')
33-
snapshot_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot')
34-
file_storage_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Storage')
35-
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
36-
37-
for datacenter in datacenters:
38-
closure = []
39-
for pod in pods:
40-
if datacenter['location']['location']['name'] in str(pod['name']):
41-
closure.append(pod['name'])
42-
43-
notes = '-'
44-
if len(closure) > 0:
45-
notes = 'closed soon: %s' % (', '.join(closure))
46-
datacenter_table.add_row([datacenter['location']['locationId'],
47-
datacenter.get('description'),
48-
datacenter['keyname'], notes])
49-
50-
tables.append(datacenter_table)
33+
if datacenters != []:
34+
datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter')
35+
36+
for datacenter in datacenters:
37+
closure = []
38+
for pod in pods:
39+
if datacenter['location']['location']['name'] in str(pod['name']):
40+
closure.append(pod['name'])
41+
42+
notes = '-'
43+
if len(closure) > 0:
44+
notes = 'closed soon: %s' % (', '.join(closure))
45+
datacenter_table.add_row([datacenter['location']['locationId'],
46+
datacenter.get('description'),
47+
datacenter['keyname'], notes])
48+
tables.append(datacenter_table)
49+
else:
50+
raise exceptions.CLIAbort('Location does not exit.')
51+
5152
tables.append(_file_ios_get_table(items, prices))
5253
tables.append(_file_storage_table(items, prices))
5354
tables.append(_file_snapshot_get_table(items, prices))

0 commit comments

Comments
 (0)