mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Merge branch 'master' into 1.5
This commit is contained in:
8 files changed
+102
-13
No files matched your search
@@ -37,6 +37,9 @@ class FileHandler:
|
||||
def read(request, response):
|
||||
response.enable_chunked_encoding()
|
||||
|
||||
if not request.json.get("location").endswith(".pcap"):
|
||||
raise aiohttp.web.HTTPForbidden(text="Only .pcap file are allowed")
|
||||
|
||||
try:
|
||||
with open(request.json.get("location"), "rb") as f:
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
@@ -41,6 +41,8 @@ from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS
|
||||
from ...utils.asyncio import monitor_process
|
||||
from ...utils.images import md5sum
|
||||
from .qcow2 import Qcow2, Qcow2Error
|
||||
from ...utils import macaddress_to_int, int_to_macaddress
|
||||
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -1326,7 +1328,7 @@ class QemuVM(BaseVM):
|
||||
patched_qemu = True
|
||||
|
||||
for adapter_number, adapter in enumerate(self._ethernet_adapters):
|
||||
mac = "%s%02x" % (self._mac_address[:-2], (int(self._mac_address[-2:]) + adapter_number) % 255)
|
||||
mac = int_to_macaddress(macaddress_to_int(self._mac_address) + adapter_number)
|
||||
nio = adapter.get_nio(0)
|
||||
if self._legacy_networking:
|
||||
# legacy QEMU networking syntax (-net)
|
||||
|
||||
@@ -618,7 +618,7 @@ class VMware(BaseManager):
|
||||
yield from self.check_vmware_version()
|
||||
|
||||
inventory_path = self.get_vmware_inventory_path()
|
||||
if os.path.exists(inventory_path) and self.host_type == "ws":
|
||||
if os.path.exists(inventory_path) and self.host_type != "player":
|
||||
# inventory may exist for VMware player if VMware workstation has been previously installed
|
||||
return self._get_vms_from_inventory(inventory_path)
|
||||
else:
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import textwrap
|
||||
import posixpath
|
||||
|
||||
|
||||
@@ -26,3 +27,20 @@ def force_unix_path(path):
|
||||
|
||||
path = path.replace("\\", "/")
|
||||
return posixpath.normpath(path)
|
||||
|
||||
|
||||
def macaddress_to_int(macaddress):
|
||||
"""
|
||||
Convert a macaddress with the format 00:0c:29:11:b0:0a to a int
|
||||
|
||||
:param macaddress: The mac address
|
||||
:returns: Integer
|
||||
"""
|
||||
return int(macaddress.replace(":", ""), 16)
|
||||
|
||||
|
||||
def int_to_macaddress(integer):
|
||||
"""
|
||||
Convert an integer to a macaddress
|
||||
"""
|
||||
return ":".join(textwrap.wrap("%012x" % (integer), width=2))
|
||||
Reference in new issue
Block a user