66import SoftLayer
77from SoftLayer .CLI .command import SLCommand
88from SoftLayer .CLI import environment
9+ from SoftLayer .CLI import exceptions
910from SoftLayer .CLI import formatting
1011
1112PACKAGE_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 ))
0 commit comments