Commit 27a3fdec authored by Valentin Reis's avatar Valentin Reis

[refactor] messaging style + cmd_listen application_uuid relaxing

This commit does two things:
- re-indents the message schema to be more readable
- lets `cmd listen --filter` print any incoming message, without
discriminating on container_uuid. This makes cmd listen usable until
a proper application_uuid management is written into nrm.
parent bfbddc9b
......@@ -65,19 +65,25 @@ class CommandLineInterface(object):
def print_if_filter():
if argv.filter:
if argv.filter == msg.type:
if (msg.type == "performance" or
msg.type == "progress"):
print("%s, %s, %s" % (msg.type, time.time(),
msg.payload))
if msg.type == "power":
print("%s, %s, %s" % (msg.type, time.time(),
msg.total))
sys.stdout.flush()
else:
print("%s, %s" % (msg.type, time.time()))
sys.stdout.flush()
if argv.uuid:
uuid = getattr(msg, 'container_uuid', None)
if argv.uuid == uuid or msg.type == "power":
print_if_filter()
else:
print_if_filter()
# if argv.uuid:
# uuid = getattr(msg, 'container_uuid', None)
# if argv.uuid == uuid or msg.type == "power":
# print_if_filter()
# else:
# print_if_filter()
def do_run(self, argv):
""" Connect to the NRM and ask to spawn a container and run a command
......
......@@ -41,7 +41,7 @@ class Daemon(object):
pub = {'api': 'up_pub',
'type': 'progress',
'payload': msg.payload,
'container_uuid': msg.container_uuid}
'application_uuid': msg.application_uuid}
self.upstream_pub_server.sendmsg(
PUB_MSG['progress'](**pub))
elif msg.type == 'performance':
......
......@@ -20,53 +20,98 @@ logger = logging.getLogger('nrm')
# basic field type information.
APIS = ['up_rpc_req', 'up_rpc_rep', 'up_pub', 'down_event']
MSGFORMATS = {k: {} for k in APIS}
MSGFORMATS['up_rpc_req'] = {'list': {},
'run': {'manifest': basestring,
MSGFORMATS['up_rpc_req'] = {
'list': {},
'run': {
'manifest': basestring,
'path': basestring,
'args': list,
'container_uuid': basestring,
'environ': dict},
'kill': {'container_uuid': basestring},
'setpower': {'limit': basestring},
'environ': dict
},
'kill': {
'container_uuid': basestring
},
'setpower': {
'limit': basestring
}
}
MSGFORMATS['up_rpc_rep'] = {
'list': {
'payload': list
},
'stdout': {
'container_uuid': basestring,
'payload': basestring
},
'stderr': {
'container_uuid': basestring,
'payload': basestring
},
'process_start': {
'container_uuid': basestring,
'pid': int
},
'process_exit': {
'container_uuid': basestring,
'status': basestring
},
'getpower': {
'limit': basestring
}
MSGFORMATS['up_rpc_rep'] = {'list': {'payload': list},
'stdout': {'container_uuid': basestring,
'payload': basestring},
'stderr': {'container_uuid': basestring,
'payload': basestring},
'process_start': {'container_uuid': basestring,
'pid': int},
'process_exit': {'container_uuid': basestring,
'status': basestring},
'getpower': {'limit': basestring},
}
MSGFORMATS['up_pub'] = {'power': {'total': float, 'limit': float},
'container_start': {'container_uuid': basestring,
MSGFORMATS['up_pub'] = {
'power': {
'total': float,
'limit': float
},
'container_start': {
'container_uuid': basestring,
'errno': int,
'power': basestring},
'container_exit': {'container_uuid': basestring,
'profile_data': dict},
'performance': {'container_uuid': basestring,
'payload': int},
'progress': {'application_uuid': basestring,
'payload': int},
'power': dict
},
'container_exit': {
'container_uuid': basestring,
'profile_data': dict
},
'performance': {
'container_uuid': basestring,
'payload': int
},
'progress': {
'application_uuid': basestring,
'payload': int
}
MSGFORMATS['down_event'] = {'application_start':
{'container_uuid': basestring,
'application_uuid': basestring},
'application_exit':
{'application_uuid': basestring},
'performance': {'payload': int,
}
MSGFORMATS['down_event'] = {
'application_start': {
'container_uuid': basestring,
'application_uuid': basestring
},
'application_exit': {
'application_uuid': basestring
},
'performance': {
'container_uuid': basestring,
'application_uuid': basestring,
'container_uuid': basestring},
'progress': {'payload': int,
'payload': int,
},
'progress': {
'application_uuid': basestring,
'container_uuid': basestring},
'phase_context': {'cpu': int,
'aggregation': int,
'computetime': int,
'totaltime': int,
'application_uuid': basestring},
'container_uuid': basestring,
'payload': int
},
'phase_context': {
'cpu': int,
'startcompute': int,
'endcompute': int,
'startbarrier': int,
'endbarrier': int
}
}
# Mirror of the message formats, using namedtuples as the actual transport
......
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