@@ -37,54 +37,27 @@ def cli(env, volume_id):
3737 table .add_row (['Type' , storage_type ])
3838 table .add_row (['Capacity (GB)' , get_capacity (file_volume )])
3939
40- used_space = int (file_volume ['bytesUsed' ]) \
41- if file_volume ['bytesUsed' ] else 0
42- if used_space < (1 << 10 ):
43- table .add_row (['Used Space' , "%dB" % used_space ])
44- elif used_space < (1 << 20 ):
45- table .add_row (['Used Space' , "%dKB" % (used_space / (1 << 10 ))])
46- elif used_space < (1 << 30 ):
47- table .add_row (['Used Space' , "%dMB" % (used_space / (1 << 20 ))])
48- else :
49- table .add_row (['Used Space' , "%dGB" % (used_space / (1 << 30 ))])
40+ used_space = formatting .convert_sizes (file_volume .get ('bytes_used' , 0 ), "GB" , False )
41+ table .add_row (['Used Space' , used_space ])
5042
5143 if file_volume .get ('provisionedIops' ):
52- table .add_row (['IOPs' , float ( file_volume ['provisionedIops' ]) ])
44+ table .add_row (['IOPs' , file_volume ['provisionedIops' ]])
5345
5446 if file_volume .get ('storageTierLevel' ):
55- table .add_row ([
56- 'Endurance Tier' ,
57- file_volume ['storageTierLevel' ],
58- ])
59-
60- table .add_row ([
61- 'Data Center' ,
62- file_volume ['serviceResource' ]['datacenter' ]['name' ],
63- ])
64- table .add_row ([
65- 'Target IP' ,
66- file_volume ['serviceResourceBackendIpAddress' ],
67- ])
47+ table .add_row (['Endurance Tier' , file_volume ['storageTierLevel' ]])
48+
49+ table .add_row (['Data Center' , file_volume ['serviceResource' ]['datacenter' ]['name' ]])
50+ table .add_row (['Target IP' , file_volume ['serviceResourceBackendIpAddress' ]])
6851
6952 if file_volume ['fileNetworkMountAddress' ]:
70- table .add_row ([
71- 'Mount Address' ,
72- file_volume ['fileNetworkMountAddress' ],
73- ])
53+ table .add_row (['Mount Address' , file_volume ['fileNetworkMountAddress' ]])
7454
7555 if file_volume ['snapshotCapacityGb' ]:
76- table .add_row ([
77- 'Snapshot Capacity (GB)' ,
78- file_volume ['snapshotCapacityGb' ],
79- ])
56+ table .add_row (['Snapshot Capacity (GB)' , file_volume ['snapshotCapacityGb' ]])
8057 if 'snapshotSizeBytes' in file_volume ['parentVolume' ]:
81- table .add_row ([
82- 'Snapshot Used (Bytes)' ,
83- file_volume ['parentVolume' ]['snapshotSizeBytes' ],
84- ])
58+ table .add_row (['Snapshot Used (Bytes)' , file_volume ['parentVolume' ]['snapshotSizeBytes' ]])
8559
86- table .add_row (['# of Active Transactions' , "%i"
87- % file_volume ['activeTransactionCount' ]])
60+ table .add_row (["# of Active Transactions" , file_volume ['activeTransactionCount' ]])
8861
8962 if file_volume ['activeTransactions' ]:
9063 for trans in file_volume ['activeTransactions' ]:
@@ -98,32 +71,22 @@ def cli(env, volume_id):
9871 # returns a string or object for 'replicationStatus'; it seems that
9972 # the type is string for File volumes and object for Block volumes
10073 if 'message' in file_volume ['replicationStatus' ]:
101- table .add_row (['Replication Status' , "%s"
102- % file_volume ['replicationStatus' ]['message' ]])
74+ table .add_row (['Replication Status' , file_volume ['replicationStatus' ]['message' ]])
10375 else :
104- table .add_row (['Replication Status' , "%s"
105- % file_volume ['replicationStatus' ]])
76+ table .add_row (['Replication Status' , file_volume ['replicationStatus' ]])
10677
107- replicant_list = []
78+ replicant_table = formatting .Table (['Id' , 'Username' , 'Target' , 'Location' , 'Schedule' ])
79+ replicant_table .align ['Name' ] = 'r'
80+ replicant_table .align ['Value' ] = 'l'
10881 for replicant in file_volume ['replicationPartners' ]:
109- replicant_table = formatting .Table (['Replicant ID' ,
110- replicant ['id' ]])
111- replicant_table .add_row ([
112- 'Volume Name' ,
113- utils .lookup (replicant , 'username' )])
11482 replicant_table .add_row ([
115- 'Target IP' ,
116- utils .lookup (replicant , 'serviceResourceBackendIpAddress' )])
117- replicant_table .add_row ([
118- 'Data Center' ,
119- utils .lookup (replicant ,
120- 'serviceResource' , 'datacenter' , 'name' )])
121- replicant_table .add_row ([
122- 'Schedule' ,
123- utils .lookup (replicant ,
124- 'replicationSchedule' , 'type' , 'keyname' )])
125- replicant_list .append (replicant_table )
126- table .add_row (['Replicant Volumes' , replicant_list ])
83+ replicant .get ('id' ),
84+ utils .lookup (replicant , 'username' ),
85+ utils .lookup (replicant , 'serviceResourceBackendIpAddress' ),
86+ utils .lookup (replicant , 'serviceResource' , 'datacenter' , 'name' ),
87+ utils .lookup (replicant , 'replicationSchedule' , 'type' , 'keyname' )
88+ ])
89+ table .add_row (['Replicant Volumes' , replicant_table ])
12790
12891 if file_volume .get ('originalVolumeSize' ):
12992 original_volume_info = formatting .Table (['Property' , 'Value' ])
0 commit comments