mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 07:11:13 +02:00
Merge branch '2.0' into 2.1
This commit is contained in:
18 files changed
+184
-30
No files matched your search
@@ -19,14 +19,16 @@
|
||||
VirtualBox VM instance.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import shlex
|
||||
import re
|
||||
import os
|
||||
import tempfile
|
||||
import sys
|
||||
import json
|
||||
import uuid
|
||||
import shlex
|
||||
import shutil
|
||||
import socket
|
||||
import asyncio
|
||||
import tempfile
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from gns3server.utils import parse_version
|
||||
@@ -209,7 +211,16 @@ class VirtualBoxVM(BaseNode):
|
||||
if os.path.exists(self._linked_vbox_file()):
|
||||
tree = ET.parse(self._linked_vbox_file())
|
||||
machine = tree.getroot().find("{http://www.virtualbox.org/}Machine")
|
||||
if machine is not None:
|
||||
if machine is not None and machine.get("uuid") != "{" + self.id + "}":
|
||||
|
||||
for image in tree.getroot().findall("{http://www.virtualbox.org/}Image"):
|
||||
currentSnapshot = machine.get("currentSnapshot")
|
||||
if currentSnapshot:
|
||||
newSnapshot = re.sub("\{.*\}", "{" + str(uuid.uuid4()) + "}", currentSnapshot)
|
||||
shutil.move(os.path.join(self.working_dir, self._vmname, "Snapshots", currentSnapshot) + ".vdi",
|
||||
os.path.join(self.working_dir, self._vmname, "Snapshots", newSnapshot) + ".vdi")
|
||||
image.set("uuid", newSnapshot)
|
||||
|
||||
machine.set("uuid", "{" + self.id + "}")
|
||||
tree.write(self._linked_vbox_file())
|
||||
|
||||
|
||||
@@ -367,7 +367,8 @@ class Controller:
|
||||
return project
|
||||
|
||||
def remove_project(self, project):
|
||||
del self._projects[project.id]
|
||||
if project.id in self._projects:
|
||||
del self._projects[project.id]
|
||||
|
||||
@asyncio.coroutine
|
||||
def load_project(self, path, load=True):
|
||||
|
||||
@@ -136,6 +136,8 @@ def _export_project_file(project, path, z, include_images, keep_compute_id, allo
|
||||
if "topology" in topology:
|
||||
if "nodes" in topology["topology"]:
|
||||
for node in topology["topology"]["nodes"]:
|
||||
if node["node_type"] == "virtualbox" and node.get("properties", {}).get("linked_clone"):
|
||||
raise aiohttp.web.HTTPConflict(text="Topology with a linked {} clone could not be exported. Use qemu instead.".format(node["node_type"]))
|
||||
if not allow_all_nodes and node["node_type"] in ["virtualbox", "vmware", "cloud"]:
|
||||
raise aiohttp.web.HTTPConflict(text="Topology with a {} could not be exported".format(node["node_type"]))
|
||||
|
||||
|
||||
@@ -536,7 +536,7 @@ class Project:
|
||||
@asyncio.coroutine
|
||||
def close(self, ignore_notification=False):
|
||||
yield from self.stop_all()
|
||||
for compute in self._project_created_on_compute:
|
||||
for compute in list(self._project_created_on_compute):
|
||||
try:
|
||||
yield from compute.post("/projects/{}/close".format(self._id), dont_connect=True)
|
||||
# We don't care if a compute is down at this step
|
||||
|
||||
@@ -20,6 +20,7 @@ import os
|
||||
import uuid
|
||||
import shutil
|
||||
import asyncio
|
||||
import aiohttp.web
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
@@ -80,10 +81,13 @@ class Snapshot:
|
||||
# We don't send close notif to clients because the close / open dance is purely internal
|
||||
yield from self._project.close(ignore_notification=True)
|
||||
self._project.controller.notification.emit("snapshot.restored", self.__json__())
|
||||
if os.path.exists(os.path.join(self._project.path, "project-files")):
|
||||
shutil.rmtree(os.path.join(self._project.path, "project-files"))
|
||||
with open(self._path, "rb") as f:
|
||||
project = yield from import_project(self._project.controller, self._project.id, f, location=self._project.path)
|
||||
try:
|
||||
if os.path.exists(os.path.join(self._project.path, "project-files")):
|
||||
shutil.rmtree(os.path.join(self._project.path, "project-files"))
|
||||
with open(self._path, "rb") as f:
|
||||
project = yield from import_project(self._project.controller, self._project.id, f, location=self._project.path)
|
||||
except (OSError, PermissionError) as e:
|
||||
raise aiohttp.web.HTTPConflict(text=str(e))
|
||||
yield from project.open()
|
||||
return project
|
||||
|
||||
|
||||
@@ -321,10 +321,12 @@ def _convert_1_3_later(topo, topo_path):
|
||||
node["properties"]["ram"] = PLATFORMS_DEFAULT_RAM[old_node["type"].lower()]
|
||||
elif old_node["type"] == "VMwareVM":
|
||||
node["node_type"] = "vmware"
|
||||
node["properties"]["linked_clone"] = old_node.get("linked_clone", False)
|
||||
if node["symbol"] is None:
|
||||
node["symbol"] = ":/symbols/vmware_guest.svg"
|
||||
elif old_node["type"] == "VirtualBoxVM":
|
||||
node["node_type"] = "virtualbox"
|
||||
node["properties"]["linked_clone"] = old_node.get("linked_clone", False)
|
||||
if node["symbol"] is None:
|
||||
node["symbol"] = ":/symbols/vbox_guest.svg"
|
||||
elif old_node["type"] == "IOUDevice":
|
||||
|
||||
@@ -53,7 +53,7 @@ class CrashReport:
|
||||
Report crash to a third party service
|
||||
"""
|
||||
|
||||
DSN = "sync+https://b7430bad849c4b88b3a928032d6cce5e:f140bfdd2ebb4bf4b929c002b45b2357@sentry.io/38482"
|
||||
DSN = "sync+https://83564b27a6f6475488a3eb74c78f1760:ed5ac7c6d3f7428d960a84da98450b69@sentry.io/38482"
|
||||
if hasattr(sys, "frozen"):
|
||||
cacert = get_resource("cacert.pem")
|
||||
if cacert is not None and os.path.isfile(cacert):
|
||||
|
||||
@@ -34,6 +34,7 @@ class SerialReaderWriterProtocol(asyncio.Protocol):
|
||||
|
||||
def __init__(self):
|
||||
self._output = asyncio.StreamReader()
|
||||
self._closed = False
|
||||
self.transport = None
|
||||
|
||||
def read(self, n=-1):
|
||||
@@ -54,9 +55,11 @@ class SerialReaderWriterProtocol(asyncio.Protocol):
|
||||
self.transport = transport
|
||||
|
||||
def data_received(self, data):
|
||||
self._output.feed_data(data)
|
||||
if not self._closed:
|
||||
self._output.feed_data(data)
|
||||
|
||||
def close(self):
|
||||
self._closed = True
|
||||
self._output.feed_eof()
|
||||
|
||||
|
||||
|
||||
@@ -25,3 +25,14 @@
|
||||
|
||||
__version__ = "2.1.0dev1"
|
||||
__version_info__ = (2, 1, 0, -99)
|
||||
|
||||
# If it's a git checkout try to add the commit
|
||||
if "dev" in __version__:
|
||||
try:
|
||||
import os
|
||||
import subprocess
|
||||
if os.path.exists(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".git")):
|
||||
r = subprocess.run(["git", "rev-parse", "--short", "HEAD"], stdout=subprocess.PIPE).stdout.decode().strip("\n")
|
||||
__version__ += "-" + r
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Reference in new issue
Block a user