Example #1
0
def operator_run(cmd, **kwargs):
    params = kwargs.get('params', [])
    fmt = kwargs.get('format', 'json')
    root = RootCmd(api=INTERNAL_API, resp_formatter_name=fmt)
    ret, _ = root([cmd] + params)
    if ret.status == STATUS_ERROR:
        raise ApiException(str(ret.value))
    return ret.value
Example #2
0
 def _run(self, cmd, kw={}):
     params = kw.get('params', [])
     fmt = kw.get('format', 'json')
     root = RootCmd(api=self.internal_api, resp_formatter_name=fmt)
     ret, _ = root([cmd] + params)
     if ret.status == STATUS_ERROR:
         raise ApiException(str(ret.value))
     return ret.value
Example #3
0
def _handle_request(request):
    LOG.debug('Request from NetworkController<<: %s %s',
              request[RPC_IDX_REQ_SYM], request[RPC_IDX_REQ_PARAM])
    operation, params = request[2], request[3]
    kwargs = {}
    if len(params) > 0:
        kwargs = params[0]
    try:
        return api.base.call(operation, **kwargs)
    except TypeError:
        LOG.error(traceback.format_exc())
        raise ApiException(desc='Invalid type for RPC parameter.')