added grpc for a node command and fixed grpc unit tests
This commit is contained in:
parent
e063fcd4fe
commit
1890db5991
5 changed files with 52 additions and 2 deletions
|
@ -329,6 +329,19 @@ class CoreGrpcClient(object):
|
|||
request = core_pb2.DeleteNodeRequest(session_id=session_id, node_id=node_id)
|
||||
return self.stub.DeleteNode(request)
|
||||
|
||||
def node_command(self, session_id, node_id, command):
|
||||
"""
|
||||
Send command to a node and get the output.
|
||||
|
||||
:param int session_id: session id
|
||||
:param int node_id: node id
|
||||
:return: response with command combined stdout/stderr
|
||||
:rtype: core_pb2.NodeCommandResponse
|
||||
:raises grpc.RpcError: when session or node doesn't exist
|
||||
"""
|
||||
request = core_pb2.NodeCommandRequest(session_id=session_id, node_id=node_id, command=command)
|
||||
return self.stub.NodeCommand(request)
|
||||
|
||||
def get_node_links(self, session_id, node_id):
|
||||
"""
|
||||
Get current links for a node.
|
||||
|
|
|
@ -484,6 +484,13 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
result = session.delete_node(request.node_id)
|
||||
return core_pb2.DeleteNodeResponse(result=result)
|
||||
|
||||
def NodeCommand(self, request, context):
|
||||
logging.debug("sending node command: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
node = self.get_node(session, request.node_id, context)
|
||||
_, output = node.cmd_output(request.command)
|
||||
return core_pb2.NodeCommandResponse(output=output)
|
||||
|
||||
def GetNodeLinks(self, request, context):
|
||||
logging.debug("get node links: %s", request)
|
||||
session = self.get_session(request.session_id, context)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue