From 4a36c6f7973bc695e1ac5c39701a3f0eda63b6ef Mon Sep 17 00:00:00 2001 From: Phillip Riscombe Burton Date: Wed, 11 Dec 2019 14:09:46 +0000 Subject: [PATCH] Support different VMware products - use 'vmrun' with VMware Workstation, VMware Server or VMware Fusion - support paths to products that include spaces --- vmrun.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vmrun.py b/vmrun.py index c340f26..430abe9 100644 --- a/vmrun.py +++ b/vmrun.py @@ -24,7 +24,7 @@ def execute( self, path, *cmd ): cmds = list(cmd) cmds.insert( 1, "\"%s\"" % self.VM_FILE ) - cmds[0] = "-T ws -gu %s -gp %s %s" % (self.VM_ADMIN, self.VM_PASS, cmds[0]) + cmds[0] = "-T %s -gu %s -gp %s %s" % (self.VM_PRODUCT, self.VM_ADMIN, self.VM_PASS, cmds[0]) params = " ".join( cmds ) if self.DEBUG: print("[DEBUG] %s" % params) @@ -46,9 +46,10 @@ def vmrun(self, *cmd): return output # TODO maintain vm's power state - def __init__( self, vmx, user='', password='', vmrun='', debug=False ): + def __init__( self, vmx, user='', password='', vmrun='', debug=False, product='ws' ): self.VM_FILE = vmx # TODO strict censor? + self.VM_PRODUCT = product # 'ws', 'server' or 'fusion' self.VM_ADMIN = user self.VM_PASS = password self.DEBUG = debug @@ -78,6 +79,8 @@ def __init__( self, vmx, user='', password='', vmrun='', debug=False ): if os.path.exists(tmp_file): self.VMRUN_PATH = tmp_file break + # escape spaces in path + self.VMRUN_PATH = self.VMRUN_PATH.replace(' ', '\\ ') # # POWER COMMANDS