mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Fix If cloud interface is down the project doesn't open
Fix https://github.com/GNS3/gns3-gui/issues/1751
This commit is contained in:
4 files changed
+33
-15
No files matched your search
@@ -81,7 +81,7 @@ class Cloud(BaseNode):
|
||||
"project_id": self.project.id,
|
||||
"ports_mapping": self._ports_mapping,
|
||||
"interfaces": host_interfaces,
|
||||
"status": "started"}
|
||||
"status": self.status}
|
||||
|
||||
@property
|
||||
def ports_mapping(self):
|
||||
@@ -118,9 +118,23 @@ class Cloud(BaseNode):
|
||||
Creates this cloud.
|
||||
"""
|
||||
|
||||
yield from self._start_ubridge()
|
||||
yield from self.start()
|
||||
log.info('Cloud "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
|
||||
|
||||
@asyncio.coroutine
|
||||
def start(self):
|
||||
if self.status != "started":
|
||||
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
||||
yield from self._stop_ubridge()
|
||||
yield from self._start_ubridge()
|
||||
for port_number in self._nios:
|
||||
if self._nios[port_number]:
|
||||
try:
|
||||
yield from self._add_ubridge_connection(self._nios[port_number], port_number)
|
||||
except (UbridgeError, NodeError) as e:
|
||||
self.status = "stopped"
|
||||
raise e
|
||||
|
||||
@asyncio.coroutine
|
||||
def close(self):
|
||||
"""
|
||||
@@ -280,18 +294,17 @@ class Cloud(BaseNode):
|
||||
port=port_number))
|
||||
self._nios[port_number] = nio
|
||||
try:
|
||||
yield from self.start()
|
||||
yield from self._add_ubridge_connection(nio, port_number)
|
||||
except NodeError as e:
|
||||
del self._nios[port_number]
|
||||
raise e
|
||||
self.project.emit("log.error", {"message": str(e)})
|
||||
yield from self._stop_ubridge()
|
||||
self.status = "stopped"
|
||||
# Cleanup stuff
|
||||
except UbridgeError as e:
|
||||
try:
|
||||
self._delete_ubridge_connection(port_number)
|
||||
except UbridgeError:
|
||||
pass
|
||||
del self._nios[port_number]
|
||||
raise e
|
||||
self.project.emit("log.error", {"message": str(e)})
|
||||
yield from self._stop_ubridge()
|
||||
self.status = "stopped"
|
||||
|
||||
@asyncio.coroutine
|
||||
def _delete_ubridge_connection(self, port_number):
|
||||
@@ -327,7 +340,9 @@ class Cloud(BaseNode):
|
||||
port=port_number))
|
||||
|
||||
del self._nios[port_number]
|
||||
yield from self._delete_ubridge_connection(port_number)
|
||||
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
||||
yield from self._delete_ubridge_connection(port_number)
|
||||
yield from self.start()
|
||||
return nio
|
||||
|
||||
@asyncio.coroutine
|
||||
|
||||
@@ -135,7 +135,8 @@ class CloudHandler:
|
||||
description="Start a cloud")
|
||||
def start(request, response):
|
||||
|
||||
Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
|
||||
node = Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
|
||||
yield from node.start()
|
||||
response.set_status(204)
|
||||
|
||||
@Route.post(
|
||||
|
||||
Reference in new issue
Block a user