Commit e626053c authored by Swann Perarnau's avatar Swann Perarnau

[feature/fix] add listen command for upstream pub

Add a listen command to get access to the event stream of the upstream
pub/sub API.

This patch gives back access from the command line to the power
information of a container, including filtering the event stream to only
have events relevent to this container.

This changes the workflow a little bit for users, but should result in a
cleaner access to profiling data in the future.

Related to #18.
parent a47ec65f
Pipeline #4382 passed with stages
in 1 minute and 6 seconds
......@@ -34,6 +34,22 @@ class CommandLineInterface(object):
self.client.wait_connected()
def do_listen(self, argv):
""" Connect to the NRM and listen for pub/sub messages."""
upstream_pub_port = 2345
upstream_pub_param = "tcp://localhost:%d" % (upstream_pub_port)
self.pub_client = nrm.messaging.UpstreamPubClient(upstream_pub_param)
self.pub_client.wait_connected()
while(True):
msg = self.pub_client.recvmsg()
if argv.uuid:
uuid = getattr(msg, 'container_uuid', None)
if argv.container == uuid:
logger.info("pub message", msg)
else:
logger.info("pub message", msg)
def do_run(self, argv):
""" Connect to the NRM and ask to spawn a container and run a command
in it.
......@@ -171,6 +187,13 @@ class CommandLineInterface(object):
parser_list = subparsers.add_parser("list")
parser_list.set_defaults(func=self.do_list)
# listen
parser_listen = subparsers.add_parser("listen")
parser_listen.add_argument("-u", "--uuid",
help="container uuid to listen for",
default=None)
parser_listen.set_defaults(func=self.do_listen)
# setpowerlimit
parser_setpower = subparsers.add_parser("setpower")
parser_setpower.add_argument("-f", "--follow",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment