function to execute wamp rpc on the board from the container
Change-Id: I88548deebc65e9a457a941dea8346a3b609d7ca5
This commit is contained in:
parent
8d762aa9fb
commit
2667a5e9b9
|
@ -15,7 +15,9 @@
|
|||
from iotronic.common import exception
|
||||
from iotronic import objects
|
||||
from iotronic.objects import base as objects_base
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -24,6 +26,12 @@ serializer = objects_base.IotronicObjectSerializer()
|
|||
|
||||
|
||||
class ConductorEndpoint(object):
|
||||
def __init__(self):
|
||||
transport = oslo_messaging.get_transport(cfg.CONF)
|
||||
self.target = oslo_messaging.Target()
|
||||
self.wamp_agent_client = oslo_messaging.RPCClient(transport,
|
||||
self.target)
|
||||
|
||||
def echo(self, ctx, data):
|
||||
LOG.info("ECHO: %s" % data)
|
||||
return data
|
||||
|
@ -69,3 +77,23 @@ class ConductorEndpoint(object):
|
|||
new_location.create()
|
||||
|
||||
return serializer.serialize_entity(ctx, new_node)
|
||||
|
||||
def execute_on_board(self, ctx, board, wamp_rpc_call, wamp_rpc_args):
|
||||
|
||||
LOG.debug('Executing \"%s\" on the board: %s', wamp_rpc_call, board)
|
||||
|
||||
uuid_agent = 'agent'
|
||||
|
||||
s4t_topic = 's4t_invoke_wamp'
|
||||
full_topic = uuid_agent + '.' + s4t_topic
|
||||
|
||||
ctxt = {}
|
||||
|
||||
self.target.topic = full_topic
|
||||
self.wamp_agent_client.prepare(timeout=10)
|
||||
|
||||
full_wamp_call = 'iotronic.' + board + "." + wamp_rpc_call
|
||||
|
||||
return self.wamp_agent_client.call(ctxt, full_topic,
|
||||
wamp_rpc_call=full_wamp_call,
|
||||
data=wamp_rpc_args)
|
||||
|
|
|
@ -114,3 +114,10 @@ class ConductorAPI(object):
|
|||
"""
|
||||
cctxt = self.client.prepare(topic=topic or self.topic, version='1.0')
|
||||
return cctxt.call(context, 'destroy_node', node_id=node_id)
|
||||
|
||||
def execute_on_board(self, context, board, wamp_rpc_call,
|
||||
wamp_rpc_args=None, topic=None):
|
||||
cctxt = self.client.prepare(topic=topic or self.topic, version='1.0')
|
||||
return cctxt.call(context, 'execute_on_board', board=board,
|
||||
wamp_rpc_call=wamp_rpc_call,
|
||||
wamp_rpc_args=wamp_rpc_args)
|
||||
|
|
Loading…
Reference in New Issue