@@ -37,54 +37,27 @@ def cli(env, volume_id):
37
37
table .add_row (['Type' , storage_type ])
38
38
table .add_row (['Capacity (GB)' , get_capacity (file_volume )])
39
39
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 ])
50
42
51
43
if file_volume .get ('provisionedIops' ):
52
- table .add_row (['IOPs' , float ( file_volume ['provisionedIops' ]) ])
44
+ table .add_row (['IOPs' , file_volume ['provisionedIops' ]])
53
45
54
46
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' ]])
68
51
69
52
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' ]])
74
54
75
55
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' ]])
80
57
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' ]])
85
59
86
- table .add_row (['# of Active Transactions' , "%i"
87
- % file_volume ['activeTransactionCount' ]])
60
+ table .add_row (["# of Active Transactions" , file_volume ['activeTransactionCount' ]])
88
61
89
62
if file_volume ['activeTransactions' ]:
90
63
for trans in file_volume ['activeTransactions' ]:
@@ -98,32 +71,22 @@ def cli(env, volume_id):
98
71
# returns a string or object for 'replicationStatus'; it seems that
99
72
# the type is string for File volumes and object for Block volumes
100
73
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' ]])
103
75
else :
104
- table .add_row (['Replication Status' , "%s"
105
- % file_volume ['replicationStatus' ]])
76
+ table .add_row (['Replication Status' , file_volume ['replicationStatus' ]])
106
77
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'
108
81
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' )])
114
82
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 ])
127
90
128
91
if file_volume .get ('originalVolumeSize' ):
129
92
original_volume_info = formatting .Table (['Property' , 'Value' ])
0 commit comments