mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-15 03:15:14 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
878987a26e | ||
|
|
c357d52ba4 | ||
|
|
773bad811a | ||
|
|
6b54cc27da | ||
|
|
351ed64de9 | ||
|
|
f41158173b | ||
|
|
cb5dc36987 | ||
|
|
cc1980ac1c | ||
|
|
8cd66cfc02 | ||
|
|
645031ee15 | ||
|
|
c70b344133 | ||
|
|
e291ec1eb9 | ||
|
|
8e8985c69f | ||
|
|
4eca82174d | ||
|
|
32f5dbb645 | ||
|
|
7aae682f0a | ||
|
|
879e32eb9a | ||
|
|
01481cde1f | ||
|
|
b5deb9d177 | ||
|
|
e1aa13fa73 | ||
|
|
62c51edbae | ||
|
|
a13d063aa1 | ||
|
|
1ef1872f8e | ||
|
|
657698a961 | ||
|
|
081ba31b50 | ||
|
|
aea4ae808f | ||
|
|
ae3515434c | ||
|
|
589c9754e8 | ||
|
|
4ecd3b2015 | ||
|
|
84ee3263ba | ||
|
|
174624121d | ||
|
|
d9a9abf845 | ||
|
|
0b07299472 | ||
|
|
7fb192699b |
No files matched your search
@@ -1,5 +1,44 @@
|
||||
# Change Log
|
||||
|
||||
## 2.1.18 22/05/2019
|
||||
|
||||
* Revert "Force aiohttp version to 2.3.10 and aiohttp-cors version to 0.5.3" Ref https://github.com/GNS3/gns3-server/issues/1583 Ref https://github.com/GNS3/gns3-server/issues/1592
|
||||
* Fix invalid reStructuredText for long description in setup.py
|
||||
|
||||
## 2.1.17 17/05/2019
|
||||
|
||||
* Force aiohttp version to 2.3.10 and aiohttp-cors version to 0.5.3 This is to fix build issue for Ubuntu 19.04 package on Launchpad. Ref #1583 https://github.com/GNS3/gns3-gui/issues/2774
|
||||
|
||||
## 2.1.16 15/04/2019
|
||||
|
||||
* Fix broken embedded console for Ethernet switch. Fixes #1574
|
||||
* Remove old unused argument option. Fixes #1569
|
||||
|
||||
## 2.1.15 21/03/2019
|
||||
|
||||
* Fix IOU symlink issue on remote servers.
|
||||
* Fix vcpus configuration for GNS3 VM on VMware. Ref #2738.
|
||||
|
||||
## 2.1.14 27/02/2019
|
||||
|
||||
* Fix issue when setting cpuid.corespersocket for the GNS3 VM. Fixes https://github.com/GNS3/gns3-gui/issues/2723
|
||||
* Bump ACPI Shutdown Timeout to 120 seconds. Ref #1536
|
||||
|
||||
## 2.1.13 26/02/2019
|
||||
|
||||
* Force jsonschema dependency to 2.6.0
|
||||
* Less aggressive connections to uBridge. Ref #1289
|
||||
* Fix topology images (Pictures) disappearing from projects. Fixes #1514.
|
||||
* Reset MAC addresses when duplicating a project. Fixes #1522
|
||||
* Fix API call to create a node from an appliance doesn't return the new node data. Fixes #1527
|
||||
* Detect invalid environment variable and send a warning when creating a Docker node. Ref #2683
|
||||
* Do not export/import symlinks for projects. Fixes #2699
|
||||
* Fix symlink not being created for duplicated IOU devices. Fixes https://github.com/GNS3/gns3-gui/issues/2699
|
||||
* Configure coresPerSocket value in VMX file for the GNS3 VM. Fixes https://github.com/GNS3/gns3-gui/issues/2688
|
||||
* Count logical CPUs to detect if the number of vCPUs is too high when configuring the GNS3 VM. Fixes #2688.
|
||||
* Add explicit error when trying to pull a Docker image from Docker Hub without Internet access. Fixes #1506.
|
||||
* Fixes double display output in GRUB in QEMU v3.1. Fixes #1516.
|
||||
|
||||
## 2.1.12 23/01/2019
|
||||
|
||||
* Tune how to get the size of SVG images. Ref https://github.com/GNS3/gns3-gui/issues/2674.
|
||||
|
||||
+5
-4
@@ -23,7 +23,7 @@ master is the next stable release, you can test it in your day to day activities
|
||||
Bug fixes or small improvements pull requests go here.
|
||||
|
||||
2.x (2.1 for example)
|
||||
********
|
||||
*********************
|
||||
Next major release
|
||||
|
||||
*Never* use this branch for production. Pull requests for major new features go here.
|
||||
@@ -100,7 +100,7 @@ All the init script require the creation of a GNS3 user. You can change it to an
|
||||
sudo adduser gns3
|
||||
|
||||
upstart
|
||||
~~~~~~~
|
||||
-------
|
||||
|
||||
For ubuntu < 15.04
|
||||
|
||||
@@ -113,7 +113,8 @@ You need to copy init/gns3.conf.upstart to /etc/init/gns3.conf
|
||||
|
||||
|
||||
systemd
|
||||
~~~~~~~~
|
||||
-------
|
||||
|
||||
You need to copy init/gns3.service.systemd to /lib/systemd/system/gns3.service
|
||||
|
||||
.. code:: bash
|
||||
@@ -219,5 +220,5 @@ If you want test coverage:
|
||||
|
||||
Security issues
|
||||
----------------
|
||||
Please contact us using contact informations available here:
|
||||
Please contact us using contact form available here:
|
||||
http://docs.gns3.com/1ON9JBXSeR7Nt2-Qum2o3ZX0GU86BZwlmNSUgvmqNWGY/index.html
|
||||
@@ -276,7 +276,7 @@ class BaseManager:
|
||||
destination_dir = destination_node.working_dir
|
||||
try:
|
||||
shutil.rmtree(destination_dir)
|
||||
shutil.copytree(source_node.working_dir, destination_dir)
|
||||
shutil.copytree(source_node.working_dir, destination_dir, symlinks=True, ignore_dangling_symlinks=True)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPConflict(text="Can't duplicate node data: {}".format(e))
|
||||
|
||||
|
||||
@@ -200,7 +200,10 @@ class Docker(BaseManager):
|
||||
|
||||
if progress_callback:
|
||||
progress_callback("Pulling '{}' from docker hub".format(image))
|
||||
response = yield from self.http_query("POST", "images/create", params={"fromImage": image}, timeout=None)
|
||||
try:
|
||||
response = yield from self.http_query("POST", "images/create", params={"fromImage": image}, timeout=None)
|
||||
except DockerError as e:
|
||||
raise DockerError("Could not pull the '{}' image from Docker Hub, please check your Internet connection (original error: {})".format(image, e))
|
||||
# The pull api will stream status via an HTTP JSON stream
|
||||
content = ""
|
||||
while True:
|
||||
|
||||
@@ -347,6 +347,9 @@ class DockerVM(BaseNode):
|
||||
if self._environment:
|
||||
for e in self._environment.strip().split("\n"):
|
||||
e = e.strip()
|
||||
if e.split("=")[0] == "":
|
||||
self.project.emit("log.warning", {"message": "{} has invalid environment variable: {}".format(self.name, e)})
|
||||
continue
|
||||
if not e.startswith("GNS3_"):
|
||||
formatted = self._format_env(variables, e)
|
||||
params["Env"].append(formatted)
|
||||
|
||||
@@ -522,8 +522,9 @@ class IOUVM(BaseNode):
|
||||
# on newer images, see https://github.com/GNS3/gns3-server/issues/1484
|
||||
try:
|
||||
symlink = os.path.join(self.working_dir, os.path.basename(self.path))
|
||||
if not os.path.islink(symlink):
|
||||
os.symlink(self.path, symlink)
|
||||
if os.path.islink(symlink):
|
||||
os.unlink(symlink)
|
||||
os.symlink(self.path, symlink)
|
||||
except OSError as e:
|
||||
raise IOUError("Could not create symbolic link: {}".format(e))
|
||||
|
||||
@@ -661,6 +662,13 @@ class IOUVM(BaseNode):
|
||||
pass
|
||||
self._iou_process = None
|
||||
|
||||
try:
|
||||
symlink = os.path.join(self.working_dir, os.path.basename(self.path))
|
||||
if os.path.islink(symlink):
|
||||
os.unlink(symlink)
|
||||
except OSError as e:
|
||||
log.warning("Could not delete symbolic link: {}".format(e))
|
||||
|
||||
self._started = False
|
||||
self.save_configs()
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ class Project:
|
||||
"""
|
||||
|
||||
files = []
|
||||
for dirpath, dirnames, filenames in os.walk(self.path):
|
||||
for dirpath, dirnames, filenames in os.walk(self.path, followlinks=False):
|
||||
for filename in filenames:
|
||||
if not filename.endswith(".ghost"):
|
||||
path = os.path.relpath(dirpath, self.path)
|
||||
|
||||
@@ -186,7 +186,7 @@ class Qemu(BaseManager):
|
||||
return ""
|
||||
else:
|
||||
try:
|
||||
output = yield from subprocess_check_output(qemu_path, "-version")
|
||||
output = yield from subprocess_check_output(qemu_path, "-version", "-nographic")
|
||||
match = re.search("version\s+([0-9a-z\-\.]+)", output)
|
||||
if match:
|
||||
version = match.group(1)
|
||||
|
||||
@@ -974,7 +974,7 @@ class QemuVM(BaseNode):
|
||||
try:
|
||||
if self.acpi_shutdown:
|
||||
yield from self._control_vm("system_powerdown")
|
||||
yield from gns3server.utils.asyncio.wait_for_process_termination(self._process, timeout=30)
|
||||
yield from gns3server.utils.asyncio.wait_for_process_termination(self._process, timeout=120)
|
||||
else:
|
||||
self._process.terminate()
|
||||
yield from gns3server.utils.asyncio.wait_for_process_termination(self._process, timeout=3)
|
||||
@@ -1601,18 +1601,19 @@ class QemuVM(BaseNode):
|
||||
|
||||
return network_options
|
||||
|
||||
def _graphic(self):
|
||||
@asyncio.coroutine
|
||||
def _disable_graphics(self):
|
||||
"""
|
||||
Adds the correct graphic options depending of the OS
|
||||
Disable graphics depending of the QEMU version
|
||||
"""
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if any(opt in self._options for opt in ["-display", "-nographic", "-curses", "-sdl" "-spice", "-vnc"]):
|
||||
return []
|
||||
if len(os.environ.get("DISPLAY", "")) > 0:
|
||||
return []
|
||||
if "-nographic" not in self._options:
|
||||
version = yield from self.manager.get_qemu_version(self.qemu_path)
|
||||
if version and parse_version(version) >= parse_version("3.0"):
|
||||
return ["-display", "none"]
|
||||
else:
|
||||
return ["-nographic"]
|
||||
return []
|
||||
|
||||
def _run_with_kvm(self, qemu_path, options):
|
||||
"""
|
||||
@@ -1678,7 +1679,8 @@ class QemuVM(BaseNode):
|
||||
raise QemuError("Console type {} is unknown".format(self._console_type))
|
||||
command.extend(self._monitor_options())
|
||||
command.extend((yield from self._network_options()))
|
||||
command.extend(self._graphic())
|
||||
if self._console_type == "telnet":
|
||||
command.extend((yield from self._disable_graphics()))
|
||||
if additional_options:
|
||||
try:
|
||||
command.extend(shlex.split(additional_options))
|
||||
|
||||
@@ -55,7 +55,7 @@ class Drawing:
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def ressource_filename(self):
|
||||
def resource_filename(self):
|
||||
"""
|
||||
If the svg content has been dump to an external file return is name otherwise None
|
||||
"""
|
||||
|
||||
@@ -31,7 +31,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def export_project(project, temporary_dir, include_images=False, keep_compute_id=False, allow_all_nodes=False):
|
||||
def export_project(project, temporary_dir, include_images=False, keep_compute_id=False, allow_all_nodes=False, reset_mac_addresses=False):
|
||||
"""
|
||||
Export a project to a zip file.
|
||||
|
||||
@@ -42,6 +42,7 @@ def export_project(project, temporary_dir, include_images=False, keep_compute_id
|
||||
:param include images: save OS images to the zip file
|
||||
:param keep_compute_id: If false replace all compute id by local (standard behavior for .gns3project to make it portable)
|
||||
:param allow_all_nodes: Allow all nodes type to be include in the zip even if not portable
|
||||
:param reset_mac_addresses: Reset MAC addresses for every nodes.
|
||||
|
||||
:returns: ZipStream object
|
||||
"""
|
||||
@@ -61,10 +62,10 @@ def export_project(project, temporary_dir, include_images=False, keep_compute_id
|
||||
# First we process the .gns3 in order to be sure we don't have an error
|
||||
for file in os.listdir(project._path):
|
||||
if file.endswith(".gns3"):
|
||||
yield from _patch_project_file(project, os.path.join(project._path, file), zstream, include_images, keep_compute_id, allow_all_nodes, temporary_dir)
|
||||
yield from _patch_project_file(project, os.path.join(project._path, file), zstream, include_images, keep_compute_id, allow_all_nodes, temporary_dir, reset_mac_addresses)
|
||||
|
||||
# Export the local files
|
||||
for root, dirs, files in os.walk(project._path, topdown=True):
|
||||
for root, dirs, files in os.walk(project._path, topdown=True, followlinks=False):
|
||||
files = [f for f in files if _is_exportable(os.path.join(root, f))]
|
||||
for file in files:
|
||||
path = os.path.join(root, file)
|
||||
@@ -125,6 +126,7 @@ def _patch_mtime(path):
|
||||
new_mtime = file_date.replace(year=1980).timestamp()
|
||||
os.utime(path, (st.st_atime, new_mtime))
|
||||
|
||||
|
||||
def _is_exportable(path):
|
||||
"""
|
||||
:returns: True if file should not be included in the final archive
|
||||
@@ -134,6 +136,10 @@ def _is_exportable(path):
|
||||
if path.endswith("snapshots"):
|
||||
return False
|
||||
|
||||
# do not export symlinks
|
||||
if os.path.islink(path):
|
||||
return False
|
||||
|
||||
# do not export directories of snapshots
|
||||
if "{sep}snapshots{sep}".format(sep=os.path.sep) in path:
|
||||
return False
|
||||
@@ -155,7 +161,7 @@ def _is_exportable(path):
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def _patch_project_file(project, path, zstream, include_images, keep_compute_id, allow_all_nodes, temporary_dir):
|
||||
def _patch_project_file(project, path, zstream, include_images, keep_compute_id, allow_all_nodes, temporary_dir, reset_mac_addresses):
|
||||
"""
|
||||
Patch a project file (.gns3) to export a project.
|
||||
The .gns3 file is renamed to project.gns3
|
||||
@@ -188,6 +194,10 @@ def _patch_project_file(project, path, zstream, include_images, keep_compute_id,
|
||||
if "properties" in node and node["node_type"] != "docker":
|
||||
for prop, value in node["properties"].items():
|
||||
|
||||
# reset the MAC address
|
||||
if reset_mac_addresses and prop in ("mac_addr", "mac_address"):
|
||||
node["properties"][prop] = None
|
||||
|
||||
if node["node_type"] == "iou":
|
||||
if not prop == "path":
|
||||
continue
|
||||
|
||||
@@ -72,15 +72,19 @@ class VMwareGNS3VM(BaseGNS3VM):
|
||||
if ram % 4 != 0:
|
||||
raise GNS3VMError("Allocated memory {} for the GNS3 VM must be a multiple of 4".format(ram))
|
||||
|
||||
available_vcpus = psutil.cpu_count(logical=False)
|
||||
available_vcpus = psutil.cpu_count(logical=True)
|
||||
if vcpus > available_vcpus:
|
||||
raise GNS3VMError("You have allocated too many vCPUs for the GNS3 VM! (max available is {} vCPUs)".format(available_vcpus))
|
||||
|
||||
try:
|
||||
pairs = VMware.parse_vmware_file(self._vmx_path)
|
||||
pairs["numvcpus"] = str(vcpus)
|
||||
pairs["memsize"] = str(ram)
|
||||
VMware.write_vmx_file(self._vmx_path, pairs)
|
||||
if vcpus > 1:
|
||||
pairs["numvcpus"] = str(vcpus)
|
||||
cores_per_sockets = int(vcpus / psutil.cpu_count(logical=False))
|
||||
if cores_per_sockets > 1:
|
||||
pairs["cpuid.corespersocket"] = str(cores_per_sockets)
|
||||
pairs["memsize"] = str(ram)
|
||||
VMware.write_vmx_file(self._vmx_path, pairs)
|
||||
log.info("GNS3 VM vCPU count set to {} and RAM amount set to {}".format(vcpus, ram))
|
||||
except OSError as e:
|
||||
raise GNS3VMError('Could not read/write VMware VMX file "{}": {}'.format(self._vmx_path, e))
|
||||
|
||||
@@ -184,9 +184,11 @@ def _move_files_to_compute(compute, project_id, directory, files_path):
|
||||
|
||||
location = os.path.join(directory, files_path)
|
||||
if os.path.exists(location):
|
||||
for (dirpath, dirnames, filenames) in os.walk(location):
|
||||
for (dirpath, dirnames, filenames) in os.walk(location, followlinks=False):
|
||||
for filename in filenames:
|
||||
path = os.path.join(dirpath, filename)
|
||||
if os.path.islink(path):
|
||||
continue
|
||||
dst = os.path.relpath(path, directory)
|
||||
yield from _upload_file(compute, project_id, path, dst)
|
||||
yield from wait_run_in_executor(shutil.rmtree, os.path.join(directory, files_path))
|
||||
@@ -213,9 +215,11 @@ def _import_images(controller, path):
|
||||
|
||||
image_dir = controller.images_path()
|
||||
root = os.path.join(path, "images")
|
||||
for (dirpath, dirnames, filenames) in os.walk(root):
|
||||
for (dirpath, dirnames, filenames) in os.walk(root, followlinks=False):
|
||||
for filename in filenames:
|
||||
path = os.path.join(dirpath, filename)
|
||||
if os.path.islink(path):
|
||||
continue
|
||||
dst = os.path.join(image_dir, os.path.relpath(path, root))
|
||||
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
||||
shutil.move(path, dst)
|
||||
@@ -146,7 +146,6 @@ class Project:
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Called when open/close a project. Cleanup internal stuff
|
||||
@@ -704,24 +703,26 @@ class Project:
|
||||
# We don't care if a compute is down at this step
|
||||
except (ComputeError, aiohttp.web.HTTPError, aiohttp.ClientResponseError, TimeoutError):
|
||||
pass
|
||||
self._cleanPictures()
|
||||
self._clean_pictures()
|
||||
self._status = "closed"
|
||||
if not ignore_notification:
|
||||
self.controller.notification.emit("project.closed", self.__json__())
|
||||
|
||||
def _cleanPictures(self):
|
||||
def _clean_pictures(self):
|
||||
"""
|
||||
Delete unused images
|
||||
Delete unused pictures.
|
||||
"""
|
||||
|
||||
# Project have been deleted
|
||||
if not os.path.exists(self.path):
|
||||
# Project have been deleted or is loading or is not opened
|
||||
if not os.path.exists(self.path) or self._loading or self._status != "opened":
|
||||
return
|
||||
try:
|
||||
pictures = set(os.listdir(self.pictures_directory))
|
||||
for drawing in self._drawings.values():
|
||||
try:
|
||||
pictures.remove(drawing.ressource_filename)
|
||||
resource_filename = drawing.resource_filename
|
||||
if resource_filename:
|
||||
pictures.remove(resource_filename)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
@@ -733,11 +734,12 @@ class Project:
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
for pict in pictures:
|
||||
os.remove(os.path.join(self.pictures_directory, pict))
|
||||
for pic_filename in pictures:
|
||||
path = os.path.join(self.pictures_directory, pic_filename)
|
||||
log.info("Deleting unused picture '{}'".format(path))
|
||||
os.remove(path)
|
||||
except OSError as e:
|
||||
log.warning(str(e))
|
||||
log.warning("Could not delete unused pictures: {}".format(e))
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete(self):
|
||||
@@ -929,7 +931,7 @@ class Project:
|
||||
self.dump()
|
||||
try:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
zipstream = yield from export_project(self, tmpdir, keep_compute_id=True, allow_all_nodes=True)
|
||||
zipstream = yield from export_project(self, tmpdir, keep_compute_id=True, allow_all_nodes=True, reset_mac_addresses=True)
|
||||
project_path = os.path.join(tmpdir, "project.gns3p")
|
||||
yield from wait_run_in_executor(self._create_duplicate_project_file, project_path, zipstream)
|
||||
with open(project_path, "rb") as f:
|
||||
|
||||
@@ -57,7 +57,7 @@ class CrashReport:
|
||||
Report crash to a third party service
|
||||
"""
|
||||
|
||||
DSN = "https://edb72a54588b4d04afc2de56b8cb5b24:7830885c8a2a4d0cb311de10ddfe3d27@sentry.io/38482"
|
||||
DSN = "https://2b1412df322748bc8b36639671f1a40e:25804fdd614d498aa429c689f540779e@sentry.io/38482"
|
||||
if hasattr(sys, "frozen"):
|
||||
cacert = get_resource("cacert.pem")
|
||||
if cacert is not None and os.path.isfile(cacert):
|
||||
|
||||
@@ -67,8 +67,9 @@ class ApplianceHandler:
|
||||
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
yield from project.add_node_from_appliance(request.match_info["appliance_id"],
|
||||
x=request.json["x"],
|
||||
y=request.json["y"],
|
||||
compute_id=request.json.get("compute_id"))
|
||||
node = yield from project.add_node_from_appliance(request.match_info["appliance_id"],
|
||||
x=request.json["x"],
|
||||
y=request.json["y"],
|
||||
compute_id=request.json.get("compute_id"))
|
||||
response.set_status(201)
|
||||
response.json(node)
|
||||
@@ -91,7 +91,6 @@ def parse_arguments(argv):
|
||||
parser.add_argument("--host", help="run on the given host/IP address")
|
||||
parser.add_argument("--port", help="run on the given port", type=int)
|
||||
parser.add_argument("--ssl", action="store_true", help="run in SSL mode")
|
||||
parser.add_argument("--no-ubridge", action="store_false", help="do not use ubridge to handle node connections")
|
||||
parser.add_argument("--config", help="Configuration file")
|
||||
parser.add_argument("--certfile", help="SSL cert file")
|
||||
parser.add_argument("--certkey", help="SSL key file")
|
||||
|
||||
@@ -137,7 +137,7 @@ VM_CREATE_SCHEMA = {
|
||||
},
|
||||
"mac_addr": {
|
||||
"description": "Base MAC address",
|
||||
"type": "string",
|
||||
"type": ["null", "string"],
|
||||
"minLength": 1,
|
||||
"pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
|
||||
},
|
||||
@@ -355,7 +355,7 @@ VM_UPDATE_SCHEMA = {
|
||||
},
|
||||
"mac_addr": {
|
||||
"description": "Base MAC address",
|
||||
"type": "string",
|
||||
"type": ["null", "string"],
|
||||
"minLength": 1,
|
||||
"pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
|
||||
},
|
||||
@@ -595,7 +595,7 @@ VM_OBJECT_SCHEMA = {
|
||||
},
|
||||
"mac_addr": {
|
||||
"description": "Base MAC address",
|
||||
"type": "string",
|
||||
"type": ["null", "string"]
|
||||
#"minLength": 1,
|
||||
#"pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
|
||||
},
|
||||
|
||||
@@ -69,7 +69,7 @@ class UBridgeHypervisor:
|
||||
connection_success = False
|
||||
last_exception = None
|
||||
while time.time() - begin < timeout:
|
||||
yield from asyncio.sleep(0.01)
|
||||
yield from asyncio.sleep(0.1)
|
||||
try:
|
||||
self._reader, self._writer = yield from asyncio.open_connection(host, self._port)
|
||||
except OSError as e:
|
||||
@@ -84,6 +84,7 @@ class UBridgeHypervisor:
|
||||
log.info("Connected to uBridge hypervisor after {:.4f} seconds".format(time.time() - begin))
|
||||
|
||||
try:
|
||||
yield from asyncio.sleep(0.1)
|
||||
version = yield from self.send("hypervisor version")
|
||||
self._version = version[0].split("-", 1)[0]
|
||||
except IndexError:
|
||||
@@ -237,7 +238,7 @@ class UBridgeHypervisor:
|
||||
.format(host=self._host, port=self._port, command=command, run=self.is_running()))
|
||||
else:
|
||||
retries += 1
|
||||
yield from asyncio.sleep(0.1)
|
||||
yield from asyncio.sleep(0.5)
|
||||
continue
|
||||
retries = 0
|
||||
buf += chunk.decode("utf-8")
|
||||
|
||||
@@ -198,8 +198,8 @@ class UnstoppableEventLoop(EventLoop):
|
||||
|
||||
|
||||
class ShellConnection(TelnetConnection):
|
||||
def __init__(self, reader, writer, shell, loop):
|
||||
super(ShellConnection, self).__init__(reader, writer)
|
||||
def __init__(self, reader, writer, shell, window_size_changed_callback, loop):
|
||||
super(ShellConnection, self).__init__(reader, writer, window_size_changed_callback)
|
||||
self._shell = shell
|
||||
self._loop = loop
|
||||
self._cli = None
|
||||
@@ -239,9 +239,12 @@ class ShellConnection(TelnetConnection):
|
||||
def disconnected(self):
|
||||
pass
|
||||
|
||||
@asyncio.coroutine
|
||||
def window_size_changed(self, columns, rows):
|
||||
self._size = Size(rows=rows, columns=columns)
|
||||
self._cb.terminal_size_changed()
|
||||
if self._window_size_changed_callback:
|
||||
yield from self._window_size_changed_callback(columns, rows)
|
||||
|
||||
@asyncio.coroutine
|
||||
def feed(self, data):
|
||||
@@ -291,8 +294,8 @@ def create_telnet_shell(shell, loop=None):
|
||||
if loop is None:
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
def factory(reader, writer):
|
||||
return ShellConnection(reader, writer, shell, loop)
|
||||
def factory(reader, writer, window_size_changed_callback):
|
||||
return ShellConnection(reader, writer, shell, window_size_changed_callback, loop)
|
||||
|
||||
return AsyncioTelnetServer(binary=True, echo=True, naws=True, connection_factory=factory)
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
# or negative for a release candidate or beta (after the base version
|
||||
# number has been incremented)
|
||||
|
||||
__version__ = "2.1.12"
|
||||
__version_info__ = (2, 1, 12, 0)
|
||||
__version__ = "2.1.18"
|
||||
__version_info__ = (2, 1, 18, 0)
|
||||
|
||||
# If it's a git checkout try to add the commit
|
||||
if "dev" in __version__:
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
jsonschema>=2.4.0
|
||||
jsonschema==2.6.0
|
||||
aiohttp>=2.3.3,<2.4.0 # pyup: ignore
|
||||
aiohttp-cors>=0.5.3,<0.6.0 # pyup: ignore
|
||||
yarl>=0.11
|
||||
@@ -8,4 +8,4 @@ psutil>=3.0.0
|
||||
zipstream>=1.1.4
|
||||
typing>=3.5.3.0 # Otherwise yarl fails with python 3.4
|
||||
prompt-toolkit==1.0.15
|
||||
async-timeout<3.0.0 # pyup: ignore; 3.0 drops support for python 3.4
|
||||
async-timeout<3.0.0 # pyup: ignore; 3.0 drops support for python 3.4
|
||||
@@ -116,6 +116,7 @@ def test_is_running(vm, running_subprocess_mock):
|
||||
|
||||
|
||||
def test_start(loop, vm, running_subprocess_mock):
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
with asyncio_patch("gns3server.compute.qemu.QemuVM.start_wrap_console"):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=running_subprocess_mock) as mock:
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.start()))
|
||||
@@ -130,6 +131,7 @@ def test_stop(loop, vm, running_subprocess_mock):
|
||||
future = asyncio.Future()
|
||||
future.set_result(True)
|
||||
process.wait.return_value = future
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
|
||||
with asyncio_patch("gns3server.compute.qemu.QemuVM.start_wrap_console"):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=process):
|
||||
@@ -213,6 +215,7 @@ def test_port_remove_nio_binding(vm, loop):
|
||||
|
||||
|
||||
def test_close(vm, port_manager, loop):
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
with asyncio_patch("gns3server.compute.qemu.QemuVM.start_wrap_console"):
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()):
|
||||
loop.run_until_complete(asyncio.ensure_future(vm.start()))
|
||||
@@ -338,6 +341,7 @@ def test_disk_options(vm, tmpdir, loop, fake_qemu_img_binary):
|
||||
|
||||
def test_cdrom_option(vm, tmpdir, loop, fake_qemu_img_binary):
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
vm._cdrom_image = str(tmpdir / "test.iso")
|
||||
open(vm._cdrom_image, "w+").close()
|
||||
|
||||
@@ -348,6 +352,7 @@ def test_cdrom_option(vm, tmpdir, loop, fake_qemu_img_binary):
|
||||
|
||||
def test_bios_option(vm, tmpdir, loop, fake_qemu_img_binary):
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
vm._bios_image = str(tmpdir / "test.img")
|
||||
open(vm._bios_image, "w+").close()
|
||||
|
||||
@@ -454,6 +459,7 @@ def test_control_vm_expect_text(vm, loop, running_subprocess_mock):
|
||||
|
||||
def test_build_command(vm, loop, fake_qemu_binary, port_manager):
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
os.environ["DISPLAY"] = "0:0"
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
cmd = loop.run_until_complete(asyncio.ensure_future(vm._build_command()))
|
||||
@@ -477,7 +483,9 @@ def test_build_command(vm, loop, fake_qemu_binary, port_manager):
|
||||
"-device",
|
||||
"e1000,mac={},netdev=gns3-0".format(vm._mac_address),
|
||||
"-netdev",
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport)
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport),
|
||||
"-display",
|
||||
"none"
|
||||
]
|
||||
|
||||
|
||||
@@ -486,6 +494,7 @@ def test_build_command_manual_uuid(vm, loop, fake_qemu_binary, port_manager):
|
||||
If user has set a uuid we keep it
|
||||
"""
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
vm.options = "-uuid e1c307a4-896f-11e6-81a5-3c07547807cc"
|
||||
os.environ["DISPLAY"] = "0:0"
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
@@ -524,7 +533,8 @@ def test_build_command_kvm(linux_platform, vm, loop, fake_qemu_binary, port_mana
|
||||
"-device",
|
||||
"e1000,mac={},netdev=gns3-0".format(vm._mac_address),
|
||||
"-netdev",
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport)
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport),
|
||||
"-nographic"
|
||||
]
|
||||
|
||||
|
||||
@@ -560,13 +570,52 @@ def test_build_command_kvm_2_4(linux_platform, vm, loop, fake_qemu_binary, port_
|
||||
"-device",
|
||||
"e1000,mac={},netdev=gns3-0".format(vm._mac_address),
|
||||
"-netdev",
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport)
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport),
|
||||
"-nographic"
|
||||
]
|
||||
|
||||
|
||||
def test_build_command_kvm_3_1(linux_platform, vm, loop, fake_qemu_binary, port_manager):
|
||||
"""
|
||||
Qemu 2.4 introduce an issue with KVM
|
||||
"""
|
||||
vm._run_with_kvm = MagicMock(return_value=True)
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="3.1.0")
|
||||
os.environ["DISPLAY"] = "0:0"
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
cmd = loop.run_until_complete(asyncio.ensure_future(vm._build_command()))
|
||||
nio = vm._local_udp_tunnels[0][0]
|
||||
assert cmd == [
|
||||
fake_qemu_binary,
|
||||
"-name",
|
||||
"test",
|
||||
"-m",
|
||||
"256M",
|
||||
"-smp",
|
||||
"cpus=1",
|
||||
"-enable-kvm",
|
||||
"-machine",
|
||||
"smm=off",
|
||||
"-boot",
|
||||
"order=c",
|
||||
"-uuid",
|
||||
vm.id,
|
||||
"-serial",
|
||||
"telnet:127.0.0.1:{},server,nowait".format(vm._internal_console_port),
|
||||
"-net",
|
||||
"none",
|
||||
"-device",
|
||||
"e1000,mac={},netdev=gns3-0".format(vm._mac_address),
|
||||
"-netdev",
|
||||
"socket,id=gns3-0,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio.rport, nio.lport),
|
||||
"-display",
|
||||
"none"
|
||||
]
|
||||
|
||||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows")
|
||||
def test_build_command_without_display(vm, loop, fake_qemu_binary):
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.5.0")
|
||||
os.environ["DISPLAY"] = ""
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
cmd = loop.run_until_complete(asyncio.ensure_future(vm._build_command()))
|
||||
@@ -575,6 +624,7 @@ def test_build_command_without_display(vm, loop, fake_qemu_binary):
|
||||
|
||||
def test_build_command_two_adapters(vm, loop, fake_qemu_binary, port_manager):
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.5.0")
|
||||
os.environ["DISPLAY"] = "0:0"
|
||||
vm.adapters = 2
|
||||
with asyncio_patch("asyncio.create_subprocess_exec", return_value=MagicMock()) as process:
|
||||
@@ -604,7 +654,8 @@ def test_build_command_two_adapters(vm, loop, fake_qemu_binary, port_manager):
|
||||
"-device",
|
||||
"e1000,mac={},netdev=gns3-1".format(int_to_macaddress(macaddress_to_int(vm._mac_address) + 1)),
|
||||
"-netdev",
|
||||
"socket,id=gns3-1,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio2.rport, nio2.lport)
|
||||
"socket,id=gns3-1,udp=127.0.0.1:{},localaddr=127.0.0.1:{}".format(nio2.rport, nio2.lport),
|
||||
"-nographic"
|
||||
]
|
||||
|
||||
|
||||
@@ -613,6 +664,7 @@ def test_build_command_two_adapters_mac_address(vm, loop, fake_qemu_binary, port
|
||||
Should support multiple base vmac address
|
||||
"""
|
||||
|
||||
vm.manager.get_qemu_version = AsyncioMagicMock(return_value="2.5.0")
|
||||
vm.adapters = 2
|
||||
vm.mac_address = "00:00:ab:0e:0f:09"
|
||||
mac_0 = vm._mac_address
|
||||
|
||||
@@ -75,14 +75,13 @@ def test_create_node_from_appliance(http_controller, controller, project, comput
|
||||
"name": "test",
|
||||
"symbol": "guest.svg",
|
||||
"default_name_format": "{name}-{0}",
|
||||
"server": "example.com"
|
||||
"compute_id": "example.com"
|
||||
})}
|
||||
with asyncio_patch("gns3server.controller.project.Project.add_node_from_appliance") as mock:
|
||||
with asyncio_patch("gns3server.controller.project.Project.add_node_from_appliance", return_value={"name": "test", "node_type": "qemu", "compute_id": "example.com"}) as mock:
|
||||
response = http_controller.post("/projects/{}/appliances/{}".format(project.id, id), {
|
||||
"x": 42,
|
||||
"y": 12
|
||||
})
|
||||
mock.assert_called_with(id, x=42, y=12, compute_id=None)
|
||||
print(response.body)
|
||||
assert response.route == "/projects/{project_id}/appliances/{appliance_id}"
|
||||
assert response.status == 201
|
||||
Reference in new issue
Block a user