mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-24 15:58:08 +00:00
Improve process to get guest IP address from GNS3 VM running in VMware workstation/player. Ref https://github.com/GNS3/gns3-gui/issues/2866
This commit is contained in:
parent
09d05accc1
commit
6ae7ef8a2e
@ -279,7 +279,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
|
|||||||
pass
|
pass
|
||||||
remaining_try -= 1
|
remaining_try -= 1
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
raise GNS3VMError("Could not get the GNS3 VM ip make sure the VM receive an IP from VirtualBox")
|
raise GNS3VMError("Could not find guest IP address for {}".format(self.vmname))
|
||||||
|
|
||||||
async def suspend(self):
|
async def suspend(self):
|
||||||
"""
|
"""
|
||||||
|
@ -164,17 +164,22 @@ class VMwareGNS3VM(BaseGNS3VM):
|
|||||||
guest_ip_address = ""
|
guest_ip_address = ""
|
||||||
log.info("Waiting for GNS3 VM IP")
|
log.info("Waiting for GNS3 VM IP")
|
||||||
while True:
|
while True:
|
||||||
guest_ip_address = await self._execute("readVariable", [self._vmx_path, "guestVar", "gns3.eth0"], timeout=120, log_level=logging.DEBUG)
|
try:
|
||||||
guest_ip_address = guest_ip_address.strip()
|
guest_ip_address = await self._execute("readVariable", [self._vmx_path, "guestVar", "gns3.eth0"], timeout=120, log_level=logging.DEBUG)
|
||||||
if len(guest_ip_address) != 0:
|
guest_ip_address = guest_ip_address.strip()
|
||||||
break
|
if len(guest_ip_address) != 0:
|
||||||
trial -= 1
|
break
|
||||||
# If ip not found fallback on old method
|
trial -= 1
|
||||||
if trial == 0:
|
# If IP address not found then fallback an old method
|
||||||
log.warning("No IP found for the VM via readVariable fallback to getGuestIPAddress")
|
if trial == 0:
|
||||||
guest_ip_address = await self._execute("getGuestIPAddress", [self._vmx_path, "-wait"], timeout=120)
|
log.warning("No IP found for the VM via readVariable fallback to getGuestIPAddress")
|
||||||
break
|
guest_ip_address = await self._execute("getGuestIPAddress", [self._vmx_path, "-wait"], timeout=120)
|
||||||
|
break
|
||||||
|
except GNS3VMError as e:
|
||||||
|
log.debug("{}".format(e))
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
if not guest_ip_address:
|
||||||
|
raise GNS3VMError("Could not find guest IP address for {}".format(self.vmname))
|
||||||
self.ip_address = guest_ip_address
|
self.ip_address = guest_ip_address
|
||||||
log.info("GNS3 VM IP address set to {}".format(guest_ip_address))
|
log.info("GNS3 VM IP address set to {}".format(guest_ip_address))
|
||||||
self.running = True
|
self.running = True
|
||||||
|
Loading…
Reference in New Issue
Block a user