1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Option to deactivate using uBridge globally.

This commit is contained in:
grossmj 2016-06-24 15:04:58 -06:00
parent abfb51baa8
commit ce3276d374
2 changed files with 21 additions and 5 deletions

View File

@ -31,6 +31,7 @@ from ..ubridge.hypervisor import Hypervisor
from ..ubridge.ubridge_error import UbridgeError from ..ubridge.ubridge_error import UbridgeError
from .nios.nio_udp import NIOUDP from .nios.nio_udp import NIOUDP
from .error import NodeError from .error import NodeError
from ..config import Config
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -50,7 +51,7 @@ class BaseNode:
:param allocate_aux: Boolean if true will allocate an aux console port :param allocate_aux: Boolean if true will allocate an aux console port
""" """
def __init__(self, name, node_id, project, manager, console=None, console_type="telnet", aux=None, allocate_aux=False, use_ubridge=True): def __init__(self, name, node_id, project, manager, console=None, console_type="telnet", aux=None, allocate_aux=False):
self._name = name self._name = name
self._usage = "" self._usage = ""
@ -63,12 +64,15 @@ class BaseNode:
self._temporary_directory = None self._temporary_directory = None
self._hw_virtualization = False self._hw_virtualization = False
self._ubridge_hypervisor = None self._ubridge_hypervisor = None
self._use_ubridge = use_ubridge
self._closed = False self._closed = False
self._node_status = "stopped" self._node_status = "stopped"
self._command_line = "" self._command_line = ""
self._allocate_aux = allocate_aux self._allocate_aux = allocate_aux
# check if the node will use uBridge or not
server_config = Config.instance().get_section_config("Server")
self._use_ubridge = server_config.getboolean("use_ubridge")
if self._console is not None: if self._console is not None:
if console_type == "vnc": if console_type == "vnc":
self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project, port_range_start=5900, port_range_end=6000) self._console = self._manager.port_manager.reserve_tcp_port(self._console, self._project, port_range_start=5900, port_range_end=6000)
@ -102,7 +106,9 @@ class BaseNode:
@property @property
def status(self): def status(self):
"""Return current node status""" """
Returns current node status
"""
return self._node_status return self._node_status
@ -114,13 +120,15 @@ class BaseNode:
def updated(self): def updated(self):
""" """
Send a updated event Sends an updated event
""" """
self.project.emit("node.updated", self) self.project.emit("node.updated", self)
@property @property
def command_line(self): def command_line(self):
"""Return command used to start the node""" """
Returns command used to start the node
"""
return self._command_line return self._command_line

View File

@ -90,6 +90,7 @@ def parse_arguments(argv):
parser.add_argument("--port", help="run on the given port", type=int) parser.add_argument("--port", help="run on the given port", type=int)
parser.add_argument("--ssl", action="store_true", help="run in SSL mode") parser.add_argument("--ssl", action="store_true", help="run in SSL mode")
parser.add_argument("--controller", action="store_true", help="start as a GNS3 controller") parser.add_argument("--controller", action="store_true", help="start as a GNS3 controller")
parser.add_argument("--no-ubridge", action="store_false", help="do not use ubridge to handle node connections")
parser.add_argument("--config", help="Configuration file") parser.add_argument("--config", help="Configuration file")
parser.add_argument("--certfile", help="SSL cert file") parser.add_argument("--certfile", help="SSL cert file")
parser.add_argument("--certkey", help="SSL key file") parser.add_argument("--certkey", help="SSL key file")
@ -117,6 +118,7 @@ def parse_arguments(argv):
"record": config.get("record", ""), "record": config.get("record", ""),
"local": config.getboolean("local", False), "local": config.getboolean("local", False),
"controller": config.getboolean("controller", False), "controller": config.getboolean("controller", False),
"use_ubridge": config.getboolean("use_ubridge", True), # this enables uBridge globally
"allow": config.getboolean("allow_remote_console", False), "allow": config.getboolean("allow_remote_console", False),
"quiet": config.getboolean("quiet", False), "quiet": config.getboolean("quiet", False),
"debug": config.getboolean("debug", False), "debug": config.getboolean("debug", False),
@ -134,6 +136,7 @@ def set_config(args):
server_config = config.get_section_config("Server") server_config = config.get_section_config("Server")
server_config["local"] = str(args.local) server_config["local"] = str(args.local)
server_config["controller"] = str(args.controller) server_config["controller"] = str(args.controller)
server_config["use_ubridge"] = str(args.no_ubridge)
server_config["allow_remote_console"] = str(args.allow) server_config["allow_remote_console"] = str(args.allow)
server_config["host"] = args.host server_config["host"] = args.host
server_config["port"] = str(args.port) server_config["port"] = str(args.port)
@ -207,6 +210,11 @@ def run():
if server_config.getboolean("local"): if server_config.getboolean("local"):
log.warning("Local mode is enabled. Beware, clients will have full control on your filesystem") log.warning("Local mode is enabled. Beware, clients will have full control on your filesystem")
if server_config.getboolean("use_ubridge"):
log.info("uBridge will be used to handle node connections")
else:
log.warn("uBridge will NOT be used to handle node connections")
# we only support Python 3 version >= 3.4 # we only support Python 3 version >= 3.4
if sys.version_info < (3, 4): if sys.version_info < (3, 4):
raise SystemExit("Python 3.4 or higher is required") raise SystemExit("Python 3.4 or higher is required")