示例#1
0
 def to_proto(self) -> core_pb2.Node:
     emane_configs = []
     for key, config in self.emane_model_configs.items():
         model, iface_id = key
         if iface_id is None:
             iface_id = -1
         config = {k: v.to_proto() for k, v in config.items()}
         emane_config = emane_pb2.NodeEmaneConfig(iface_id=iface_id,
                                                  model=model,
                                                  config=config)
         emane_configs.append(emane_config)
     service_configs = {}
     for service, service_data in self.service_configs.items():
         service_configs[service] = services_pb2.NodeServiceConfig(
             service=service, data=service_data.to_proto())
     for service, file_configs in self.service_file_configs.items():
         service_config = service_configs.get(service)
         if service_config:
             service_config.files.update(file_configs)
         else:
             service_configs[service] = services_pb2.NodeServiceConfig(
                 service=service, files=file_configs)
     config_service_configs = {}
     for service, service_config in self.config_service_configs.items():
         config_service_configs[
             service] = configservices_pb2.ConfigServiceConfig(
                 templates=service_config.templates,
                 config=service_config.config)
     return core_pb2.Node(
         id=self.id,
         name=self.name,
         type=self.type.value,
         model=self.model,
         position=self.position.to_proto(),
         services=self.services,
         config_services=self.config_services,
         emane=self.emane,
         icon=self.icon,
         image=self.image,
         server=self.server,
         dir=self.dir,
         channel=self.channel,
         canvas=self.canvas,
         wlan_config={k: v.to_proto()
                      for k, v in self.wlan_config.items()},
         mobility_config={
             k: v.to_proto()
             for k, v in self.mobility_config.items()
         },
         service_configs=service_configs,
         config_service_configs=config_service_configs,
         emane_configs=emane_configs,
     )
示例#2
0
文件: coreclient.py 项目: lyma/core
 def get_config_service_configs_proto(
         self) -> List[configservices_pb2.ConfigServiceConfig]:
     config_service_protos = []
     for node_id, node_config in self.config_service_configs.items():
         for name, service_config in node_config.items():
             config = service_config.get("config", {})
             config_proto = configservices_pb2.ConfigServiceConfig(
                 node_id=node_id,
                 name=name,
                 templates=service_config["templates"],
                 config=config,
             )
             config_service_protos.append(config_proto)
     return config_service_protos
示例#3
0
 def get_config_service_configs_proto(
         self) -> List[configservices_pb2.ConfigServiceConfig]:
     config_service_protos = []
     for node in self.session.nodes.values():
         if not NodeUtils.is_container_node(node.type):
             continue
         if not node.config_service_configs:
             continue
         for name, service_config in node.config_service_configs.items():
             config_proto = configservices_pb2.ConfigServiceConfig(
                 node_id=node.id,
                 name=name,
                 templates=service_config.templates,
                 config=service_config.config,
             )
             config_service_protos.append(config_proto)
     return config_service_protos
示例#4
0
 def get_config_service_configs_proto(
     self
 ) -> List[configservices_pb2.ConfigServiceConfig]:
     config_service_protos = []
     for canvas_node in self.canvas_nodes.values():
         if not NodeUtils.is_container_node(canvas_node.core_node.type):
             continue
         if not canvas_node.config_service_configs:
             continue
         node_id = canvas_node.core_node.id
         for name, service_config in canvas_node.config_service_configs.items():
             config = service_config.get("config", {})
             config_proto = configservices_pb2.ConfigServiceConfig(
                 node_id=node_id,
                 name=name,
                 templates=service_config["templates"],
                 config=config,
             )
             config_service_protos.append(config_proto)
     return config_service_protos