updates to break up core.proto into separate logical files

This commit is contained in:
Blake Harnden 2020-03-22 22:57:50 -07:00
parent 38f9f44cdf
commit 6a41012857
14 changed files with 673 additions and 555 deletions

View file

@ -26,11 +26,69 @@ from core.api.grpc.configservices_pb2 import (
SetNodeConfigServiceRequest, SetNodeConfigServiceRequest,
SetNodeConfigServiceResponse, SetNodeConfigServiceResponse,
) )
from core.api.grpc.core_pb2 import ( from core.api.grpc.core_pb2 import ExecuteScriptRequest, ExecuteScriptResponse
ExecuteScriptRequest, from core.api.grpc.emane_pb2 import (
ExecuteScriptResponse, EmaneLinkRequest,
EmaneLinkResponse,
EmaneModelConfig,
GetEmaneConfigRequest,
GetEmaneConfigResponse,
GetEmaneEventChannelRequest, GetEmaneEventChannelRequest,
GetEmaneEventChannelResponse, GetEmaneEventChannelResponse,
GetEmaneModelConfigRequest,
GetEmaneModelConfigResponse,
GetEmaneModelConfigsRequest,
GetEmaneModelConfigsResponse,
GetEmaneModelsRequest,
GetEmaneModelsResponse,
SetEmaneConfigRequest,
SetEmaneConfigResponse,
SetEmaneModelConfigRequest,
SetEmaneModelConfigResponse,
)
from core.api.grpc.mobility_pb2 import (
GetMobilityConfigRequest,
GetMobilityConfigResponse,
GetMobilityConfigsRequest,
GetMobilityConfigsResponse,
MobilityActionRequest,
MobilityActionResponse,
MobilityConfig,
SetMobilityConfigRequest,
SetMobilityConfigResponse,
)
from core.api.grpc.services_pb2 import (
GetNodeServiceConfigsRequest,
GetNodeServiceConfigsResponse,
GetNodeServiceFileRequest,
GetNodeServiceFileResponse,
GetNodeServiceRequest,
GetNodeServiceResponse,
GetServiceDefaultsRequest,
GetServiceDefaultsResponse,
GetServicesRequest,
GetServicesResponse,
ServiceAction,
ServiceActionRequest,
ServiceActionResponse,
ServiceConfig,
ServiceDefaults,
ServiceFileConfig,
SetNodeServiceFileRequest,
SetNodeServiceFileResponse,
SetNodeServiceRequest,
SetNodeServiceResponse,
SetServiceDefaultsRequest,
SetServiceDefaultsResponse,
)
from core.api.grpc.wlan_pb2 import (
GetWlanConfigRequest,
GetWlanConfigResponse,
GetWlanConfigsRequest,
GetWlanConfigsResponse,
SetWlanConfigRequest,
SetWlanConfigResponse,
WlanConfig,
) )
@ -178,11 +236,11 @@ class CoreGrpcClient:
location: core_pb2.SessionLocation = None, location: core_pb2.SessionLocation = None,
hooks: List[core_pb2.Hook] = None, hooks: List[core_pb2.Hook] = None,
emane_config: Dict[str, str] = None, emane_config: Dict[str, str] = None,
emane_model_configs: List[core_pb2.EmaneModelConfig] = None, emane_model_configs: List[EmaneModelConfig] = None,
wlan_configs: List[core_pb2.WlanConfig] = None, wlan_configs: List[WlanConfig] = None,
mobility_configs: List[core_pb2.MobilityConfig] = None, mobility_configs: List[MobilityConfig] = None,
service_configs: List[core_pb2.ServiceConfig] = None, service_configs: List[ServiceConfig] = None,
service_file_configs: List[core_pb2.ServiceFileConfig] = None, service_file_configs: List[ServiceFileConfig] = None,
asymmetric_links: List[core_pb2.Link] = None, asymmetric_links: List[core_pb2.Link] = None,
config_service_configs: List[configservices_pb2.ConfigServiceConfig] = None, config_service_configs: List[configservices_pb2.ConfigServiceConfig] = None,
) -> core_pb2.StartSessionResponse: ) -> core_pb2.StartSessionResponse:
@ -678,7 +736,7 @@ class CoreGrpcClient:
session_id: int, session_id: int,
state: core_pb2.SessionState, state: core_pb2.SessionState,
file_name: str, file_name: str,
file_data: bytes, file_data: str,
) -> core_pb2.AddHookResponse: ) -> core_pb2.AddHookResponse:
""" """
Add hook scripts. Add hook scripts.
@ -694,9 +752,7 @@ class CoreGrpcClient:
request = core_pb2.AddHookRequest(session_id=session_id, hook=hook) request = core_pb2.AddHookRequest(session_id=session_id, hook=hook)
return self.stub.AddHook(request) return self.stub.AddHook(request)
def get_mobility_configs( def get_mobility_configs(self, session_id: int) -> GetMobilityConfigsResponse:
self, session_id: int
) -> core_pb2.GetMobilityConfigsResponse:
""" """
Get all mobility configurations. Get all mobility configurations.
@ -704,12 +760,12 @@ class CoreGrpcClient:
:return: response with a dict of node ids to mobility configurations :return: response with a dict of node ids to mobility configurations
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetMobilityConfigsRequest(session_id=session_id) request = GetMobilityConfigsRequest(session_id=session_id)
return self.stub.GetMobilityConfigs(request) return self.stub.GetMobilityConfigs(request)
def get_mobility_config( def get_mobility_config(
self, session_id: int, node_id: int self, session_id: int, node_id: int
) -> core_pb2.GetMobilityConfigResponse: ) -> GetMobilityConfigResponse:
""" """
Get mobility configuration for a node. Get mobility configuration for a node.
@ -718,14 +774,12 @@ class CoreGrpcClient:
:return: response with a list of configuration groups :return: response with a list of configuration groups
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
request = core_pb2.GetMobilityConfigRequest( request = GetMobilityConfigRequest(session_id=session_id, node_id=node_id)
session_id=session_id, node_id=node_id
)
return self.stub.GetMobilityConfig(request) return self.stub.GetMobilityConfig(request)
def set_mobility_config( def set_mobility_config(
self, session_id: int, node_id: int, config: Dict[str, str] self, session_id: int, node_id: int, config: Dict[str, str]
) -> core_pb2.SetMobilityConfigResponse: ) -> SetMobilityConfigResponse:
""" """
Set mobility configuration for a node. Set mobility configuration for a node.
@ -735,15 +789,15 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
mobility_config = core_pb2.MobilityConfig(node_id=node_id, config=config) mobility_config = MobilityConfig(node_id=node_id, config=config)
request = core_pb2.SetMobilityConfigRequest( request = SetMobilityConfigRequest(
session_id=session_id, mobility_config=mobility_config session_id=session_id, mobility_config=mobility_config
) )
return self.stub.SetMobilityConfig(request) return self.stub.SetMobilityConfig(request)
def mobility_action( def mobility_action(
self, session_id: int, node_id: int, action: core_pb2.ServiceAction self, session_id: int, node_id: int, action: ServiceAction
) -> core_pb2.MobilityActionResponse: ) -> MobilityActionResponse:
""" """
Send a mobility action for a node. Send a mobility action for a node.
@ -753,23 +807,21 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
request = core_pb2.MobilityActionRequest( request = MobilityActionRequest(
session_id=session_id, node_id=node_id, action=action session_id=session_id, node_id=node_id, action=action
) )
return self.stub.MobilityAction(request) return self.stub.MobilityAction(request)
def get_services(self) -> core_pb2.GetServicesResponse: def get_services(self) -> GetServicesResponse:
""" """
Get all currently loaded services. Get all currently loaded services.
:return: response with a list of services :return: response with a list of services
""" """
request = core_pb2.GetServicesRequest() request = GetServicesRequest()
return self.stub.GetServices(request) return self.stub.GetServices(request)
def get_service_defaults( def get_service_defaults(self, session_id: int) -> GetServiceDefaultsResponse:
self, session_id: int
) -> core_pb2.GetServiceDefaultsResponse:
""" """
Get default services for different default node models. Get default services for different default node models.
@ -777,12 +829,12 @@ class CoreGrpcClient:
:return: response with a dict of node model to a list of services :return: response with a dict of node model to a list of services
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetServiceDefaultsRequest(session_id=session_id) request = GetServiceDefaultsRequest(session_id=session_id)
return self.stub.GetServiceDefaults(request) return self.stub.GetServiceDefaults(request)
def set_service_defaults( def set_service_defaults(
self, session_id: int, service_defaults: Dict[str, List[str]] self, session_id: int, service_defaults: Dict[str, List[str]]
) -> core_pb2.SetServiceDefaultsResponse: ) -> SetServiceDefaultsResponse:
""" """
Set default services for node models. Set default services for node models.
@ -794,16 +846,14 @@ class CoreGrpcClient:
defaults = [] defaults = []
for node_type in service_defaults: for node_type in service_defaults:
services = service_defaults[node_type] services = service_defaults[node_type]
default = core_pb2.ServiceDefaults(node_type=node_type, services=services) default = ServiceDefaults(node_type=node_type, services=services)
defaults.append(default) defaults.append(default)
request = core_pb2.SetServiceDefaultsRequest( request = SetServiceDefaultsRequest(session_id=session_id, defaults=defaults)
session_id=session_id, defaults=defaults
)
return self.stub.SetServiceDefaults(request) return self.stub.SetServiceDefaults(request)
def get_node_service_configs( def get_node_service_configs(
self, session_id: int self, session_id: int
) -> core_pb2.GetNodeServiceConfigsResponse: ) -> GetNodeServiceConfigsResponse:
""" """
Get service data for a node. Get service data for a node.
@ -811,12 +861,12 @@ class CoreGrpcClient:
:return: response with all node service configs :return: response with all node service configs
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetNodeServiceConfigsRequest(session_id=session_id) request = GetNodeServiceConfigsRequest(session_id=session_id)
return self.stub.GetNodeServiceConfigs(request) return self.stub.GetNodeServiceConfigs(request)
def get_node_service( def get_node_service(
self, session_id: int, node_id: int, service: str self, session_id: int, node_id: int, service: str
) -> core_pb2.GetNodeServiceResponse: ) -> GetNodeServiceResponse:
""" """
Get service data for a node. Get service data for a node.
@ -826,14 +876,14 @@ class CoreGrpcClient:
:return: response with node service data :return: response with node service data
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
request = core_pb2.GetNodeServiceRequest( request = GetNodeServiceRequest(
session_id=session_id, node_id=node_id, service=service session_id=session_id, node_id=node_id, service=service
) )
return self.stub.GetNodeService(request) return self.stub.GetNodeService(request)
def get_node_service_file( def get_node_service_file(
self, session_id: int, node_id: int, service: str, file_name: str self, session_id: int, node_id: int, service: str, file_name: str
) -> core_pb2.GetNodeServiceFileResponse: ) -> GetNodeServiceFileResponse:
""" """
Get a service file for a node. Get a service file for a node.
@ -844,7 +894,7 @@ class CoreGrpcClient:
:return: response with file data :return: response with file data
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
request = core_pb2.GetNodeServiceFileRequest( request = GetNodeServiceFileRequest(
session_id=session_id, node_id=node_id, service=service, file=file_name session_id=session_id, node_id=node_id, service=service, file=file_name
) )
return self.stub.GetNodeServiceFile(request) return self.stub.GetNodeServiceFile(request)
@ -859,7 +909,7 @@ class CoreGrpcClient:
startup: List[str] = None, startup: List[str] = None,
validate: List[str] = None, validate: List[str] = None,
shutdown: List[str] = None, shutdown: List[str] = None,
) -> core_pb2.SetNodeServiceResponse: ) -> SetNodeServiceResponse:
""" """
Set service data for a node. Set service data for a node.
@ -874,7 +924,7 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
config = core_pb2.ServiceConfig( config = ServiceConfig(
node_id=node_id, node_id=node_id,
service=service, service=service,
files=files, files=files,
@ -883,12 +933,12 @@ class CoreGrpcClient:
validate=validate, validate=validate,
shutdown=shutdown, shutdown=shutdown,
) )
request = core_pb2.SetNodeServiceRequest(session_id=session_id, config=config) request = SetNodeServiceRequest(session_id=session_id, config=config)
return self.stub.SetNodeService(request) return self.stub.SetNodeService(request)
def set_node_service_file( def set_node_service_file(
self, session_id: int, node_id: int, service: str, file_name: str, data: bytes self, session_id: int, node_id: int, service: str, file_name: str, data: str
) -> core_pb2.SetNodeServiceFileResponse: ) -> SetNodeServiceFileResponse:
""" """
Set a service file for a node. Set a service file for a node.
@ -900,21 +950,15 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
config = core_pb2.ServiceFileConfig( config = ServiceFileConfig(
node_id=node_id, service=service, file=file_name, data=data node_id=node_id, service=service, file=file_name, data=data
) )
request = core_pb2.SetNodeServiceFileRequest( request = SetNodeServiceFileRequest(session_id=session_id, config=config)
session_id=session_id, config=config
)
return self.stub.SetNodeServiceFile(request) return self.stub.SetNodeServiceFile(request)
def service_action( def service_action(
self, self, session_id: int, node_id: int, service: str, action: ServiceAction
session_id: int, ) -> ServiceActionResponse:
node_id: int,
service: str,
action: core_pb2.ServiceAction,
) -> core_pb2.ServiceActionResponse:
""" """
Send an action to a service for a node. Send an action to a service for a node.
@ -926,12 +970,12 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session or node doesn't exist :raises grpc.RpcError: when session or node doesn't exist
""" """
request = core_pb2.ServiceActionRequest( request = ServiceActionRequest(
session_id=session_id, node_id=node_id, service=service, action=action session_id=session_id, node_id=node_id, service=service, action=action
) )
return self.stub.ServiceAction(request) return self.stub.ServiceAction(request)
def get_wlan_configs(self, session_id: int) -> core_pb2.GetWlanConfigsResponse: def get_wlan_configs(self, session_id: int) -> GetWlanConfigsResponse:
""" """
Get all wlan configurations. Get all wlan configurations.
@ -939,12 +983,10 @@ class CoreGrpcClient:
:return: response with a dict of node ids to wlan configurations :return: response with a dict of node ids to wlan configurations
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetWlanConfigsRequest(session_id=session_id) request = GetWlanConfigsRequest(session_id=session_id)
return self.stub.GetWlanConfigs(request) return self.stub.GetWlanConfigs(request)
def get_wlan_config( def get_wlan_config(self, session_id: int, node_id: int) -> GetWlanConfigResponse:
self, session_id: int, node_id: int
) -> core_pb2.GetWlanConfigResponse:
""" """
Get wlan configuration for a node. Get wlan configuration for a node.
@ -953,12 +995,12 @@ class CoreGrpcClient:
:return: response with a list of configuration groups :return: response with a list of configuration groups
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetWlanConfigRequest(session_id=session_id, node_id=node_id) request = GetWlanConfigRequest(session_id=session_id, node_id=node_id)
return self.stub.GetWlanConfig(request) return self.stub.GetWlanConfig(request)
def set_wlan_config( def set_wlan_config(
self, session_id: int, node_id: int, config: Dict[str, str] self, session_id: int, node_id: int, config: Dict[str, str]
) -> core_pb2.SetWlanConfigResponse: ) -> SetWlanConfigResponse:
""" """
Set wlan configuration for a node. Set wlan configuration for a node.
@ -968,13 +1010,11 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
wlan_config = core_pb2.WlanConfig(node_id=node_id, config=config) wlan_config = WlanConfig(node_id=node_id, config=config)
request = core_pb2.SetWlanConfigRequest( request = SetWlanConfigRequest(session_id=session_id, wlan_config=wlan_config)
session_id=session_id, wlan_config=wlan_config
)
return self.stub.SetWlanConfig(request) return self.stub.SetWlanConfig(request)
def get_emane_config(self, session_id: int) -> core_pb2.GetEmaneConfigResponse: def get_emane_config(self, session_id: int) -> GetEmaneConfigResponse:
""" """
Get session emane configuration. Get session emane configuration.
@ -982,12 +1022,12 @@ class CoreGrpcClient:
:return: response with a list of configuration groups :return: response with a list of configuration groups
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetEmaneConfigRequest(session_id=session_id) request = GetEmaneConfigRequest(session_id=session_id)
return self.stub.GetEmaneConfig(request) return self.stub.GetEmaneConfig(request)
def set_emane_config( def set_emane_config(
self, session_id: int, config: Dict[str, str] self, session_id: int, config: Dict[str, str]
) -> core_pb2.SetEmaneConfigResponse: ) -> SetEmaneConfigResponse:
""" """
Set session emane configuration. Set session emane configuration.
@ -996,10 +1036,10 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.SetEmaneConfigRequest(session_id=session_id, config=config) request = SetEmaneConfigRequest(session_id=session_id, config=config)
return self.stub.SetEmaneConfig(request) return self.stub.SetEmaneConfig(request)
def get_emane_models(self, session_id: int) -> core_pb2.GetEmaneModelsResponse: def get_emane_models(self, session_id: int) -> GetEmaneModelsResponse:
""" """
Get session emane models. Get session emane models.
@ -1007,12 +1047,12 @@ class CoreGrpcClient:
:return: response with a list of emane models :return: response with a list of emane models
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetEmaneModelsRequest(session_id=session_id) request = GetEmaneModelsRequest(session_id=session_id)
return self.stub.GetEmaneModels(request) return self.stub.GetEmaneModels(request)
def get_emane_model_config( def get_emane_model_config(
self, session_id: int, node_id: int, model: str, interface_id: int = -1 self, session_id: int, node_id: int, model: str, interface_id: int = -1
) -> core_pb2.GetEmaneModelConfigResponse: ) -> GetEmaneModelConfigResponse:
""" """
Get emane model configuration for a node or a node's interface. Get emane model configuration for a node or a node's interface.
@ -1023,7 +1063,7 @@ class CoreGrpcClient:
:return: response with a list of configuration groups :return: response with a list of configuration groups
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetEmaneModelConfigRequest( request = GetEmaneModelConfigRequest(
session_id=session_id, node_id=node_id, model=model, interface=interface_id session_id=session_id, node_id=node_id, model=model, interface=interface_id
) )
return self.stub.GetEmaneModelConfig(request) return self.stub.GetEmaneModelConfig(request)
@ -1035,7 +1075,7 @@ class CoreGrpcClient:
model: str, model: str,
config: Dict[str, str], config: Dict[str, str],
interface_id: int = -1, interface_id: int = -1,
) -> core_pb2.SetEmaneModelConfigResponse: ) -> SetEmaneModelConfigResponse:
""" """
Set emane model configuration for a node or a node's interface. Set emane model configuration for a node or a node's interface.
@ -1047,17 +1087,15 @@ class CoreGrpcClient:
:return: response with result of success or failure :return: response with result of success or failure
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
model_config = core_pb2.EmaneModelConfig( model_config = EmaneModelConfig(
node_id=node_id, model=model, config=config, interface_id=interface_id node_id=node_id, model=model, config=config, interface_id=interface_id
) )
request = core_pb2.SetEmaneModelConfigRequest( request = SetEmaneModelConfigRequest(
session_id=session_id, emane_model_config=model_config session_id=session_id, emane_model_config=model_config
) )
return self.stub.SetEmaneModelConfig(request) return self.stub.SetEmaneModelConfig(request)
def get_emane_model_configs( def get_emane_model_configs(self, session_id: int) -> GetEmaneModelConfigsResponse:
self, session_id: int
) -> core_pb2.GetEmaneModelConfigsResponse:
""" """
Get all emane model configurations for a session. Get all emane model configurations for a session.
@ -1065,7 +1103,7 @@ class CoreGrpcClient:
:return: response with a dictionary of node/interface ids to configurations :return: response with a dictionary of node/interface ids to configurations
:raises grpc.RpcError: when session doesn't exist :raises grpc.RpcError: when session doesn't exist
""" """
request = core_pb2.GetEmaneModelConfigsRequest(session_id=session_id) request = GetEmaneModelConfigsRequest(session_id=session_id)
return self.stub.GetEmaneModelConfigs(request) return self.stub.GetEmaneModelConfigs(request)
def save_xml(self, session_id: int, file_path: str) -> core_pb2.SaveXmlResponse: def save_xml(self, session_id: int, file_path: str) -> core_pb2.SaveXmlResponse:
@ -1096,7 +1134,7 @@ class CoreGrpcClient:
def emane_link( def emane_link(
self, session_id: int, nem_one: int, nem_two: int, linked: bool self, session_id: int, nem_one: int, nem_two: int, linked: bool
) -> core_pb2.EmaneLinkResponse: ) -> EmaneLinkResponse:
""" """
Helps broadcast wireless link/unlink between EMANE nodes. Helps broadcast wireless link/unlink between EMANE nodes.
@ -1106,7 +1144,7 @@ class CoreGrpcClient:
:param linked: True to link, False to unlink :param linked: True to link, False to unlink
:return: core_pb2.EmaneLinkResponse :return: core_pb2.EmaneLinkResponse
""" """
request = core_pb2.EmaneLinkRequest( request = EmaneLinkRequest(
session_id=session_id, nem_one=nem_one, nem_two=nem_two, linked=linked session_id=session_id, nem_one=nem_one, nem_two=nem_two, linked=linked
) )
return self.stub.EmaneLink(request) return self.stub.EmaneLink(request)
@ -1191,7 +1229,8 @@ class CoreGrpcClient:
@contextmanager @contextmanager
def context_connect(self) -> Generator: def context_connect(self) -> Generator:
""" """
Makes a context manager based connection to the server, will close after context ends. Makes a context manager based connection to the server, will close after
context ends.
:return: nothing :return: nothing
""" """

