mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Default preferences for remote servers.
This commit is contained in:
parent
7c99ee9de8
commit
551b98880b
@ -27,6 +27,7 @@ import shutil
|
|||||||
import glob
|
import glob
|
||||||
import socket
|
import socket
|
||||||
from gns3server.modules import IModule
|
from gns3server.modules import IModule
|
||||||
|
from gns3server.config import Config
|
||||||
|
|
||||||
from .hypervisor import Hypervisor
|
from .hypervisor import Hypervisor
|
||||||
from .hypervisor_manager import HypervisorManager
|
from .hypervisor_manager import HypervisorManager
|
||||||
@ -104,8 +105,27 @@ class Dynamips(IModule):
|
|||||||
|
|
||||||
def __init__(self, name, *args, **kwargs):
|
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 = None
|
||||||
self._hypervisor_manager_settings = {}
|
self._hypervisor_manager_settings = {}
|
||||||
self._routers = {}
|
self._routers = {}
|
||||||
@ -116,7 +136,6 @@ class Dynamips(IModule):
|
|||||||
self._projects_dir = kwargs["projects_dir"]
|
self._projects_dir = kwargs["projects_dir"]
|
||||||
self._tempdir = kwargs["temp_dir"]
|
self._tempdir = kwargs["temp_dir"]
|
||||||
self._working_dir = self._projects_dir
|
self._working_dir = self._projects_dir
|
||||||
self._dynamips = ""
|
|
||||||
self._host = kwargs["host"]
|
self._host = kwargs["host"]
|
||||||
|
|
||||||
if not sys.platform.startswith("win32"):
|
if not sys.platform.startswith("win32"):
|
||||||
@ -278,6 +297,7 @@ class Dynamips(IModule):
|
|||||||
|
|
||||||
Optional request parameters:
|
Optional request parameters:
|
||||||
- working_dir (path to a working directory)
|
- working_dir (path to a working directory)
|
||||||
|
- project_name
|
||||||
|
|
||||||
:param request: JSON request
|
:param request: JSON request
|
||||||
"""
|
"""
|
||||||
@ -450,8 +470,12 @@ class Dynamips(IModule):
|
|||||||
ghost.ghost_status = 1
|
ghost.ghost_status = 1
|
||||||
ghost.ghost_file = ghost_instance
|
ghost.ghost_file = ghost_instance
|
||||||
ghost.ram = router.ram
|
ghost.ram = router.ram
|
||||||
|
try:
|
||||||
ghost.start()
|
ghost.start()
|
||||||
ghost.stop()
|
ghost.stop()
|
||||||
|
except DynamipsError:
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
ghost.clean_delete()
|
ghost.clean_delete()
|
||||||
|
|
||||||
if router.ghost_file != ghost_instance:
|
if router.ghost_file != ghost_instance:
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
Manages Dynamips hypervisors (load-balancing etc.)
|
Manages Dynamips hypervisors (load-balancing etc.)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from gns3server.config import Config
|
||||||
from .hypervisor import Hypervisor
|
from .hypervisor import Hypervisor
|
||||||
from .dynamips_error import DynamipsError
|
from .dynamips_error import DynamipsError
|
||||||
from ..attic import find_unused_port
|
from ..attic import find_unused_port
|
||||||
@ -47,21 +48,24 @@ class HypervisorManager(object):
|
|||||||
self._path = path
|
self._path = path
|
||||||
self._working_dir = working_dir
|
self._working_dir = working_dir
|
||||||
self._host = host
|
self._host = host
|
||||||
self._hypervisor_start_port_range = 7200
|
|
||||||
self._hypervisor_end_port_range = 7700
|
config = Config.instance()
|
||||||
self._console_start_port_range = 2001
|
dynamips_config = config.get_section_config("DYNAMIPS")
|
||||||
self._console_end_port_range = 2500
|
self._hypervisor_start_port_range = dynamips_config.get("hypervisor_start_port_range", 7200)
|
||||||
self._aux_start_port_range = 2501
|
self._hypervisor_end_port_range = dynamips_config.get("hypervisor_end_port_range", 7700)
|
||||||
self._aux_end_port_range = 3000
|
self._console_start_port_range = dynamips_config.get("console_start_port_range", 2001)
|
||||||
self._udp_start_port_range = 10001
|
self._console_end_port_range = dynamips_config.get("console_end_port_range", 2500)
|
||||||
self._udp_end_port_range = 20000
|
self._aux_start_port_range = dynamips_config.get("aux_start_port_range", 2501)
|
||||||
self._ghost_ios_support = True
|
self._aux_end_port_range = dynamips_config.get("aux_end_port_range", 3000)
|
||||||
self._mmap_support = True
|
self._udp_start_port_range = dynamips_config.get("udp_start_port_range", 10001)
|
||||||
self._jit_sharing_support = False
|
self._udp_end_port_range = dynamips_config.get("udp_end_port_range", 20000)
|
||||||
self._sparse_memory_support = True
|
self._ghost_ios_support = dynamips_config.get("ghost_ios_support", True)
|
||||||
self._allocate_hypervisor_per_device = True
|
self._mmap_support = dynamips_config.get("mmap_support", True)
|
||||||
self._memory_usage_limit_per_hypervisor = 1024
|
self._jit_sharing_support = dynamips_config.get("jit_sharing_support", False)
|
||||||
self._allocate_hypervisor_per_ios_image = True
|
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):
|
def __del__(self):
|
||||||
"""
|
"""
|
||||||
|
@ -774,6 +774,9 @@ class Router(object):
|
|||||||
:param idlepc: idlepc value (string)
|
:param idlepc: idlepc value (string)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if not idlepc:
|
||||||
|
idlepc = "0x0"
|
||||||
|
|
||||||
if not self.is_running():
|
if not self.is_running():
|
||||||
# router is not running
|
# router is not running
|
||||||
self._hypervisor.send("vm set_idle_pc {name} {idlepc}".format(name=self._name,
|
self._hypervisor.send("vm set_idle_pc {name} {idlepc}".format(name=self._name,
|
||||||
|
@ -202,8 +202,7 @@ VM_UPDATE_SCHEMA = {
|
|||||||
"idlepc": {
|
"idlepc": {
|
||||||
"description": "idle-pc value",
|
"description": "idle-pc value",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"minLength": 1,
|
"pattern": "^(0x[0-9a-fA-F]+)?$"
|
||||||
"pattern": "^0x[0-9a-fA-F]+$"
|
|
||||||
},
|
},
|
||||||
"idlemax": {
|
"idlemax": {
|
||||||
"description": "idlemax value",
|
"description": "idlemax value",
|
||||||
|
@ -66,7 +66,7 @@ class IOU(IModule):
|
|||||||
# get the iouyap location
|
# get the iouyap location
|
||||||
config = Config.instance()
|
config = Config.instance()
|
||||||
iou_config = config.get_section_config(name.upper())
|
iou_config = config.get_section_config(name.upper())
|
||||||
self._iouyap = iou_config.get("iouyap")
|
self._iouyap = iou_config.get("iouyap_path")
|
||||||
if not self._iouyap or not os.path.isfile(self._iouyap):
|
if not self._iouyap or not os.path.isfile(self._iouyap):
|
||||||
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
||||||
# look for iouyap in the current working directory and $PATH
|
# look for iouyap in the current working directory and $PATH
|
||||||
@ -86,11 +86,11 @@ class IOU(IModule):
|
|||||||
# a new process start when calling IModule
|
# a new process start when calling IModule
|
||||||
IModule.__init__(self, name, *args, **kwargs)
|
IModule.__init__(self, name, *args, **kwargs)
|
||||||
self._iou_instances = {}
|
self._iou_instances = {}
|
||||||
self._console_start_port_range = 4001
|
self._console_start_port_range = iou_config.get("console_start_port_range", 4001)
|
||||||
self._console_end_port_range = 4512
|
self._console_end_port_range = iou_config.get("console_end_port_range", 4512)
|
||||||
self._allocated_udp_ports = []
|
self._allocated_udp_ports = []
|
||||||
self._udp_start_port_range = 30001
|
self._udp_start_port_range = iou_config.get("udp_start_port_range", 30001)
|
||||||
self._udp_end_port_range = 40001
|
self._udp_end_port_range = iou_config.get("udp_end_port_range", 40001)
|
||||||
self._host = kwargs["host"]
|
self._host = kwargs["host"]
|
||||||
self._projects_dir = kwargs["projects_dir"]
|
self._projects_dir = kwargs["projects_dir"]
|
||||||
self._tempdir = kwargs["temp_dir"]
|
self._tempdir = kwargs["temp_dir"]
|
||||||
|
@ -61,7 +61,7 @@ class VPCS(IModule):
|
|||||||
# get the VPCS location
|
# get the VPCS location
|
||||||
config = Config.instance()
|
config = Config.instance()
|
||||||
vpcs_config = config.get_section_config(name.upper())
|
vpcs_config = config.get_section_config(name.upper())
|
||||||
self._vpcs = vpcs_config.get("vpcs")
|
self._vpcs = vpcs_config.get("vpcs_path")
|
||||||
if not self._vpcs or not os.path.isfile(self._vpcs):
|
if not self._vpcs or not os.path.isfile(self._vpcs):
|
||||||
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
paths = [os.getcwd()] + os.environ["PATH"].split(":")
|
||||||
# look for VPCS in the current working directory and $PATH
|
# look for VPCS in the current working directory and $PATH
|
||||||
@ -81,11 +81,11 @@ class VPCS(IModule):
|
|||||||
# a new process start when calling IModule
|
# a new process start when calling IModule
|
||||||
IModule.__init__(self, name, *args, **kwargs)
|
IModule.__init__(self, name, *args, **kwargs)
|
||||||
self._vpcs_instances = {}
|
self._vpcs_instances = {}
|
||||||
self._console_start_port_range = 4512
|
self._console_start_port_range = vpcs_config.get("console_start_port_range", 4512)
|
||||||
self._console_end_port_range = 5000
|
self._console_end_port_range = vpcs_config.get("console_end_port_range", 5000)
|
||||||
self._allocated_udp_ports = []
|
self._allocated_udp_ports = []
|
||||||
self._udp_start_port_range = 40001
|
self._udp_start_port_range = vpcs_config.get("udp_start_port_range", 40001)
|
||||||
self._udp_end_port_range = 40512
|
self._udp_end_port_range = vpcs_config.get("udp_end_port_range", 40512)
|
||||||
self._host = kwargs["host"]
|
self._host = kwargs["host"]
|
||||||
self._projects_dir = kwargs["projects_dir"]
|
self._projects_dir = kwargs["projects_dir"]
|
||||||
self._tempdir = kwargs["temp_dir"]
|
self._tempdir = kwargs["temp_dir"]
|
||||||
|
Loading…
Reference in New Issue
Block a user