MCPcopy Create free account
hub / github.com/NetSys/bess / run_module_command

Method run_module_command

pybess/bess.py:475–506  ·  view source on GitHub ↗
(self, name, cmd, arg_type, arg)

Source from the content-addressed store, hash-verified

473 return self._request('DisconnectModules', request)
474
475 def run_module_command(self, name, cmd, arg_type, arg):
476 request = bess_msg.CommandRequest()
477 request.name = name
478 request.cmd = cmd
479
480 try:
481 message_type = getattr(module_pb, arg_type)
482 except AttributeError as e:
483 raise self.APIError('Unknown arg "%s"' % arg_type)
484
485 try:
486 arg_msg = pb_conv.dict_to_protobuf(message_type, arg)
487 except (KeyError, ValueError) as e:
488 raise self.APIError(e)
489
490 request.arg.Pack(arg_msg)
491
492 try:
493 response = self._request('ModuleCommand', request)
494 except self.Error as e:
495 e.info.update(module=name, command=cmd, command_arg=arg)
496 raise
497
498 if response.HasField('data'):
499 response_type_str = response.data.type_url.split('.')[-1]
500 response_type = getattr(module_pb, response_type_str,
501 module_msg.EmptyArg)
502 result = response_type()
503 response.data.Unpack(result)
504 return result
505 else:
506 return response
507
508 # It might be nice if we could name hook instances directly,
509 # rather than using <hook, module, direction, gate> tuples...

Callers 5

command_moduleFunction · 0.80
nextMethod · 0.80
_callback_factoryFunction · 0.80

Calls 1

_requestMethod · 0.95

Tested by 2