Move code for exposing VM ip to the VM itself. And display VM starting status

Fix #1621
This commit is contained in:
Julien Duponchelle committed 2016-10-26 18:32:01 +02:00
1 parent fd911542f7
commit 620de3ff25
3 files changed
+19 -39

No files matched your search

+3 -4
View File
@@ -84,13 +84,10 @@ class Compute:
self._id = compute_id
self.protocol = protocol
self._console_host = console_host
self.host = host
self.port = port
self._user = None
if console_host is None:
self._console_host = host
else:
self._console_host = console_host
self._password = None
self._connected = False
self._closed = False # Close mean we are destroying the compute node
@@ -217,6 +214,8 @@ class Compute:
@host.setter
def host(self, host):
self._host = host
if self._console_host is None:
self._console_host = host
@property
def console_host(self):
+16 -9
View File
@@ -263,15 +263,22 @@ class GNS3VM:
engine.vmname = self._settings["vmname"]
engine.ram = self._settings["ram"]
engine.vpcus = self._settings["vcpus"]
yield from engine.start()
yield from self._controller.add_compute(compute_id="vm",
name="GNS3 VM ({})".format(engine.vmname),
protocol=self.protocol,
host=self.ip_address,
port=self.port,
user=self.user,
password=self.password,
force=True)
compute = yield from self._controller.add_compute(compute_id="vm",
name="GNS3 VM is starting ({})".format(engine.vmname),
host=None,
force=True)
try:
yield from engine.start()
except Exception as e:
yield from self._controller.delete_compute("vm")
raise e
yield from compute.update(name="GNS3 VM ({})".format(engine.vmname),
protocol=self.protocol,
host=self.ip_address,
port=self.port,
user=self.user,
password=self.password)
@locked_coroutine
def _suspend(self):