updates to break up core.proto into separate logical files
This commit is contained in:
parent
38f9f44cdf
commit
6a41012857
14 changed files with 673 additions and 555 deletions
|
@ -26,11 +26,69 @@ from core.api.grpc.configservices_pb2 import (
|
|||
SetNodeConfigServiceRequest,
|
||||
SetNodeConfigServiceResponse,
|
||||
)
|
||||
from core.api.grpc.core_pb2 import (
|
||||
ExecuteScriptRequest,
|
||||
ExecuteScriptResponse,
|
||||
from core.api.grpc.core_pb2 import ExecuteScriptRequest, ExecuteScriptResponse
|
||||
from core.api.grpc.emane_pb2 import (
|
||||
EmaneLinkRequest,
|
||||
EmaneLinkResponse,
|
||||
EmaneModelConfig,
|
||||
GetEmaneConfigRequest,
|
||||
GetEmaneConfigResponse,
|
||||
GetEmaneEventChannelRequest,
|
||||
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,
|
||||
hooks: List[core_pb2.Hook] = None,
|
||||
emane_config: Dict[str, str] = None,
|
||||
emane_model_configs: List[core_pb2.EmaneModelConfig] = None,
|
||||
wlan_configs: List[core_pb2.WlanConfig] = None,
|
||||
mobility_configs: List[core_pb2.MobilityConfig] = None,
|
||||
service_configs: List[core_pb2.ServiceConfig] = None,
|
||||
service_file_configs: List[core_pb2.ServiceFileConfig] = None,
|
||||
emane_model_configs: List[EmaneModelConfig] = None,
|
||||
wlan_configs: List[WlanConfig] = None,
|
||||
mobility_configs: List[MobilityConfig] = None,
|
||||
service_configs: List[ServiceConfig] = None,
|
||||
service_file_configs: List[ServiceFileConfig] = None,
|
||||
asymmetric_links: List[core_pb2.Link] = None,
|
||||
config_service_configs: List[configservices_pb2.ConfigServiceConfig] = None,
|
||||
) -> core_pb2.StartSessionResponse:
|
||||
|
@ -678,7 +736,7 @@ class CoreGrpcClient:
|
|||
session_id: int,
|
||||
state: core_pb2.SessionState,
|
||||
file_name: str,
|
||||
file_data: bytes,
|
||||
file_data: str,
|
||||
) -> core_pb2.AddHookResponse:
|
||||
"""
|
||||
Add hook scripts.
|
||||
|
@ -694,9 +752,7 @@ class CoreGrpcClient:
|
|||
request = core_pb2.AddHookRequest(session_id=session_id, hook=hook)
|
||||
return self.stub.AddHook(request)
|
||||
|
||||
def get_mobility_configs(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetMobilityConfigsResponse:
|
||||
def get_mobility_configs(self, session_id: int) -> GetMobilityConfigsResponse:
|
||||
"""
|
||||
Get all mobility configurations.
|
||||
|
||||
|
@ -704,12 +760,12 @@ class CoreGrpcClient:
|
|||
:return: response with a dict of node ids to mobility configurations
|
||||
: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)
|
||||
|
||||
def get_mobility_config(
|
||||
self, session_id: int, node_id: int
|
||||
) -> core_pb2.GetMobilityConfigResponse:
|
||||
) -> GetMobilityConfigResponse:
|
||||
"""
|
||||
Get mobility configuration for a node.
|
||||
|
||||
|
@ -718,14 +774,12 @@ class CoreGrpcClient:
|
|||
:return: response with a list of configuration groups
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetMobilityConfigRequest(
|
||||
session_id=session_id, node_id=node_id
|
||||
)
|
||||
request = GetMobilityConfigRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.GetMobilityConfig(request)
|
||||
|
||||
def set_mobility_config(
|
||||
self, session_id: int, node_id: int, config: Dict[str, str]
|
||||
) -> core_pb2.SetMobilityConfigResponse:
|
||||
) -> SetMobilityConfigResponse:
|
||||
"""
|
||||
Set mobility configuration for a node.
|
||||
|
||||
|
@ -735,15 +789,15 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
mobility_config = core_pb2.MobilityConfig(node_id=node_id, config=config)
|
||||
request = core_pb2.SetMobilityConfigRequest(
|
||||
mobility_config = MobilityConfig(node_id=node_id, config=config)
|
||||
request = SetMobilityConfigRequest(
|
||||
session_id=session_id, mobility_config=mobility_config
|
||||
)
|
||||
return self.stub.SetMobilityConfig(request)
|
||||
|
||||
def mobility_action(
|
||||
self, session_id: int, node_id: int, action: core_pb2.ServiceAction
|
||||
) -> core_pb2.MobilityActionResponse:
|
||||
self, session_id: int, node_id: int, action: ServiceAction
|
||||
) -> MobilityActionResponse:
|
||||
"""
|
||||
Send a mobility action for a node.
|
||||
|
||||
|
@ -753,23 +807,21 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
: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
|
||||
)
|
||||
return self.stub.MobilityAction(request)
|
||||
|
||||
def get_services(self) -> core_pb2.GetServicesResponse:
|
||||
def get_services(self) -> GetServicesResponse:
|
||||
"""
|
||||
Get all currently loaded services.
|
||||
|
||||
:return: response with a list of services
|
||||
"""
|
||||
request = core_pb2.GetServicesRequest()
|
||||
request = GetServicesRequest()
|
||||
return self.stub.GetServices(request)
|
||||
|
||||
def get_service_defaults(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetServiceDefaultsResponse:
|
||||
def get_service_defaults(self, session_id: int) -> GetServiceDefaultsResponse:
|
||||
"""
|
||||
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
|
||||
: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)
|
||||
|
||||
def set_service_defaults(
|
||||
self, session_id: int, service_defaults: Dict[str, List[str]]
|
||||
) -> core_pb2.SetServiceDefaultsResponse:
|
||||
) -> SetServiceDefaultsResponse:
|
||||
"""
|
||||
Set default services for node models.
|
||||
|
||||
|
@ -794,16 +846,14 @@ class CoreGrpcClient:
|
|||
defaults = []
|
||||
for node_type in service_defaults:
|
||||
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)
|
||||
request = core_pb2.SetServiceDefaultsRequest(
|
||||
session_id=session_id, defaults=defaults
|
||||
)
|
||||
request = SetServiceDefaultsRequest(session_id=session_id, defaults=defaults)
|
||||
return self.stub.SetServiceDefaults(request)
|
||||
|
||||
def get_node_service_configs(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetNodeServiceConfigsResponse:
|
||||
) -> GetNodeServiceConfigsResponse:
|
||||
"""
|
||||
Get service data for a node.
|
||||
|
||||
|
@ -811,12 +861,12 @@ class CoreGrpcClient:
|
|||
:return: response with all node service configs
|
||||
: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)
|
||||
|
||||
def get_node_service(
|
||||
self, session_id: int, node_id: int, service: str
|
||||
) -> core_pb2.GetNodeServiceResponse:
|
||||
) -> GetNodeServiceResponse:
|
||||
"""
|
||||
Get service data for a node.
|
||||
|
||||
|
@ -826,14 +876,14 @@ class CoreGrpcClient:
|
|||
:return: response with node service data
|
||||
: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
|
||||
)
|
||||
return self.stub.GetNodeService(request)
|
||||
|
||||
def get_node_service_file(
|
||||
self, session_id: int, node_id: int, service: str, file_name: str
|
||||
) -> core_pb2.GetNodeServiceFileResponse:
|
||||
) -> GetNodeServiceFileResponse:
|
||||
"""
|
||||
Get a service file for a node.
|
||||
|
||||
|
@ -844,7 +894,7 @@ class CoreGrpcClient:
|
|||
:return: response with file data
|
||||
: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
|
||||
)
|
||||
return self.stub.GetNodeServiceFile(request)
|
||||
|
@ -859,7 +909,7 @@ class CoreGrpcClient:
|
|||
startup: List[str] = None,
|
||||
validate: List[str] = None,
|
||||
shutdown: List[str] = None,
|
||||
) -> core_pb2.SetNodeServiceResponse:
|
||||
) -> SetNodeServiceResponse:
|
||||
"""
|
||||
Set service data for a node.
|
||||
|
||||
|
@ -874,7 +924,7 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
config = core_pb2.ServiceConfig(
|
||||
config = ServiceConfig(
|
||||
node_id=node_id,
|
||||
service=service,
|
||||
files=files,
|
||||
|
@ -883,12 +933,12 @@ class CoreGrpcClient:
|
|||
validate=validate,
|
||||
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)
|
||||
|
||||
def set_node_service_file(
|
||||
self, session_id: int, node_id: int, service: str, file_name: str, data: bytes
|
||||
) -> core_pb2.SetNodeServiceFileResponse:
|
||||
self, session_id: int, node_id: int, service: str, file_name: str, data: str
|
||||
) -> SetNodeServiceFileResponse:
|
||||
"""
|
||||
Set a service file for a node.
|
||||
|
||||
|
@ -900,21 +950,15 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
: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
|
||||
)
|
||||
request = core_pb2.SetNodeServiceFileRequest(
|
||||
session_id=session_id, config=config
|
||||
)
|
||||
request = SetNodeServiceFileRequest(session_id=session_id, config=config)
|
||||
return self.stub.SetNodeServiceFile(request)
|
||||
|
||||
def service_action(
|
||||
self,
|
||||
session_id: int,
|
||||
node_id: int,
|
||||
service: str,
|
||||
action: core_pb2.ServiceAction,
|
||||
) -> core_pb2.ServiceActionResponse:
|
||||
self, session_id: int, node_id: int, service: str, action: ServiceAction
|
||||
) -> ServiceActionResponse:
|
||||
"""
|
||||
Send an action to a service for a node.
|
||||
|
||||
|
@ -926,12 +970,12 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
: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
|
||||
)
|
||||
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.
|
||||
|
||||
|
@ -939,12 +983,10 @@ class CoreGrpcClient:
|
|||
:return: response with a dict of node ids to wlan configurations
|
||||
: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)
|
||||
|
||||
def get_wlan_config(
|
||||
self, session_id: int, node_id: int
|
||||
) -> core_pb2.GetWlanConfigResponse:
|
||||
def get_wlan_config(self, session_id: int, node_id: int) -> GetWlanConfigResponse:
|
||||
"""
|
||||
Get wlan configuration for a node.
|
||||
|
||||
|
@ -953,12 +995,12 @@ class CoreGrpcClient:
|
|||
:return: response with a list of configuration groups
|
||||
: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)
|
||||
|
||||
def set_wlan_config(
|
||||
self, session_id: int, node_id: int, config: Dict[str, str]
|
||||
) -> core_pb2.SetWlanConfigResponse:
|
||||
) -> SetWlanConfigResponse:
|
||||
"""
|
||||
Set wlan configuration for a node.
|
||||
|
||||
|
@ -968,13 +1010,11 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
wlan_config = core_pb2.WlanConfig(node_id=node_id, config=config)
|
||||
request = core_pb2.SetWlanConfigRequest(
|
||||
session_id=session_id, wlan_config=wlan_config
|
||||
)
|
||||
wlan_config = WlanConfig(node_id=node_id, config=config)
|
||||
request = SetWlanConfigRequest(session_id=session_id, wlan_config=wlan_config)
|
||||
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.
|
||||
|
||||
|
@ -982,12 +1022,12 @@ class CoreGrpcClient:
|
|||
:return: response with a list of configuration groups
|
||||
: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)
|
||||
|
||||
def set_emane_config(
|
||||
self, session_id: int, config: Dict[str, str]
|
||||
) -> core_pb2.SetEmaneConfigResponse:
|
||||
) -> SetEmaneConfigResponse:
|
||||
"""
|
||||
Set session emane configuration.
|
||||
|
||||
|
@ -996,10 +1036,10 @@ class CoreGrpcClient:
|
|||
:return: response with result of success or failure
|
||||
: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)
|
||||
|
||||
def get_emane_models(self, session_id: int) -> core_pb2.GetEmaneModelsResponse:
|
||||
def get_emane_models(self, session_id: int) -> GetEmaneModelsResponse:
|
||||
"""
|
||||
Get session emane models.
|
||||
|
||||
|
@ -1007,12 +1047,12 @@ class CoreGrpcClient:
|
|||
:return: response with a list of emane models
|
||||
: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)
|
||||
|
||||
def get_emane_model_config(
|
||||
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.
|
||||
|
||||
|
@ -1023,7 +1063,7 @@ class CoreGrpcClient:
|
|||
:return: response with a list of configuration groups
|
||||
: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
|
||||
)
|
||||
return self.stub.GetEmaneModelConfig(request)
|
||||
|
@ -1035,7 +1075,7 @@ class CoreGrpcClient:
|
|||
model: str,
|
||||
config: Dict[str, str],
|
||||
interface_id: int = -1,
|
||||
) -> core_pb2.SetEmaneModelConfigResponse:
|
||||
) -> SetEmaneModelConfigResponse:
|
||||
"""
|
||||
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
|
||||
: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
|
||||
)
|
||||
request = core_pb2.SetEmaneModelConfigRequest(
|
||||
request = SetEmaneModelConfigRequest(
|
||||
session_id=session_id, emane_model_config=model_config
|
||||
)
|
||||
return self.stub.SetEmaneModelConfig(request)
|
||||
|
||||
def get_emane_model_configs(
|
||||
self, session_id: int
|
||||
) -> core_pb2.GetEmaneModelConfigsResponse:
|
||||
def get_emane_model_configs(self, session_id: int) -> GetEmaneModelConfigsResponse:
|
||||
"""
|
||||
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
|
||||
: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)
|
||||
|
||||
def save_xml(self, session_id: int, file_path: str) -> core_pb2.SaveXmlResponse:
|
||||
|
@ -1096,7 +1134,7 @@ class CoreGrpcClient:
|
|||
|
||||
def emane_link(
|
||||
self, session_id: int, nem_one: int, nem_two: int, linked: bool
|
||||
) -> core_pb2.EmaneLinkResponse:
|
||||
) -> EmaneLinkResponse:
|
||||
"""
|
||||
Helps broadcast wireless link/unlink between EMANE nodes.
|
||||
|
||||
|
@ -1106,7 +1144,7 @@ class CoreGrpcClient:
|
|||
:param linked: True to link, False to unlink
|
||||
:return: core_pb2.EmaneLinkResponse
|
||||
"""
|
||||
request = core_pb2.EmaneLinkRequest(
|
||||
request = EmaneLinkRequest(
|
||||
session_id=session_id, nem_one=nem_one, nem_two=nem_two, linked=linked
|
||||
)
|
||||
return self.stub.EmaneLink(request)
|
||||
|
@ -1191,7 +1229,8 @@ class CoreGrpcClient:
|
|||
@contextmanager
|
||||
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
|
||||
"""
|
||||
|
|
|
@ -6,6 +6,7 @@ import netaddr
|
|||
|
||||
from core import utils
|
||||
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.emulator.data import LinkData
|
||||
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
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
@ -386,14 +387,14 @@ def service_configuration(session: Session, config: core_pb2.ServiceConfig) -> N
|
|||
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.
|
||||
|
||||
:param service: service to get proto data for
|
||||
:return: service proto data
|
||||
"""
|
||||
return core_pb2.NodeServiceData(
|
||||
return NodeServiceData(
|
||||
executables=service.executables,
|
||||
dependencies=service.dependencies,
|
||||
dirs=service.dirs,
|
||||
|
|
|
@ -19,6 +19,7 @@ from core.api.grpc import (
|
|||
core_pb2_grpc,
|
||||
grpcutils,
|
||||
)
|
||||
from core.api.grpc.common_pb2 import MappedConfig
|
||||
from core.api.grpc.configservices_pb2 import (
|
||||
ConfigService,
|
||||
GetConfigServiceDefaultsRequest,
|
||||
|
@ -34,10 +35,24 @@ from core.api.grpc.configservices_pb2 import (
|
|||
SetNodeConfigServiceRequest,
|
||||
SetNodeConfigServiceResponse,
|
||||
)
|
||||
from core.api.grpc.core_pb2 import (
|
||||
ExecuteScriptResponse,
|
||||
from core.api.grpc.core_pb2 import ExecuteScriptResponse
|
||||
from core.api.grpc.emane_pb2 import (
|
||||
EmaneLinkRequest,
|
||||
EmaneLinkResponse,
|
||||
GetEmaneConfigRequest,
|
||||
GetEmaneConfigResponse,
|
||||
GetEmaneEventChannelRequest,
|
||||
GetEmaneEventChannelResponse,
|
||||
GetEmaneModelConfigRequest,
|
||||
GetEmaneModelConfigResponse,
|
||||
GetEmaneModelConfigsRequest,
|
||||
GetEmaneModelConfigsResponse,
|
||||
GetEmaneModelsRequest,
|
||||
GetEmaneModelsResponse,
|
||||
SetEmaneConfigRequest,
|
||||
SetEmaneConfigResponse,
|
||||
SetEmaneModelConfigRequest,
|
||||
SetEmaneModelConfigResponse,
|
||||
)
|
||||
from core.api.grpc.events import EventStreamer
|
||||
from core.api.grpc.grpcutils import (
|
||||
|
@ -46,6 +61,48 @@ from core.api.grpc.grpcutils import (
|
|||
get_links,
|
||||
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.emulator.coreemu import CoreEmu
|
||||
from core.emulator.data import LinkData
|
||||
|
@ -919,8 +976,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
return core_pb2.AddHookResponse(result=True)
|
||||
|
||||
def GetMobilityConfigs(
|
||||
self, request: core_pb2.GetMobilityConfigsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetMobilityConfigsResponse:
|
||||
self, request: GetMobilityConfigsRequest, context: ServicerContext
|
||||
) -> GetMobilityConfigsResponse:
|
||||
"""
|
||||
Retrieve all mobility configurations from a session
|
||||
|
||||
|
@ -931,7 +988,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
"""
|
||||
logging.debug("get mobility configs: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
response = core_pb2.GetMobilityConfigsResponse()
|
||||
response = GetMobilityConfigsResponse()
|
||||
for node_id in session.mobility.node_configurations:
|
||||
model_config = session.mobility.node_configurations[node_id]
|
||||
if node_id == -1:
|
||||
|
@ -941,13 +998,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
continue
|
||||
current_config = session.mobility.get_model_config(node_id, model_name)
|
||||
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)
|
||||
return response
|
||||
|
||||
def GetMobilityConfig(
|
||||
self, request: core_pb2.GetMobilityConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.GetMobilityConfigResponse:
|
||||
self, request: GetMobilityConfigRequest, context: ServicerContext
|
||||
) -> GetMobilityConfigResponse:
|
||||
"""
|
||||
Retrieve mobility configuration of a node
|
||||
|
||||
|
@ -962,11 +1019,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
request.node_id, Ns2ScriptedMobility.name
|
||||
)
|
||||
config = get_config_options(current_config, Ns2ScriptedMobility)
|
||||
return core_pb2.GetMobilityConfigResponse(config=config)
|
||||
return GetMobilityConfigResponse(config=config)
|
||||
|
||||
def SetMobilityConfig(
|
||||
self, request: core_pb2.SetMobilityConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.SetMobilityConfigResponse:
|
||||
self, request: SetMobilityConfigRequest, context: ServicerContext
|
||||
) -> SetMobilityConfigResponse:
|
||||
"""
|
||||
Set mobility configuration of a node
|
||||
|
||||
|
@ -981,11 +1038,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session.mobility.set_model_config(
|
||||
mobility_config.node_id, Ns2ScriptedMobility.name, mobility_config.config
|
||||
)
|
||||
return core_pb2.SetMobilityConfigResponse(result=True)
|
||||
return SetMobilityConfigResponse(result=True)
|
||||
|
||||
def MobilityAction(
|
||||
self, request: core_pb2.MobilityActionRequest, context: ServicerContext
|
||||
) -> core_pb2.MobilityActionResponse:
|
||||
self, request: MobilityActionRequest, context: ServicerContext
|
||||
) -> MobilityActionResponse:
|
||||
"""
|
||||
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)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
result = True
|
||||
if request.action == core_pb2.MobilityAction.START:
|
||||
if request.action == MobilityAction.START:
|
||||
node.mobility.start()
|
||||
elif request.action == core_pb2.MobilityAction.PAUSE:
|
||||
elif request.action == MobilityAction.PAUSE:
|
||||
node.mobility.pause()
|
||||
elif request.action == core_pb2.MobilityAction.STOP:
|
||||
elif request.action == MobilityAction.STOP:
|
||||
node.mobility.stop(move_initial=True)
|
||||
else:
|
||||
result = False
|
||||
return core_pb2.MobilityActionResponse(result=result)
|
||||
return MobilityActionResponse(result=result)
|
||||
|
||||
def GetServices(
|
||||
self, request: core_pb2.GetServicesRequest, context: ServicerContext
|
||||
) -> core_pb2.GetServicesResponse:
|
||||
self, request: GetServicesRequest, context: ServicerContext
|
||||
) -> GetServicesResponse:
|
||||
"""
|
||||
Retrieve all the services that are running
|
||||
|
||||
|
@ -1022,13 +1079,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
services = []
|
||||
for name in ServiceManager.services:
|
||||
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)
|
||||
return core_pb2.GetServicesResponse(services=services)
|
||||
return GetServicesResponse(services=services)
|
||||
|
||||
def GetServiceDefaults(
|
||||
self, request: core_pb2.GetServiceDefaultsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetServiceDefaultsResponse:
|
||||
self, request: GetServiceDefaultsRequest, context: ServicerContext
|
||||
) -> GetServiceDefaultsResponse:
|
||||
"""
|
||||
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 = []
|
||||
for node_type in session.services.default_services:
|
||||
services = session.services.default_services[node_type]
|
||||
service_defaults = core_pb2.ServiceDefaults(
|
||||
node_type=node_type, services=services
|
||||
)
|
||||
service_defaults = ServiceDefaults(node_type=node_type, services=services)
|
||||
all_service_defaults.append(service_defaults)
|
||||
return core_pb2.GetServiceDefaultsResponse(defaults=all_service_defaults)
|
||||
return GetServiceDefaultsResponse(defaults=all_service_defaults)
|
||||
|
||||
def SetServiceDefaults(
|
||||
self, request: core_pb2.SetServiceDefaultsRequest, context: ServicerContext
|
||||
) -> core_pb2.SetServiceDefaultsResponse:
|
||||
self, request: SetServiceDefaultsRequest, context: ServicerContext
|
||||
) -> SetServiceDefaultsResponse:
|
||||
"""
|
||||
Set new default services to the session after whipping out the old ones
|
||||
:param request: set-service-defaults
|
||||
|
@ -1065,11 +1120,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session.services.default_services[
|
||||
service_defaults.node_type
|
||||
] = service_defaults.services
|
||||
return core_pb2.SetServiceDefaultsResponse(result=True)
|
||||
return SetServiceDefaultsResponse(result=True)
|
||||
|
||||
def GetNodeServiceConfigs(
|
||||
self, request: core_pb2.GetNodeServiceConfigsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetNodeServiceConfigsResponse:
|
||||
self, request: GetNodeServiceConfigsRequest, context: ServicerContext
|
||||
) -> GetNodeServiceConfigsResponse:
|
||||
"""
|
||||
Retrieve all node service configurations.
|
||||
|
||||
|
@ -1085,18 +1140,18 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
for name in service_configs:
|
||||
service = session.services.get_service(node_id, name)
|
||||
service_proto = grpcutils.get_service_configuration(service)
|
||||
config = core_pb2.GetNodeServiceConfigsResponse.ServiceConfig(
|
||||
config = GetNodeServiceConfigsResponse.ServiceConfig(
|
||||
node_id=node_id,
|
||||
service=name,
|
||||
data=service_proto,
|
||||
files=service.config_data,
|
||||
)
|
||||
configs.append(config)
|
||||
return core_pb2.GetNodeServiceConfigsResponse(configs=configs)
|
||||
return GetNodeServiceConfigsResponse(configs=configs)
|
||||
|
||||
def GetNodeService(
|
||||
self, request: core_pb2.GetNodeServiceRequest, context: ServicerContext
|
||||
) -> core_pb2.GetNodeServiceResponse:
|
||||
self, request: GetNodeServiceRequest, context: ServicerContext
|
||||
) -> GetNodeServiceResponse:
|
||||
"""
|
||||
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
|
||||
)
|
||||
service_proto = grpcutils.get_service_configuration(service)
|
||||
return core_pb2.GetNodeServiceResponse(service=service_proto)
|
||||
return GetNodeServiceResponse(service=service_proto)
|
||||
|
||||
def GetNodeServiceFile(
|
||||
self, request: core_pb2.GetNodeServiceFileRequest, context: ServicerContext
|
||||
) -> core_pb2.GetNodeServiceFileResponse:
|
||||
self, request: GetNodeServiceFileRequest, context: ServicerContext
|
||||
) -> GetNodeServiceFileResponse:
|
||||
"""
|
||||
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(
|
||||
node, request.service, request.file
|
||||
)
|
||||
return core_pb2.GetNodeServiceFileResponse(data=file_data.data)
|
||||
return GetNodeServiceFileResponse(data=file_data.data)
|
||||
|
||||
def SetNodeService(
|
||||
self, request: core_pb2.SetNodeServiceRequest, context: ServicerContext
|
||||
) -> core_pb2.SetNodeServiceResponse:
|
||||
self, request: SetNodeServiceRequest, context: ServicerContext
|
||||
) -> SetNodeServiceResponse:
|
||||
"""
|
||||
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)
|
||||
config = request.config
|
||||
grpcutils.service_configuration(session, config)
|
||||
return core_pb2.SetNodeServiceResponse(result=True)
|
||||
return SetNodeServiceResponse(result=True)
|
||||
|
||||
def SetNodeServiceFile(
|
||||
self, request: core_pb2.SetNodeServiceFileRequest, context: ServicerContext
|
||||
) -> core_pb2.SetNodeServiceFileResponse:
|
||||
self, request: SetNodeServiceFileRequest, context: ServicerContext
|
||||
) -> SetNodeServiceFileResponse:
|
||||
"""
|
||||
Store the customized service file in the service config
|
||||
|
||||
|
@ -1166,11 +1221,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session.services.set_service_file(
|
||||
config.node_id, config.service, config.file, config.data
|
||||
)
|
||||
return core_pb2.SetNodeServiceFileResponse(result=True)
|
||||
return SetNodeServiceFileResponse(result=True)
|
||||
|
||||
def ServiceAction(
|
||||
self, request: core_pb2.ServiceActionRequest, context: ServicerContext
|
||||
) -> core_pb2.ServiceActionResponse:
|
||||
self, request: ServiceActionRequest, context: ServicerContext
|
||||
) -> ServiceActionResponse:
|
||||
"""
|
||||
Take action whether to start, stop, restart, validate the service or none of
|
||||
the above.
|
||||
|
@ -1192,26 +1247,26 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
context.abort(grpc.StatusCode.NOT_FOUND, "service not found")
|
||||
|
||||
status = -1
|
||||
if request.action == core_pb2.ServiceAction.START:
|
||||
if request.action == ServiceAction.START:
|
||||
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)
|
||||
elif request.action == core_pb2.ServiceAction.RESTART:
|
||||
elif request.action == ServiceAction.RESTART:
|
||||
status = session.services.stop_service(node, service)
|
||||
if not status:
|
||||
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)
|
||||
|
||||
result = False
|
||||
if not status:
|
||||
result = True
|
||||
|
||||
return core_pb2.ServiceActionResponse(result=result)
|
||||
return ServiceActionResponse(result=result)
|
||||
|
||||
def GetWlanConfigs(
|
||||
self, request: core_pb2.GetWlanConfigsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetWlanConfigsResponse:
|
||||
self, request: GetWlanConfigsRequest, context: ServicerContext
|
||||
) -> GetWlanConfigsResponse:
|
||||
"""
|
||||
Retrieve all wireless-lan configurations.
|
||||
|
||||
|
@ -1221,7 +1276,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
"""
|
||||
logging.debug("get wlan configs: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
response = core_pb2.GetWlanConfigsResponse()
|
||||
response = GetWlanConfigsResponse()
|
||||
for node_id in session.mobility.node_configurations:
|
||||
model_config = session.mobility.node_configurations[node_id]
|
||||
if node_id == -1:
|
||||
|
@ -1231,13 +1286,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
continue
|
||||
current_config = session.mobility.get_model_config(node_id, model_name)
|
||||
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)
|
||||
return response
|
||||
|
||||
def GetWlanConfig(
|
||||
self, request: core_pb2.GetWlanConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.GetWlanConfigResponse:
|
||||
self, request: GetWlanConfigRequest, context: ServicerContext
|
||||
) -> GetWlanConfigResponse:
|
||||
"""
|
||||
Retrieve wireless-lan configuration of a node
|
||||
|
||||
|
@ -1251,11 +1306,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
request.node_id, BasicRangeModel.name
|
||||
)
|
||||
config = get_config_options(current_config, BasicRangeModel)
|
||||
return core_pb2.GetWlanConfigResponse(config=config)
|
||||
return GetWlanConfigResponse(config=config)
|
||||
|
||||
def SetWlanConfig(
|
||||
self, request: core_pb2.SetWlanConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.SetWlanConfigResponse:
|
||||
self, request: SetWlanConfigRequest, context: ServicerContext
|
||||
) -> SetWlanConfigResponse:
|
||||
"""
|
||||
Set configuration data for a model
|
||||
|
||||
|
@ -1272,11 +1327,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
if session.state == EventTypes.RUNTIME_STATE:
|
||||
node = self.get_node(session, wlan_config.node_id, context)
|
||||
node.updatemodel(wlan_config.config)
|
||||
return core_pb2.SetWlanConfigResponse(result=True)
|
||||
return SetWlanConfigResponse(result=True)
|
||||
|
||||
def GetEmaneConfig(
|
||||
self, request: core_pb2.GetEmaneConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.GetEmaneConfigResponse:
|
||||
self, request: GetEmaneConfigRequest, context: ServicerContext
|
||||
) -> GetEmaneConfigResponse:
|
||||
"""
|
||||
Retrieve EMANE configuration of a session
|
||||
|
||||
|
@ -1288,11 +1343,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session = self.get_session(request.session_id, context)
|
||||
current_config = session.emane.get_configs()
|
||||
config = get_config_options(current_config, session.emane.emane_config)
|
||||
return core_pb2.GetEmaneConfigResponse(config=config)
|
||||
return GetEmaneConfigResponse(config=config)
|
||||
|
||||
def SetEmaneConfig(
|
||||
self, request: core_pb2.SetEmaneConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.SetEmaneConfigResponse:
|
||||
self, request: SetEmaneConfigRequest, context: ServicerContext
|
||||
) -> SetEmaneConfigResponse:
|
||||
"""
|
||||
Set EMANE configuration of a session
|
||||
|
||||
|
@ -1304,11 +1359,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session = self.get_session(request.session_id, context)
|
||||
config = session.emane.get_configs()
|
||||
config.update(request.config)
|
||||
return core_pb2.SetEmaneConfigResponse(result=True)
|
||||
return SetEmaneConfigResponse(result=True)
|
||||
|
||||
def GetEmaneModels(
|
||||
self, request: core_pb2.GetEmaneModelsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetEmaneModelsResponse:
|
||||
self, request: GetEmaneModelsRequest, context: ServicerContext
|
||||
) -> GetEmaneModelsResponse:
|
||||
"""
|
||||
Retrieve all the EMANE models in the session
|
||||
|
||||
|
@ -1323,11 +1378,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
if len(model.split("_")) != 2:
|
||||
continue
|
||||
models.append(model)
|
||||
return core_pb2.GetEmaneModelsResponse(models=models)
|
||||
return GetEmaneModelsResponse(models=models)
|
||||
|
||||
def GetEmaneModelConfig(
|
||||
self, request: core_pb2.GetEmaneModelConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.GetEmaneModelConfigResponse:
|
||||
self, request: GetEmaneModelConfigRequest, context: ServicerContext
|
||||
) -> GetEmaneModelConfigResponse:
|
||||
"""
|
||||
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)
|
||||
current_config = session.emane.get_model_config(_id, request.model)
|
||||
config = get_config_options(current_config, model)
|
||||
return core_pb2.GetEmaneModelConfigResponse(config=config)
|
||||
return GetEmaneModelConfigResponse(config=config)
|
||||
|
||||
def SetEmaneModelConfig(
|
||||
self, request: core_pb2.SetEmaneModelConfigRequest, context: ServicerContext
|
||||
) -> core_pb2.SetEmaneModelConfigResponse:
|
||||
self, request: SetEmaneModelConfigRequest, context: ServicerContext
|
||||
) -> SetEmaneModelConfigResponse:
|
||||
"""
|
||||
Set EMANE model configuration of a node
|
||||
|
||||
|
@ -1360,11 +1415,11 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
model_config = request.emane_model_config
|
||||
_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)
|
||||
return core_pb2.SetEmaneModelConfigResponse(result=True)
|
||||
return SetEmaneModelConfigResponse(result=True)
|
||||
|
||||
def GetEmaneModelConfigs(
|
||||
self, request: core_pb2.GetEmaneModelConfigsRequest, context: ServicerContext
|
||||
) -> core_pb2.GetEmaneModelConfigsResponse:
|
||||
self, request: GetEmaneModelConfigsRequest, context: ServicerContext
|
||||
) -> GetEmaneModelConfigsResponse:
|
||||
"""
|
||||
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)
|
||||
config = get_config_options(current_config, model)
|
||||
node_id, interface = grpcutils.parse_emane_model_id(_id)
|
||||
model_config = core_pb2.GetEmaneModelConfigsResponse.ModelConfig(
|
||||
model_config = GetEmaneModelConfigsResponse.ModelConfig(
|
||||
node_id=node_id,
|
||||
model=model_name,
|
||||
interface=interface,
|
||||
config=config,
|
||||
)
|
||||
configs.append(model_config)
|
||||
return core_pb2.GetEmaneModelConfigsResponse(configs=configs)
|
||||
return GetEmaneModelConfigsResponse(configs=configs)
|
||||
|
||||
def SaveXml(
|
||||
self, request: core_pb2.SaveXmlRequest, context: ServicerContext
|
||||
|
@ -1469,8 +1524,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
return core_pb2.GetInterfacesResponse(interfaces=interfaces)
|
||||
|
||||
def EmaneLink(
|
||||
self, request: core_pb2.EmaneLinkRequest, context: ServicerContext
|
||||
) -> core_pb2.EmaneLinkResponse:
|
||||
self, request: EmaneLinkRequest, context: ServicerContext
|
||||
) -> EmaneLinkResponse:
|
||||
"""
|
||||
Helps broadcast wireless link/unlink between EMANE nodes.
|
||||
|
||||
|
@ -1505,9 +1560,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
network_id=emane_one.id,
|
||||
)
|
||||
session.broadcast_link(link)
|
||||
return core_pb2.EmaneLinkResponse(result=True)
|
||||
return EmaneLinkResponse(result=True)
|
||||
else:
|
||||
return core_pb2.EmaneLinkResponse(result=False)
|
||||
return EmaneLinkResponse(result=False)
|
||||
|
||||
def GetConfigServices(
|
||||
self, request: GetConfigServicesRequest, context: ServicerContext
|
||||
|
|
|
@ -11,6 +11,10 @@ from typing import TYPE_CHECKING, Dict, List
|
|||
import grpc
|
||||
|
||||
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.dialogs.mobilityplayer import MobilityPlayer
|
||||
from core.gui.dialogs.sessions import SessionsDialog
|
||||
|
@ -617,9 +621,7 @@ class CoreClient:
|
|||
except grpc.RpcError as e:
|
||||
self.app.after(0, show_grpc_error, e, self.app, self.app)
|
||||
|
||||
def get_node_service(
|
||||
self, node_id: int, service_name: str
|
||||
) -> core_pb2.NodeServiceData:
|
||||
def get_node_service(self, node_id: int, service_name: str) -> NodeServiceData:
|
||||
response = self.client.get_node_service(self.session_id, node_id, service_name)
|
||||
logging.debug(
|
||||
"get node(%s) %s service, response: %s", node_id, service_name, response
|
||||
|
@ -635,7 +637,7 @@ class CoreClient:
|
|||
startups: List[str],
|
||||
validations: List[str],
|
||||
shutdowns: List[str],
|
||||
) -> core_pb2.NodeServiceData:
|
||||
) -> NodeServiceData:
|
||||
response = self.client.set_node_service(
|
||||
self.session_id,
|
||||
node_id,
|
||||
|
@ -675,7 +677,7 @@ class CoreClient:
|
|||
return response.data
|
||||
|
||||
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(
|
||||
self.session_id, node_id, service_name, file_name, data
|
||||
|
@ -912,40 +914,40 @@ class CoreClient:
|
|||
self.links[edge.token] = edge
|
||||
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 = []
|
||||
for node_id, config in self.wlan_configs.items():
|
||||
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)
|
||||
return configs
|
||||
|
||||
def get_mobility_configs_proto(self) -> List[core_pb2.MobilityConfig]:
|
||||
def get_mobility_configs_proto(self) -> List[MobilityConfig]:
|
||||
configs = []
|
||||
for node_id, config in self.mobility_configs.items():
|
||||
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)
|
||||
return configs
|
||||
|
||||
def get_emane_model_configs_proto(self) -> List[core_pb2.EmaneModelConfig]:
|
||||
def get_emane_model_configs_proto(self) -> List[EmaneModelConfig]:
|
||||
configs = []
|
||||
for key, config in self.emane_model_configs.items():
|
||||
node_id, model, interface = key
|
||||
config = {x: config[x].value for x in config}
|
||||
if interface is None:
|
||||
interface = -1
|
||||
config_proto = core_pb2.EmaneModelConfig(
|
||||
config_proto = EmaneModelConfig(
|
||||
node_id=node_id, interface_id=interface, model=model, config=config
|
||||
)
|
||||
configs.append(config_proto)
|
||||
return configs
|
||||
|
||||
def get_service_configs_proto(self) -> List[core_pb2.ServiceConfig]:
|
||||
def get_service_configs_proto(self) -> List[ServiceConfig]:
|
||||
configs = []
|
||||
for node_id, services in self.service_configs.items():
|
||||
for name, config in services.items():
|
||||
config_proto = core_pb2.ServiceConfig(
|
||||
config_proto = ServiceConfig(
|
||||
node_id=node_id,
|
||||
service=name,
|
||||
directories=config.dirs,
|
||||
|
@ -957,12 +959,12 @@ class CoreClient:
|
|||
configs.append(config_proto)
|
||||
return configs
|
||||
|
||||
def get_service_file_configs_proto(self) -> List[core_pb2.ServiceFileConfig]:
|
||||
def get_service_file_configs_proto(self) -> List[ServiceFileConfig]:
|
||||
configs = []
|
||||
for (node_id, file_configs) in self.file_configs.items():
|
||||
for service, file_config in file_configs.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
|
||||
)
|
||||
configs.append(config_proto)
|
||||
|
|
|
@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any, List
|
|||
|
||||
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.errors import show_grpc_error
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
|
@ -256,9 +256,9 @@ class ConfigServiceConfigDialog(Dialog):
|
|||
|
||||
label = ttk.Label(frame, text="Validation Mode")
|
||||
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"
|
||||
elif self.validation_mode == core_pb2.ServiceValidationMode.NON_BLOCKING:
|
||||
elif self.validation_mode == ServiceValidationMode.NON_BLOCKING:
|
||||
mode = "NON_BLOCKING"
|
||||
else:
|
||||
mode = "TIMER"
|
||||
|
|
|
@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any
|
|||
|
||||
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.errors import show_grpc_error
|
||||
from core.gui.images import ImageEnum, Images
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, Any, List
|
|||
|
||||
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.dialog import Dialog
|
||||
from core.gui.errors import show_grpc_error
|
||||
|
@ -331,9 +331,9 @@ class ServiceConfigDialog(Dialog):
|
|||
|
||||
label = ttk.Label(frame, text="Validation Mode")
|
||||
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"
|
||||
elif self.validation_mode == core_pb2.ServiceValidationMode.NON_BLOCKING:
|
||||
elif self.validation_mode == ServiceValidationMode.NON_BLOCKING:
|
||||
mode = "NON_BLOCKING"
|
||||
else:
|
||||
mode = "TIMER"
|
||||
|
|
|
@ -10,3 +10,7 @@ message ConfigOption {
|
|||
repeated string select = 5;
|
||||
string group = 6;
|
||||
}
|
||||
|
||||
message MappedConfig {
|
||||
map<string, common.ConfigOption> config = 1;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ syntax = "proto3";
|
|||
|
||||
package core;
|
||||
|
||||
option java_package = "com.core.client.grpc";
|
||||
option java_outer_classname = "CoreProto";
|
||||
|
||||
import "core/api/grpc/configservices.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 {
|
||||
// session rpc
|
||||
|
@ -78,33 +79,33 @@ service CoreApi {
|
|||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
|
@ -122,27 +123,27 @@ service CoreApi {
|
|||
}
|
||||
|
||||
// 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
|
||||
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
|
||||
|
@ -154,7 +155,7 @@ service CoreApi {
|
|||
// utilities
|
||||
rpc GetInterfaces (GetInterfacesRequest) returns (GetInterfacesResponse) {
|
||||
}
|
||||
rpc EmaneLink (EmaneLinkRequest) returns (EmaneLinkResponse) {
|
||||
rpc EmaneLink (emane.EmaneLinkRequest) returns (emane.EmaneLinkResponse) {
|
||||
}
|
||||
rpc ExecuteScript (ExecuteScriptRequest) returns (ExecuteScriptResponse) {
|
||||
}
|
||||
|
@ -168,11 +169,11 @@ message StartSessionRequest {
|
|||
repeated Hook hooks = 4;
|
||||
SessionLocation location = 5;
|
||||
map<string, string> emane_config = 6;
|
||||
repeated WlanConfig wlan_configs = 7;
|
||||
repeated EmaneModelConfig emane_model_configs = 8;
|
||||
repeated MobilityConfig mobility_configs = 9;
|
||||
repeated ServiceConfig service_configs = 10;
|
||||
repeated ServiceFileConfig service_file_configs = 11;
|
||||
repeated wlan.WlanConfig wlan_configs = 7;
|
||||
repeated emane.EmaneModelConfig emane_model_configs = 8;
|
||||
repeated mobility.MobilityConfig mobility_configs = 9;
|
||||
repeated services.ServiceConfig service_configs = 10;
|
||||
repeated services.ServiceFileConfig service_file_configs = 11;
|
||||
repeated Link asymmetric_links = 12;
|
||||
repeated configservices.ConfigServiceConfig config_service_configs = 13;
|
||||
}
|
||||
|
@ -515,226 +516,6 @@ message AddHookResponse {
|
|||
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 {
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
@ -761,17 +542,6 @@ message GetInterfacesResponse {
|
|||
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 {
|
||||
string script = 1;
|
||||
}
|
||||
|
@ -781,40 +551,6 @@ message ExecuteScriptResponse {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
enum Enum {
|
||||
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 {
|
||||
enum Enum {
|
||||
DEFAULT = 0;
|
||||
|
@ -934,33 +645,6 @@ message Hook {
|
|||
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 {
|
||||
int32 id = 1;
|
||||
SessionState.Enum state = 2;
|
||||
|
|
92
daemon/proto/core/api/grpc/emane.proto
Normal file
92
daemon/proto/core/api/grpc/emane.proto
Normal 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;
|
||||
}
|
54
daemon/proto/core/api/grpc/mobility.proto
Normal file
54
daemon/proto/core/api/grpc/mobility.proto
Normal 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;
|
||||
}
|
149
daemon/proto/core/api/grpc/services.proto
Normal file
149
daemon/proto/core/api/grpc/services.proto
Normal 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;
|
||||
}
|
36
daemon/proto/core/api/grpc/wlan.proto
Normal file
36
daemon/proto/core/api/grpc/wlan.proto
Normal 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;
|
||||
}
|
|
@ -7,6 +7,10 @@ from mock import patch
|
|||
|
||||
from core.api.grpc import core_pb2
|
||||
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.enumerations import ConfigFlags
|
||||
from core.emane.ieee80211abg import EmaneIeee80211abgModel
|
||||
|
@ -69,7 +73,7 @@ class TestGrpc:
|
|||
model_node_id = 20
|
||||
model_config_key = "bandwidth"
|
||||
model_config_value = "500000"
|
||||
model_config = core_pb2.EmaneModelConfig(
|
||||
model_config = EmaneModelConfig(
|
||||
node_id=model_node_id,
|
||||
interface_id=-1,
|
||||
model=EmaneIeee80211abgModel.name,
|
||||
|
@ -78,21 +82,21 @@ class TestGrpc:
|
|||
model_configs = [model_config]
|
||||
wlan_config_key = "range"
|
||||
wlan_config_value = "333"
|
||||
wlan_config = core_pb2.WlanConfig(
|
||||
wlan_config = WlanConfig(
|
||||
node_id=wlan_node.id, config={wlan_config_key: wlan_config_value}
|
||||
)
|
||||
wlan_configs = [wlan_config]
|
||||
mobility_config_key = "refresh_ms"
|
||||
mobility_config_value = "60"
|
||||
mobility_config = core_pb2.MobilityConfig(
|
||||
mobility_config = MobilityConfig(
|
||||
node_id=wlan_node.id, config={mobility_config_key: mobility_config_value}
|
||||
)
|
||||
mobility_configs = [mobility_config]
|
||||
service_config = core_pb2.ServiceConfig(
|
||||
service_config = ServiceConfig(
|
||||
node_id=node_one.id, service="DefaultRoute", validate=["echo hello"]
|
||||
)
|
||||
service_configs = [service_config]
|
||||
service_file_config = core_pb2.ServiceFileConfig(
|
||||
service_file_config = ServiceFileConfig(
|
||||
node_id=node_one.id,
|
||||
service="DefaultRoute",
|
||||
file="defaultroute.sh",
|
||||
|
@ -829,9 +833,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
with client.context_connect():
|
||||
response = client.mobility_action(
|
||||
session.id, wlan.id, core_pb2.MobilityAction.STOP
|
||||
)
|
||||
response = client.mobility_action(session.id, wlan.id, MobilityAction.STOP)
|
||||
|
||||
# then
|
||||
assert response.result is True
|
||||
|
@ -971,7 +973,7 @@ class TestGrpc:
|
|||
# then
|
||||
with client.context_connect():
|
||||
response = client.service_action(
|
||||
session.id, node.id, service_name, core_pb2.ServiceAction.STOP
|
||||
session.id, node.id, service_name, ServiceAction.STOP
|
||||
)
|
||||
|
||||
# then
|
||||
|
|
Loading…
Reference in a new issue