Skip to content

Commit

Permalink
ectl: improve/fix vm listing
Browse files Browse the repository at this point in the history
1. Remove the full guest name from the vm-list. Too much information on
   the screen.
2. Normalize the power state to in case it isn't available by the server
   at the time of the listing.

Signed-off-by: Omer Caspi <[email protected]>
  • Loading branch information
omercsp committed May 14, 2021
1 parent f58d582 commit 2e56a80
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def esxi_connect(config, args):


_MAX_DEPTH = 10
_VM_PRINT_FMT = "{:<16}{:<30}{:<8}{:<18}"
_VM_PRINT_FMT = "{:<60}{:<8}{:<18}"


# VM level functions and definitions
Expand All @@ -95,15 +95,17 @@ def print_vm_info(vm, depth=1):
power = power[7:]
if power == "On":
ip = summary.guest.ipAddress
else:
power = "n/a"
if ip is None:
ip = "n/a"

print(_VM_PRINT_FMT.format(summary.config.name, summary.config.guestFullName, power, ip))
print(_VM_PRINT_FMT.format(summary.config.name, power, ip))


def print_vm_list(si):
print(_VM_PRINT_FMT.format("Name", "Guest ID", "Power", "IP Address"))
print(_VM_PRINT_FMT.format("----", "--------", "-----", "----------"))
print(_VM_PRINT_FMT.format("Name", "Power", "IP Address"))
print(_VM_PRINT_FMT.format("----", "-----", "----------"))
content = si.RetrieveContent()
for child in content.rootFolder.childEntity:
if hasattr(child, 'vmFolder'):
Expand Down

0 comments on commit 2e56a80

Please sign in to comment.