updated all grpc variables to use more explicit naming for session/node/interface ids
This commit is contained in:
parent
d9bf4f5926
commit
3e194af5ee
5 changed files with 370 additions and 363 deletions
|
@ -149,27 +149,27 @@ class CoreGrpcClient(object):
|
|||
self.stub = None
|
||||
self.channel = None
|
||||
|
||||
def create_session(self, _id=None):
|
||||
def create_session(self, session_id=None):
|
||||
"""
|
||||
Create a session.
|
||||
|
||||
:param int _id: id for session, default is None and one will be created for you
|
||||
:param int session_id: id for session, default is None and one will be created for you
|
||||
:return: response with created session id
|
||||
:rtype: core_pb2.CreateSessionResponse
|
||||
"""
|
||||
request = core_pb2.CreateSessionRequest(id=_id)
|
||||
request = core_pb2.CreateSessionRequest(session_id=session_id)
|
||||
return self.stub.CreateSession(request)
|
||||
|
||||
def delete_session(self, _id):
|
||||
def delete_session(self, session_id):
|
||||
"""
|
||||
Delete a session.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:return: response with result of deletion success or failure
|
||||
:rtype: core_pb2.DeleteSessionResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.DeleteSessionRequest(id=_id)
|
||||
request = core_pb2.DeleteSessionRequest(session_id=session_id)
|
||||
return self.stub.DeleteSession(request)
|
||||
|
||||
def get_sessions(self):
|
||||
|
@ -181,60 +181,60 @@ class CoreGrpcClient(object):
|
|||
"""
|
||||
return self.stub.GetSessions(core_pb2.GetSessionsRequest())
|
||||
|
||||
def get_session(self, _id):
|
||||
def get_session(self, session_id):
|
||||
"""
|
||||
Retrieve a session.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:return: response with sessions state, nodes, and links
|
||||
:rtype: core_pb2.GetSessionResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionRequest(id=_id)
|
||||
request = core_pb2.GetSessionRequest(session_id=session_id)
|
||||
return self.stub.GetSession(request)
|
||||
|
||||
def get_session_options(self, _id):
|
||||
def get_session_options(self, session_id):
|
||||
"""
|
||||
Retrieve session options.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:return: response with a list of configuration groups
|
||||
:rtype: core_pb2.GetSessionOptionsResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionOptionsRequest(id=_id)
|
||||
request = core_pb2.GetSessionOptionsRequest(session_id=session_id)
|
||||
return self.stub.GetSessionOptions(request)
|
||||
|
||||
def set_session_options(self, _id, config):
|
||||
def set_session_options(self, session_id, config):
|
||||
"""
|
||||
Set options for a session.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param dict[str, str] config: configuration values to set
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.SetSessionOptionsResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetSessionOptionsRequest(id=_id, config=config)
|
||||
request = core_pb2.SetSessionOptionsRequest(session_id=session_id, config=config)
|
||||
return self.stub.SetSessionOptions(request)
|
||||
|
||||
def get_session_location(self, _id):
|
||||
def get_session_location(self, session_id):
|
||||
"""
|
||||
Get session location.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:return: response with session position reference and scale
|
||||
:rtype: core_pb2.GetSessionLocationResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetSessionLocationRequest(id=_id)
|
||||
request = core_pb2.GetSessionLocationRequest(session_id=session_id)
|
||||
return self.stub.GetSessionLocation(request)
|
||||
|
||||
def set_session_location(self, _id, x=None, y=None, z=None, lat=None, lon=None, alt=None, scale=None):
|
||||
def set_session_location(self, session_id, x=None, y=None, z=None, lat=None, lon=None, alt=None, scale=None):
|
||||
"""
|
||||
Set session location.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param float x: x position
|
||||
:param float y: y position
|
||||
:param float z: z position
|
||||
|
@ -247,173 +247,173 @@ class CoreGrpcClient(object):
|
|||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
position = core_pb2.Position(x=x, y=y, z=z, lat=lat, lon=lon, alt=alt)
|
||||
request = core_pb2.SetSessionLocationRequest(id=_id, position=position, scale=scale)
|
||||
request = core_pb2.SetSessionLocationRequest(session_id=session_id, position=position, scale=scale)
|
||||
return self.stub.SetSessionLocation(request)
|
||||
|
||||
def set_session_state(self, _id, state):
|
||||
def set_session_state(self, session_id, state):
|
||||
"""
|
||||
Set session state.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param core_pb2.SessionState state: session state to transition to
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.SetSessionStateResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetSessionStateRequest(id=_id, state=state)
|
||||
request = core_pb2.SetSessionStateRequest(session_id=session_id, state=state)
|
||||
return self.stub.SetSessionState(request)
|
||||
|
||||
def node_events(self, _id, handler):
|
||||
def node_events(self, session_id, handler):
|
||||
"""
|
||||
Listen for session node events.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param handler: handler for every event
|
||||
:return: nothing
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.NodeEventsRequest(id=_id)
|
||||
request = core_pb2.NodeEventsRequest(session_id=session_id)
|
||||
stream = self.stub.NodeEvents(request)
|
||||
start_streamer(stream, handler)
|
||||
|
||||
def link_events(self, _id, handler):
|
||||
def link_events(self, session_id, handler):
|
||||
"""
|
||||
Listen for session link events.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param handler: handler for every event
|
||||
:return: nothing
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.LinkEventsRequest(id=_id)
|
||||
request = core_pb2.LinkEventsRequest(session_id=session_id)
|
||||
stream = self.stub.LinkEvents(request)
|
||||
start_streamer(stream, handler)
|
||||
|
||||
def session_events(self, _id, handler):
|
||||
def session_events(self, session_id, handler):
|
||||
"""
|
||||
Listen for session events.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param handler: handler for every event
|
||||
:return: nothing
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SessionEventsRequest(id=_id)
|
||||
request = core_pb2.SessionEventsRequest(session_id=session_id)
|
||||
stream = self.stub.SessionEvents(request)
|
||||
start_streamer(stream, handler)
|
||||
|
||||
def config_events(self, _id, handler):
|
||||
def config_events(self, session_id, handler):
|
||||
"""
|
||||
Listen for session config events.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param handler: handler for every event
|
||||
:return: nothing
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.ConfigEventsRequest(id=_id)
|
||||
request = core_pb2.ConfigEventsRequest(session_id=session_id)
|
||||
stream = self.stub.ConfigEvents(request)
|
||||
start_streamer(stream, handler)
|
||||
|
||||
def exception_events(self, _id, handler):
|
||||
def exception_events(self, session_id, handler):
|
||||
"""
|
||||
Listen for session exception events.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param handler: handler for every event
|
||||
:return: nothing
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.ExceptionEventsRequest(id=_id)
|
||||
request = core_pb2.ExceptionEventsRequest(session_id=session_id)
|
||||
stream = self.stub.ExceptionEvents(request)
|
||||
start_streamer(stream, handler)
|
||||
|
||||
def file_events(self, _id, handler):
|
||||
def file_events(self, session_id, handler):
|
||||
"""
|
||||
Listen for session file events.
|
||||
|
||||
:param int _id: id of session
|
||||
:param int session_id: id of session
|
||||
:param handler: handler for every event
|
||||
:return: nothing
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.FileEventsRequest(id=_id)
|
||||
request = core_pb2.FileEventsRequest(session_id=session_id)
|
||||
stream = self.stub.FileEvents(request)
|
||||
start_streamer(stream, handler)
|
||||
|
||||
def add_node(self, session, node):
|
||||
def add_node(self, session_id, node):
|
||||
"""
|
||||
Add node to session.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:param core_pb2.Node node: node to add
|
||||
:return: response with node id
|
||||
:rtype: core_pb2.AddNodeResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.AddNodeRequest(session=session, node=node)
|
||||
request = core_pb2.AddNodeRequest(session_id=session_id, node=node)
|
||||
return self.stub.AddNode(request)
|
||||
|
||||
def get_node(self, session, _id):
|
||||
def get_node(self, session_id, node_id):
|
||||
"""
|
||||
Get node details.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:return: response with node details
|
||||
:rtype: core_pb2.GetNodeResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetNodeRequest(session=session, id=_id)
|
||||
request = core_pb2.GetNodeRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.GetNode(request)
|
||||
|
||||
def edit_node(self, session, _id, position):
|
||||
def edit_node(self, session_id, node_id, position):
|
||||
"""
|
||||
Edit a node, currently only changes position.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param core_pb2.Position position: position to set node to
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.EditNodeResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.EditNodeRequest(session=session, id=_id, position=position)
|
||||
request = core_pb2.EditNodeRequest(session_id=session_id, node_id=node_id, position=position)
|
||||
return self.stub.EditNode(request)
|
||||
|
||||
def delete_node(self, session, _id):
|
||||
def delete_node(self, session_id, node_id):
|
||||
"""
|
||||
Delete node from session.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.DeleteNodeResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.DeleteNodeRequest(session=session, id=_id)
|
||||
request = core_pb2.DeleteNodeRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.DeleteNode(request)
|
||||
|
||||
def get_node_links(self, session, _id):
|
||||
def get_node_links(self, session_id, node_id):
|
||||
"""
|
||||
Get current links for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:return: response with a list of links
|
||||
:rtype: core_pb2.GetNodeLinksResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetNodeLinksRequest(session=session, id=_id)
|
||||
request = core_pb2.GetNodeLinksRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.GetNodeLinks(request)
|
||||
|
||||
def add_link(self, session, node_one, node_two, interface_one=None, interface_two=None, options=None):
|
||||
def add_link(self, session_id, node_one_id, node_two_id, interface_one=None, interface_two=None, options=None):
|
||||
"""
|
||||
Add a link between nodes.
|
||||
|
||||
:param int session: session id
|
||||
:param int node_one: node one id
|
||||
:param int node_two: node two id
|
||||
:param int session_id: session id
|
||||
:param int node_one_id: node one id
|
||||
:param int node_two_id: node two id
|
||||
:param core_pb2.Interface interface_one: node one interface data
|
||||
:param core_pb2.Interface interface_two: node two interface data
|
||||
:param core_pb2.LinkOptions options: options for link (jitter, bandwidth, etc)
|
||||
|
@ -422,65 +422,65 @@ class CoreGrpcClient(object):
|
|||
:raises grpc.RpcError: when session or one of the nodes don't exist
|
||||
"""
|
||||
link = core_pb2.Link(
|
||||
node_one=node_one, node_two=node_two, type=core_pb2.LINK_WIRED,
|
||||
node_one_id=node_one_id, node_two_id=node_two_id, type=core_pb2.LINK_WIRED,
|
||||
interface_one=interface_one, interface_two=interface_two, options=options)
|
||||
request = core_pb2.AddLinkRequest(session=session, link=link)
|
||||
request = core_pb2.AddLinkRequest(session_id=session_id, link=link)
|
||||
return self.stub.AddLink(request)
|
||||
|
||||
def edit_link(self, session, node_one, node_two, options, interface_one=None, interface_two=None):
|
||||
def edit_link(self, session_id, node_one_id, node_two_id, options, interface_one_id=None, interface_two_id=None):
|
||||
"""
|
||||
Edit a link between nodes.
|
||||
|
||||
:param int session: session id
|
||||
:param int node_one: node one id
|
||||
:param int node_two: node two id
|
||||
:param int session_id: session id
|
||||
:param int node_one_id: node one id
|
||||
:param int node_two_id: node two id
|
||||
:param core_pb2.LinkOptions options: options for link (jitter, bandwidth, etc)
|
||||
:param int interface_one: node one interface id
|
||||
:param int interface_two: node two interface id
|
||||
:param int interface_one_id: node one interface id
|
||||
:param int interface_two_id: node two interface id
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.EditLinkResponse
|
||||
:raises grpc.RpcError: when session or one of the nodes don't exist
|
||||
"""
|
||||
request = core_pb2.EditLinkRequest(
|
||||
session=session, node_one=node_one, node_two=node_two, options=options,
|
||||
interface_one=interface_one, interface_two=interface_two)
|
||||
session_id=session_id, node_one_id=node_one_id, node_two_id=node_two_id, options=options,
|
||||
interface_one_id=interface_one_id, interface_two_id=interface_two_id)
|
||||
return self.stub.EditLink(request)
|
||||
|
||||
def delete_link(self, session, node_one, node_two, interface_one=None, interface_two=None):
|
||||
def delete_link(self, session_id, node_one_id, node_two_id, interface_one_id=None, interface_two_id=None):
|
||||
"""
|
||||
Delete a link between nodes.
|
||||
|
||||
:param int session: session id
|
||||
:param int node_one: node one id
|
||||
:param int node_two: node two id
|
||||
:param int interface_one: node one interface id
|
||||
:param int interface_two: node two interface id
|
||||
:param int session_id: session id
|
||||
:param int node_one_id: node one id
|
||||
:param int node_two_id: node two id
|
||||
:param int interface_one_id: node one interface id
|
||||
:param int interface_two_id: node two interface id
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.DeleteLinkResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.DeleteLinkRequest(
|
||||
session=session, node_one=node_one, node_two=node_two,
|
||||
interface_one=interface_one, interface_two=interface_two)
|
||||
session_id=session_id, node_one_id=node_one_id, node_two_id=node_two_id,
|
||||
interface_one_id=interface_one_id, interface_two_id=interface_two_id)
|
||||
return self.stub.DeleteLink(request)
|
||||
|
||||
def get_hooks(self, session):
|
||||
def get_hooks(self, session_id):
|
||||
"""
|
||||
Get all hook scripts.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:return: response with a list of hooks
|
||||
:rtype: core_pb2.GetHooksResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetHooksRequest(session=session)
|
||||
request = core_pb2.GetHooksRequest(session_id=session_id)
|
||||
return self.stub.GetHooks(request)
|
||||
|
||||
def add_hook(self, session, state, file_name, file_data):
|
||||
def add_hook(self, session_id, state, file_name, file_data):
|
||||
"""
|
||||
Add hook scripts.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:param core_pb2.SessionState state: state to trigger hook
|
||||
:param str file_name: name of file for hook script
|
||||
:param bytes file_data: hook script contents
|
||||
|
@ -489,60 +489,60 @@ class CoreGrpcClient(object):
|
|||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
hook = core_pb2.Hook(state=state, file=file_name, data=file_data)
|
||||
request = core_pb2.AddHookRequest(session=session, hook=hook)
|
||||
request = core_pb2.AddHookRequest(session_id=session_id, hook=hook)
|
||||
return self.stub.AddHook(request)
|
||||
|
||||
def get_mobility_configs(self, session):
|
||||
def get_mobility_configs(self, session_id):
|
||||
"""
|
||||
Get all mobility configurations.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:return: response with a dict of node ids to mobility configurations
|
||||
:rtype: core_pb2.GetMobilityConfigsResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetMobilityConfigsRequest(session=session)
|
||||
request = core_pb2.GetMobilityConfigsRequest(session_id=session_id)
|
||||
return self.stub.GetMobilityConfigs(request)
|
||||
|
||||
def get_mobility_config(self, session, _id):
|
||||
def get_mobility_config(self, session_id, node_id):
|
||||
"""
|
||||
Get mobility configuration for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:return: response with a list of configuration groups
|
||||
:rtype: core_pb2.GetMobilityConfigResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetMobilityConfigRequest(session=session, id=_id)
|
||||
request = core_pb2.GetMobilityConfigRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.GetMobilityConfig(request)
|
||||
|
||||
def set_mobility_config(self, session, _id, config):
|
||||
def set_mobility_config(self, session_id, node_id, config):
|
||||
"""
|
||||
Set mobility configuration for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param dict[str, str] config: mobility configuration
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.SetMobilityConfigResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetMobilityConfigRequest(session=session, id=_id, config=config)
|
||||
request = core_pb2.SetMobilityConfigRequest(session_id=session_id, node_id=node_id, config=config)
|
||||
return self.stub.SetMobilityConfig(request)
|
||||
|
||||
def mobility_action(self, session, _id, action):
|
||||
def mobility_action(self, session_id, node_id, action):
|
||||
"""
|
||||
Send a mobility action for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param core_pb2.ServiceAction action: action to take
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.MobilityActionResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.MobilityActionRequest(session=session, id=_id, action=action)
|
||||
request = core_pb2.MobilityActionRequest(session_id=session_id, node_id=node_id, action=action)
|
||||
return self.stub.MobilityAction(request)
|
||||
|
||||
def get_services(self):
|
||||
|
@ -555,23 +555,23 @@ class CoreGrpcClient(object):
|
|||
request = core_pb2.GetServicesRequest()
|
||||
return self.stub.GetServices(request)
|
||||
|
||||
def get_service_defaults(self, session):
|
||||
def get_service_defaults(self, session_id):
|
||||
"""
|
||||
Get default services for different default node models.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:return: response with a dict of node model to a list of services
|
||||
:rtype: core_pb2.GetServiceDefaultsResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetServiceDefaultsRequest(session=session)
|
||||
request = core_pb2.GetServiceDefaultsRequest(session_id=session_id)
|
||||
return self.stub.GetServiceDefaults(request)
|
||||
|
||||
def set_service_defaults(self, session, service_defaults):
|
||||
def set_service_defaults(self, session_id, service_defaults):
|
||||
"""
|
||||
Set default services for node models.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:param dict service_defaults: node models to lists of services
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.SetServiceDefaultsResponse
|
||||
|
@ -582,44 +582,45 @@ class CoreGrpcClient(object):
|
|||
services = service_defaults[node_type]
|
||||
default = core_pb2.ServiceDefaults(node_type=node_type, services=services)
|
||||
defaults.append(default)
|
||||
request = core_pb2.SetServiceDefaultsRequest(session=session, defaults=defaults)
|
||||
request = core_pb2.SetServiceDefaultsRequest(session_id=session_id, defaults=defaults)
|
||||
return self.stub.SetServiceDefaults(request)
|
||||
|
||||
def get_node_service(self, session, _id, service):
|
||||
def get_node_service(self, session_id, node_id, service):
|
||||
"""
|
||||
Get service data for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str service: service name
|
||||
:return: response with node service data
|
||||
:rtype: core_pb2.GetNodeServiceResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetNodeServiceRequest(session=session, id=_id, service=service)
|
||||
request = core_pb2.GetNodeServiceRequest(session_id=session_id, node_id=node_id, service=service)
|
||||
return self.stub.GetNodeService(request)
|
||||
|
||||
def get_node_service_file(self, session, _id, service, file_name):
|
||||
def get_node_service_file(self, session_id, node_id, service, file_name):
|
||||
"""
|
||||
Get a service file for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str service: service name
|
||||
:param str file_name: file name to get data for
|
||||
:return: response with file data
|
||||
:rtype: core_pb2.GetNodeServiceFileResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetNodeServiceFileRequest(session=session, id=_id, service=service, file=file_name)
|
||||
request = core_pb2.GetNodeServiceFileRequest(
|
||||
session_id=session_id, node_id=node_id, service=service, file=file_name)
|
||||
return self.stub.GetNodeServiceFile(request)
|
||||
|
||||
def set_node_service(self, session, _id, service, startup, validate, shutdown):
|
||||
def set_node_service(self, session_id, node_id, service, startup, validate, shutdown):
|
||||
"""
|
||||
Set service data for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str service: service name
|
||||
:param list startup: startup commands
|
||||
:param list validate: validation commands
|
||||
|
@ -629,15 +630,16 @@ class CoreGrpcClient(object):
|
|||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetNodeServiceRequest(
|
||||
session=session, id=_id, service=service, startup=startup, validate=validate, shutdown=shutdown)
|
||||
session_id=session_id, node_id=node_id, service=service, startup=startup, validate=validate,
|
||||
shutdown=shutdown)
|
||||
return self.stub.SetNodeService(request)
|
||||
|
||||
def set_node_service_file(self, session, _id, service, file_name, data):
|
||||
def set_node_service_file(self, session_id, node_id, service, file_name, data):
|
||||
"""
|
||||
Set a service file for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str service: service name
|
||||
:param str file_name: file name to save
|
||||
:param bytes data: data to save for file
|
||||
|
@ -646,109 +648,110 @@ class CoreGrpcClient(object):
|
|||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetNodeServiceFileRequest(
|
||||
session=session, id=_id, service=service, file=file_name, data=data)
|
||||
session_id=session_id, node_id=node_id, service=service, file=file_name, data=data)
|
||||
return self.stub.SetNodeServiceFile(request)
|
||||
|
||||
def service_action(self, session, _id, service, action):
|
||||
def service_action(self, session_id, node_id, service, action):
|
||||
"""
|
||||
Send an action to a service for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str service: service name
|
||||
:param core_pb2.ServiceAction action: action for service (start, stop, restart, validate)
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.ServiceActionResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.ServiceActionRequest(session=session, id=_id, service=service, action=action)
|
||||
request = core_pb2.ServiceActionRequest(session_id=session_id, node_id=node_id, service=service, action=action)
|
||||
return self.stub.ServiceAction(request)
|
||||
|
||||
def get_wlan_config(self, session, _id):
|
||||
def get_wlan_config(self, session_id, node_id):
|
||||
"""
|
||||
Get wlan configuration for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:return: response with a list of configuration groups
|
||||
:rtype: core_pb2.GetWlanConfigResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetWlanConfigRequest(session=session, id=_id)
|
||||
request = core_pb2.GetWlanConfigRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.GetWlanConfig(request)
|
||||
|
||||
def set_wlan_config(self, session, _id, config):
|
||||
def set_wlan_config(self, session_id, node_id, config):
|
||||
"""
|
||||
Set wlan configuration for a node.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param dict[str, str] config: wlan configuration
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.SetWlanConfigResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetWlanConfigRequest(session=session, id=_id, config=config)
|
||||
request = core_pb2.SetWlanConfigRequest(session_id=session_id, node_id=node_id, config=config)
|
||||
return self.stub.SetWlanConfig(request)
|
||||
|
||||
def get_emane_config(self, session):
|
||||
def get_emane_config(self, session_id):
|
||||
"""
|
||||
Get session emane configuration.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:return: response with a list of configuration groups
|
||||
:rtype: core_pb2.GetEmaneConfigResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetEmaneConfigRequest(session=session)
|
||||
request = core_pb2.GetEmaneConfigRequest(session_id=session_id)
|
||||
return self.stub.GetEmaneConfig(request)
|
||||
|
||||
def set_emane_config(self, session, config):
|
||||
def set_emane_config(self, session_id, config):
|
||||
"""
|
||||
Set session emane configuration.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:param dict[str, str] config: emane configuration
|
||||
:return: response with result of success or failure
|
||||
:rtype: core_pb2.SetEmaneConfigResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetEmaneConfigRequest(session=session, config=config)
|
||||
request = core_pb2.SetEmaneConfigRequest(session_id=session_id, config=config)
|
||||
return self.stub.SetEmaneConfig(request)
|
||||
|
||||
def get_emane_models(self, session):
|
||||
def get_emane_models(self, session_id):
|
||||
"""
|
||||
Get session emane models.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:return: response with a list of emane models
|
||||
:rtype: core_pb2.GetEmaneModelsResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetEmaneModelsRequest(session=session)
|
||||
request = core_pb2.GetEmaneModelsRequest(session_id=session_id)
|
||||
return self.stub.GetEmaneModels(request)
|
||||
|
||||
def get_emane_model_config(self, session, _id, model, interface_id=-1):
|
||||
def get_emane_model_config(self, session_id, node_id, model, interface_id=-1):
|
||||
"""
|
||||
Get emane model configuration for a node or a node's interface.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str model: emane model name
|
||||
:param int interface_id: node interface id
|
||||
:return: response with a list of configuration groups
|
||||
:rtype: core_pb2.GetEmaneModelConfigResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetEmaneModelConfigRequest(session=session, id=_id, model=model, interface=interface_id)
|
||||
request = core_pb2.GetEmaneModelConfigRequest(
|
||||
session_id=session_id, node_id=node_id, model=model, interface=interface_id)
|
||||
return self.stub.GetEmaneModelConfig(request)
|
||||
|
||||
def set_emane_model_config(self, session, _id, model, config, interface_id=-1):
|
||||
def set_emane_model_config(self, session_id, node_id, model, config, interface_id=-1):
|
||||
"""
|
||||
Set emane model configuration for a node or a node's interface.
|
||||
|
||||
:param int session: session id
|
||||
:param int _id: node id
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:param str model: emane model name
|
||||
:param dict[str, str] config: emane model configuration
|
||||
:param int interface_id: node interface id
|
||||
|
@ -757,30 +760,30 @@ class CoreGrpcClient(object):
|
|||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.SetEmaneModelConfigRequest(
|
||||
session=session, id=_id, model=model, config=config, interface=interface_id)
|
||||
session_id=session_id, node_id=node_id, model=model, config=config, interface_id=interface_id)
|
||||
return self.stub.SetEmaneModelConfig(request)
|
||||
|
||||
def get_emane_model_configs(self, session):
|
||||
def get_emane_model_configs(self, session_id):
|
||||
"""
|
||||
Get all emane model configurations for a session.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:return: response with a dictionary of node/interface ids to configurations
|
||||
:rtype: core_pb2.GetEmaneModelConfigsResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
request = core_pb2.GetEmaneModelConfigsRequest(session=session)
|
||||
request = core_pb2.GetEmaneModelConfigsRequest(session_id=session_id)
|
||||
return self.stub.GetEmaneModelConfigs(request)
|
||||
|
||||
def save_xml(self, session, file_path):
|
||||
def save_xml(self, session_id, file_path):
|
||||
"""
|
||||
Save the current scenario to an XML file.
|
||||
|
||||
:param int session: session id
|
||||
:param int session_id: session id
|
||||
:param str file_path: local path to save scenario XML file to
|
||||
:return: nothing
|
||||
"""
|
||||
request = core_pb2.SaveXmlRequest(session=session)
|
||||
request = core_pb2.SaveXmlRequest(session_id=session_id)
|
||||
response = self.stub.SaveXml(request)
|
||||
with open(file_path, "wb") as xml_file:
|
||||
xml_file.write(response.data)
|
||||
|
|
|
@ -58,11 +58,11 @@ def get_links(session, node):
|
|||
return links
|
||||
|
||||
|
||||
def get_emane_model_id(_id, interface):
|
||||
if interface >= 0:
|
||||
return _id * 1000 + interface
|
||||
def get_emane_model_id(node_id, interface_id):
|
||||
if interface_id >= 0:
|
||||
return node_id * 1000 + interface_id
|
||||
else:
|
||||
return _id
|
||||
return node_id
|
||||
|
||||
|
||||
def convert_link(session, link_data):
|
||||
|
@ -99,7 +99,7 @@ def convert_link(session, link_data):
|
|||
)
|
||||
|
||||
return core_pb2.Link(
|
||||
type=link_data.link_type, node_one=link_data.node1_id, node_two=link_data.node2_id,
|
||||
type=link_data.link_type, node_one_id=link_data.node1_id, node_two_id=link_data.node2_id,
|
||||
interface_one=interface_one, interface_two=interface_two, options=options
|
||||
)
|
||||
|
||||
|
@ -135,29 +135,29 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
except KeyboardInterrupt:
|
||||
self.server.stop(None)
|
||||
|
||||
def get_session(self, _id, context):
|
||||
session = self.coreemu.sessions.get(_id)
|
||||
def get_session(self, session_id, context):
|
||||
session = self.coreemu.sessions.get(session_id)
|
||||
if not session:
|
||||
context.abort(grpc.StatusCode.NOT_FOUND, "session {} not found".format(_id))
|
||||
context.abort(grpc.StatusCode.NOT_FOUND, "session {} not found".format(session_id))
|
||||
return session
|
||||
|
||||
def get_node(self, session, _id, context):
|
||||
def get_node(self, session, node_id, context):
|
||||
try:
|
||||
return session.get_object(_id)
|
||||
return session.get_object(node_id)
|
||||
except KeyError:
|
||||
context.abort(grpc.StatusCode.NOT_FOUND, "node {} not found".format(_id))
|
||||
context.abort(grpc.StatusCode.NOT_FOUND, "node {} not found".format(node_id))
|
||||
|
||||
def CreateSession(self, request, context):
|
||||
logging.debug("create session: %s", request)
|
||||
session = self.coreemu.create_session(request.id)
|
||||
session = self.coreemu.create_session(request.session_id)
|
||||
session.set_state(EventTypes.DEFINITION_STATE)
|
||||
session.location.setrefgeo(47.57917, -122.13232, 2.0)
|
||||
session.location.refscale = 150000.0
|
||||
return core_pb2.CreateSessionResponse(id=session.id, state=session.state)
|
||||
return core_pb2.CreateSessionResponse(session_id=session.id, state=session.state)
|
||||
|
||||
def DeleteSession(self, request, context):
|
||||
logging.debug("delete session: %s", request)
|
||||
result = self.coreemu.delete_session(request.id)
|
||||
result = self.coreemu.delete_session(request.session_id)
|
||||
return core_pb2.DeleteSessionResponse(result=result)
|
||||
|
||||
def GetSessions(self, request, context):
|
||||
|
@ -172,7 +172,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetSessionLocation(self, request, context):
|
||||
logging.debug("get session location: %s", request)
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
x, y, z = session.location.refxyz
|
||||
lat, lon, alt = session.location.refgeo
|
||||
position = core_pb2.Position(x=x, y=y, z=z, lat=lat, lon=lon, alt=alt)
|
||||
|
@ -180,7 +180,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SetSessionLocation(self, request, context):
|
||||
logging.debug("set session location: %s", request)
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
session.location.refxyz = (request.position.x, request.position.y, request.position.z)
|
||||
session.location.setrefgeo(request.position.lat, request.position.lon, request.position.alt)
|
||||
session.location.refscale = request.scale
|
||||
|
@ -188,7 +188,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SetSessionState(self, request, context):
|
||||
logging.debug("set session state: %s", request)
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
|
||||
try:
|
||||
state = EventTypes(request.state)
|
||||
|
@ -213,7 +213,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetSessionOptions(self, request, context):
|
||||
logging.debug("get session options: %s", request)
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.options.get_configs()
|
||||
defaults = session.options.default_values()
|
||||
defaults.update(config)
|
||||
|
@ -222,14 +222,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SetSessionOptions(self, request, context):
|
||||
logging.debug("set session options: %s", request)
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.options.get_configs()
|
||||
config.update(request.config)
|
||||
return core_pb2.SetSessionOptionsResponse(result=True)
|
||||
|
||||
def GetSession(self, request, context):
|
||||
logging.debug("get session: %s", request)
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
|
||||
links = []
|
||||
nodes = []
|
||||
|
@ -263,7 +263,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
return core_pb2.GetSessionResponse(session=session_proto)
|
||||
|
||||
def NodeEvents(self, request, context):
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
queue = Queue()
|
||||
session.node_handlers.append(queue.put)
|
||||
|
||||
|
@ -283,7 +283,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
self._cancel_stream(context)
|
||||
|
||||
def LinkEvents(self, request, context):
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
queue = Queue()
|
||||
session.link_handlers.append(queue.put)
|
||||
|
||||
|
@ -318,7 +318,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
unidirectional=event.unidirectional
|
||||
)
|
||||
link = core_pb2.Link(
|
||||
type=event.link_type, node_one=event.node1_id, node_two=event.node2_id,
|
||||
type=event.link_type, node_one_id=event.node1_id, node_two_id=event.node2_id,
|
||||
interface_one=interface_one, interface_two=interface_two, options=options)
|
||||
link_event = core_pb2.LinkEvent(message_type=event.message_type, link=link)
|
||||
yield link_event
|
||||
|
@ -328,7 +328,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
self._cancel_stream(context)
|
||||
|
||||
def SessionEvents(self, request, context):
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
queue = Queue()
|
||||
session.event_handlers.append(queue.put)
|
||||
|
||||
|
@ -339,12 +339,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
if event_time is not None:
|
||||
event_time = float(event_time)
|
||||
session_event = core_pb2.SessionEvent(
|
||||
node=event.node,
|
||||
node_id=event.node,
|
||||
event=event.event_type,
|
||||
name=event.name,
|
||||
data=event.data,
|
||||
time=event_time,
|
||||
session=session.id
|
||||
session_id=session.id
|
||||
)
|
||||
yield session_event
|
||||
except Empty:
|
||||
|
@ -353,16 +353,19 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
self._cancel_stream(context)
|
||||
|
||||
def ConfigEvents(self, request, context):
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
queue = Queue()
|
||||
session.config_handlers.append(queue.put)
|
||||
|
||||
while self._is_running(context):
|
||||
try:
|
||||
event = queue.get(timeout=1)
|
||||
session_id = None
|
||||
if event.session is not None:
|
||||
session_id = int(event.session)
|
||||
config_event = core_pb2.ConfigEvent(
|
||||
message_type=event.message_type,
|
||||
node=event.node,
|
||||
node_id=event.node,
|
||||
object=event.object,
|
||||
type=event.type,
|
||||
captions=event.captions,
|
||||
|
@ -370,7 +373,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
data_values=event.data_values,
|
||||
possible_values=event.possible_values,
|
||||
groups=event.groups,
|
||||
session=event.session,
|
||||
session_id=session_id,
|
||||
interface=event.interface_number,
|
||||
network_id=event.network_id,
|
||||
opaque=event.opaque,
|
||||
|
@ -383,7 +386,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
self._cancel_stream(context)
|
||||
|
||||
def ExceptionEvents(self, request, context):
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
queue = Queue()
|
||||
session.exception_handlers.append(queue.put)
|
||||
|
||||
|
@ -391,8 +394,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
try:
|
||||
event = queue.get(timeout=1)
|
||||
exception_event = core_pb2.ExceptionEvent(
|
||||
node=event.node,
|
||||
session=int(event.session),
|
||||
node_id=event.node,
|
||||
session_id=int(event.session),
|
||||
level=event.level.value,
|
||||
source=event.source,
|
||||
date=event.date,
|
||||
|
@ -406,7 +409,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
self._cancel_stream(context)
|
||||
|
||||
def FileEvents(self, request, context):
|
||||
session = self.get_session(request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
queue = Queue()
|
||||
session.file_handlers.append(queue.put)
|
||||
|
||||
|
@ -415,13 +418,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
event = queue.get(timeout=1)
|
||||
file_event = core_pb2.FileEvent(
|
||||
message_type=event.message_type,
|
||||
node=event.node,
|
||||
node_id=event.node,
|
||||
name=event.name,
|
||||
mode=event.mode,
|
||||
number=event.number,
|
||||
type=event.type,
|
||||
source=event.source,
|
||||
session=event.session,
|
||||
session_id=event.session,
|
||||
data=event.data,
|
||||
compressed_data=event.compressed_data
|
||||
)
|
||||
|
@ -433,7 +436,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def AddNode(self, request, context):
|
||||
logging.debug("add node: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
|
||||
node_proto = request.node
|
||||
node_id = node_proto.id
|
||||
|
@ -457,12 +460,12 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
if emane_model:
|
||||
session.emane.set_model_config(node_id, emane_model)
|
||||
|
||||
return core_pb2.AddNodeResponse(id=node.objid)
|
||||
return core_pb2.AddNodeResponse(node_id=node.objid)
|
||||
|
||||
def GetNode(self, request, context):
|
||||
logging.debug("get node: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node = self.get_node(session, request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
|
||||
interfaces = []
|
||||
for interface_id, interface in node._netif.iteritems():
|
||||
|
@ -489,8 +492,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def EditNode(self, request, context):
|
||||
logging.debug("edit node: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node_id = request.id
|
||||
session = self.get_session(request.session_id, context)
|
||||
node_id = request.node_id
|
||||
node_options = NodeOptions()
|
||||
x = request.position.x
|
||||
y = request.position.y
|
||||
|
@ -504,26 +507,26 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def DeleteNode(self, request, context):
|
||||
logging.debug("delete node: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
result = session.delete_node(request.id)
|
||||
session = self.get_session(request.session_id, context)
|
||||
result = session.delete_node(request.node_id)
|
||||
return core_pb2.DeleteNodeResponse(result=result)
|
||||
|
||||
def GetNodeLinks(self, request, context):
|
||||
logging.debug("get node links: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node = self.get_node(session, request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
links = get_links(session, node)
|
||||
return core_pb2.GetNodeLinksResponse(links=links)
|
||||
|
||||
def AddLink(self, request, context):
|
||||
logging.debug("add link: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
|
||||
# validate node exist
|
||||
self.get_node(session, request.link.node_one, context)
|
||||
self.get_node(session, request.link.node_two, context)
|
||||
node_one = request.link.node_one
|
||||
node_two = request.link.node_two
|
||||
self.get_node(session, request.link.node_one_id, context)
|
||||
self.get_node(session, request.link.node_two_id, context)
|
||||
node_one_id = request.link.node_one_id
|
||||
node_two_id = request.link.node_two_id
|
||||
|
||||
interface_one = None
|
||||
interface_one_data = request.link.interface_one
|
||||
|
@ -587,16 +590,16 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
link_options.key = options_data.key
|
||||
link_options.opaque = options_data.opaque
|
||||
|
||||
session.add_link(node_one, node_two, interface_one, interface_two, link_options=link_options)
|
||||
session.add_link(node_one_id, node_two_id, interface_one, interface_two, link_options=link_options)
|
||||
return core_pb2.AddLinkResponse(result=True)
|
||||
|
||||
def EditLink(self, request, context):
|
||||
logging.debug("edit link: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node_one = request.node_one
|
||||
node_two = request.node_two
|
||||
interface_one_id = request.interface_one
|
||||
interface_two_id = request.interface_two
|
||||
session = self.get_session(request.session_id, context)
|
||||
node_one_id = request.node_one_id
|
||||
node_two_id = request.node_two_id
|
||||
interface_one_id = request.interface_one_id
|
||||
interface_two_id = request.interface_two_id
|
||||
options_data = request.options
|
||||
link_options = LinkOptions()
|
||||
link_options.delay = options_data.delay
|
||||
|
@ -610,22 +613,22 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
link_options.unidirectional = options_data.unidirectional
|
||||
link_options.key = options_data.key
|
||||
link_options.opaque = options_data.opaque
|
||||
session.update_link(node_one, node_two, interface_one_id, interface_two_id, link_options)
|
||||
session.update_link(node_one_id, node_two_id, interface_one_id, interface_two_id, link_options)
|
||||
return core_pb2.EditLinkResponse(result=True)
|
||||
|
||||
def DeleteLink(self, request, context):
|
||||
logging.debug("delete link: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node_one = request.node_one
|
||||
node_two = request.node_two
|
||||
interface_one = request.interface_one
|
||||
interface_two = request.interface_two
|
||||
session.delete_link(node_one, node_two, interface_one, interface_two)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node_one_id = request.node_one_id
|
||||
node_two_id = request.node_two_id
|
||||
interface_one_id = request.interface_one_id
|
||||
interface_two_id = request.interface_two_id
|
||||
session.delete_link(node_one_id, node_two_id, interface_one_id, interface_two_id)
|
||||
return core_pb2.DeleteLinkResponse(result=True)
|
||||
|
||||
def GetHooks(self, request, context):
|
||||
logging.debug("get hooks: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
hooks = []
|
||||
for state, state_hooks in session._hooks.iteritems():
|
||||
for file_name, file_data in state_hooks:
|
||||
|
@ -635,14 +638,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def AddHook(self, request, context):
|
||||
logging.debug("add hook: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
hook = request.hook
|
||||
session.add_hook(hook.state, hook.file, None, hook.data)
|
||||
return core_pb2.AddHookResponse(result=True)
|
||||
|
||||
def GetMobilityConfigs(self, request, context):
|
||||
logging.debug("get mobility configs: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
response = core_pb2.GetMobilityConfigsResponse()
|
||||
for node_id, model_config in session.mobility.node_configurations.iteritems():
|
||||
if node_id == -1:
|
||||
|
@ -657,21 +660,21 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetMobilityConfig(self, request, context):
|
||||
logging.debug("get mobility config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
config = session.mobility.get_model_config(request.id, Ns2ScriptedMobility.name)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.mobility.get_model_config(request.node_id, Ns2ScriptedMobility.name)
|
||||
groups = get_config_groups(config, Ns2ScriptedMobility)
|
||||
return core_pb2.GetMobilityConfigResponse(groups=groups)
|
||||
|
||||
def SetMobilityConfig(self, request, context):
|
||||
logging.debug("set mobility config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session.mobility.set_model_config(request.id, Ns2ScriptedMobility.name, request.config)
|
||||
session = self.get_session(request.session_id, context)
|
||||
session.mobility.set_model_config(request.node_id, Ns2ScriptedMobility.name, request.config)
|
||||
return core_pb2.SetMobilityConfigResponse(result=True)
|
||||
|
||||
def MobilityAction(self, request, context):
|
||||
logging.debug("mobility action: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node = self.get_node(session, request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
result = True
|
||||
if request.action == core_pb2.MOBILITY_START:
|
||||
node.mobility.start()
|
||||
|
@ -693,7 +696,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetServiceDefaults(self, request, context):
|
||||
logging.debug("get service defaults: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
all_service_defaults = []
|
||||
for node_type in session.services.default_services:
|
||||
services = session.services.default_services[node_type]
|
||||
|
@ -703,7 +706,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SetServiceDefaults(self, request, context):
|
||||
logging.debug("set service defaults: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
session.services.default_services.clear()
|
||||
for service_defaults in request.defaults:
|
||||
session.services.default_services[service_defaults.node_type] = service_defaults.services
|
||||
|
@ -711,8 +714,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetNodeService(self, request, context):
|
||||
logging.debug("get node service: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
service = session.services.get_service(request.id, request.service, default_service=True)
|
||||
session = self.get_session(request.session_id, context)
|
||||
service = session.services.get_service(request.node_id, request.service, default_service=True)
|
||||
service_proto = core_pb2.NodeServiceData(
|
||||
executables=service.executables,
|
||||
dependencies=service.dependencies,
|
||||
|
@ -729,8 +732,8 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetNodeServiceFile(self, request, context):
|
||||
logging.debug("get node service file: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node = self.get_node(session, request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
service = None
|
||||
for current_service in node.services:
|
||||
if current_service.name == request.service:
|
||||
|
@ -743,9 +746,9 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SetNodeService(self, request, context):
|
||||
logging.debug("set node service: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session.services.set_service(request.id, request.service)
|
||||
service = session.services.get_service(request.id, request.service)
|
||||
session = self.get_session(request.session_id, context)
|
||||
session.services.set_service(request.node_id, request.service)
|
||||
service = session.services.get_service(request.node_id, request.service)
|
||||
service.startup = tuple(request.startup)
|
||||
service.validate = tuple(request.validate)
|
||||
service.shutdown = tuple(request.shutdown)
|
||||
|
@ -753,14 +756,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SetNodeServiceFile(self, request, context):
|
||||
logging.debug("set node service file: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session.services.set_service_file(request.id, request.service, request.file, request.data)
|
||||
session = self.get_session(request.session_id, context)
|
||||
session.services.set_service_file(request.node_id, request.service, request.file, request.data)
|
||||
return core_pb2.SetNodeServiceFileResponse(result=True)
|
||||
|
||||
def ServiceAction(self, request, context):
|
||||
logging.debug("service action: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
node = self.get_node(session, request.id, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
service = None
|
||||
for current_service in node.services:
|
||||
if current_service.name == request.service:
|
||||
|
@ -790,34 +793,34 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetWlanConfig(self, request, context):
|
||||
logging.debug("get wlan config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
config = session.mobility.get_model_config(request.id, BasicRangeModel.name)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.mobility.get_model_config(request.node_id, BasicRangeModel.name)
|
||||
groups = get_config_groups(config, BasicRangeModel)
|
||||
return core_pb2.GetWlanConfigResponse(groups=groups)
|
||||
|
||||
def SetWlanConfig(self, request, context):
|
||||
logging.debug("set wlan config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session.mobility.set_model_config(request.id, BasicRangeModel.name, request.config)
|
||||
session = self.get_session(request.session_id, context)
|
||||
session.mobility.set_model_config(request.node_id, BasicRangeModel.name, request.config)
|
||||
return core_pb2.SetWlanConfigResponse(result=True)
|
||||
|
||||
def GetEmaneConfig(self, request, context):
|
||||
logging.debug("get emane config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.emane.get_configs()
|
||||
groups = get_config_groups(config, session.emane.emane_config)
|
||||
return core_pb2.GetEmaneConfigResponse(groups=groups)
|
||||
|
||||
def SetEmaneConfig(self, request, context):
|
||||
logging.debug("set emane config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
config = session.emane.get_configs()
|
||||
config.update(request.config)
|
||||
return core_pb2.SetEmaneConfigResponse(result=True)
|
||||
|
||||
def GetEmaneModels(self, request, context):
|
||||
logging.debug("get emane models: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
models = []
|
||||
for model in session.emane.models.keys():
|
||||
if len(model.split("_")) != 2:
|
||||
|
@ -827,23 +830,23 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def GetEmaneModelConfig(self, request, context):
|
||||
logging.debug("get emane model config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
model = session.emane.models[request.model]
|
||||
_id = get_emane_model_id(request.id, request.interface)
|
||||
_id = get_emane_model_id(request.node_id, request.interface)
|
||||
config = session.emane.get_model_config(_id, request.model)
|
||||
groups = get_config_groups(config, model)
|
||||
return core_pb2.GetEmaneModelConfigResponse(groups=groups)
|
||||
|
||||
def SetEmaneModelConfig(self, request, context):
|
||||
logging.debug("set emane model config: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
_id = get_emane_model_id(request.id, request.interface)
|
||||
session = self.get_session(request.session_id, context)
|
||||
_id = get_emane_model_id(request.node_id, request.interface_id)
|
||||
session.emane.set_model_config(_id, request.model, request.config)
|
||||
return core_pb2.SetEmaneModelConfigResponse(result=True)
|
||||
|
||||
def GetEmaneModelConfigs(self, request, context):
|
||||
logging.debug("get emane model configs: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
response = core_pb2.GetEmaneModelConfigsResponse()
|
||||
for node_id, model_config in session.emane.node_configurations.iteritems():
|
||||
if node_id == -1:
|
||||
|
@ -860,7 +863,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
def SaveXml(self, request, context):
|
||||
logging.debug("save xml: %s", request)
|
||||
session = self.get_session(request.session, context)
|
||||
session = self.get_session(request.session_id, context)
|
||||
|
||||
_, temp_path = tempfile.mkstemp()
|
||||
session.save_xml(temp_path)
|
||||
|
@ -881,7 +884,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
|
||||
try:
|
||||
session.open_xml(temp_path, start=True)
|
||||
return core_pb2.OpenXmlResponse(session=session.id, result=True)
|
||||
return core_pb2.OpenXmlResponse(session_id=session.id, result=True)
|
||||
except IOError:
|
||||
logging.exception("error opening session file")
|
||||
self.coreemu.delete_session(session.id)
|
||||
|
|
|
@ -13,26 +13,27 @@ def main():
|
|||
|
||||
with core.context_connect():
|
||||
# create session
|
||||
session = core.create_session()
|
||||
logging.info("created session: %s", session)
|
||||
response = core.create_session()
|
||||
logging.info("created session: %s", response)
|
||||
|
||||
# handle events session may broadcast
|
||||
core.exception_events(session.id, log_event)
|
||||
core.node_events(session.id, log_event)
|
||||
core.session_events(session.id, log_event)
|
||||
core.link_events(session.id, log_event)
|
||||
core.file_events(session.id, log_event)
|
||||
core.config_events(session.id, log_event)
|
||||
session_id = response.session_id
|
||||
core.exception_events(session_id, log_event)
|
||||
core.node_events(session_id, log_event)
|
||||
core.session_events(session_id, log_event)
|
||||
core.link_events(session_id, log_event)
|
||||
core.file_events(session_id, log_event)
|
||||
core.config_events(session_id, log_event)
|
||||
|
||||
# change session state
|
||||
response = core.set_session_state(session.id, core_pb2.STATE_CONFIGURATION)
|
||||
response = core.set_session_state(session_id, core_pb2.STATE_CONFIGURATION)
|
||||
logging.info("set session state: %s", response)
|
||||
|
||||
# create switch node
|
||||
switch = core_pb2.Node(type=core_pb2.NODE_SWITCH)
|
||||
response = core.add_node(session.id, switch)
|
||||
response = core.add_node(session_id, switch)
|
||||
logging.info("created switch: %s", response)
|
||||
switch_id = response.id
|
||||
switch_id = response.node_id
|
||||
|
||||
# helper to create interfaces
|
||||
interface_helper = client.InterfaceHelper(ip4_prefix="10.83.0.0/16")
|
||||
|
@ -41,17 +42,17 @@ def main():
|
|||
# create node
|
||||
position = core_pb2.Position(x=50 + 50 * i, y=50)
|
||||
node = core_pb2.Node(position=position)
|
||||
response = core.add_node(session.id, node)
|
||||
response = core.add_node(session_id, node)
|
||||
logging.info("created node: %s", response)
|
||||
node_id = response.id
|
||||
node_id = response.node_id
|
||||
|
||||
# create link
|
||||
interface_one = interface_helper.create_interface(node_id, 0)
|
||||
response = core.add_link(session.id, node_id, switch_id, interface_one)
|
||||
response = core.add_link(session_id, node_id, switch_id, interface_one)
|
||||
logging.info("created link: %s", response)
|
||||
|
||||
# change session state
|
||||
response = core.set_session_state(session.id, core_pb2.STATE_INSTANTIATION)
|
||||
response = core.set_session_state(session_id, core_pb2.STATE_INSTANTIATION)
|
||||
logging.info("set session state: %s", response)
|
||||
|
||||
|
||||
|
|
|
@ -120,16 +120,16 @@ service CoreApi {
|
|||
|
||||
// rpc request/response messages
|
||||
message CreateSessionRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message CreateSessionResponse {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
SessionState state = 2;
|
||||
}
|
||||
|
||||
message DeleteSessionRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message DeleteSessionResponse {
|
||||
|
@ -144,7 +144,7 @@ message GetSessionsResponse {
|
|||
}
|
||||
|
||||
message GetSessionRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetSessionResponse {
|
||||
|
@ -152,7 +152,7 @@ message GetSessionResponse {
|
|||
}
|
||||
|
||||
message GetSessionOptionsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetSessionOptionsResponse {
|
||||
|
@ -160,7 +160,7 @@ message GetSessionOptionsResponse {
|
|||
}
|
||||
|
||||
message SetSessionOptionsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
map<string, string> config = 2;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ message SetSessionOptionsResponse {
|
|||
}
|
||||
|
||||
message GetSessionLocationRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetSessionLocationResponse {
|
||||
|
@ -178,7 +178,7 @@ message GetSessionLocationResponse {
|
|||
}
|
||||
|
||||
message SetSessionLocationRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
Position position = 2;
|
||||
float scale = 3;
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ message SetSessionLocationResponse {
|
|||
}
|
||||
|
||||
message SetSessionStateRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
SessionState state = 2;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ message SetSessionStateResponse {
|
|||
}
|
||||
|
||||
message NodeEventsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message NodeEvent {
|
||||
|
@ -205,7 +205,7 @@ message NodeEvent {
|
|||
}
|
||||
|
||||
message LinkEventsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message LinkEvent {
|
||||
|
@ -214,25 +214,25 @@ message LinkEvent {
|
|||
}
|
||||
|
||||
message SessionEventsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message SessionEvent {
|
||||
int32 node = 1;
|
||||
int32 node_id = 1;
|
||||
int32 event = 2;
|
||||
string name = 3;
|
||||
bytes data = 4;
|
||||
float time = 5;
|
||||
int32 session = 6;
|
||||
int32 session_id = 6;
|
||||
}
|
||||
|
||||
message ConfigEventsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message ConfigEvent {
|
||||
MessageType message_type = 1;
|
||||
int32 node = 2;
|
||||
int32 node_id = 2;
|
||||
string object = 3;
|
||||
int32 type = 4;
|
||||
repeated int32 data_types = 5;
|
||||
|
@ -241,19 +241,19 @@ message ConfigEvent {
|
|||
string bitmap = 8;
|
||||
string possible_values = 9;
|
||||
string groups = 10;
|
||||
string session = 11;
|
||||
int32 session_id = 11;
|
||||
int32 interface = 12;
|
||||
int32 network_id = 13;
|
||||
string opaque = 14;
|
||||
}
|
||||
|
||||
message ExceptionEventsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message ExceptionEvent {
|
||||
int32 node = 1;
|
||||
int32 session = 2;
|
||||
int32 node_id = 1;
|
||||
int32 session_id = 2;
|
||||
ExceptionLevel level = 3;
|
||||
string source = 4;
|
||||
string date = 5;
|
||||
|
@ -262,34 +262,34 @@ message ExceptionEvent {
|
|||
}
|
||||
|
||||
message FileEventsRequest {
|
||||
int32 id = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message FileEvent {
|
||||
MessageType message_type = 1;
|
||||
int32 node = 2;
|
||||
int32 node_id = 2;
|
||||
string name = 3;
|
||||
string mode = 4;
|
||||
int32 number = 5;
|
||||
string type = 6;
|
||||
string source = 7;
|
||||
int32 session = 8;
|
||||
int32 session_id = 8;
|
||||
bytes data = 9;
|
||||
bytes compressed_data = 10;
|
||||
}
|
||||
|
||||
message AddNodeRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
Node node = 2;
|
||||
}
|
||||
|
||||
message AddNodeResponse {
|
||||
int32 id = 1;
|
||||
int32 node_id = 1;
|
||||
}
|
||||
|
||||
message GetNodeRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
}
|
||||
|
||||
message GetNodeResponse {
|
||||
|
@ -298,8 +298,8 @@ message GetNodeResponse {
|
|||
}
|
||||
|
||||
message EditNodeRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
Position position = 3;
|
||||
}
|
||||
|
||||
|
@ -308,8 +308,8 @@ message EditNodeResponse {
|
|||
}
|
||||
|
||||
message DeleteNodeRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
}
|
||||
|
||||
message DeleteNodeResponse {
|
||||
|
@ -317,8 +317,8 @@ message DeleteNodeResponse {
|
|||
}
|
||||
|
||||
message GetNodeLinksRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
}
|
||||
|
||||
message GetNodeLinksResponse {
|
||||
|
@ -326,7 +326,7 @@ message GetNodeLinksResponse {
|
|||
}
|
||||
|
||||
message AddLinkRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
Link link = 2;
|
||||
}
|
||||
|
||||
|
@ -335,11 +335,11 @@ message AddLinkResponse {
|
|||
}
|
||||
|
||||
message EditLinkRequest {
|
||||
int32 session = 1;
|
||||
int32 node_one = 2;
|
||||
int32 node_two = 3;
|
||||
int32 interface_one = 4;
|
||||
int32 interface_two = 5;
|
||||
int32 session_id = 1;
|
||||
int32 node_one_id = 2;
|
||||
int32 node_two_id = 3;
|
||||
int32 interface_one_id = 4;
|
||||
int32 interface_two_id = 5;
|
||||
LinkOptions options = 6;
|
||||
}
|
||||
|
||||
|
@ -348,11 +348,11 @@ message EditLinkResponse {
|
|||
}
|
||||
|
||||
message DeleteLinkRequest {
|
||||
int32 session = 1;
|
||||
int32 node_one = 2;
|
||||
int32 node_two = 3;
|
||||
int32 interface_one = 4;
|
||||
int32 interface_two = 5;
|
||||
int32 session_id = 1;
|
||||
int32 node_one_id = 2;
|
||||
int32 node_two_id = 3;
|
||||
int32 interface_one_id = 4;
|
||||
int32 interface_two_id = 5;
|
||||
}
|
||||
|
||||
message DeleteLinkResponse {
|
||||
|
@ -360,7 +360,7 @@ message DeleteLinkResponse {
|
|||
}
|
||||
|
||||
message GetHooksRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetHooksResponse {
|
||||
|
@ -368,7 +368,7 @@ message GetHooksResponse {
|
|||
}
|
||||
|
||||
message AddHookRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
Hook hook = 2;
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ message AddHookResponse {
|
|||
}
|
||||
|
||||
message GetMobilityConfigsRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetMobilityConfigsResponse {
|
||||
|
@ -388,8 +388,8 @@ message GetMobilityConfigsResponse {
|
|||
}
|
||||
|
||||
message GetMobilityConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
}
|
||||
|
||||
message GetMobilityConfigResponse {
|
||||
|
@ -397,8 +397,8 @@ message GetMobilityConfigResponse {
|
|||
}
|
||||
|
||||
message SetMobilityConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
map<string, string> config = 3;
|
||||
}
|
||||
|
||||
|
@ -407,8 +407,8 @@ message SetMobilityConfigResponse {
|
|||
}
|
||||
|
||||
message MobilityActionRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
MobilityAction action = 3;
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ message GetServicesResponse {
|
|||
}
|
||||
|
||||
message GetServiceDefaultsRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetServiceDefaultsResponse {
|
||||
|
@ -433,7 +433,7 @@ message GetServiceDefaultsResponse {
|
|||
}
|
||||
|
||||
message SetServiceDefaultsRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
repeated ServiceDefaults defaults = 2;
|
||||
}
|
||||
|
||||
|
@ -442,8 +442,8 @@ message SetServiceDefaultsResponse {
|
|||
}
|
||||
|
||||
message GetNodeServiceRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
string service = 3;
|
||||
}
|
||||
|
||||
|
@ -452,8 +452,8 @@ message GetNodeServiceResponse {
|
|||
}
|
||||
|
||||
message GetNodeServiceFileRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
string service = 3;
|
||||
string file = 4;
|
||||
}
|
||||
|
@ -463,8 +463,8 @@ message GetNodeServiceFileResponse {
|
|||
}
|
||||
|
||||
message SetNodeServiceRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
string service = 3;
|
||||
repeated string startup = 4;
|
||||
repeated string validate = 5;
|
||||
|
@ -476,8 +476,8 @@ message SetNodeServiceResponse {
|
|||
}
|
||||
|
||||
message SetNodeServiceFileRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
string service = 3;
|
||||
string file = 4;
|
||||
bytes data = 5;
|
||||
|
@ -488,8 +488,8 @@ message SetNodeServiceFileResponse {
|
|||
}
|
||||
|
||||
message ServiceActionRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
string service = 3;
|
||||
ServiceAction action = 4;
|
||||
}
|
||||
|
@ -499,8 +499,8 @@ message ServiceActionResponse {
|
|||
}
|
||||
|
||||
message GetWlanConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
}
|
||||
|
||||
message GetWlanConfigResponse {
|
||||
|
@ -508,8 +508,8 @@ message GetWlanConfigResponse {
|
|||
}
|
||||
|
||||
message SetWlanConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
map<string, string> config = 3;
|
||||
}
|
||||
|
||||
|
@ -518,7 +518,7 @@ message SetWlanConfigResponse {
|
|||
}
|
||||
|
||||
message GetEmaneConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetEmaneConfigResponse {
|
||||
|
@ -526,7 +526,7 @@ message GetEmaneConfigResponse {
|
|||
}
|
||||
|
||||
message SetEmaneConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
map<string, string> config = 2;
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ message SetEmaneConfigResponse {
|
|||
}
|
||||
|
||||
message GetEmaneModelsRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetEmaneModelsResponse {
|
||||
|
@ -543,8 +543,8 @@ message GetEmaneModelsResponse {
|
|||
}
|
||||
|
||||
message GetEmaneModelConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
int32 interface = 3;
|
||||
string model = 4;
|
||||
}
|
||||
|
@ -554,9 +554,9 @@ message GetEmaneModelConfigResponse {
|
|||
}
|
||||
|
||||
message SetEmaneModelConfigRequest {
|
||||
int32 session = 1;
|
||||
int32 id = 2;
|
||||
int32 interface = 3;
|
||||
int32 session_id = 1;
|
||||
int32 node_id = 2;
|
||||
int32 interface_id = 3;
|
||||
string model = 4;
|
||||
map<string, string> config = 5;
|
||||
}
|
||||
|
@ -566,7 +566,7 @@ message SetEmaneModelConfigResponse {
|
|||
}
|
||||
|
||||
message GetEmaneModelConfigsRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message GetEmaneModelConfigsResponse {
|
||||
|
@ -578,7 +578,7 @@ message GetEmaneModelConfigsResponse {
|
|||
}
|
||||
|
||||
message SaveXmlRequest {
|
||||
int32 session = 1;
|
||||
int32 session_id = 1;
|
||||
}
|
||||
|
||||
message SaveXmlResponse {
|
||||
|
@ -591,7 +591,7 @@ message OpenXmlRequest {
|
|||
|
||||
message OpenXmlResponse {
|
||||
bool result = 1;
|
||||
int32 session = 2;
|
||||
int32 session_id = 2;
|
||||
}
|
||||
|
||||
// data structures for messages below
|
||||
|
@ -733,8 +733,8 @@ message Node {
|
|||
}
|
||||
|
||||
message Link {
|
||||
int32 node_one = 1;
|
||||
int32 node_two = 2;
|
||||
int32 node_one_id = 1;
|
||||
int32 node_two_id = 2;
|
||||
LinkType type = 3;
|
||||
Interface interface_one = 4;
|
||||
Interface interface_two = 5;
|
||||
|
|
|
@ -25,13 +25,13 @@ class TestGrpc:
|
|||
response = client.create_session(session_id)
|
||||
|
||||
# then
|
||||
assert isinstance(response.id, int)
|
||||
assert isinstance(response.session_id, int)
|
||||
assert isinstance(response.state, int)
|
||||
session = grpc_server.coreemu.sessions.get(response.id)
|
||||
session = grpc_server.coreemu.sessions.get(response.session_id)
|
||||
assert session is not None
|
||||
assert session.state == response.state
|
||||
if session_id is not None:
|
||||
assert response.id == session_id
|
||||
assert response.session_id == session_id
|
||||
assert session.id == session_id
|
||||
|
||||
@pytest.mark.parametrize("session_id, expected", [
|
||||
|
@ -181,8 +181,8 @@ class TestGrpc:
|
|||
response = client.add_node(session.id, node)
|
||||
|
||||
# then
|
||||
assert response.id is not None
|
||||
assert session.get_object(response.id) is not None
|
||||
assert response.node_id is not None
|
||||
assert session.get_object(response.node_id) is not None
|
||||
|
||||
def test_get_node(self, grpc_server):
|
||||
# given
|
||||
|
@ -298,7 +298,7 @@ class TestGrpc:
|
|||
|
||||
# then
|
||||
assert response.result is True
|
||||
assert response.session is not None
|
||||
assert response.session_id is not None
|
||||
|
||||
def test_get_node_links(self, grpc_server, ip_prefixes):
|
||||
# given
|
||||
|
|
Loading…
Reference in a new issue