Commit d859a647 authored by Sridutt Bhalachandra's avatar Sridutt Bhalachandra

[Feature] Power profile in exit event response

Added power profile data to the exit event response at the end of
application run. The profile data is generated using functions from
`SensorManager` and is obtained using the sensor update in `Daemon`

See Issue #12
parent 36401a84
Pipeline #3798 passed with stages
in 2 minutes and 22 seconds
......@@ -91,8 +91,9 @@ class ContainerManager(object):
pp =
if pp.enabled in ["1", "True"]:
if pp.profile in ["1", "True"]:
# TODO: Take appropriate action
container_power['profile'] = dict()
container_power['profile']['start'] = dict()
container_power['profile']['end'] = dict()
if pp.policy != "NONE":
container_power['policy'] = pp.policy
container_power['damper'] = pp.damper
......@@ -93,6 +93,10 @@ class Daemon(object):
if container.power['profile']:
p = container.power['profile']
p['start'] = self.machine_info['energy']['energy']
p['start']['time'] = self.machine_info['time']
# TODO: obviously we need to send more info than that
update = {'type': 'container',
'event': 'start',
......@@ -179,14 +183,29 @@ class Daemon(object):
# check if this is an exit
if os.WIFEXITED(status) or os.WIFSIGNALED(status):
container = self.container_manager.pids[pid]
if container.power['policy']:
pp = container.power
if pp['policy']:
msg = {'type': 'container',
'event': 'exit',
'status': status,
'uuid': container.uuid,
if pp['profile']:
e = pp['profile']['end']
self.machine_info = self.sensor_manager.do_update()
e = self.machine_info['energy']['energy']
e['time'] = self.machine_info['time']
s = pp['profile']['start']
# Calculate difference between the values
diff = self.sensor_manager.calc_difference(s, e)
# Get final package temperature
temp = self.machine_info['temperature']
diff['temp'] = map(lambda k: temp[k]['pkg'], temp)"Container %r profile data: %r",
container.uuid, diff)
msg['profile_data'] = diff
logger.debug("child update ignored")
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