View file

@ -6,6 +6,7 @@ import netaddr
from core import utils from core import utils
from core.api.grpc import common_pb2, core_pb2 from core.api.grpc import common_pb2, core_pb2
from core.api.grpc.services_pb2 import NodeServiceData, ServiceConfig
from core.config import ConfigurableOptions from core.config import ConfigurableOptions
from core.emulator.data import LinkData from core.emulator.data import LinkData
from core.emulator.emudata import InterfaceData, LinkOptions, NodeOptions from core.emulator.emudata import InterfaceData, LinkOptions, NodeOptions
@ -364,7 +365,7 @@ def session_location(session: Session, location: core_pb2.SessionLocation) -> No
session.location.refscale = location.scale session.location.refscale = location.scale
def service_configuration(session: Session, config: core_pb2.ServiceConfig) -> None: def service_configuration(session: Session, config: ServiceConfig) -> None:
""" """
Convenience method for setting a node service configuration. Convenience method for setting a node service configuration.
@ -386,14 +387,14 @@ def service_configuration(session: Session, config: core_pb2.ServiceConfig) -> N
service.shutdown = tuple(config.shutdown) service.shutdown = tuple(config.shutdown)
def get_service_configuration(service: Type[CoreService]) -> core_pb2.NodeServiceData: def get_service_configuration(service: Type[CoreService]) -> NodeServiceData:
""" """
Convenience for converting a service to service data proto. Convenience for converting a service to service data proto.
:param service: service to get proto data for :param service: service to get proto data for
:return: service proto data :return: service proto data
""" """
return core_pb2.NodeServiceData( return NodeServiceData(
executables=service.executables, executables=service.executables,
dependencies=service.dependencies, dependencies=service.dependencies,
dirs=service.dirs, dirs=service.dirs,

View file

@ -19,6 +19,7 @@ from core.api.grpc import (
core_pb2_grpc, core_pb2_grpc,
grpcutils, grpcutils,
) )
from core.api.grpc.common_pb2 import MappedConfig
from core.api.grpc.configservices_pb2 import ( from core.api.grpc.configservices_pb2 import (
ConfigService, ConfigService,
GetConfigServiceDefaultsRequest, GetConfigServiceDefaultsRequest,
@ -34,10 +35,24 @@ from core.api.grpc.configservices_pb2 import (
SetNodeConfigServiceRequest, SetNodeConfigServiceRequest,
SetNodeConfigServiceResponse, SetNodeConfigServiceResponse,
) )
from core.api.grpc.core_pb2 import ( from core.api.grpc.core_pb2 import ExecuteScriptResponse
ExecuteScriptResponse, from core.api.grpc.emane_pb2 import (
EmaneLinkRequest,
EmaneLinkResponse,
GetEmaneConfigRequest,
GetEmaneConfigResponse,
GetEmaneEventChannelRequest, GetEmaneEventChannelRequest,
GetEmaneEventChannelResponse, GetEmaneEventChannelResponse,
GetEmaneModelConfigRequest,
GetEmaneModelConfigResponse,
GetEmaneModelConfigsRequest,
GetEmaneModelConfigsResponse,
GetEmaneModelsRequest,
GetEmaneModelsResponse,
SetEmaneConfigRequest,
SetEmaneConfigResponse,
SetEmaneModelConfigRequest,
SetEmaneModelConfigResponse,
) )
from core.api.grpc.events import EventStreamer from core.api.grpc.events import EventStreamer
from core.api.grpc.grpcutils import ( from core.api.grpc.grpcutils import (
@ -46,6 +61,48 @@ from core.api.grpc.grpcutils import (
get_links, get_links,
get_net_stats, get_net_stats,
) )
from core.api.grpc.mobility_pb2 import (
GetMobilityConfigRequest,
GetMobilityConfigResponse,
GetMobilityConfigsRequest,
GetMobilityConfigsResponse,
MobilityAction,
MobilityActionRequest,
MobilityActionResponse,
SetMobilityConfigRequest,
SetMobilityConfigResponse,
)
from core.api.grpc.services_pb2 import (
GetNodeServiceConfigsRequest,
GetNodeServiceConfigsResponse,
GetNodeServiceFileRequest,
GetNodeServiceFileResponse,
GetNodeServiceRequest,
GetNodeServiceResponse,
GetServiceDefaultsRequest,
GetServiceDefaultsResponse,
GetServicesRequest,
GetServicesResponse,
Service,
ServiceAction,
ServiceActionRequest,
ServiceActionResponse,
ServiceDefaults,
SetNodeServiceFileRequest,
SetNodeServiceFileResponse,
SetNodeServiceRequest,
SetNodeServiceResponse,
SetServiceDefaultsRequest,
SetServiceDefaultsResponse,
)
from core.api.grpc.wlan_pb2 import (
GetWlanConfigRequest,
GetWlanConfigResponse,
GetWlanConfigsRequest,
GetWlanConfigsResponse,
SetWlanConfigRequest,
SetWlanConfigResponse,
)
from core.emane.nodes import EmaneNet from core.emane.nodes import EmaneNet
from core.emulator.coreemu import CoreEmu from core.emulator.coreemu import CoreEmu
from core.emulator.data import LinkData from core.emulator.data import LinkData
@ -919,8 +976,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
return core_pb2.AddHookResponse(result=True) return core_pb2.AddHookResponse(result=True)
def GetMobilityConfigs( def GetMobilityConfigs(
self, request: core_pb2.GetMobilityConfigsRequest, context: ServicerContext self, request: GetMobilityConfigsRequest, context: ServicerContext
) -> core_pb2.GetMobilityConfigsResponse: ) -> GetMobilityConfigsResponse:
""" """
Retrieve all mobility configurations from a session Retrieve all mobility configurations from a session
@ -931,7 +988,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
""" """
logging.debug("get mobility configs: %s", request) logging.debug("get mobility configs: %s", request)
session = self.get_session(request.session_id, context) session = self.get_session(request.session_id, context)
response = core_pb2.GetMobilityConfigsResponse() response = GetMobilityConfigsResponse()
for node_id in session.mobility.node_configurations: for node_id in session.mobility.node_configurations:
model_config = session.mobility.node_configurations[node_id] model_config = session.mobility.node_configurations[node_id]
if node_id == -1: if node_id == -1:
@ -941,13 +998,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
continue continue
current_config = session.mobility.get_model_config(node_id, model_name) current_config = session.mobility.get_model_config(node_id, model_name)
config = get_config_options(current_config, Ns2ScriptedMobility) config = get_config_options(current_config, Ns2ScriptedMobility)
mapped_config = core_pb2.MappedConfig(config=config) mapped_config = MappedConfig(config=config)
response.configs[node_id].CopyFrom(mapped_config) response.configs[node_id].CopyFrom(mapped_config)
return response return response
def GetMobilityConfig( def GetMobilityConfig(
self, request: core_pb2.GetMobilityConfigRequest, context: ServicerContext self, request: GetMobilityConfigRequest, context: ServicerContext
) -> core_pb2.GetMobilityConfigResponse: ) -> GetMobilityConfigResponse:
""" """
Retrieve mobility configuration of a node Retrieve mobility configuration of a node
@ -962,11 +1019,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
request.node_id, Ns2ScriptedMobility.name request.node_id, Ns2ScriptedMobility.name
) )
config = get_config_options(current_config, Ns2ScriptedMobility) config = get_config_options(current_config, Ns2ScriptedMobility)
return core_pb2.GetMobilityConfigResponse(config=config) return GetMobilityConfigResponse(config=config)
def SetMobilityConfig( def SetMobilityConfig(
self, request: core_pb2.SetMobilityConfigRequest, context: ServicerContext self, request: SetMobilityConfigRequest, context: ServicerContext
) -> core_pb2.SetMobilityConfigResponse: ) -> SetMobilityConfigResponse:
""" """
Set mobility configuration of a node Set mobility configuration of a node
@ -981,11 +1038,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.mobility.set_model_config( session.mobility.set_model_config(
mobility_config.node_id, Ns2ScriptedMobility.name, mobility_config.config mobility_config.node_id, Ns2ScriptedMobility.name, mobility_config.config
) )
return core_pb2.SetMobilityConfigResponse(result=True) return SetMobilityConfigResponse(result=True)
def MobilityAction( def MobilityAction(
self, request: core_pb2.MobilityActionRequest, context: ServicerContext self, request: MobilityActionRequest, context: ServicerContext
) -> core_pb2.MobilityActionResponse: ) -> MobilityActionResponse:
""" """
Take mobility action whether to start, pause, stop or none of those Take mobility action whether to start, pause, stop or none of those
@ -998,19 +1055,19 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session = self.get_session(request.session_id, context) session = self.get_session(request.session_id, context)
node = self.get_node(session, request.node_id, context) node = self.get_node(session, request.node_id, context)
result = True result = True
if request.action == core_pb2.MobilityAction.START: if request.action == MobilityAction.START:
node.mobility.start() node.mobility.start()
elif request.action == core_pb2.MobilityAction.PAUSE: elif request.action == MobilityAction.PAUSE:
node.mobility.pause() node.mobility.pause()
elif request.action == core_pb2.MobilityAction.STOP: elif request.action == MobilityAction.STOP:
node.mobility.stop(move_initial=True) node.mobility.stop(move_initial=True)
else: else:
result = False result = False
return core_pb2.MobilityActionResponse(result=result) return MobilityActionResponse(result=result)
def GetServices( def GetServices(
self, request: core_pb2.GetServicesRequest, context: ServicerContext self, request: GetServicesRequest, context: ServicerContext
) -> core_pb2.GetServicesResponse: ) -> GetServicesResponse:
""" """
Retrieve all the services that are running Retrieve all the services that are running
@ -1022,13 +1079,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
services = [] services = []
for name in ServiceManager.services: for name in ServiceManager.services:
service = ServiceManager.services[name] service = ServiceManager.services[name]
service_proto = core_pb2.Service(group=service.group, name=service.name) service_proto = Service(group=service.group, name=service.name)
services.append(service_proto) services.append(service_proto)
return core_pb2.GetServicesResponse(services=services) return GetServicesResponse(services=services)
def GetServiceDefaults( def GetServiceDefaults(
self, request: core_pb2.GetServiceDefaultsRequest, context: ServicerContext self, request: GetServiceDefaultsRequest, context: ServicerContext
) -> core_pb2.GetServiceDefaultsResponse: ) -> GetServiceDefaultsResponse:
""" """
Retrieve all the default services of all node types in a session Retrieve all the default services of all node types in a session
@ -1042,15 +1099,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
all_service_defaults = [] all_service_defaults = []
for node_type in session.services.default_services: for node_type in session.services.default_services:
services = session.services.default_services[node_type] services = session.services.default_services[node_type]
service_defaults = core_pb2.ServiceDefaults( service_defaults = ServiceDefaults(node_type=node_type, services=services)
node_type=node_type, services=services
)
all_service_defaults.append(service_defaults) all_service_defaults.append(service_defaults)
return core_pb2.GetServiceDefaultsResponse(defaults=all_service_defaults) return GetServiceDefaultsResponse(defaults=all_service_defaults)
def SetServiceDefaults( def SetServiceDefaults(
self, request: core_pb2.SetServiceDefaultsRequest, context: ServicerContext self, request: SetServiceDefaultsRequest, context: ServicerContext
) -> core_pb2.SetServiceDefaultsResponse: ) -> SetServiceDefaultsResponse:
""" """
Set new default services to the session after whipping out the old ones Set new default services to the session after whipping out the old ones
:param request: set-service-defaults :param request: set-service-defaults
@ -1065,11 +1120,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.services.default_services[ session.services.default_services[
service_defaults.node_type service_defaults.node_type
] = service_defaults.services ] = service_defaults.services
return core_pb2.SetServiceDefaultsResponse(result=True) return SetServiceDefaultsResponse(result=True)
def GetNodeServiceConfigs( def GetNodeServiceConfigs(
self, request: core_pb2.GetNodeServiceConfigsRequest, context: ServicerContext self, request: GetNodeServiceConfigsRequest, context: ServicerContext
) -> core_pb2.GetNodeServiceConfigsResponse: ) -> GetNodeServiceConfigsResponse:
""" """
Retrieve all node service configurations. Retrieve all node service configurations.
@ -1085,18 +1140,18 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
for name in service_configs: for name in service_configs:
service = session.services.get_service(node_id, name) service = session.services.get_service(node_id, name)
service_proto = grpcutils.get_service_configuration(service) service_proto = grpcutils.get_service_configuration(service)
config = core_pb2.GetNodeServiceConfigsResponse.ServiceConfig( config = GetNodeServiceConfigsResponse.ServiceConfig(
node_id=node_id, node_id=node_id,
service=name, service=name,
data=service_proto, data=service_proto,
files=service.config_data, files=service.config_data,
) )
configs.append(config) configs.append(config)
return core_pb2.GetNodeServiceConfigsResponse(configs=configs) return GetNodeServiceConfigsResponse(configs=configs)
def GetNodeService( def GetNodeService(
self, request: core_pb2.GetNodeServiceRequest, context: ServicerContext self, request: GetNodeServiceRequest, context: ServicerContext
) -> core_pb2.GetNodeServiceResponse: ) -> GetNodeServiceResponse:
""" """
Retrieve a requested service from a node Retrieve a requested service from a node
@ -1111,11 +1166,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
request.node_id, request.service, default_service=True request.node_id, request.service, default_service=True
) )
service_proto = grpcutils.get_service_configuration(service) service_proto = grpcutils.get_service_configuration(service)
return core_pb2.GetNodeServiceResponse(service=service_proto) return GetNodeServiceResponse(service=service_proto)
def GetNodeServiceFile( def GetNodeServiceFile(
self, request: core_pb2.GetNodeServiceFileRequest, context: ServicerContext self, request: GetNodeServiceFileRequest, context: ServicerContext
) -> core_pb2.GetNodeServiceFileResponse: ) -> GetNodeServiceFileResponse:
""" """
Retrieve a requested service file from a node Retrieve a requested service file from a node
@ -1130,11 +1185,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
file_data = session.services.get_service_file( file_data = session.services.get_service_file(
node, request.service, request.file node, request.service, request.file
) )
return core_pb2.GetNodeServiceFileResponse(data=file_data.data) return GetNodeServiceFileResponse(data=file_data.data)
def SetNodeService( def SetNodeService(
self, request: core_pb2.SetNodeServiceRequest, context: ServicerContext self, request: SetNodeServiceRequest, context: ServicerContext
) -> core_pb2.SetNodeServiceResponse: ) -> SetNodeServiceResponse:
""" """
Set a node service for a node Set a node service for a node
@ -1147,11 +1202,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session = self.get_session(request.session_id, context) session = self.get_session(request.session_id, context)
config = request.config config = request.config
grpcutils.service_configuration(session, config) grpcutils.service_configuration(session, config)
return core_pb2.SetNodeServiceResponse(result=True) return SetNodeServiceResponse(result=True)
def SetNodeServiceFile( def SetNodeServiceFile(
self, request: core_pb2.SetNodeServiceFileRequest, context: ServicerContext self, request: SetNodeServiceFileRequest, context: ServicerContext
) -> core_pb2.SetNodeServiceFileResponse: ) -> SetNodeServiceFileResponse:
""" """
Store the customized service file in the service config Store the customized service file in the service config
@ -1166,11 +1221,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.services.set_service_file( session.services.set_service_file(
config.node_id, config.service, config.file, config.data config.node_id, config.service, config.file, config.data
) )
return core_pb2.SetNodeServiceFileResponse(result=True) return SetNodeServiceFileResponse(result=True)
def ServiceAction( def ServiceAction(
self, request: core_pb2.ServiceActionRequest, context: ServicerContext self, request: ServiceActionRequest, context: ServicerContext
) -> core_pb2.ServiceActionResponse: ) -> ServiceActionResponse:
""" """
Take action whether to start, stop, restart, validate the service or none of Take action whether to start, stop, restart, validate the service or none of
the above. the above.
@ -1192,26 +1247,26 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
context.abort(grpc.StatusCode.NOT_FOUND, "service not found") context.abort(grpc.StatusCode.NOT_FOUND, "service not found")
status = -1 status = -1
if request.action == core_pb2.ServiceAction.START: if request.action == ServiceAction.START:
status = session.services.startup_service(node, service, wait=True) status = session.services.startup_service(node, service, wait=True)
elif request.action == core_pb2.ServiceAction.STOP: elif request.action == ServiceAction.STOP:
status = session.services.stop_service(node, service) status = session.services.stop_service(node, service)
elif request.action == core_pb2.ServiceAction.RESTART: elif request.action == ServiceAction.RESTART:
status = session.services.stop_service(node, service) status = session.services.stop_service(node, service)
if not status: if not status:
status = session.services.startup_service(node, service, wait=True) status = session.services.startup_service(node, service, wait=True)
elif request.action == core_pb2.ServiceAction.VALIDATE: elif request.action == ServiceAction.VALIDATE:
status = session.services.validate_service(node, service) status = session.services.validate_service(node, service)
result = False result = False
if not status: if not status:
result = True result = True
return core_pb2.ServiceActionResponse(result=result) return ServiceActionResponse(result=result)
def GetWlanConfigs( def GetWlanConfigs(
self, request: core_pb2.GetWlanConfigsRequest, context: ServicerContext self, request: GetWlanConfigsRequest, context: ServicerContext
) -> core_pb2.GetWlanConfigsResponse: ) -> GetWlanConfigsResponse:
""" """
Retrieve all wireless-lan configurations. Retrieve all wireless-lan configurations.
@ -1221,7 +1276,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
""" """
logging.debug("get wlan configs: %s", request) logging.debug("get wlan configs: %s", request)
session = self.get_session(request.session_id, context) session = self.get_session(request.session_id, context)
response = core_pb2.GetWlanConfigsResponse() response = GetWlanConfigsResponse()
for node_id in session.mobility.node_configurations: for node_id in session.mobility.node_configurations:
model_config = session.mobility.node_configurations[node_id] model_config = session.mobility.node_configurations[node_id]
if node_id == -1: if node_id == -1:
@ -1231,13 +1286,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
continue continue
current_config = session.mobility.get_model_config(node_id, model_name) current_config = session.mobility.get_model_config(node_id, model_name)
config = get_config_options(current_config, BasicRangeModel) config = get_config_options(current_config, BasicRangeModel)
mapped_config = core_pb2.MappedConfig(config=config) mapped_config = MappedConfig(config=config)
response.configs[node_id].CopyFrom(mapped_config) response.configs[node_id].CopyFrom(mapped_config)
return response return response
def GetWlanConfig( def GetWlanConfig(
self, request: core_pb2.GetWlanConfigRequest, context: ServicerContext self, request: GetWlanConfigRequest, context: ServicerContext
) -> core_pb2.GetWlanConfigResponse: ) -> GetWlanConfigResponse:
""" """
Retrieve wireless-lan configuration of a node Retrieve wireless-lan configuration of a node
@ -1251,11 +1306,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
request.node_id, BasicRangeModel.name request.node_id, BasicRangeModel.name
) )
config = get_config_options(current_config, BasicRangeModel) config = get_config_options(current_config, BasicRangeModel)
return core_pb2.GetWlanConfigResponse(config=config) return GetWlanConfigResponse(config=config)
def SetWlanConfig( def SetWlanConfig(
self, request: core_pb2.SetWlanConfigRequest, context: ServicerContext self, request: SetWlanConfigRequest, context: ServicerContext
) -> core_pb2.SetWlanConfigResponse: ) -> SetWlanConfigResponse:
""" """
Set configuration data for a model Set configuration data for a model
@ -1272,11 +1327,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
if session.state == EventTypes.RUNTIME_STATE: if session.state == EventTypes.RUNTIME_STATE:
node = self.get_node(session, wlan_config.node_id, context) node = self.get_node(session, wlan_config.node_id, context)
node.updatemodel(wlan_config.config) node.updatemodel(wlan_config.config)
return core_pb2.SetWlanConfigResponse(result=True) return SetWlanConfigResponse(result=True)
def GetEmaneConfig( def GetEmaneConfig(
self, request: core_pb2.GetEmaneConfigRequest, context: ServicerContext self, request: GetEmaneConfigRequest, context: ServicerContext
) -> core_pb2.GetEmaneConfigResponse: ) -> GetEmaneConfigResponse:
""" """
Retrieve EMANE configuration of a session Retrieve EMANE configuration of a session
@ -1288,11 +1343,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session = self.get_session(request.session_id, context) session = self.get_session(request.session_id, context)
current_config = session.emane.get_configs() current_config = session.emane.get_configs()
config = get_config_options(current_config, session.emane.emane_config) config = get_config_options(current_config, session.emane.emane_config)
return core_pb2.GetEmaneConfigResponse(config=config) return GetEmaneConfigResponse(config=config)
def SetEmaneConfig( def SetEmaneConfig(
self, request: core_pb2.SetEmaneConfigRequest, context: ServicerContext self, request: SetEmaneConfigRequest, context: ServicerContext
) -> core_pb2.SetEmaneConfigResponse: ) -> SetEmaneConfigResponse:
""" """
Set EMANE configuration of a session Set EMANE configuration of a session
@ -1304,11 +1359,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session = self.get_session(request.session_id, context) session = self.get_session(request.session_id, context)
config = session.emane.get_configs() config = session.emane.get_configs()
config.update(request.config) config.update(request.config)
return core_pb2.SetEmaneConfigResponse(result=True) return SetEmaneConfigResponse(result=True)
def GetEmaneModels( def GetEmaneModels(
self, request: core_pb2.GetEmaneModelsRequest, context: ServicerContext self, request: GetEmaneModelsRequest, context: ServicerContext
) -> core_pb2.GetEmaneModelsResponse: ) -> GetEmaneModelsResponse:
""" """
Retrieve all the EMANE models in the session Retrieve all the EMANE models in the session
@ -1323,11 +1378,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
if len(model.split("_")) != 2: if len(model.split("_")) != 2:
continue continue
models.append(model) models.append(model)
return core_pb2.GetEmaneModelsResponse(models=models) return GetEmaneModelsResponse(models=models)
def GetEmaneModelConfig( def GetEmaneModelConfig(
self, request: core_pb2.GetEmaneModelConfigRequest, context: ServicerContext self, request: GetEmaneModelConfigRequest, context: ServicerContext
) -> core_pb2.GetEmaneModelConfigResponse: ) -> GetEmaneModelConfigResponse:
""" """
Retrieve EMANE model configuration of a node Retrieve EMANE model configuration of a node
@ -1342,11 +1397,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
_id = get_emane_model_id(request.node_id, request.interface) _id = get_emane_model_id(request.node_id, request.interface)
current_config = session.emane.get_model_config(_id, request.model) current_config = session.emane.get_model_config(_id, request.model)
config = get_config_options(current_config, model) config = get_config_options(current_config, model)
return core_pb2.GetEmaneModelConfigResponse(config=config) return GetEmaneModelConfigResponse(config=config)
def SetEmaneModelConfig( def SetEmaneModelConfig(
self, request: core_pb2.SetEmaneModelConfigRequest, context: ServicerContext self, request: SetEmaneModelConfigRequest, context: ServicerContext
) -> core_pb2.SetEmaneModelConfigResponse: ) -> SetEmaneModelConfigResponse:
""" """
Set EMANE model configuration of a node Set EMANE model configuration of a node
@ -1360,11 +1415,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
model_config = request.emane_model_config model_config = request.emane_model_config
_id = get_emane_model_id(model_config.node_id, model_config.interface_id) _id = get_emane_model_id(model_config.node_id, model_config.interface_id)
session.emane.set_model_config(_id, model_config.model, model_config.config) session.emane.set_model_config(_id, model_config.model, model_config.config)
return core_pb2.SetEmaneModelConfigResponse(result=True) return SetEmaneModelConfigResponse(result=True)
def GetEmaneModelConfigs( def GetEmaneModelConfigs(
self, request: core_pb2.GetEmaneModelConfigsRequest, context: ServicerContext self, request: GetEmaneModelConfigsRequest, context: ServicerContext
) -> core_pb2.GetEmaneModelConfigsResponse: ) -> GetEmaneModelConfigsResponse:
""" """
Retrieve all EMANE model configurations of a session Retrieve all EMANE model configurations of a session
@ -1388,14 +1443,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
current_config = session.emane.get_model_config(_id, model_name) current_config = session.emane.get_model_config(_id, model_name)
config = get_config_options(current_config, model) config = get_config_options(current_config, model)
node_id, interface = grpcutils.parse_emane_model_id(_id) node_id, interface = grpcutils.parse_emane_model_id(_id)
model_config = core_pb2.GetEmaneModelConfigsResponse.ModelConfig( model_config = GetEmaneModelConfigsResponse.ModelConfig(
node_id=node_id, node_id=node_id,
model=model_name, model=model_name,
interface=interface, interface=interface,
config=config, config=config,
) )
configs.append(model_config) configs.append(model_config)
return core_pb2.GetEmaneModelConfigsResponse(configs=configs) return GetEmaneModelConfigsResponse(configs=configs)
def SaveXml( def SaveXml(
self, request: core_pb2.SaveXmlRequest, context: ServicerContext self, request: core_pb2.SaveXmlRequest, context: ServicerContext
@ -1469,8 +1524,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
return core_pb2.GetInterfacesResponse(interfaces=interfaces) return core_pb2.GetInterfacesResponse(interfaces=interfaces)
def EmaneLink( def EmaneLink(
self, request: core_pb2.EmaneLinkRequest, context: ServicerContext self, request: EmaneLinkRequest, context: ServicerContext
) -> core_pb2.EmaneLinkResponse: ) -> EmaneLinkResponse:
""" """
Helps broadcast wireless link/unlink between EMANE nodes. Helps broadcast wireless link/unlink between EMANE nodes.
@ -1505,9 +1560,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
network_id=emane_one.id, network_id=emane_one.id,
) )
session.broadcast_link(link) session.broadcast_link(link)
return core_pb2.EmaneLinkResponse(result=True) return EmaneLinkResponse(result=True)
else: else:
return core_pb2.EmaneLinkResponse(result=False) return EmaneLinkResponse(result=False)
def GetConfigServices( def GetConfigServices(
self, request: GetConfigServicesRequest, context: ServicerContext self, request: GetConfigServicesRequest, context: ServicerContext

View file

@ -11,6 +11,10 @@ from typing import TYPE_CHECKING, Dict, List
import grpc import grpc
from core.api.grpc import client, common_pb2, configservices_pb2, core_pb2 from core.api.grpc import client, common_pb2, configservices_pb2, core_pb2
from core.api.grpc.emane_pb2 import EmaneModelConfig
from core.api.grpc.mobility_pb2 import MobilityConfig
from core.api.grpc.services_pb2 import NodeServiceData, ServiceConfig, ServiceFileConfig
from core.api.grpc.wlan_pb2 import WlanConfig
from core.gui import appconfig from core.gui import appconfig
from core.gui.dialogs.mobilityplayer import MobilityPlayer from core.gui.dialogs.mobilityplayer import MobilityPlayer
from core.gui.dialogs.sessions import SessionsDialog from core.gui.dialogs.sessions import SessionsDialog
@ -617,9 +621,7 @@ class CoreClient:
except grpc.RpcError as e: except grpc.RpcError as e:
self.app.after(0, show_grpc_error, e, self.app, self.app) self.app.after(0, show_grpc_error, e, self.app, self.app)
def get_node_service( def get_node_service(self, node_id: int, service_name: str) -> NodeServiceData:
self, node_id: int, service_name: str
) -> core_pb2.NodeServiceData:
response = self.client.get_node_service(self.session_id, node_id, service_name) response = self.client.get_node_service(self.session_id, node_id, service_name)
logging.debug( logging.debug(
"get node(%s) %s service, response: %s", node_id, service_name, response "get node(%s) %s service, response: %s", node_id, service_name, response
@ -635,7 +637,7 @@ class CoreClient:
startups: List[str], startups: List[str],
validations: List[str], validations: List[str],
shutdowns: List[str], shutdowns: List[str],
) -> core_pb2.NodeServiceData: ) -> NodeServiceData:
response = self.client.set_node_service( response = self.client.set_node_service(
self.session_id, self.session_id,
node_id, node_id,
@ -675,7 +677,7 @@ class CoreClient:
return response.data return response.data
def set_node_service_file( def set_node_service_file(
self, node_id: int, service_name: str, file_name: str, data: bytes self, node_id: int, service_name: str, file_name: str, data: str
): ):
response = self.client.set_node_service_file( response = self.client.set_node_service_file(
self.session_id, node_id, service_name, file_name, data self.session_id, node_id, service_name, file_name, data
@ -912,40 +914,40 @@ class CoreClient:
self.links[edge.token] = edge self.links[edge.token] = edge
logging.info("Add link between %s and %s", src_node.name, dst_node.name) logging.info("Add link between %s and %s", src_node.name, dst_node.name)
def get_wlan_configs_proto(self) -> List[core_pb2.WlanConfig]: def get_wlan_configs_proto(self) -> List[WlanConfig]:
configs = [] configs = []
for node_id, config in self.wlan_configs.items(): for node_id, config in self.wlan_configs.items():
config = {x: config[x].value for x in config} config = {x: config[x].value for x in config}
wlan_config = core_pb2.WlanConfig(node_id=node_id, config=config) wlan_config = WlanConfig(node_id=node_id, config=config)
configs.append(wlan_config) configs.append(wlan_config)
return configs return configs
def get_mobility_configs_proto(self) -> List[core_pb2.MobilityConfig]: def get_mobility_configs_proto(self) -> List[MobilityConfig]:
configs = [] configs = []
for node_id, config in self.mobility_configs.items(): for node_id, config in self.mobility_configs.items():
config = {x: config[x].value for x in config} config = {x: config[x].value for x in config}
mobility_config = core_pb2.MobilityConfig(node_id=node_id, config=config) mobility_config = MobilityConfig(node_id=node_id, config=config)
configs.append(mobility_config) configs.append(mobility_config)
return configs return configs
def get_emane_model_configs_proto(self) -> List[core_pb2.EmaneModelConfig]: def get_emane_model_configs_proto(self) -> List[EmaneModelConfig]:
configs = [] configs = []
for key, config in self.emane_model_configs.items(): for key, config in self.emane_model_configs.items():
node_id, model, interface = key node_id, model, interface = key
config = {x: config[x].value for x in config} config = {x: config[x].value for x in config}
if interface is None: if interface is None:
interface = -1 interface = -1
config_proto = core_pb2.EmaneModelConfig( config_proto = EmaneModelConfig(
node_id=node_id, interface_id=interface, model=model, config=config node_id=node_id, interface_id=interface, model=model, config=config
) )
configs.append(config_proto) configs.append(config_proto)
return configs return configs
def get_service_configs_proto(self) -> List[core_pb2.ServiceConfig]: def get_service_configs_proto(self) -> List[ServiceConfig]:
configs = [] configs = []
for node_id, services in self.service_configs.items(): for node_id, services in self.service_configs.items():
for name, config in services.items(): for name, config in services.items():
config_proto = core_pb2.ServiceConfig( config_proto = ServiceConfig(
node_id=node_id, node_id=node_id,
service=name, service=name,
directories=config.dirs, directories=config.dirs,
@ -957,12 +959,12 @@ class CoreClient:
configs.append(config_proto) configs.append(config_proto)
return configs return configs
def get_service_file_configs_proto(self) -> List[core_pb2.ServiceFileConfig]: def get_service_file_configs_proto(self) -> List[ServiceFileConfig]:
configs = [] configs = []
for (node_id, file_configs) in self.file_configs.items(): for (node_id, file_configs) in self.file_configs.items():
for service, file_config in file_configs.items(): for service, file_config in file_configs.items():
for file, data in file_config.items(): for file, data in file_config.items():
config_proto = core_pb2.ServiceFileConfig( config_proto = ServiceFileConfig(
node_id=node_id, service=service, file=file, data=data node_id=node_id, service=service, file=file, data=data
) )
configs.append(config_proto) configs.append(config_proto)

View file

@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, List
import grpc import grpc
from core.api.grpc import core_pb2 from core.api.grpc.services_pb2 import ServiceValidationMode
from core.gui.dialogs.dialog import Dialog from core.gui.dialogs.dialog import Dialog
from core.gui.errors import show_grpc_error from core.gui.errors import show_grpc_error
from core.gui.themes import FRAME_PAD, PADX, PADY from core.gui.themes import FRAME_PAD, PADX, PADY
@ -256,9 +256,9 @@ class ConfigServiceConfigDialog(Dialog):
label = ttk.Label(frame, text="Validation Mode") label = ttk.Label(frame, text="Validation Mode")
label.grid(row=1, column=0, sticky="w", padx=PADX) label.grid(row=1, column=0, sticky="w", padx=PADX)
if self.validation_mode == core_pb2.ServiceValidationMode.BLOCKING: if self.validation_mode == ServiceValidationMode.BLOCKING:
mode = "BLOCKING" mode = "BLOCKING"
elif self.validation_mode == core_pb2.ServiceValidationMode.NON_BLOCKING: elif self.validation_mode == ServiceValidationMode.NON_BLOCKING:
mode = "NON_BLOCKING" mode = "NON_BLOCKING"
else: else:
mode = "TIMER" mode = "TIMER"

View file

@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any
import grpc import grpc
from core.api.grpc.core_pb2 import MobilityAction from core.api.grpc.mobility_pb2 import MobilityAction
from core.gui.dialogs.dialog import Dialog from core.gui.dialogs.dialog import Dialog
from core.gui.errors import show_grpc_error from core.gui.errors import show_grpc_error
from core.gui.images import ImageEnum, Images from core.gui.images import ImageEnum, Images

View file

@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Any, List
import grpc import grpc
from core.api.grpc import core_pb2 from core.api.grpc.services_pb2 import ServiceValidationMode
from core.gui.dialogs.copyserviceconfig import CopyServiceConfigDialog from core.gui.dialogs.copyserviceconfig import CopyServiceConfigDialog
from core.gui.dialogs.dialog import Dialog from core.gui.dialogs.dialog import Dialog
from core.gui.errors import show_grpc_error from core.gui.errors import show_grpc_error
@ -331,9 +331,9 @@ class ServiceConfigDialog(Dialog):
label = ttk.Label(frame, text="Validation Mode") label = ttk.Label(frame, text="Validation Mode")
label.grid(row=1, column=0, sticky="w", padx=PADX) label.grid(row=1, column=0, sticky="w", padx=PADX)
if self.validation_mode == core_pb2.ServiceValidationMode.BLOCKING: if self.validation_mode == ServiceValidationMode.BLOCKING:
mode = "BLOCKING" mode = "BLOCKING"
elif self.validation_mode == core_pb2.ServiceValidationMode.NON_BLOCKING: elif self.validation_mode == ServiceValidationMode.NON_BLOCKING:
mode = "NON_BLOCKING" mode = "NON_BLOCKING"
else: else:
mode = "TIMER" mode = "TIMER"

View file

@ -10,3 +10,7 @@ message ConfigOption {
repeated string select = 5; repeated string select = 5;
string group = 6; string group = 6;
} }
message MappedConfig {
map<string, common.ConfigOption> config = 1;
}

View file

@ -2,11 +2,12 @@ syntax = "proto3";
package core; package core;
option java_package = "com.core.client.grpc";
option java_outer_classname = "CoreProto";
import "core/api/grpc/configservices.proto"; import "core/api/grpc/configservices.proto";
import "core/api/grpc/common.proto"; import "core/api/grpc/common.proto";
import "core/api/grpc/emane.proto";
import "core/api/grpc/mobility.proto";
import "core/api/grpc/services.proto";
import "core/api/grpc/wlan.proto";
service CoreApi { service CoreApi {
// session rpc // session rpc
@ -78,33 +79,33 @@ service CoreApi {
} }
// mobility rpc // mobility rpc
rpc GetMobilityConfigs (GetMobilityConfigsRequest) returns (GetMobilityConfigsResponse) { rpc GetMobilityConfigs (mobility.GetMobilityConfigsRequest) returns (mobility.GetMobilityConfigsResponse) {
} }
rpc GetMobilityConfig (GetMobilityConfigRequest) returns (GetMobilityConfigResponse) { rpc GetMobilityConfig (mobility.GetMobilityConfigRequest) returns (mobility.GetMobilityConfigResponse) {
} }
rpc SetMobilityConfig (SetMobilityConfigRequest) returns (SetMobilityConfigResponse) { rpc SetMobilityConfig (mobility.SetMobilityConfigRequest) returns (mobility.SetMobilityConfigResponse) {
} }
rpc MobilityAction (MobilityActionRequest) returns (MobilityActionResponse) { rpc MobilityAction (mobility.MobilityActionRequest) returns (mobility.MobilityActionResponse) {
} }
// service rpc // service rpc
rpc GetServices (GetServicesRequest) returns (GetServicesResponse) { rpc GetServices (services.GetServicesRequest) returns (services.GetServicesResponse) {
} }
rpc GetServiceDefaults (GetServiceDefaultsRequest) returns (GetServiceDefaultsResponse) { rpc GetServiceDefaults (services.GetServiceDefaultsRequest) returns (services.GetServiceDefaultsResponse) {
} }
rpc SetServiceDefaults (SetServiceDefaultsRequest) returns (SetServiceDefaultsResponse) { rpc SetServiceDefaults (services.SetServiceDefaultsRequest) returns (services.SetServiceDefaultsResponse) {
} }
rpc GetNodeServiceConfigs (GetNodeServiceConfigsRequest) returns (GetNodeServiceConfigsResponse) { rpc GetNodeServiceConfigs (services.GetNodeServiceConfigsRequest) returns (services.GetNodeServiceConfigsResponse) {
} }
rpc GetNodeService (GetNodeServiceRequest) returns (GetNodeServiceResponse) { rpc GetNodeService (services.GetNodeServiceRequest) returns (services.GetNodeServiceResponse) {
} }
rpc GetNodeServiceFile (GetNodeServiceFileRequest) returns (GetNodeServiceFileResponse) { rpc GetNodeServiceFile (services.GetNodeServiceFileRequest) returns (services.GetNodeServiceFileResponse) {
} }
rpc SetNodeService (SetNodeServiceRequest) returns (SetNodeServiceResponse) { rpc SetNodeService (services.SetNodeServiceRequest) returns (services.SetNodeServiceResponse) {
} }
rpc SetNodeServiceFile (SetNodeServiceFileRequest) returns (SetNodeServiceFileResponse) { rpc SetNodeServiceFile (services.SetNodeServiceFileRequest) returns (services.SetNodeServiceFileResponse) {
} }
rpc ServiceAction (ServiceActionRequest) returns (ServiceActionResponse) { rpc ServiceAction (services.ServiceActionRequest) returns (services.ServiceActionResponse) {
} }
// config services // config services
@ -122,27 +123,27 @@ service CoreApi {
} }
// wlan rpc // wlan rpc
rpc GetWlanConfigs (GetWlanConfigsRequest) returns (GetWlanConfigsResponse) { rpc GetWlanConfigs (wlan.GetWlanConfigsRequest) returns (wlan.GetWlanConfigsResponse) {
} }
rpc GetWlanConfig (GetWlanConfigRequest) returns (GetWlanConfigResponse) { rpc GetWlanConfig (wlan.GetWlanConfigRequest) returns (wlan.GetWlanConfigResponse) {
} }
rpc SetWlanConfig (SetWlanConfigRequest) returns (SetWlanConfigResponse) { rpc SetWlanConfig (wlan.SetWlanConfigRequest) returns (wlan.SetWlanConfigResponse) {
} }
// emane rpc // emane rpc
rpc GetEmaneConfig (GetEmaneConfigRequest) returns (GetEmaneConfigResponse) { rpc GetEmaneConfig (emane.GetEmaneConfigRequest) returns (emane.GetEmaneConfigResponse) {
} }
rpc SetEmaneConfig (SetEmaneConfigRequest) returns (SetEmaneConfigResponse) { rpc SetEmaneConfig (emane.SetEmaneConfigRequest) returns (emane.SetEmaneConfigResponse) {
} }
rpc GetEmaneModels (GetEmaneModelsRequest) returns (GetEmaneModelsResponse) { rpc GetEmaneModels (emane.GetEmaneModelsRequest) returns (emane.GetEmaneModelsResponse) {
} }
rpc GetEmaneModelConfig (GetEmaneModelConfigRequest) returns (GetEmaneModelConfigResponse) { rpc GetEmaneModelConfig (emane.GetEmaneModelConfigRequest) returns (emane.GetEmaneModelConfigResponse) {
} }
rpc SetEmaneModelConfig (SetEmaneModelConfigRequest) returns (SetEmaneModelConfigResponse) { rpc SetEmaneModelConfig (emane.SetEmaneModelConfigRequest) returns (emane.SetEmaneModelConfigResponse) {
} }
rpc GetEmaneModelConfigs (GetEmaneModelConfigsRequest) returns (GetEmaneModelConfigsResponse) { rpc GetEmaneModelConfigs (emane.GetEmaneModelConfigsRequest) returns (emane.GetEmaneModelConfigsResponse) {
} }
rpc GetEmaneEventChannel (GetEmaneEventChannelRequest) returns (GetEmaneEventChannelResponse) { rpc GetEmaneEventChannel (emane.GetEmaneEventChannelRequest) returns (emane.GetEmaneEventChannelResponse) {
} }
// xml rpc // xml rpc
@ -154,7 +155,7 @@ service CoreApi {
// utilities // utilities
rpc GetInterfaces (GetInterfacesRequest) returns (GetInterfacesResponse) { rpc GetInterfaces (GetInterfacesRequest) returns (GetInterfacesResponse) {
} }
rpc EmaneLink (EmaneLinkRequest) returns (EmaneLinkResponse) { rpc EmaneLink (emane.EmaneLinkRequest) returns (emane.EmaneLinkResponse) {
} }
rpc ExecuteScript (ExecuteScriptRequest) returns (ExecuteScriptResponse) { rpc ExecuteScript (ExecuteScriptRequest) returns (ExecuteScriptResponse) {
} }
@ -168,11 +169,11 @@ message StartSessionRequest {
repeated Hook hooks = 4; repeated Hook hooks = 4;
SessionLocation location = 5; SessionLocation location = 5;
map<string, string> emane_config = 6; map<string, string> emane_config = 6;
repeated WlanConfig wlan_configs = 7; repeated wlan.WlanConfig wlan_configs = 7;
repeated EmaneModelConfig emane_model_configs = 8; repeated emane.EmaneModelConfig emane_model_configs = 8;
repeated MobilityConfig mobility_configs = 9; repeated mobility.MobilityConfig mobility_configs = 9;
repeated ServiceConfig service_configs = 10; repeated services.ServiceConfig service_configs = 10;
repeated ServiceFileConfig service_file_configs = 11; repeated services.ServiceFileConfig service_file_configs = 11;
repeated Link asymmetric_links = 12; repeated Link asymmetric_links = 12;
repeated configservices.ConfigServiceConfig config_service_configs = 13; repeated configservices.ConfigServiceConfig config_service_configs = 13;
} }
@ -515,226 +516,6 @@ message AddHookResponse {
bool result = 1; bool result = 1;
} }
message GetMobilityConfigsRequest {
int32 session_id = 1;
}
message GetMobilityConfigsResponse {
map<int32, MappedConfig> configs = 1;
}
message GetMobilityConfigRequest {
int32 session_id = 1;
int32 node_id = 2;
}
message GetMobilityConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetMobilityConfigRequest {
int32 session_id = 1;
MobilityConfig mobility_config = 2;
}
message SetMobilityConfigResponse {
bool result = 1;
}
message MobilityActionRequest {
int32 session_id = 1;
int32 node_id = 2;
MobilityAction.Enum action = 3;
}
message MobilityActionResponse {
bool result = 1;
}
message GetServicesRequest {
}
message GetServicesResponse {
repeated Service services = 1;
}
message GetServiceDefaultsRequest {
int32 session_id = 1;
}
message GetServiceDefaultsResponse {
repeated ServiceDefaults defaults = 1;
}
message SetServiceDefaultsRequest {
int32 session_id = 1;
repeated ServiceDefaults defaults = 2;
}
message SetServiceDefaultsResponse {
bool result = 1;
}
message GetNodeServiceConfigsRequest {
int32 session_id = 1;
}
message GetNodeServiceConfigsResponse {
message ServiceConfig {
int32 node_id = 1;
string service = 2;
NodeServiceData data = 3;
map<string, string> files = 4;
}
repeated ServiceConfig configs = 1;
}
message GetNodeServiceRequest {
int32 session_id = 1;
int32 node_id = 2;
string service = 3;
}
message GetNodeServiceResponse {
NodeServiceData service = 1;
}
message GetNodeServiceFileRequest {
int32 session_id = 1;
int32 node_id = 2;
string service = 3;
string file = 4;
}
message GetNodeServiceFileResponse {
string data = 1;
}
message SetNodeServiceRequest {
int32 session_id = 1;
ServiceConfig config = 2;
}
message SetNodeServiceResponse {
bool result = 1;
}
message SetNodeServiceFileRequest {
int32 session_id = 1;
ServiceFileConfig config = 2;
}
message SetNodeServiceFileResponse {
bool result = 1;
}
message ServiceActionRequest {
int32 session_id = 1;
int32 node_id = 2;
string service = 3;
ServiceAction.Enum action = 4;
}
message ServiceActionResponse {
bool result = 1;
}
message GetWlanConfigsRequest {
int32 session_id = 1;
}
message GetWlanConfigsResponse {
map<int32, MappedConfig> configs = 1;
}
message GetWlanConfigRequest {
int32 session_id = 1;
int32 node_id = 2;
}
message GetWlanConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetWlanConfigRequest {
int32 session_id = 1;
WlanConfig wlan_config = 2;
}
message SetWlanConfigResponse {
bool result = 1;
}
message GetEmaneConfigRequest {
int32 session_id = 1;
}
message GetEmaneConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetEmaneConfigRequest {
int32 session_id = 1;
map<string, string> config = 2;
}
message SetEmaneConfigResponse {
bool result = 1;
}
message GetEmaneModelsRequest {
int32 session_id = 1;
}
message GetEmaneModelsResponse {
repeated string models = 1;
}
message GetEmaneModelConfigRequest {
int32 session_id = 1;
int32 node_id = 2;
int32 interface = 3;
string model = 4;
}
message GetEmaneModelConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetEmaneModelConfigRequest {
int32 session_id = 1;
EmaneModelConfig emane_model_config = 2;
}
message SetEmaneModelConfigResponse {
bool result = 1;
}
message GetEmaneModelConfigsRequest {
int32 session_id = 1;
}
message GetEmaneModelConfigsResponse {
message ModelConfig {
int32 node_id = 1;
string model = 2;
int32 interface = 3;
map<string, common.ConfigOption> config = 4;
}
repeated ModelConfig configs = 1;
}
message GetEmaneEventChannelRequest {
int32 session_id = 1;
}
message GetEmaneEventChannelResponse {
string group = 1;
int32 port = 2;
string device = 3;
}
message SaveXmlRequest { message SaveXmlRequest {
int32 session_id = 1; int32 session_id = 1;
} }
@ -761,17 +542,6 @@ message GetInterfacesResponse {
repeated string interfaces = 1; repeated string interfaces = 1;
} }
message EmaneLinkRequest {
int32 session_id = 1;
int32 nem_one = 2;
int32 nem_two = 3;
bool linked = 4;
}
message EmaneLinkResponse {
bool result = 1;
}
message ExecuteScriptRequest { message ExecuteScriptRequest {
string script = 1; string script = 1;
} }
@ -781,40 +551,6 @@ message ExecuteScriptResponse {
} }
// data structures for messages below // data structures for messages below
message WlanConfig {
int32 node_id = 1;
map<string, string> config = 2;
}
message MobilityConfig {
int32 node_id = 1;
map<string, string> config = 2;
}
message EmaneModelConfig {
int32 node_id = 1;
int32 interface_id = 2;
string model = 3;
map<string, string> config = 4;
}
message ServiceConfig {
int32 node_id = 1;
string service = 2;
repeated string startup = 3;
repeated string validate = 4;
repeated string shutdown = 5;
repeated string files = 6;
repeated string directories = 7;
}
message ServiceFileConfig {
int32 node_id = 1;
string service = 2;
string file = 3;
string data = 4;
}
message EventType { message EventType {
enum Enum { enum Enum {
SESSION = 0; SESSION = 0;
@ -893,31 +629,6 @@ message ConfigOptionType {
} }
} }
message ServiceValidationMode {
enum Enum {
BLOCKING = 0;
NON_BLOCKING = 1;
TIMER = 2;
}
}
message ServiceAction {
enum Enum {
START = 0;
STOP = 1;
RESTART = 2;
VALIDATE = 3;
}
}
message MobilityAction {
enum Enum {
START = 0;
PAUSE = 1;
STOP = 2;
}
}
message ExceptionLevel { message ExceptionLevel {
enum Enum { enum Enum {
DEFAULT = 0; DEFAULT = 0;
@ -934,33 +645,6 @@ message Hook {
string data = 3; string data = 3;
} }
message ServiceDefaults {
string node_type = 1;
repeated string services = 2;
}
message Service {
string group = 1;
string name = 2;
}
message NodeServiceData {
repeated string executables = 1;
repeated string dependencies = 2;
repeated string dirs = 3;
repeated string configs = 4;
repeated string startup = 5;
repeated string validate = 6;
ServiceValidationMode.Enum validation_mode = 7;
int32 validation_timer = 8;
repeated string shutdown = 9;
string meta = 10;
}
message MappedConfig {
map<string, common.ConfigOption> config = 1;
}
message Session { message Session {
int32 id = 1; int32 id = 1;
SessionState.Enum state = 2; SessionState.Enum state = 2;

View file

@ -0,0 +1,92 @@
syntax = "proto3";
package emane;
import "core/api/grpc/common.proto";
message GetEmaneConfigRequest {
int32 session_id = 1;
}
message GetEmaneConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetEmaneConfigRequest {
int32 session_id = 1;
map<string, string> config = 2;
}
message SetEmaneConfigResponse {
bool result = 1;
}
message GetEmaneModelsRequest {
int32 session_id = 1;
}
message GetEmaneModelsResponse {
repeated string models = 1;
}
message GetEmaneModelConfigRequest {
int32 session_id = 1;
int32 node_id = 2;
int32 interface = 3;
string model = 4;
}
message GetEmaneModelConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetEmaneModelConfigRequest {
int32 session_id = 1;
EmaneModelConfig emane_model_config = 2;
}
message SetEmaneModelConfigResponse {
bool result = 1;
}
message GetEmaneModelConfigsRequest {
int32 session_id = 1;
}
message GetEmaneModelConfigsResponse {
message ModelConfig {
int32 node_id = 1;
string model = 2;
int32 interface = 3;
map<string, common.ConfigOption> config = 4;
}
repeated ModelConfig configs = 1;
}
message GetEmaneEventChannelRequest {
int32 session_id = 1;
}
message GetEmaneEventChannelResponse {
string group = 1;
int32 port = 2;
string device = 3;
}
message EmaneLinkRequest {
int32 session_id = 1;
int32 nem_one = 2;
int32 nem_two = 3;
bool linked = 4;
}
message EmaneLinkResponse {
bool result = 1;
}
message EmaneModelConfig {
int32 node_id = 1;
int32 interface_id = 2;
string model = 3;
map<string, string> config = 4;
}

View file

@ -0,0 +1,54 @@
syntax = "proto3";
package mobility;
import "core/api/grpc/common.proto";
message MobilityAction {
enum Enum {
START = 0;
PAUSE = 1;
STOP = 2;
}
}
message MobilityConfig {
int32 node_id = 1;
map<string, string> config = 2;
}
message GetMobilityConfigsRequest {
int32 session_id = 1;
}
message GetMobilityConfigsResponse {
map<int32, common.MappedConfig> configs = 1;
}
message GetMobilityConfigRequest {
int32 session_id = 1;
int32 node_id = 2;
}
message GetMobilityConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetMobilityConfigRequest {
int32 session_id = 1;
MobilityConfig mobility_config = 2;
}
message SetMobilityConfigResponse {
bool result = 1;
}
message MobilityActionRequest {
int32 session_id = 1;
int32 node_id = 2;
MobilityAction.Enum action = 3;
}
message MobilityActionResponse {
bool result = 1;
}

View file

@ -0,0 +1,149 @@
syntax = "proto3";
package services;
message ServiceConfig {
int32 node_id = 1;
string service = 2;
repeated string startup = 3;
repeated string validate = 4;
repeated string shutdown = 5;
repeated string files = 6;
repeated string directories = 7;
}
message ServiceFileConfig {
int32 node_id = 1;
string service = 2;
string file = 3;
string data = 4;
}
message ServiceValidationMode {
enum Enum {
BLOCKING = 0;
NON_BLOCKING = 1;
TIMER = 2;
}
}
message ServiceAction {
enum Enum {
START = 0;
STOP = 1;
RESTART = 2;
VALIDATE = 3;
}
}
message ServiceDefaults {
string node_type = 1;
repeated string services = 2;
}
message Service {
string group = 1;
string name = 2;
}
message NodeServiceData {
repeated string executables = 1;
repeated string dependencies = 2;
repeated string dirs = 3;
repeated string configs = 4;
repeated string startup = 5;
repeated string validate = 6;
ServiceValidationMode.Enum validation_mode = 7;
int32 validation_timer = 8;
repeated string shutdown = 9;
string meta = 10;
}
message GetServicesRequest {
}
message GetServicesResponse {
repeated Service services = 1;
}
message GetServiceDefaultsRequest {
int32 session_id = 1;
}
message GetServiceDefaultsResponse {
repeated ServiceDefaults defaults = 1;
}
message SetServiceDefaultsRequest {
int32 session_id = 1;
repeated ServiceDefaults defaults = 2;
}
message SetServiceDefaultsResponse {
bool result = 1;
}
message GetNodeServiceConfigsRequest {
int32 session_id = 1;
}
message GetNodeServiceConfigsResponse {
message ServiceConfig {
int32 node_id = 1;
string service = 2;
NodeServiceData data = 3;
map<string, string> files = 4;
}
repeated ServiceConfig configs = 1;
}
message GetNodeServiceRequest {
int32 session_id = 1;
int32 node_id = 2;
string service = 3;
}
message GetNodeServiceResponse {
NodeServiceData service = 1;
}
message GetNodeServiceFileRequest {
int32 session_id = 1;
int32 node_id = 2;
string service = 3;
string file = 4;
}
message GetNodeServiceFileResponse {
string data = 1;
}
message SetNodeServiceRequest {
int32 session_id = 1;
ServiceConfig config = 2;
}
message SetNodeServiceResponse {
bool result = 1;
}
message SetNodeServiceFileRequest {
int32 session_id = 1;
ServiceFileConfig config = 2;
}
message SetNodeServiceFileResponse {
bool result = 1;
}
message ServiceActionRequest {
int32 session_id = 1;
int32 node_id = 2;
string service = 3;
ServiceAction.Enum action = 4;
}
message ServiceActionResponse {
bool result = 1;
}

View file

@ -0,0 +1,36 @@
syntax = "proto3";
package wlan;
import "core/api/grpc/common.proto";
message WlanConfig {
int32 node_id = 1;
map<string, string> config = 2;
}
message GetWlanConfigsRequest {
int32 session_id = 1;
}
message GetWlanConfigsResponse {
map<int32, common.MappedConfig> configs = 1;
}
message GetWlanConfigRequest {
int32 session_id = 1;
int32 node_id = 2;
}
message GetWlanConfigResponse {
map<string, common.ConfigOption> config = 1;
}
message SetWlanConfigRequest {
int32 session_id = 1;
WlanConfig wlan_config = 2;
}
message SetWlanConfigResponse {
bool result = 1;
}

View file

@ -7,6 +7,10 @@ from mock import patch
from core.api.grpc import core_pb2 from core.api.grpc import core_pb2
from core.api.grpc.client import CoreGrpcClient, InterfaceHelper from core.api.grpc.client import CoreGrpcClient, InterfaceHelper
from core.api.grpc.emane_pb2 import EmaneModelConfig
from core.api.grpc.mobility_pb2 import MobilityAction, MobilityConfig
from core.api.grpc.services_pb2 import ServiceAction, ServiceConfig, ServiceFileConfig
from core.api.grpc.wlan_pb2 import WlanConfig
from core.api.tlv.dataconversion import ConfigShim from core.api.tlv.dataconversion import ConfigShim
from core.api.tlv.enumerations import ConfigFlags from core.api.tlv.enumerations import ConfigFlags
from core.emane.ieee80211abg import EmaneIeee80211abgModel from core.emane.ieee80211abg import EmaneIeee80211abgModel
@ -69,7 +73,7 @@ class TestGrpc:
model_node_id = 20 model_node_id = 20
model_config_key = "bandwidth" model_config_key = "bandwidth"
model_config_value = "500000" model_config_value = "500000"
model_config = core_pb2.EmaneModelConfig( model_config = EmaneModelConfig(
node_id=model_node_id, node_id=model_node_id,
interface_id=-1, interface_id=-1,
model=EmaneIeee80211abgModel.name, model=EmaneIeee80211abgModel.name,
@ -78,21 +82,21 @@ class TestGrpc:
model_configs = [model_config] model_configs = [model_config]
wlan_config_key = "range" wlan_config_key = "range"
wlan_config_value = "333" wlan_config_value = "333"
wlan_config = core_pb2.WlanConfig( wlan_config = WlanConfig(
node_id=wlan_node.id, config={wlan_config_key: wlan_config_value} node_id=wlan_node.id, config={wlan_config_key: wlan_config_value}
) )
wlan_configs = [wlan_config] wlan_configs = [wlan_config]
mobility_config_key = "refresh_ms" mobility_config_key = "refresh_ms"
mobility_config_value = "60" mobility_config_value = "60"
mobility_config = core_pb2.MobilityConfig( mobility_config = MobilityConfig(
node_id=wlan_node.id, config={mobility_config_key: mobility_config_value} node_id=wlan_node.id, config={mobility_config_key: mobility_config_value}
) )
mobility_configs = [mobility_config] mobility_configs = [mobility_config]
service_config = core_pb2.ServiceConfig( service_config = ServiceConfig(
node_id=node_one.id, service="DefaultRoute", validate=["echo hello"] node_id=node_one.id, service="DefaultRoute", validate=["echo hello"]
) )
service_configs = [service_config] service_configs = [service_config]
service_file_config = core_pb2.ServiceFileConfig( service_file_config = ServiceFileConfig(
node_id=node_one.id, node_id=node_one.id,
service="DefaultRoute", service="DefaultRoute",
file="defaultroute.sh", file="defaultroute.sh",
@ -829,9 +833,7 @@ class TestGrpc:
# then # then
with client.context_connect(): with client.context_connect():
response = client.mobility_action( response = client.mobility_action(session.id, wlan.id, MobilityAction.STOP)
session.id, wlan.id, core_pb2.MobilityAction.STOP
)
# then # then
assert response.result is True assert response.result is True
@ -971,7 +973,7 @@ class TestGrpc:
# then # then
with client.context_connect(): with client.context_connect():
response = client.service_action( response = client.service_action(
session.id, node.id, service_name, core_pb2.ServiceAction.STOP session.id, node.id, service_name, ServiceAction.STOP
) )
# then # then