def test_set_emane_model_config(self, grpc_server): # given client = CoreGrpcClient() session = grpc_server.coreemu.create_session() session.set_location(47.57917, -122.13232, 2.00000, 1.0) options = NodeOptions() options.emane = EmaneIeee80211abgModel.name emane_network = session.add_node(_type=NodeTypes.EMANE, options=options) session.emane.set_model(emane_network, EmaneIeee80211abgModel) config_key = "bandwidth" config_value = "900000" # then with client.context_connect(): response = client.set_emane_model_config( session.id, emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value}, ) # then assert response.result is True config = session.emane.get_model_config(emane_network.id, EmaneIeee80211abgModel.name) assert config[config_key] == config_value
def add_node_data( node_proto: core_pb2.Node) -> Tuple[NodeTypes, int, NodeOptions]: """ Convert node protobuf message to data for creating a node. :param node_proto: node proto message :return: node type, id, and options """ _id = node_proto.id _type = node_proto.type if _type is None: _type = NodeTypes.DEFAULT.value _type = NodeTypes(_type) options = NodeOptions(name=node_proto.name, model=node_proto.model) options.icon = node_proto.icon options.opaque = node_proto.opaque options.image = node_proto.image options.services = node_proto.services options.config_services = node_proto.config_services if node_proto.emane: options.emane = node_proto.emane if node_proto.server: options.server = node_proto.server position = node_proto.position options.set_position(position.x, position.y) if node_proto.HasField("geo"): geo = node_proto.geo options.set_location(geo.lat, geo.lon, geo.alt) return _type, _id, options
def test_get_emane_model_configs(self, grpc_server): # given client = CoreGrpcClient() session = grpc_server.coreemu.create_session() session.set_location(47.57917, -122.13232, 2.00000, 1.0) options = NodeOptions() options.emane = EmaneIeee80211abgModel.name emane_network = session.add_node(_type=NodeTypes.EMANE, options=options) session.emane.set_model(emane_network, EmaneIeee80211abgModel) config_key = "platform_id_start" config_value = "2" session.emane.set_model_config(emane_network.id, EmaneIeee80211abgModel.name, {config_key: config_value}) # then with client.context_connect(): response = client.get_emane_model_configs(session.id) # then assert len(response.configs) == 1 model_config = response.configs[0] assert emane_network.id == model_config.node_id assert model_config.model == EmaneIeee80211abgModel.name assert len(model_config.config) > 0 assert model_config.interface == -1
def add_node_data(node_proto): """ Convert node protobuf message to data for creating a node. :param core_pb2.Node node_proto: node proto message :return: node type, id, and options :rtype: tuple """ _id = node_proto.id _type = node_proto.type if _type is None: _type = NodeTypes.DEFAULT.value _type = NodeTypes(_type) options = NodeOptions(name=node_proto.name, model=node_proto.model) options.icon = node_proto.icon options.opaque = node_proto.opaque options.image = node_proto.image options.services = node_proto.services if node_proto.emane: options.emane = node_proto.emane if node_proto.server: options.server = node_proto.server position = node_proto.position options.set_position(position.x, position.y) options.set_location(position.lat, position.lon, position.alt) return _type, _id, options
def test_get_emane_model_config(self, grpc_server): # given client = CoreGrpcClient() session = grpc_server.coreemu.create_session() session.set_location(47.57917, -122.13232, 2.00000, 1.0) options = NodeOptions() options.emane = EmaneIeee80211abgModel.name emane_network = session.add_node(_type=NodeTypes.EMANE, options=options) session.emane.set_model(emane_network, EmaneIeee80211abgModel) # then with client.context_connect(): response = client.get_emane_model_config( session.id, emane_network.id, EmaneIeee80211abgModel.name) # then assert len(response.config) > 0