Skip to content
Open
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
15 changes: 10 additions & 5 deletions vmfusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def __init__( self, bundle_directory=None, vmrun_path=None ):
def __vmrun( self, command ):
base = [ self.tool_path, '-T', 'fusion' ]
base.extend( command )

proc = subprocess.Popen( base, stdout=subprocess.PIPE )
stdout = proc.stdout.readlines()
stdout = [x.decode('utf8') for x in proc.stdout.readlines()]

if len(stdout) and stdout[0].startswith('Error'):
raise VMRunException(stdout[0])
Expand All @@ -62,7 +62,7 @@ def list( self ):
# [optional absolute path to VMX n]
data = {}
data[ 'count' ] = int(output[0].split(':')[1].strip())
data[ 'machines' ] = [vmx.strip() for vmx in output[1:]]
data[ 'machines' ] = [vmx.strip() for vmx in output[1:]]

return data

Expand Down Expand Up @@ -151,6 +151,9 @@ def delete_snapshot( self, vmx, name ):

self.__vmrun( [ 'deleteSnapshot', vmx, name ] )

def fetch_ipaddress(self, vmx):
vmx = get_abspath( vmx )
return self.__vmrun( ['getGuestIPAddress', vmx, '-wait'] )[0].strip('\n')

class VM(object):
"""
Expand Down Expand Up @@ -194,6 +197,8 @@ def revert_to_snapshot(self, name):
def delete_snapshot(self, name):
return self.vmrun.delete_snapshot(self.vmx, name)

def fetch_ipaddress(self):
return self.vmrun.fetch_ipaddress(self.vmx)

class vdiskmanager_cli( object ):
# Valid disks
Expand Down Expand Up @@ -335,8 +340,8 @@ def load( self ):
if mac not in all_leases or lease.starts.datetime > all_leases[mac].starts.datetime:
all_leases[ mac ] = lease

except AttributeError, e:
print e
except AttributeError as e:
print(e)

for mac in all_leases:
all_leases[ mac ] = all_leases[ mac ].ipaddress
Expand Down