def start(cls, config_path: str = CONFIG_PATH) -> None: """ Starts the runtime server with all components :param config_path: Path to an alternative config directory """ cls.CONFIG_PATH = config_path # set the config_path at the manager ConfigManager.set_config_path(config_path) # read from config the Vlan mode vlan_activate = ConfigManager.get_server_property("Vlan_On") cls.VLAN = vlan_activate # read from config if debug mode is on log_level = ConfigManager.get_server_property("Log_Level") debug_mode = False if log_level is 10: debug_mode = True cls.DEBUG = debug_mode # load Router configs cls.__load_configuration() if cls.VLAN: from util.router_info import RouterInfo # TODO: Die Funktion 'cls.update_router_info' sollte verwendet werden RouterInfo.update(cls.get_routers()[0]) print("Runtime Server started") cls._ipc_server.start_ipc_server( cls, True) # serves forever - works like a while(true)
def start(cls, config_path: str = CONFIG_PATH) -> None: """ Starts the runtime server with all components :param config_path: Path to an alternative config directory """ cls.CONFIG_PATH = config_path # set the config_path at the manager ConfigManager.set_config_path(config_path) # read from config the Vlan mode vlan_activate = ConfigManager.get_server_property("Vlan_On") cls.VLAN = vlan_activate # read from config if debug mode is on log_level = int(ConfigManager.get_server_property("Log_Level")) debug_mode = False if log_level is 10: debug_mode = True cls.DEBUG = debug_mode # create instance and give params to the logger object Logger().setup(log_level, log_level, log_level) # load Router configs cls.__load_configuration() if cls.VLAN: from util.router_info import RouterInfo # TODO: Die Funktion 'cls.update_router_info' sollte verwendet werden RouterInfo.update(cls.get_routers()[0]) print("Runtime Server started") cls._ipc_server.start_ipc_server(cls, True) # serves forever - works like a while(true)
def update_router_info(cls, router_ids: List[int], update_all: bool) -> None: """ Updates all the information about the :py:class:`Router` :param router_ids: List of unique numbers to identify a :py:class:`Router` :param update_all: Is True if all Routers should be updated """ from util.router_info import RouterInfo if update_all: for router in cls.get_routers(): RouterInfo.update(router) else: for router_id in router_ids: router = cls.get_router_by_id(router_id) RouterInfo.update(router)
def test_router_info(self): print("Test Router_Info") router = self._create_router() # NVAssisten nv_assist = NVAssistent("eth0") nv_assist.create_namespace_vlan(router) # Set netns for the current process netns.setns(router.namespace_name) print("Get informations via ssh-commands ...") router_info = RouterInfo(router) router_info.start() router_info.join() print(str(router)) # Close Namespaces and VLANs nv_assist.close()
def test_router_info(self): # Create router router = Router(1, "vlan1", 21, "10.223.254.254", 16, "192.168.1.1", 24, "root", "root", 1) router.model = "TP-LINK TL-WR841N/ND v9" router.mac = "e8:de:27:b7:7c:e2" router.mode = Mode.normal router_info = RouterInfo(router) router_info.start() router_info.join()