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
|
return self._host_type
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def execute(self, subcommand, args, timeout=120):
|
def execute(self, subcommand, args, timeout=120, log_level=logging.INFO):
|
||||||
try:
|
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:
|
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)
|
# 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):
|
if self.host_type == "ws" and "VIX_SERVICEPROVIDER_VMWARE_WORKSTATION" in str(e):
|
||||||
self._host_type = "player"
|
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:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
@asyncio.coroutine
|
@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:
|
if self.host_type is None:
|
||||||
yield from self.check_vmware_version()
|
yield from self.check_vmware_version()
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ class VMware(BaseManager):
|
|||||||
command = [vmrun_path, "-T", self.host_type, subcommand]
|
command = [vmrun_path, "-T", self.host_type, subcommand]
|
||||||
command.extend(args)
|
command.extend(args)
|
||||||
command_string = " ".join(command)
|
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:
|
try:
|
||||||
process = yield from asyncio.create_subprocess_exec(*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
process = yield from asyncio.create_subprocess_exec(*command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
|
||||||
except (OSError, subprocess.SubprocessError) as e:
|
except (OSError, subprocess.SubprocessError) as e:
|
||||||
|
@ -279,7 +279,6 @@ class GNS3VM:
|
|||||||
port=self.port,
|
port=self.port,
|
||||||
user=self.user,
|
user=self.user,
|
||||||
password=self.password)
|
password=self.password)
|
||||||
print(compute.password)
|
|
||||||
|
|
||||||
@locked_coroutine
|
@locked_coroutine
|
||||||
def _suspend(self):
|
def _suspend(self):
|
||||||
|
@ -44,10 +44,10 @@ class VMwareGNS3VM(BaseGNS3VM):
|
|||||||
return self._vmx_path
|
return self._vmx_path
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _execute(self, subcommand, args, timeout=60):
|
def _execute(self, subcommand, args, timeout=60, log_level=logging.INFO):
|
||||||
|
|
||||||
try:
|
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))
|
return (''.join(result))
|
||||||
except VMwareError as e:
|
except VMwareError as e:
|
||||||
raise GNS3VMError("Error while executing VMware command: {}".format(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)
|
# get the guest IP address (first adapter only)
|
||||||
trial = 120
|
trial = 120
|
||||||
guest_ip_address = ""
|
guest_ip_address = ""
|
||||||
|
log.info("Waiting for GNS3 VM IP")
|
||||||
while True:
|
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()
|
guest_ip_address = guest_ip_address.strip()
|
||||||
if len(guest_ip_address) != 0:
|
if len(guest_ip_address) != 0:
|
||||||
break
|
break
|
||||||
trial -= 1
|
trial -= 1
|
||||||
# If ip not found fallback on old method
|
# If ip not found fallback on old method
|
||||||
if trial == 0:
|
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)
|
guest_ip_address = yield from self._execute("getGuestIPAddress", [self._vmx_path, "-wait"], timeout=120)
|
||||||
break
|
break
|
||||||
yield from asyncio.sleep(1)
|
yield from asyncio.sleep(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user