Ejemplo n.º 1
0
    def load(self) -> None:
        try:
            self.core.create_nodes_and_links()
            service = self.core.config_services[self.service_name]
            self.dependencies = service.dependencies[:]
            self.executables = service.executables[:]
            self.directories = service.directories[:]
            self.templates = service.files[:]
            self.startup_commands = service.startup[:]
            self.validation_commands = service.validate[:]
            self.shutdown_commands = service.shutdown[:]
            self.validation_mode = service.validation_mode
            self.validation_time = service.validation_timer
            self.validation_period.set(service.validation_period)

            response = self.core.client.get_config_service_defaults(self.service_name)
            self.original_service_files = response.templates
            self.temp_service_files = dict(self.original_service_files)
            self.modes = sorted(x.name for x in response.modes)
            self.mode_configs = {x.name: x.config for x in response.modes}
            self.config = ConfigOption.from_dict(response.config)
            self.default_config = {x.name: x.value for x in self.config.values()}
            service_config = self.node.config_service_configs.get(self.service_name)
            if service_config:
                for key, value in service_config.config.items():
                    self.config[key].value = value
                logging.info("default config: %s", self.default_config)
                for file, data in service_config.templates.items():
                    self.modified_files.add(file)
                    self.temp_service_files[file] = data
        except grpc.RpcError as e:
            self.app.show_grpc_exception("Get Config Service Error", e)
            self.has_error = True
Ejemplo n.º 2
0
 def get_mobility_config(self, node_id: int) -> Dict[str, ConfigOption]:
     response = self.client.get_mobility_config(self.session.id, node_id)
     config = response.config
     logging.debug(
         "get mobility config from node %s, result configuration: %s",
         node_id,
         config,
     )
     return ConfigOption.from_dict(config)
Ejemplo n.º 3
0
 def get_config(self) -> Dict[str, ConfigOption]:
     try:
         session_id = self.app.core.session.id
         response = self.app.core.client.get_session_options(session_id)
         return ConfigOption.from_dict(response.config)
     except grpc.RpcError as e:
         self.app.show_grpc_exception("Get Session Options Error", e)
         self.has_error = True
         self.destroy()
Ejemplo n.º 4
0
 def get_wlan_configs_proto(self) -> List[wlan_pb2.WlanConfig]:
     configs = []
     for node in self.session.nodes.values():
         if node.type != NodeType.WIRELESS_LAN:
             continue
         if not node.wlan_config:
             continue
         config = ConfigOption.to_dict(node.wlan_config)
         wlan_config = wlan_pb2.WlanConfig(node_id=node.id, config=config)
         configs.append(wlan_config)
     return configs
Ejemplo n.º 5
0
 def get_mobility_configs_proto(self) -> List[mobility_pb2.MobilityConfig]:
     configs = []
     for node in self.session.nodes.values():
         if not NodeUtils.is_mobility(node):
             continue
         if not node.mobility_config:
             continue
         config = ConfigOption.to_dict(node.mobility_config)
         mobility_config = mobility_pb2.MobilityConfig(node_id=node.id,
                                                       config=config)
         configs.append(mobility_config)
     return configs
Ejemplo n.º 6
0
 def get_emane_model_configs_proto(
         self) -> List[emane_pb2.EmaneModelConfig]:
     configs = []
     for node in self.session.nodes.values():
         if node.type != NodeType.EMANE:
             continue
         for key, config in node.emane_model_configs.items():
             model, iface_id = key
             config = ConfigOption.to_dict(config)
             if iface_id is None:
                 iface_id = -1
             config_proto = emane_pb2.EmaneModelConfig(node_id=node.id,
                                                       iface_id=iface_id,
                                                       model=model,
                                                       config=config)
             configs.append(config_proto)
     return configs
Ejemplo n.º 7
0
 def get_emane_model_config(
         self,
         node_id: int,
         model: str,
         iface_id: int = None) -> Dict[str, ConfigOption]:
     if iface_id is None:
         iface_id = -1
     response = self.client.get_emane_model_config(self.session.id, node_id,
                                                   model, iface_id)
     config = response.config
     logging.debug(
         "get emane model config: node id: %s, EMANE model: %s, "
         "interface: %s, config: %s",
         node_id,
         model,
         iface_id,
         config,
     )
     return ConfigOption.from_dict(config)