mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
parent
f968f6616f
commit
477091207d
@ -24,7 +24,7 @@ import aiohttp
|
|||||||
|
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from .project import Project
|
from .project import Project
|
||||||
from .compute import Compute
|
from .compute import Compute, ComputeError
|
||||||
from .notification import Notification
|
from .notification import Notification
|
||||||
from .symbols import Symbols
|
from .symbols import Symbols
|
||||||
from ..version import __version__
|
from ..version import __version__
|
||||||
@ -84,7 +84,7 @@ class Controller:
|
|||||||
try:
|
try:
|
||||||
yield from compute.close()
|
yield from compute.close()
|
||||||
# We don't care if a compute is down at this step
|
# We don't care if a compute is down at this step
|
||||||
except (aiohttp.errors.ClientOSError, aiohttp.web_exceptions.HTTPError, OSError):
|
except (ComputeError, aiohttp.web_exceptions.HTTPError, OSError):
|
||||||
pass
|
pass
|
||||||
yield from self.gns3vm.exit_vm()
|
yield from self.gns3vm.exit_vm()
|
||||||
self._computes = {}
|
self._computes = {}
|
||||||
|
@ -362,7 +362,7 @@ class Compute:
|
|||||||
if not self._connected and not self._closed:
|
if not self._connected and not self._closed:
|
||||||
try:
|
try:
|
||||||
response = yield from self._run_http_query("GET", "/capabilities")
|
response = yield from self._run_http_query("GET", "/capabilities")
|
||||||
except (aiohttp.errors.ClientOSError, aiohttp.errors.ClientRequestError, aiohttp.ClientResponseError):
|
except ComputeError:
|
||||||
# Try to reconnect after 2 seconds if server unavailable only if not during tests (otherwise we create a ressources usage bomb)
|
# Try to reconnect after 2 seconds if server unavailable only if not during tests (otherwise we create a ressources usage bomb)
|
||||||
if not hasattr(sys, "_called_from_test") or not sys._called_from_test:
|
if not hasattr(sys, "_called_from_test") or not sys._called_from_test:
|
||||||
asyncio.get_event_loop().call_later(2, lambda: asyncio.async(self.connect()))
|
asyncio.get_event_loop().call_later(2, lambda: asyncio.async(self.connect()))
|
||||||
@ -465,7 +465,10 @@ class Compute:
|
|||||||
data = send_data(data)
|
data = send_data(data)
|
||||||
else:
|
else:
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
|
try:
|
||||||
response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout)
|
response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout)
|
||||||
|
except (aiohttp.errors.ClientOSError, aiohttp.errors.ClientRequestError, aiohttp.ClientResponseError) as e:
|
||||||
|
raise ComputeError(str(e))
|
||||||
body = yield from response.read()
|
body = yield from response.read()
|
||||||
if body and not raw:
|
if body and not raw:
|
||||||
body = body.decode()
|
body = body.decode()
|
||||||
|
@ -22,7 +22,7 @@ import uuid
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
from .compute import ComputeConflict
|
from .compute import ComputeConflict, ComputeError
|
||||||
from .ports.port_factory import PortFactory, StandardPortFactory, DynamipsPortFactory
|
from .ports.port_factory import PortFactory, StandardPortFactory, DynamipsPortFactory
|
||||||
from ..utils.images import images_directories
|
from ..utils.images import images_directories
|
||||||
from ..utils.qt import qt_font_to_style
|
from ..utils.qt import qt_font_to_style
|
||||||
@ -399,7 +399,7 @@ class Node:
|
|||||||
try:
|
try:
|
||||||
yield from self.post("/stop", timeout=240)
|
yield from self.post("/stop", timeout=240)
|
||||||
# We don't care if a node is down at this step
|
# We don't care if a node is down at this step
|
||||||
except (aiohttp.errors.ClientOSError, aiohttp.errors.ClientHttpProcessingError, aiohttp.web.HTTPError):
|
except (ComputeError, aiohttp.errors.ClientHttpProcessingError, aiohttp.web.HTTPError):
|
||||||
pass
|
pass
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
raise aiohttp.web.HTTPRequestTimeout(text="Timeout when stopping {}".format(self._name))
|
raise aiohttp.web.HTTPRequestTimeout(text="Timeout when stopping {}".format(self._name))
|
||||||
|
@ -27,6 +27,7 @@ import tempfile
|
|||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
from .node import Node
|
from .node import Node
|
||||||
|
from .compute import ComputeError
|
||||||
from .snapshot import Snapshot
|
from .snapshot import Snapshot
|
||||||
from .drawing import Drawing
|
from .drawing import Drawing
|
||||||
from .topology import project_to_topology, load_topology
|
from .topology import project_to_topology, load_topology
|
||||||
@ -541,7 +542,7 @@ class Project:
|
|||||||
try:
|
try:
|
||||||
yield from compute.post("/projects/{}/close".format(self._id))
|
yield from compute.post("/projects/{}/close".format(self._id))
|
||||||
# We don't care if a compute is down at this step
|
# We don't care if a compute is down at this step
|
||||||
except (aiohttp.errors.ClientOSError, aiohttp.web.HTTPError, aiohttp.ClientResponseError, TimeoutError):
|
except (ComputeError, aiohttp.web.HTTPError, aiohttp.ClientResponseError, TimeoutError):
|
||||||
pass
|
pass
|
||||||
self._cleanPictures()
|
self._cleanPictures()
|
||||||
self._status = "closed"
|
self._status = "closed"
|
||||||
@ -646,7 +647,7 @@ class Project:
|
|||||||
try:
|
try:
|
||||||
yield from compute.post("/projects/{}/close".format(self._id))
|
yield from compute.post("/projects/{}/close".format(self._id))
|
||||||
# We don't care if a compute is down at this step
|
# We don't care if a compute is down at this step
|
||||||
except (aiohttp.errors.ClientOSError, aiohttp.web.HTTPNotFound, aiohttp.web.HTTPConflict):
|
except (ComputeError, aiohttp.web.HTTPNotFound, aiohttp.web.HTTPConflict):
|
||||||
pass
|
pass
|
||||||
shutil.copy(path + ".backup", path)
|
shutil.copy(path + ".backup", path)
|
||||||
self._status = "closed"
|
self._status = "closed"
|
||||||
|
Loading…
Reference in New Issue
Block a user