mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
parent
65090c6f87
commit
1bb760d3f0
@ -357,19 +357,19 @@ class VMware(BaseManager):
|
||||
return self._host_type
|
||||
|
||||
@asyncio.coroutine
|
||||
def execute(self, subcommand, args, timeout=120):
|
||||
def execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
|
||||
try:
|
||||
return (yield from self._execute(subcommand, args, timeout=timeout))
|
||||
return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level))
|
||||
except VMwareError as e:
|
||||
# We can fail to detect that it's VMware player instead of Workstation (due to marketing change Player is now Player Workstation)
|
||||
if self.host_type == "ws" and "VIX_SERVICEPROVIDER_VMWARE_WORKSTATION" in str(e):
|
||||
self._host_type = "player"
|
||||
return (yield from self._execute(subcommand, args, timeout=timeout))
|
||||
return (yield from self._execute(subcommand, args, timeout=timeout, log_level=log_level))
|
||||
else:
|
||||
raise e
|
||||
|
||||
@asyncio.coroutine
|
||||
def _execute(self, subcommand, args, timeout=120):
|
||||
def _execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
|
||||
if self.host_type is None:
|
||||
yield from self.check_vmware_version()
|
||||
|
||||
@ -380,7 +380,7 @@ class VMware(BaseManager):
|
||||
command = [vmrun_path, "-T", self.host_type, subcommand]
|
||||
command.extend(args)
|
||||
command_string = " ".join(command)
|
||||
log.info("Executing vmrun with command: {}".format(command_string))
|
||||
log.log(log_level, "Executing vmrun with command: {}".format(command_string))
|
||||
try:
|
||||
process = yield from asyncio.create_subprocess_exec(*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
||||
except (OSError, subprocess.SubprocessError) as e:
|
||||
|
@ -279,7 +279,6 @@ class GNS3VM:
|
||||
port=self.port,
|
||||
user=self.user,
|
||||
password=self.password)
|
||||
print(compute.password)
|
||||
|
||||
@locked_coroutine
|
||||
def _suspend(self):
|
||||
|
@ -44,10 +44,10 @@ class VMwareGNS3VM(BaseGNS3VM):
|
||||
return self._vmx_path
|
||||
|
||||
@asyncio.coroutine
|
||||
def _execute(self, subcommand, args, timeout=60):
|
||||
def _execute(self, subcommand, args, timeout=60, log_level=logging.INFO):
|
||||
|
||||
try:
|
||||
result = yield from self._vmware_manager.execute(subcommand, args, timeout)
|
||||
result = yield from self._vmware_manager.execute(subcommand, args, timeout, log_level=log_level)
|
||||
return (''.join(result))
|
||||
except VMwareError as e:
|
||||
raise GNS3VMError("Error while executing VMware command: {}".format(e))
|
||||
@ -132,14 +132,16 @@ class VMwareGNS3VM(BaseGNS3VM):
|
||||
# get the guest IP address (first adapter only)
|
||||
trial = 120
|
||||
guest_ip_address = ""
|
||||
log.info("Waiting for GNS3 VM IP")
|
||||
while True:
|
||||
guest_ip_address = yield from self._execute("readVariable", [self._vmx_path, "guestVar", "gns3.eth0"], timeout=120)
|
||||
guest_ip_address = yield from self._execute("readVariable", [self._vmx_path, "guestVar", "gns3.eth0"], timeout=120, log_level=logging.DEBUG)
|
||||
guest_ip_address = guest_ip_address.strip()
|
||||
if len(guest_ip_address) != 0:
|
||||
break
|
||||
trial -= 1
|
||||
# If ip not found fallback on old method
|
||||
if trial == 0:
|
||||
log.warn("No IP found for the VM via readVariable fallback to getGuestIPAddress")
|
||||
guest_ip_address = yield from self._execute("getGuestIPAddress", [self._vmx_path, "-wait"], timeout=120)
|
||||
break
|
||||
yield from asyncio.sleep(1)
|
||||
|
Loading…
Reference in New Issue
Block a user