Skip to content

Commit c690793

Browse files
caberoscaberos
authored andcommitted
fix the team code review comments
1 parent 5fef788 commit c690793

File tree

3 files changed

+37
-43
lines changed

3 files changed

+37
-43
lines changed

SoftLayer/CLI/hardware/create_options.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,12 @@ def cli(env, prices, location=None):
2525
routers = account_manager.get_routers(location=location)
2626
network_manager = network.NetworkManager(env.client)
2727

28-
closing_filter = {
29-
'capabilities': {
30-
'operation': 'in',
31-
'options': [{'name': 'data', 'value': ['CLOSURE_ANNOUNCED']}]
32-
},
33-
'name': {
34-
'operation': 'orderBy',
35-
'options': [{'name': 'sort', 'value': ['DESC']}]
36-
}
37-
}
38-
39-
pods_mask = """mask[name, datacenterLongName, frontendRouterId, capabilities, datacenterId, backendRouterId,
40-
backendRouterName, frontendRouterName]"""
41-
pods = network_manager.get_pods(mask=pods_mask, filter=closing_filter)
28+
29+
pods = network_manager.get_closed_pods()
4230
tables = []
4331

4432
# Datacenters
45-
dc_table = formatting.Table(['Datacenter', 'Value', 'note'], title="Datacenters")
33+
dc_table = formatting.Table(['Datacenter', 'Value', 'Note'], title="Datacenters")
4634
dc_table.sortby = 'Value'
4735
dc_table.align = 'l'
4836
for location_info in options['locations']:
@@ -51,11 +39,10 @@ def cli(env, prices, location=None):
5139
if ((location_info['key'] in str(pod['name']))):
5240
closure.append(pod['name'])
5341

54-
if len(closure) == 0:
55-
closure = ''
56-
else:
57-
closure = 'closed soon: %s' % (str(closure))
58-
dc_table.add_row([location_info['name'], location_info['key'], str(closure)])
42+
notes = '-'
43+
if len(closure) > 0:
44+
notes = 'closed soon: %s' % (', '.join(closure))
45+
dc_table.add_row([location_info['name'], location_info['key'], notes])
5946
tables.append(dc_table)
6047

6148
tables.append(_preset_prices_table(options['sizes'], prices))

SoftLayer/CLI/virt/create_options.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,12 @@ def cli(env, vsi_type, prices, location=None):
2626
network_manager = network.NetworkManager(env.client)
2727
options = vsi.get_create_options(vsi_type, location)
2828

29-
closing_filter = {
30-
'capabilities': {
31-
'operation': 'in',
32-
'options': [{'name': 'data', 'value': ['CLOSURE_ANNOUNCED']}]
33-
},
34-
'name': {
35-
'operation': 'orderBy',
36-
'options': [{'name': 'sort', 'value': ['DESC']}]
37-
}
38-
}
39-
40-
pods_mask = """mask[name, datacenterLongName, frontendRouterId, capabilities, datacenterId, backendRouterId,
41-
backendRouterName, frontendRouterName]"""
42-
pods = network_manager.get_pods(mask=pods_mask, filter=closing_filter)
29+
pods = network_manager.get_closed_pods()
4330

4431
tables = []
4532

4633
# Datacenters
47-
dc_table = formatting.Table(['Datacenter', 'Value', 'note'], title="Datacenters")
34+
dc_table = formatting.Table(['Datacenter', 'Value', 'Note'], title="Datacenters")
4835
dc_table.sortby = 'Value'
4936
dc_table.align = 'l'
5037
for location_info in options['locations']:
@@ -53,11 +40,10 @@ def cli(env, vsi_type, prices, location=None):
5340
if ((location_info['key'] in str(pod['name']))):
5441
closure.append(pod['name'])
5542

56-
if len(closure) == 0:
57-
closure = ''
58-
else:
59-
closure = 'closed soon: %s' % (str(closure))
60-
dc_table.add_row([location_info['name'], location_info['key'], str(closure)])
43+
notes = '-'
44+
if len(closure) > 0:
45+
notes = 'closed soon: %s' % (', '.join(closure))
46+
dc_table.add_row([location_info['name'], location_info['key'], notes])
6147
tables.append(dc_table)
6248

6349
if vsi_type == 'CLOUD_SERVER':

SoftLayer/managers/network.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,16 +779,17 @@ def cancel_item(self, identifier, cancel_immediately,
779779
customer_note,
780780
id=identifier)
781781

782-
def get_pods(self, mask=None, filter=None, datacenter=None):
782+
def get_pods(self, datacenter=None):
783783
"""Calls SoftLayer_Network_Pod::getAllObjects()
784784
785785
returns list of all network pods and their routers.
786786
"""
787+
_filter = None
787788

788789
if datacenter:
789-
filter = {"datacenterName": {"operation": datacenter}}
790+
_filter = {"datacenterName": {"operation": datacenter}}
790791

791-
return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', mask=mask, filter=filter)
792+
return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', filter=_filter)
792793

793794
def get_list_datacenter(self):
794795
"""Calls SoftLayer_Location::getDatacenters()
@@ -803,3 +804,23 @@ def get_routers(self, identifier):
803804
returns all routers locations.
804805
"""
805806
return self.client.call('SoftLayer_Location_Datacenter', 'getHardwareRouters', id=identifier)
807+
808+
def get_closed_pods(self):
809+
"""Calls SoftLayer_Network_Pod::getAllObjects()
810+
811+
returns list of all closing network pods.
812+
"""
813+
closing_filter = {
814+
'capabilities': {
815+
'operation': 'in',
816+
'options': [{'name': 'data', 'value': ['CLOSURE_ANNOUNCED']}]
817+
},
818+
'name': {
819+
'operation': 'orderBy',
820+
'options': [{'name': 'sort', 'value': ['DESC']}]
821+
}
822+
}
823+
824+
mask = """mask[name, datacenterLongName, frontendRouterId, capabilities, datacenterId, backendRouterId,
825+
backendRouterName, frontendRouterName]"""
826+
return self.client.call('SoftLayer_Network_Pod', 'getAllObjects', mask=mask, filter=closing_filter)

0 commit comments

Comments
 (0)