grpc: removed set node service file, achieved with start session, removed get node config service configs, achieved with get session
This commit is contained in:
parent
3e2cb86b6b
commit
e299d3dd16
6 changed files with 1 additions and 117 deletions
|
@ -24,7 +24,6 @@ from core.api.grpc import (
|
|||
from core.api.grpc.configservices_pb2 import (
|
||||
GetConfigServiceDefaultsRequest,
|
||||
GetConfigServicesRequest,
|
||||
GetNodeConfigServiceConfigsRequest,
|
||||
GetNodeConfigServiceRequest,
|
||||
GetNodeConfigServicesRequest,
|
||||
SetNodeConfigServiceRequest,
|
||||
|
@ -52,7 +51,6 @@ from core.api.grpc.services_pb2 import (
|
|||
GetServicesRequest,
|
||||
ServiceActionRequest,
|
||||
ServiceDefaults,
|
||||
SetNodeServiceFileRequest,
|
||||
SetServiceDefaultsRequest,
|
||||
)
|
||||
from core.api.grpc.wlan_pb2 import (
|
||||
|
@ -905,22 +903,6 @@ class CoreGrpcClient:
|
|||
response = self.stub.GetNodeServiceFile(request)
|
||||
return response.data
|
||||
|
||||
def set_node_service_file(
|
||||
self, session_id: int, service_file_config: wrappers.ServiceFileConfig
|
||||
) -> bool:
|
||||
"""
|
||||
Set a service file for a node.
|
||||
|
||||
:param session_id: session id
|
||||
:param service_file_config: configuration to set
|
||||
:return: True for success, False otherwise
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
config = service_file_config.to_proto()
|
||||
request = SetNodeServiceFileRequest(session_id=session_id, config=config)
|
||||
response = self.stub.SetNodeServiceFile(request)
|
||||
return response.result
|
||||
|
||||
def service_action(
|
||||
self,
|
||||
session_id: int,
|
||||
|
@ -1131,24 +1113,6 @@ class CoreGrpcClient:
|
|||
response = self.stub.GetConfigServiceDefaults(request)
|
||||
return wrappers.ConfigServiceDefaults.from_proto(response)
|
||||
|
||||
def get_node_config_service_configs(
|
||||
self, session_id: int
|
||||
) -> List[wrappers.ConfigServiceConfig]:
|
||||
"""
|
||||
Retrieves all node config service configurations for a session.
|
||||
|
||||
:param session_id: session to get config service configurations for
|
||||
:return: list of node config service configs
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = GetNodeConfigServiceConfigsRequest(session_id=session_id)
|
||||
response = self.stub.GetNodeConfigServiceConfigs(request)
|
||||
configs = []
|
||||
for config_proto in response.configs:
|
||||
config = wrappers.ConfigServiceConfig.from_proto(config_proto)
|
||||
configs.append(config)
|
||||
return configs
|
||||
|
||||
def get_node_config_service(
|
||||
self, session_id: int, node_id: int, name: str
|
||||
) -> Dict[str, str]:
|
||||
|
|
|
@ -26,8 +26,6 @@ from core.api.grpc.configservices_pb2 import (
|
|||
GetConfigServiceDefaultsResponse,
|
||||
GetConfigServicesRequest,
|
||||
GetConfigServicesResponse,
|
||||
GetNodeConfigServiceConfigsRequest,
|
||||
GetNodeConfigServiceConfigsResponse,
|
||||
GetNodeConfigServiceRequest,
|
||||
GetNodeConfigServiceResponse,
|
||||
GetNodeConfigServicesRequest,
|
||||
|
@ -78,8 +76,6 @@ from core.api.grpc.services_pb2 import (
|
|||
ServiceAction,
|
||||
ServiceActionRequest,
|
||||
ServiceActionResponse,
|
||||
SetNodeServiceFileRequest,
|
||||
SetNodeServiceFileResponse,
|
||||
SetServiceDefaultsRequest,
|
||||
SetServiceDefaultsResponse,
|
||||
)
|
||||
|
@ -1052,25 +1048,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
)
|
||||
return GetNodeServiceFileResponse(data=file_data.data)
|
||||
|
||||
def SetNodeServiceFile(
|
||||
self, request: SetNodeServiceFileRequest, context: ServicerContext
|
||||
) -> SetNodeServiceFileResponse:
|
||||
"""
|
||||
Store the customized service file in the service config
|
||||
|
||||
:param request:
|
||||
set-node-service-file request
|
||||
:param context: context object
|
||||
:return: set-node-service-file response
|
||||
"""
|
||||
logger.debug("set node service file: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = request.config
|
||||
session.services.set_service_file(
|
||||
config.node_id, config.service, config.file, config.data
|
||||
)
|
||||
return SetNodeServiceFileResponse(result=True)
|
||||
|
||||
def ServiceAction(
|
||||
self, request: ServiceActionRequest, context: ServicerContext
|
||||
) -> ServiceActionResponse:
|
||||
|
@ -1427,21 +1404,6 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
templates=templates, config=config, modes=modes
|
||||
)
|
||||
|
||||
def GetNodeConfigServiceConfigs(
|
||||
self, request: GetNodeConfigServiceConfigsRequest, context: ServicerContext
|
||||
) -> GetNodeConfigServiceConfigsResponse:
|
||||
"""
|
||||
Get current custom templates and config for configuration services for a given
|
||||
node.
|
||||
|
||||
:param request: get node config service configs request
|
||||
:param context: grpc context
|
||||
:return: get node config service configs response
|
||||
"""
|
||||
session = self.get_session(request.session_id, context)
|
||||
configs = grpcutils.get_node_config_service_configs(session)
|
||||
return GetNodeConfigServiceConfigsResponse(configs=configs)
|
||||
|
||||
def GetNodeConfigServices(
|
||||
self, request: GetNodeConfigServicesRequest, context: ServicerContext
|
||||
) -> GetNodeConfigServicesResponse:
|
||||
|
|
|
@ -57,14 +57,6 @@ message GetConfigServiceDefaultsResponse {
|
|||
repeated ConfigMode modes = 3;
|
||||
}
|
||||
|
||||
message GetNodeConfigServiceConfigsRequest {
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetNodeConfigServiceConfigsResponse {
|
||||
repeated ConfigServiceConfig configs = 1;
|
||||
}
|
||||
|
||||
message GetNodeConfigServiceRequest {
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
|
|
|
@ -79,13 +79,11 @@ service CoreApi {
|
|||
}
|
||||
rpc GetNodeServiceFile (services.GetNodeServiceFileRequest) returns (services.GetNodeServiceFileResponse) {
|
||||
}
|
||||
rpc SetNodeServiceFile (services.SetNodeServiceFileRequest) returns (services.SetNodeServiceFileResponse) {
|
||||
}
|
||||
rpc ServiceAction (services.ServiceActionRequest) returns (services.ServiceActionResponse) {
|
||||
}
|
||||
|
||||
// config services
|
||||
rpc GetNodeConfigServiceConfigs (configservices.GetNodeConfigServiceConfigsRequest) returns (configservices.GetNodeConfigServiceConfigsResponse) {
|
||||
rpc GetConfigServiceDefaults (configservices.GetConfigServiceDefaultsRequest) returns (configservices.GetConfigServiceDefaultsResponse) {
|
||||
}
|
||||
rpc GetNodeConfigService (configservices.GetNodeConfigServiceRequest) returns (configservices.GetNodeConfigServiceResponse) {
|
||||
}
|
||||
|
@ -135,8 +133,6 @@ service CoreApi {
|
|||
}
|
||||
rpc GetConfigServices (configservices.GetConfigServicesRequest) returns (configservices.GetConfigServicesResponse) {
|
||||
}
|
||||
rpc GetConfigServiceDefaults (configservices.GetConfigServiceDefaultsRequest) returns (configservices.GetConfigServiceDefaultsResponse) {
|
||||
}
|
||||
rpc GetServices (services.GetServicesRequest) returns (services.GetServicesResponse) {
|
||||
}
|
||||
rpc GetServiceDefaults (services.GetServiceDefaultsRequest) returns (services.GetServiceDefaultsResponse) {
|
||||
|
|
|
@ -112,15 +112,6 @@ message GetNodeServiceFileResponse {
|
|||
string data = 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;
|
||||
|
|
|
@ -27,7 +27,6 @@ from core.api.grpc.wrappers import (
|
|||
NodeType,
|
||||
Position,
|
||||
ServiceAction,
|
||||
ServiceFileConfig,
|
||||
ServiceValidationMode,
|
||||
SessionLocation,
|
||||
SessionState,
|
||||
|
@ -737,26 +736,6 @@ class TestGrpcw:
|
|||
# then
|
||||
assert data is not None
|
||||
|
||||
def test_set_node_service_file(self, grpc_server: CoreGrpcServer):
|
||||
# given
|
||||
client = CoreGrpcClient()
|
||||
session = grpc_server.coreemu.create_session()
|
||||
node = session.add_node(CoreNode)
|
||||
config = ServiceFileConfig(
|
||||
node.id, "DefaultRoute", "defaultroute.sh", "echo hello"
|
||||
)
|
||||
|
||||
# then
|
||||
with client.context_connect():
|
||||
result = client.set_node_service_file(session.id, config)
|
||||
|
||||
# then
|
||||
assert result is True
|
||||
service_file = session.services.get_service_file(
|
||||
node, config.service, config.file
|
||||
)
|
||||
assert service_file.data == config.data
|
||||
|
||||
def test_service_action(self, grpc_server: CoreGrpcServer):
|
||||
# given
|
||||
client = CoreGrpcClient()
|
||||
|
|
Loading…
Reference in a new issue