@@ -28,33 +28,35 @@ def cli(env, identifier):
2828 table .align ['name' ] = 'r'
2929 table .align ['value' ] = 'l'
3030
31- table .add_row (['id ' , image ['id' ]])
32- table .add_row (['global_identifier ' ,
31+ table .add_row (['Id ' , image ['id' ]])
32+ table .add_row (['Global Identifier ' ,
3333 image .get ('globalIdentifier' , formatting .blank ())])
34- table .add_row (['name ' , image ['name' ].strip ()])
35- table .add_row (['status ' , formatting .FormattedItem (
34+ table .add_row (['Name ' , image ['name' ].strip ()])
35+ table .add_row (['Status ' , formatting .FormattedItem (
3636 utils .lookup (image , 'status' , 'keyname' ),
3737 utils .lookup (image , 'status' , 'name' ),
3838 )])
3939
4040 table .add_row ([
41- 'active_transaction ' ,
41+ 'Active Transaction ' ,
4242 formatting .listing (_get_transaction_groups (children_images ), separator = ',' ),
4343 ])
44- table .add_row (['account' , image .get ('accountId' , formatting .blank ())])
45- table .add_row (['visibility' ,
44+ table .add_row (['Account' , image .get ('accountId' , formatting .blank ())])
45+ table .add_row (['Created' , image .get ('createDate' )])
46+ table .add_row (['Total Size' , formatting .b_to_gb (total_size )])
47+ table .add_row (['Visibility' ,
4648 image_mod .PUBLIC_TYPE if image ['publicFlag' ]
4749 else image_mod .PRIVATE_TYPE ])
48- table .add_row (['type ' ,
50+ table .add_row (['Type ' ,
4951 formatting .FormattedItem (
5052 utils .lookup (image , 'imageType' , 'keyName' ),
5153 utils .lookup (image , 'imageType' , 'name' ),
5254 )])
53- table .add_row (['flex ' , image .get ('flexImageFlag' )])
54- table .add_row (['note ' , image .get ('note' )])
55- table .add_row (['created ' , image . get ( 'createDate' )])
56- table .add_row (['total_size ' , formatting . b_to_gb ( total_size )])
57- table .add_row (['datacenters ' , _get_datacenter_table ( children_images )])
55+ table .add_row (['Flex ' , image .get ('flexImageFlag' )])
56+ table .add_row (['Note ' , image .get ('note' )])
57+ table .add_row (['Datacenters ' , _get_datacenter_table ( children_images )])
58+ table .add_row (['Virtual Disks ' , _get_virtual_disks ( children_images )])
59+ table .add_row (['Share Image ' , _get_share_image ( image )])
5860
5961 env .fout (table )
6062
@@ -64,7 +66,7 @@ def _get_datacenter_table(children_images):
6466
6567 :param children_images: A list of images.
6668 """
67- table_datacenter = formatting .Table (['DC' , 'size ' , 'transaction ' ])
69+ table_datacenter = formatting .Table (['DC' , 'Size ' , 'Transaction ' ])
6870 for child in children_images :
6971 table_datacenter .add_row ([
7072 utils .lookup (child , 'datacenter' , 'name' ),
@@ -85,3 +87,51 @@ def _get_transaction_groups(children_images):
8587 transactions .add (utils .lookup (child , 'transaction' , 'transactionGroup' , 'name' ))
8688
8789 return transactions
90+
91+
92+ def _get_virtual_disks (children_images ):
93+ """Returns datacenters as a table.
94+
95+ :param children_images: A list of images.
96+ """
97+
98+ table_virtual_disks = formatting .Table (['Device' , 'Capacity' , 'Size On Disk' ])
99+
100+ if utils .lookup (children_images [0 ], 'blockDevices' ):
101+ for block_devices in children_images [0 ]['blockDevices' ]:
102+ device_name = utils .lookup (block_devices , 'diskImage' , 'name' )
103+ software_references = utils .lookup (block_devices , 'diskImage' , 'softwareReferences' )
104+ if len (software_references ) > 0 :
105+ device_name = utils .lookup (software_references [0 ], 'softwareDescription' , 'longDescription' )
106+
107+ size_on_disk = formatting .b_to_gb (block_devices .get ('diskSpace' , 0 ))
108+ if block_devices .get ('diskSpace' , 0 ) == 0 :
109+ size_on_disk = 'N/A'
110+
111+ capacity = str (utils .lookup (block_devices , 'diskImage' , 'capacity' )) + \
112+ ' ' + utils .lookup (block_devices , 'diskImage' , 'units' )
113+
114+ table_virtual_disks .add_row ([
115+ device_name ,
116+ capacity ,
117+ size_on_disk
118+ ])
119+
120+ return table_virtual_disks
121+
122+
123+ def _get_share_image (image ):
124+ """Returns shares image as a table.
125+
126+ :param image: Detail information about image.
127+ """
128+ table_share_account = formatting .Table (['Account' , 'Shared On' ])
129+ if utils .lookup (image , 'accountReferences' ):
130+ for account in image ['accountReferences' ]:
131+ if account ['accountId' ] != image ['accountId' ]:
132+ table_share_account .add_row ([
133+ utils .lookup (account , 'accountId' ),
134+ utils .lookup (account , 'createDate' ),
135+ ])
136+
137+ return table_share_account
0 commit comments