Skip to content

Commit 036181d

Browse files
Merge pull request #1321 from ATGE/issues/1318
#1318 Add disk number to `slcli vs detail`
2 parents 6f125e8 + 2c66f4c commit 036181d

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

SoftLayer/CLI/virt/detail.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from SoftLayer.CLI import environment
1010
from SoftLayer.CLI import formatting
1111
from SoftLayer.CLI import helpers
12-
from SoftLayer.CLI.virt.storage import get_local_type
12+
from SoftLayer.CLI.virt.storage import get_local_storage_table
1313
from SoftLayer import utils
1414

1515
LOGGER = logging.getLogger(__name__)
@@ -35,11 +35,7 @@ def cli(env, identifier, passwords=False, price=False):
3535
result = utils.NestedDict(result)
3636
local_disks = vsi.get_local_disks(vs_id)
3737

38-
table_local_disks = formatting.Table(['Type', 'Name', 'Capacity'])
39-
for disks in local_disks:
40-
if 'diskImage' in disks:
41-
table_local_disks.add_row([get_local_type(disks), disks['mountType'],
42-
str(disks['diskImage']['capacity']) + " " + str(disks['diskImage']['units'])])
38+
table_local_disks = get_local_storage_table(local_disks)
4339

4440
table.add_row(['id', result['id']])
4541
table.add_row(['guid', result['globalIdentifier']])
@@ -173,7 +169,7 @@ def _get_owner_row(result):
173169
owner = utils.lookup(result, 'billingItem', 'orderItem', 'order', 'userRecord', 'username')
174170
else:
175171
owner = formatting.blank()
176-
return(['owner', owner])
172+
return (['owner', owner])
177173

178174

179175
def _get_vlan_table(result):

SoftLayer/CLI/virt/storage.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,8 @@ def cli(env, identifier):
4848
nas['allowedVirtualGuests'][0]['datacenter']['longName'],
4949
nas.get('notes', None)])
5050

51-
table_local_disks = formatting.Table(['Type', 'Name', 'Capacity'], title="Other storage details")
52-
for disks in local_disks:
53-
if 'diskImage' in disks:
54-
table_local_disks.add_row([get_local_type(disks), disks['mountType'],
55-
str(disks['diskImage']['capacity']) + " " + str(disks['diskImage']['units'])])
51+
table_local_disks = get_local_storage_table(local_disks)
52+
table_local_disks.title = "Other storage details"
5653

5754
env.fout(table_credentials)
5855
env.fout(table_iscsi)
@@ -64,10 +61,28 @@ def cli(env, identifier):
6461
def get_local_type(disks):
6562
"""Returns the virtual server local disk type.
6663
67-
:param disks: virtual serve local disks.
64+
:param disks: virtual server local disks.
6865
"""
6966
disk_type = 'System'
7067
if 'SWAP' in disks.get('diskImage', {}).get('description', []):
7168
disk_type = 'Swap'
7269

7370
return disk_type
71+
72+
73+
def get_local_storage_table(local_disks):
74+
"""Returns a formatting local disk table
75+
76+
:param local_disks: virtual server local disks.
77+
"""
78+
table_local_disks = formatting.Table(['Type', 'Name', 'Drive', 'Capacity'])
79+
for disk in local_disks:
80+
if 'diskImage' in disk:
81+
table_local_disks.add_row([
82+
get_local_type(disk),
83+
disk['mountType'],
84+
disk['device'],
85+
"{capacity} {unit}".format(capacity=disk['diskImage']['capacity'],
86+
unit=disk['diskImage']['units'])
87+
])
88+
return table_local_disks

0 commit comments

Comments
 (0)