mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Merge branch '2.1' into 2.2
# Conflicts: # gns3server/version.py # requirements.txt
This commit is contained in:
commit
96d5e351f7
235 files changed
+3037
-864
No files matched your search
@@ -90,9 +90,9 @@ class ProjectManager:
|
||||
return
|
||||
# send a warning if used disk space is >= 90%
|
||||
if used_disk_space >= 90:
|
||||
message = 'Only {}% or less of disk space detected in "{}" on "{}"'.format(used_disk_space,
|
||||
project.path,
|
||||
platform.node())
|
||||
message = 'Only {:.2f}% or less of free disk space detected in "{}" on "{}"'.format(100 - used_disk_space,
|
||||
project.path,
|
||||
platform.node())
|
||||
log.warning(message)
|
||||
project.emit("log.warning", {"message": message})
|
||||
|
||||
|
||||
@@ -337,12 +337,13 @@ class Compute:
|
||||
return response
|
||||
|
||||
@asyncio.coroutine
|
||||
def stream_file(self, project, path):
|
||||
def stream_file(self, project, path, timeout=None):
|
||||
"""
|
||||
Read file of a project and stream it
|
||||
|
||||
:param project: A project object
|
||||
:param path: The path of the file in the project
|
||||
:param timeout: timeout
|
||||
:returns: A file stream
|
||||
"""
|
||||
|
||||
@@ -361,7 +362,7 @@ class Compute:
|
||||
self._response.close()
|
||||
|
||||
url = self._getUrl("/projects/{}/stream/{}".format(project.id, path))
|
||||
response = yield from self._session().request("GET", url, auth=self._auth, timeout=None)
|
||||
response = yield from self._session().request("GET", url, auth=self._auth, timeout=timeout)
|
||||
if response.status == 404:
|
||||
raise aiohttp.web.HTTPNotFound(text="{} not found on compute".format(path))
|
||||
elif response.status == 403:
|
||||
@@ -527,8 +528,8 @@ class Compute:
|
||||
headers=headers
|
||||
))
|
||||
response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout)
|
||||
except asyncio.TimeoutError as e:
|
||||
raise ComputeError("Timeout error when connecting to {}".format(url))
|
||||
except asyncio.TimeoutError:
|
||||
raise ComputeError("Timeout error for {} call to {} after {}s".format(method, url, timeout))
|
||||
except (aiohttp.ClientError, aiohttp.ServerDisconnectedError, ValueError, KeyError, socket.gaierror) as e:
|
||||
# aiohttp 2.3.1 raises socket.gaierror when cannot find host
|
||||
raise ComputeError(str(e))
|
||||
@@ -641,7 +642,7 @@ class Compute:
|
||||
List files in the project on computes
|
||||
"""
|
||||
path = "/projects/{}/files".format(project.id)
|
||||
res = yield from self.http_query("GET", path, timeout=120)
|
||||
res = yield from self.http_query("GET", path, timeout=None)
|
||||
return res.json
|
||||
|
||||
@asyncio.coroutine
|
||||
|
||||
@@ -248,6 +248,7 @@ class Node:
|
||||
|
||||
@symbol.setter
|
||||
def symbol(self, val):
|
||||
|
||||
if val is None:
|
||||
val = ":/symbols/computer.svg"
|
||||
|
||||
@@ -261,8 +262,9 @@ class Node:
|
||||
self._symbol = val
|
||||
try:
|
||||
self._width, self._height, filetype = self._project.controller.symbols.get_size(val)
|
||||
# If symbol is invalid we replace it by default
|
||||
except (ValueError, OSError):
|
||||
except (ValueError, OSError) as e:
|
||||
log.error("Could not write symbol: {}".format(e))
|
||||
# If symbol is invalid we replace it by the default
|
||||
self.symbol = ":/symbols/computer.svg"
|
||||
if self._label is None:
|
||||
# Apply to label user style or default
|
||||
@@ -336,7 +338,7 @@ class Node:
|
||||
self._links.remove(link)
|
||||
|
||||
@property
|
||||
def link(self):
|
||||
def links(self):
|
||||
return self._links
|
||||
|
||||
@asyncio.coroutine
|
||||
|
||||
@@ -307,6 +307,28 @@ class NodeHandler:
|
||||
yield from project.delete_node(request.match_info["node_id"])
|
||||
response.set_status(204)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/nodes/{node_id}/links",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
"node_id": "Node UUID"
|
||||
},
|
||||
status_codes={
|
||||
200: "Links returned",
|
||||
400: "Invalid request",
|
||||
404: "Instance doesn't exist"
|
||||
},
|
||||
description="Return all the links connected to this node")
|
||||
def links(request, response):
|
||||
|
||||
project = yield from Controller.instance().get_loaded_project(request.match_info["project_id"])
|
||||
node = project.get_node(request.match_info["node_id"])
|
||||
links = []
|
||||
for link in node.links:
|
||||
links.append(link.__json__())
|
||||
response.json(links)
|
||||
response.set_status(200)
|
||||
|
||||
@Route.get(
|
||||
r"/projects/{project_id}/nodes/{node_id}/dynamips/auto_idlepc",
|
||||
parameters={
|
||||
|
||||
@@ -158,7 +158,7 @@ def md5sum(path, stopped_event=None):
|
||||
|
||||
try:
|
||||
with open(path + '.md5sum') as f:
|
||||
md5 = f.read()
|
||||
md5 = f.read().strip()
|
||||
if len(md5) == 32:
|
||||
return md5
|
||||
# Unicode error is when user rename an image to .md5sum ....
|
||||
|
||||
@@ -103,10 +103,16 @@ def get_size(data, default_width=0, default_height=0):
|
||||
root = tree.getroot()
|
||||
|
||||
try:
|
||||
width = _svg_convert_size(root.attrib.get("width", "0"))
|
||||
height = _svg_convert_size(root.attrib.get("height", "0"))
|
||||
except IndexError:
|
||||
raise ValueError("Invalid SVG file")
|
||||
width_attr = root.attrib.get("width", "0")
|
||||
height_attr = root.attrib.get("height", "0")
|
||||
if width_attr.endswith("%") or height_attr.endswith("%"):
|
||||
# check to viewBox attribute if width or height value is a percentage
|
||||
_, _, width_attr, height_attr = root.attrib.get("viewBox").split()
|
||||
else:
|
||||
width = _svg_convert_size(width_attr)
|
||||
height = _svg_convert_size(height_attr)
|
||||
except (AttributeError, IndexError) as e:
|
||||
raise ValueError("Invalid SVG file: {}".format(e))
|
||||
|
||||
return width, height, filetype
|
||||
|
||||
|
||||
Reference in new issue
Block a user