Commit 4cdbe191 authored by Valentin Reis's avatar Valentin Reis

Merge branch 'pretty-printing-cmd-listen' into 'master'

[feature] Adds a --filter option to `cmd` for pretty-printing.

See merge request !44
parents cf83c4a9 e4ed3804
Pipeline #4888 failed with stages
in 4 minutes and 28 seconds
...@@ -8,6 +8,7 @@ import os ...@@ -8,6 +8,7 @@ import os
import nrm.messaging import nrm.messaging
import uuid import uuid
import sys import sys
import time
import collections import collections
RPC_MSG = nrm.messaging.MSGTYPES['up_rpc_req'] RPC_MSG = nrm.messaging.MSGTYPES['up_rpc_req']
...@@ -59,12 +60,24 @@ class CommandLineInterface(object): ...@@ -59,12 +60,24 @@ class CommandLineInterface(object):
while(True): while(True):
msg = self.pub_client.recvmsg() msg = self.pub_client.recvmsg()
logger.debug("pub message: %s", msg)
def print_if_filter():
if argv.filter:
if argv.filter == msg.type:
print("%s, %s, %s" % (msg.type, time.time(),
print("%s, %s" % (msg.type, time.time()))
if argv.uuid: if argv.uuid:
uuid = getattr(msg, 'container_uuid', None) uuid = getattr(msg, 'container_uuid', None)
if argv.uuid == uuid: if argv.uuid == uuid:"pub message: %s", msg) print_if_filter()
else: else:"pub message: %s", msg) print_if_filter()
def do_run(self, argv): def do_run(self, argv):
""" Connect to the NRM and ask to spawn a container and run a command """ Connect to the NRM and ask to spawn a container and run a command
...@@ -227,6 +240,10 @@ class CommandLineInterface(object): ...@@ -227,6 +240,10 @@ class CommandLineInterface(object):
parser_listen.add_argument("-u", "--uuid", parser_listen.add_argument("-u", "--uuid",
help="container uuid to listen for", help="container uuid to listen for",
default=None) default=None)
parser_listen.add_argument("-f", "--filter",
help="type of message to filter and \
\ prettyprint, in {power,performance}",
parser_listen.set_defaults(func=self.do_listen) parser_listen.set_defaults(func=self.do_listen)
# setpowerlimit # setpowerlimit
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment