mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Drop Windows support
This commit is contained in:
1 parent
4fb0cd9321
commit
74c675d5b0
47 files changed
+223
-1004
No files matched your search
@@ -348,23 +348,10 @@ class Dynamips(BaseManager):
|
||||
nio.suspend = nio_settings.get("suspend", False)
|
||||
elif nio_settings["type"] == "nio_generic_ethernet":
|
||||
ethernet_device = nio_settings["ethernet_device"]
|
||||
if sys.platform.startswith("win"):
|
||||
# replace the interface name by the GUID on Windows
|
||||
windows_interfaces = interfaces()
|
||||
npf_interface = None
|
||||
for interface in windows_interfaces:
|
||||
if interface["name"] == ethernet_device:
|
||||
npf_interface = interface["id"]
|
||||
if not npf_interface:
|
||||
raise DynamipsError(f"Could not find interface {ethernet_device} on this host")
|
||||
else:
|
||||
ethernet_device = npf_interface
|
||||
if not is_interface_up(ethernet_device):
|
||||
raise DynamipsError(f"Ethernet interface {ethernet_device} is down")
|
||||
nio = NIOGenericEthernet(node.hypervisor, ethernet_device)
|
||||
elif nio_settings["type"] == "nio_linux_ethernet":
|
||||
if sys.platform.startswith("win"):
|
||||
raise DynamipsError("This NIO type is not supported on Windows")
|
||||
ethernet_device = nio_settings["ethernet_device"]
|
||||
nio = NIOLinuxEthernet(node.hypervisor, ethernet_device)
|
||||
elif nio_settings["type"] == "nio_tap":
|
||||
@@ -564,7 +551,6 @@ class Dynamips(BaseManager):
|
||||
|
||||
await vm.set_idlepc("0x0")
|
||||
was_auto_started = False
|
||||
old_priority = None
|
||||
try:
|
||||
status = await vm.get_status()
|
||||
if status != "running":
|
||||
@@ -576,8 +562,6 @@ class Dynamips(BaseManager):
|
||||
if not idlepcs:
|
||||
raise DynamipsError("No Idle-PC values found")
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
old_priority = vm.set_process_priority_windows(vm.hypervisor.process.pid)
|
||||
for idlepc in idlepcs:
|
||||
match = re.search(r"^0x[0-9a-f]{8}$", idlepc.split()[0])
|
||||
if not match:
|
||||
@@ -606,8 +590,6 @@ class Dynamips(BaseManager):
|
||||
except DynamipsError:
|
||||
raise
|
||||
finally:
|
||||
if old_priority is not None:
|
||||
vm.set_process_priority_windows(vm.hypervisor.process.pid, old_priority)
|
||||
if was_auto_started:
|
||||
await vm.stop()
|
||||
return validated_idlepc
|
||||
|
||||
@@ -118,11 +118,6 @@ class Hypervisor(DynamipsHypervisor):
|
||||
|
||||
self._command = self._build_command()
|
||||
env = os.environ.copy()
|
||||
if sys.platform.startswith("win"):
|
||||
# add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if installed)
|
||||
system_root = os.path.join(os.path.expandvars("%SystemRoot%"), "System32", "Npcap")
|
||||
if os.path.isdir(system_root):
|
||||
env["PATH"] = system_root + ";" + env["PATH"]
|
||||
try:
|
||||
log.info(f"Starting Dynamips: {self._command}")
|
||||
self._stdout_file = os.path.join(self.working_dir, f"dynamips_i{self._id}_stdout.txt")
|
||||
|
||||
@@ -103,10 +103,7 @@ class Router(BaseNode):
|
||||
self._idlesleep = 30
|
||||
self._ghost_file = ""
|
||||
self._ghost_status = 0
|
||||
if sys.platform.startswith("win"):
|
||||
self._exec_area = 16 # 16 MB by default on Windows (Cygwin)
|
||||
else:
|
||||
self._exec_area = 64 # 64 MB on other systems
|
||||
self._exec_area = 64
|
||||
self._disk0 = 0 # Megabytes
|
||||
self._disk1 = 0 # Megabytes
|
||||
self._auto_delete_disks = False
|
||||
@@ -711,29 +708,6 @@ class Router(BaseNode):
|
||||
log.info(f'Router "{self._name}" [{self._id}]: idle-PC set to {idlepc}')
|
||||
self._idlepc = idlepc
|
||||
|
||||
def set_process_priority_windows(self, pid, priority=None):
|
||||
"""
|
||||
Sets process priority on Windows
|
||||
|
||||
:param pid: process PID
|
||||
"""
|
||||
|
||||
import win32api
|
||||
import win32process
|
||||
import win32con
|
||||
import pywintypes
|
||||
|
||||
old_priority = None
|
||||
try:
|
||||
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
|
||||
old_priority = win32process.GetPriorityClass(handle)
|
||||
if priority is None:
|
||||
priority = win32process.BELOW_NORMAL_PRIORITY_CLASS
|
||||
win32process.SetPriorityClass(handle, priority)
|
||||
except pywintypes.error as e:
|
||||
log.error(f"Cannot set priority for Dynamips process (PID={pid}) ")
|
||||
return old_priority
|
||||
|
||||
async def get_idle_pc_prop(self):
|
||||
"""
|
||||
Gets the idle PC proposals.
|
||||
@@ -751,13 +725,8 @@ class Router(BaseNode):
|
||||
await asyncio.sleep(20) # leave time to the router to boot
|
||||
|
||||
log.info(f'Router "{self._name}" [{self._id}] has started calculating Idle-PC values')
|
||||
old_priority = None
|
||||
if sys.platform.startswith("win"):
|
||||
old_priority = self.set_process_priority_windows(self._hypervisor.process.pid)
|
||||
begin = time.time()
|
||||
idlepcs = await self._hypervisor.send(f'vm get_idle_pc_prop "{self._name}" 0')
|
||||
if old_priority is not None:
|
||||
self.set_process_priority_windows(self._hypervisor.process.pid, old_priority)
|
||||
log.info(
|
||||
'Router "{name}" [{id}] has finished calculating Idle-PC values after {time:.4f} seconds'.format(
|
||||
name=self._name, id=self._id, time=time.time() - begin
|
||||
|
||||
Reference in new issue
Block a user