Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions SoftLayer/CLI/virt/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.CLI import helpers
from SoftLayer.CLI.virt.storage import get_local_type
from SoftLayer.CLI.virt.storage import get_local_storage_table
from SoftLayer import utils

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

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

table.add_row(['id', result['id']])
table.add_row(['guid', result['globalIdentifier']])
Expand Down Expand Up @@ -173,7 +169,7 @@ def _get_owner_row(result):
owner = utils.lookup(result, 'billingItem', 'orderItem', 'order', 'userRecord', 'username')
else:
owner = formatting.blank()
return(['owner', owner])
return (['owner', owner])


def _get_vlan_table(result):
Expand Down
27 changes: 21 additions & 6 deletions SoftLayer/CLI/virt/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ def cli(env, identifier):
nas['allowedVirtualGuests'][0]['datacenter']['longName'],
nas.get('notes', None)])

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

env.fout(table_credentials)
env.fout(table_iscsi)
Expand All @@ -64,10 +61,28 @@ def cli(env, identifier):
def get_local_type(disks):
"""Returns the virtual server local disk type.

:param disks: virtual serve local disks.
:param disks: virtual server local disks.
"""
disk_type = 'System'
if 'SWAP' in disks.get('diskImage', {}).get('description', []):
disk_type = 'Swap'

return disk_type


def get_local_storage_table(local_disks):
"""Returns a formatting local disk table

:param local_disks: virtual server local disks.
"""
table_local_disks = formatting.Table(['Type', 'Name', 'Drive', 'Capacity'])
for disk in local_disks:
if 'diskImage' in disk:
table_local_disks.add_row([
get_local_type(disk),
disk['mountType'],
disk['device'],
"{capacity} {unit}".format(capacity=disk['diskImage']['capacity'],
unit=disk['diskImage']['units'])
])
return table_local_disks