Skip to content

Commit ad94609

Browse files
author
Flavio Fernandes
committed
virtual detail: show dedicated host info, if applicable
This is only applicable for VSIs that were created to be in a dedicated host. Provide id and name of the dedicated host where VSI is running.
1 parent fc8d42c commit ad94609

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

SoftLayer/CLI/virt/detail.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def cli(env, identifier, passwords=False, price=False):
4545
table.add_row(['active_transaction', formatting.active_txn(result)])
4646
table.add_row(['datacenter',
4747
result['datacenter']['name'] or formatting.blank()])
48+
_cli_helper_dedicated_host(env, result, table)
4849
operating_system = utils.lookup(result,
4950
'operatingSystem',
5051
'softwareLicense',
@@ -138,3 +139,19 @@ def cli(env, identifier, passwords=False, price=False):
138139
pass
139140

140141
env.fout(table)
142+
143+
144+
def _cli_helper_dedicated_host(env, result, table):
145+
"""Get details on dedicated host for a virtual server."""
146+
147+
dedicated_host_id = utils.lookup(result, 'dedicatedHost', 'id')
148+
if dedicated_host_id:
149+
table.add_row(['dedicated_host_id', dedicated_host_id])
150+
# Try to find name of dedicated host
151+
try:
152+
dedicated_host = env.client.call('Virtual_DedicatedHost', 'getObject',
153+
id=dedicated_host_id)
154+
except SoftLayer.SoftLayerAPIError:
155+
dedicated_host = {}
156+
table.add_row(['dedicated_host',
157+
dedicated_host.get('name') or formatting.blank()])

0 commit comments

Comments
 (0)