mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Default preferences for remote servers.
This commit is contained in:
1 parent
7c99ee9de8
commit
551b98880b
6 files changed
+62
-32
No files matched your search
@@ -27,6 +27,7 @@ import shutil
|
||||
import glob
|
||||
import socket
|
||||
from gns3server.modules import IModule
|
||||
from gns3server.config import Config
|
||||
|
||||
from .hypervisor import Hypervisor
|
||||
from .hypervisor_manager import HypervisorManager
|
||||
@@ -104,8 +105,27 @@ class Dynamips(IModule):
|
||||
|
||||
def __init__(self, name, *args, **kwargs):
|
||||
|
||||
IModule.__init__(self, name, *args, **kwargs)
|
||||
# get the Dynamips location
|
||||
config = Config.instance()
|
||||
dynamips_config = config.get_section_config(name.upper())
|
||||
self._dynamips = dynamips_config.get("dynamips_path")
|
||||
if not self._dynamips or not os.path.isfile(self._dynamips):
|
||||
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
||||
# look for Dynamips in the current working directory and $PATH
|
||||
for path in paths:
|
||||
try:
|
||||
if "dynamips" in os.listdir(path) and os.access(os.path.join(path, "dynamips"), os.X_OK):
|
||||
self._dynamips = os.path.join(path, "dynamips")
|
||||
break
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
if not self._dynamips:
|
||||
log.warning("dynamips binary couldn't be found!")
|
||||
elif not os.access(self._dynamips, os.X_OK):
|
||||
log.warning("dynamips is not executable")
|
||||
|
||||
IModule.__init__(self, name, *args, **kwargs)
|
||||
self._hypervisor_manager = None
|
||||
self._hypervisor_manager_settings = {}
|
||||
self._routers = {}
|
||||
@@ -116,7 +136,6 @@ class Dynamips(IModule):
|
||||
self._projects_dir = kwargs["projects_dir"]
|
||||
self._tempdir = kwargs["temp_dir"]
|
||||
self._working_dir = self._projects_dir
|
||||
self._dynamips = ""
|
||||
self._host = kwargs["host"]
|
||||
|
||||
if not sys.platform.startswith("win32"):
|
||||
@@ -278,6 +297,7 @@ class Dynamips(IModule):
|
||||
|
||||
Optional request parameters:
|
||||
- working_dir (path to a working directory)
|
||||
- project_name
|
||||
|
||||
:param request: JSON request
|
||||
"""
|
||||
@@ -450,9 +470,13 @@ class Dynamips(IModule):
|
||||
ghost.ghost_status = 1
|
||||
ghost.ghost_file = ghost_instance
|
||||
ghost.ram = router.ram
|
||||
ghost.start()
|
||||
ghost.stop()
|
||||
ghost.clean_delete()
|
||||
try:
|
||||
ghost.start()
|
||||
ghost.stop()
|
||||
except DynamipsError:
|
||||
raise
|
||||
finally:
|
||||
ghost.clean_delete()
|
||||
|
||||
if router.ghost_file != ghost_instance:
|
||||
# set the ghost file to the router
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
Manages Dynamips hypervisors (load-balancing etc.)
|
||||
"""
|
||||
|
||||
from gns3server.config import Config
|
||||
from .hypervisor import Hypervisor
|
||||
from .dynamips_error import DynamipsError
|
||||
from ..attic import find_unused_port
|
||||
@@ -47,21 +48,24 @@ class HypervisorManager(object):
|
||||
self._path = path
|
||||
self._working_dir = working_dir
|
||||
self._host = host
|
||||
self._hypervisor_start_port_range = 7200
|
||||
self._hypervisor_end_port_range = 7700
|
||||
self._console_start_port_range = 2001
|
||||
self._console_end_port_range = 2500
|
||||
self._aux_start_port_range = 2501
|
||||
self._aux_end_port_range = 3000
|
||||
self._udp_start_port_range = 10001
|
||||
self._udp_end_port_range = 20000
|
||||
self._ghost_ios_support = True
|
||||
self._mmap_support = True
|
||||
self._jit_sharing_support = False
|
||||
self._sparse_memory_support = True
|
||||
self._allocate_hypervisor_per_device = True
|
||||
self._memory_usage_limit_per_hypervisor = 1024
|
||||
self._allocate_hypervisor_per_ios_image = True
|
||||
|
||||
config = Config.instance()
|
||||
dynamips_config = config.get_section_config("DYNAMIPS")
|
||||
self._hypervisor_start_port_range = dynamips_config.get("hypervisor_start_port_range", 7200)
|
||||
self._hypervisor_end_port_range = dynamips_config.get("hypervisor_end_port_range", 7700)
|
||||
self._console_start_port_range = dynamips_config.get("console_start_port_range", 2001)
|
||||
self._console_end_port_range = dynamips_config.get("console_end_port_range", 2500)
|
||||
self._aux_start_port_range = dynamips_config.get("aux_start_port_range", 2501)
|
||||
self._aux_end_port_range = dynamips_config.get("aux_end_port_range", 3000)
|
||||
self._udp_start_port_range = dynamips_config.get("udp_start_port_range", 10001)
|
||||
self._udp_end_port_range = dynamips_config.get("udp_end_port_range", 20000)
|
||||
self._ghost_ios_support = dynamips_config.get("ghost_ios_support", True)
|
||||
self._mmap_support = dynamips_config.get("mmap_support", True)
|
||||
self._jit_sharing_support = dynamips_config.get("jit_sharing_support", False)
|
||||
self._sparse_memory_support = dynamips_config.get("sparse_memory_support", True)
|
||||
self._allocate_hypervisor_per_device = dynamips_config.get("allocate_hypervisor_per_device", True)
|
||||
self._memory_usage_limit_per_hypervisor = dynamips_config.get("memory_usage_limit_per_hypervisor", 1024)
|
||||
self._allocate_hypervisor_per_ios_image = dynamips_config.get("allocate_hypervisor_per_ios_image", True)
|
||||
|
||||
def __del__(self):
|
||||
"""
|
||||
|
||||
@@ -774,6 +774,9 @@ class Router(object):
|
||||
:param idlepc: idlepc value (string)
|
||||
"""
|
||||
|
||||
if not idlepc:
|
||||
idlepc = "0x0"
|
||||
|
||||
if not self.is_running():
|
||||
# router is not running
|
||||
self._hypervisor.send("vm set_idle_pc {name} {idlepc}".format(name=self._name,
|
||||
|
||||
@@ -202,8 +202,7 @@ VM_UPDATE_SCHEMA = {
|
||||
"idlepc": {
|
||||
"description": "idle-pc value",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"pattern": "^0x[0-9a-fA-F]+$"
|
||||
"pattern": "^(0x[0-9a-fA-F]+)?$"
|
||||
},
|
||||
"idlemax": {
|
||||
"description": "idlemax value",
|
||||
|
||||
Reference in new issue
Block a user