Commit 0aa4c14e authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[1175] fix conflicts with trac519

parent 9daa2f68
......@@ -308,9 +308,11 @@ class BoB:
return process_list
def _get_stats_data(self):
return { "stats_data": {
'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}}
return { "owner": "Boss",
"data": { 'boot_time':
time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}
}
def command_handler(self, command, args):
logger.debug(DBG_COMMANDS, BIND10_RECEIVED_COMMAND, command)
......@@ -325,17 +327,18 @@ class BoB:
answer = isc.config.ccsession.create_answer(0, self._get_stats_data())
elif command == "sendstats":
# send statistics data to the stats daemon immediately
statistics_data = {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
}
stats_data = self._get_stats_data()
valid = self.ccs.get_module_spec().validate_statistics(
True, statistics_data)
True, stats_data["data"])
if valid:
cmd = isc.config.ccsession.create_command(
'set', { "owner": "Boss",
"data": statistics_data })
'set', stats_data })
seq = self.cc_session.group_sendmsg(cmd, 'Stats')
self.cc_session.group_recvmsg(True, seq)
# Consume the answer, in case it becomes a orphan message.
try:
self.cc_session.group_recvmsg(False, seq)
except isc.cc.session.SessionTimeout:
pass
answer = isc.config.ccsession.create_answer(0)
else:
logger.fatal(BIND10_INVALID_STATISTICS_DATA);
......
......@@ -145,14 +145,6 @@ class Stats:
raise StatsError(STATS_UNKNOWN_COMMAND_IN_SPEC, cmd["command_name"])
self.mccs.start()
def _update_stats_data(self, args):
# 'args' must be dictionary type
if isinstance(args, dict) and isinstance(args.get('stats_data'), dict):
self.stats_data.update(args['stats_data'])
# overwrite "stats.LastUpdateTime"
self.stats_data['stats.last_update_time'] = get_datetime()
def start(self):
"""
Start stats module
......@@ -162,9 +154,26 @@ class Stats:
# request Bob to send statistics data
logger.debug(DBG_STATS_MESSAGING, STATS_SEND_REQUEST_BOSS)
cmd = isc.config.ccsession.create_command("sendstats", None)
cmd = isc.config.ccsession.create_command("getstats", None)
seq = self.cc_session.group_sendmsg(cmd, 'Boss')
self.cc_session.group_recvmsg(True, seq)
try:
answer, env = self.cc_session.group_recvmsg(False, seq)
if answer:
rcode, args = isc.config.ccsession.parse_answer(answer)
if rcode == 0:
errors = self.update_statistics_data(
args["owner"], **args["data"])
if errors:
raise StatsError("boss spec file is incorrect: "
+ ", ".join(errors))
errors = self.update_statistics_data(
self.module_name,
last_update_time=get_datetime())
if errors:
raise StatsError("stats spec file is incorrect: "
+ ", ".join(errors))
except isc.cc.session.SessionTimeout:
pass
# initialized Statistics data
errors = self.update_statistics_data(
......
......@@ -153,13 +153,16 @@ class MockBoss:
def command_handler(self, command, *args, **kwargs):
self._started.set()
self.got_command_name = command
params = { "owner": "Boss",
"data": {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', self._BASETIME)
}
}
if command == 'sendstats':
params = { "owner": "Boss",
"data": {
'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', self._BASETIME)
}
}
return send_command("set", "Stats", params=params, session=self.cc_session)
send_command("set", "Stats", params=params, session=self.cc_session)
return isc.config.create_answer(0)
elif command == 'getstats':
return isc.config.create_answer(0, params)
return isc.config.create_answer(1, "Unknown Command")
class MockAuth:
......
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