コード例 #1
0
 def start_session(self) -> core_pb2.StartSessionResponse:
     self.interfaces_manager.reset_mac()
     nodes = [x.core_node for x in self.canvas_nodes.values()]
     links = []
     for edge in self.links.values():
         link = core_pb2.Link()
         link.CopyFrom(edge.link)
         if link.HasField("interface_one") and not link.interface_one.mac:
             link.interface_one.mac = self.interfaces_manager.next_mac()
         if link.HasField("interface_two") and not link.interface_two.mac:
             link.interface_two.mac = self.interfaces_manager.next_mac()
         links.append(link)
     wlan_configs = self.get_wlan_configs_proto()
     mobility_configs = self.get_mobility_configs_proto()
     emane_model_configs = self.get_emane_model_configs_proto()
     hooks = list(self.hooks.values())
     service_configs = self.get_service_configs_proto()
     file_configs = self.get_service_file_configs_proto()
     asymmetric_links = [
         x.asymmetric_link for x in self.links.values() if x.asymmetric_link
     ]
     config_service_configs = self.get_config_service_configs_proto()
     if self.emane_config:
         emane_config = {x: self.emane_config[x].value for x in self.emane_config}
     else:
         emane_config = None
     response = core_pb2.StartSessionResponse(result=False)
     try:
         response = self.client.start_session(
             self.session_id,
             nodes,
             links,
             self.location,
             hooks,
             emane_config,
             emane_model_configs,
             wlan_configs,
             mobility_configs,
             service_configs,
             file_configs,
             asymmetric_links,
             config_service_configs,
         )
         logging.info(
             "start session(%s), result: %s", self.session_id, response.result
         )
         if response.result:
             self.set_metadata()
     except grpc.RpcError as e:
         self.app.show_grpc_exception("Start Session Error", e)
     return response
コード例 #2
0
    def start_session(self) -> core_pb2.StartSessionResponse:
        nodes = [x.core_node for x in self.canvas_nodes.values()]
        links = [x.link for x in self.links.values()]
        wlan_configs = self.get_wlan_configs_proto()
        mobility_configs = self.get_mobility_configs_proto()
        emane_model_configs = self.get_emane_model_configs_proto()
        hooks = list(self.hooks.values())
        service_configs = self.get_service_configs_proto()
        file_configs = self.get_service_file_configs_proto()
        asymmetric_links = [
            x.asymmetric_link for x in self.links.values() if x.asymmetric_link
        ]
        config_service_configs = self.get_config_service_configs_proto()
        if self.emane_config:
            emane_config = {
                x: self.emane_config[x].value
                for x in self.emane_config
            }
        else:
            emane_config = None

        response = core_pb2.StartSessionResponse(result=False)
        try:
            response = self.client.start_session(
                self.session_id,
                nodes,
                links,
                self.location,
                hooks,
                emane_config,
                emane_model_configs,
                wlan_configs,
                mobility_configs,
                service_configs,
                file_configs,
                asymmetric_links,
                config_service_configs,
            )
            logging.info("start session(%s), result: %s", self.session_id,
                         response.result)

            if response.result:
                self.set_metadata()
        except grpc.RpcError as e:
            self.app.after(0, show_grpc_error, e, self.app, self.app)
        return response