|
| 1 | +"""Display details for a specified cloud object storage.""" |
| 2 | +# :license: MIT, see LICENSE for more details. |
| 3 | + |
| 4 | +import click |
| 5 | +import SoftLayer |
| 6 | +from SoftLayer.CLI import environment |
| 7 | +from SoftLayer.CLI import formatting |
| 8 | + |
| 9 | + |
| 10 | +@click.command(cls=SoftLayer.CLI.command.SLCommand, ) |
| 11 | +@click.argument('object_id') |
| 12 | +@environment.pass_env |
| 13 | +def cli(env, object_id): |
| 14 | + """Display details for a cloud object storage.""" |
| 15 | + |
| 16 | + block_manager = SoftLayer.BlockStorageManager(env.client) |
| 17 | + |
| 18 | + cloud = block_manager.get_volume_details(object_id) |
| 19 | + bucket = block_manager.get_buckets(object_id) |
| 20 | + |
| 21 | + table = formatting.KeyValueTable(['Name', 'Value']) |
| 22 | + table.align['Name'] = 'r' |
| 23 | + table.align['Value'] = 'l' |
| 24 | + |
| 25 | + table.add_row(['Id', cloud.get('id')]) |
| 26 | + table.add_row(['Username', cloud.get('username')]) |
| 27 | + table.add_row(['Name Service Resource', cloud['serviceResource']['name']]) |
| 28 | + table.add_row(['Type Service Resource', cloud['serviceResource']['type']['type']]) |
| 29 | + table.add_row(['Datacenter', cloud['serviceResource']['datacenter']['name']]) |
| 30 | + table.add_row(['Storage type', cloud['storageType']['keyName']]) |
| 31 | + table.add_row(['Bytes Used', formatting.b_to_gb(bucket[0]['bytesUsed'])]) |
| 32 | + table.add_row(['Bucket name', bucket[0]['name']]) |
| 33 | + |
| 34 | + env.fout(table) |
0 commit comments