|
| 1 | +"""List all options for ordering a file storage.""" |
| 2 | +# :license: MIT, see LICENSE for more details. |
| 3 | + |
| 4 | +import click |
| 5 | + |
| 6 | +import SoftLayer |
| 7 | +from SoftLayer.CLI.command import SLCommand |
| 8 | +from SoftLayer.CLI import environment |
| 9 | +from SoftLayer.CLI import formatting |
| 10 | + |
| 11 | + |
| 12 | +PACKAGE_STORAGE = 759 |
| 13 | + |
| 14 | + |
| 15 | +@click.command(cls=SLCommand) |
| 16 | +@environment.pass_env |
| 17 | +def cli(env): |
| 18 | + """List all options for ordering a file storage""" |
| 19 | + |
| 20 | + order_manager = SoftLayer.OrderingManager(env.client) |
| 21 | + items = order_manager.get_items(PACKAGE_STORAGE) |
| 22 | + datacenters = order_manager.get_regions(PACKAGE_STORAGE) |
| 23 | + |
| 24 | + iops_table = formatting.Table(['Id', 'Description', 'KeyName'], title='IOPS') |
| 25 | + snapshot_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Snapshot') |
| 26 | + storage_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Storage') |
| 27 | + datacenter_table = formatting.Table(['Id', 'Description', 'KeyName'], title='Datacenter') |
| 28 | + |
| 29 | + for datacenter in datacenters: |
| 30 | + datacenter_table.add_row([datacenter['location']['locationId'], |
| 31 | + datacenter.get('description'), |
| 32 | + datacenter['keyname']]) |
| 33 | + |
| 34 | + for item in items: |
| 35 | + if item['itemCategory']['categoryCode'] == 'performance_storage_space': |
| 36 | + storage_table.add_row([item.get('id'), item.get('description'), |
| 37 | + item.get('keyName')]) |
| 38 | + |
| 39 | + if item['itemCategory']['categoryCode'] == 'storage_tier_level': |
| 40 | + iops_table.add_row([item.get('id'), item.get('description'), |
| 41 | + item.get('keyName')]) |
| 42 | + |
| 43 | + if item['itemCategory']['categoryCode'] == 'storage_snapshot_space': |
| 44 | + snapshot_table.add_row([item.get('id'), item.get('description'), |
| 45 | + item.get('keyName')]) |
| 46 | + |
| 47 | + env.fout(datacenter_table) |
| 48 | + env.fout(iops_table) |
| 49 | + env.fout(storage_table) |
| 50 | + env.fout(snapshot_table) |
0 commit comments