# It counts the number of instances of same module by
# examining the third value from the array result of
# 'show_processes' of Init
- seq = self.cc_session.group_sendmsg(
- isc.config.ccsession.create_command("show_processes"),
- 'Init')
- (answer, env) = self.cc_session.group_recvmsg(False, seq)
- modules = []
- if answer:
- (rcode, value) = isc.config.ccsession.parse_answer(answer)
- if rcode == 0 and type(value) is list:
+ try:
+ value = self.mccs.rpc_call('show_processes', 'Init')
+ if type(value) is list:
# NOTE: For example, the "show_processes" command
# of Init is assumed to return the response in this
# format:
# release.
modules = [ v[2] if type(v) is list and len(v) > 2 \
else None for v in value ]
+ except isc.config.RPCError:
+ # TODO: Is it OK to just pass? As part of refactoring, preserving
+ # the original behaviour.
+ pass
# start requesting each module to collect statistics data
sequences = []
for (module_name, data) in self.get_statistics_data().items():
module_name)
cmd = isc.config.ccsession.create_command(
"getstats", None) # no argument
- seq = self.cc_session.group_sendmsg(cmd, module_name)
+ # Not using rpc_call here, we query a lot of modules in parallel
+ # here
+ seq = self.cc_session.group_sendmsg(cmd, module_name,
+ want_answer=True)
sequences.append((module_name, seq))
cnt = modules.count(module_name)
if cnt > 1:
raises StatsError.
"""
modules = {}
- seq = self.cc_session.group_sendmsg(
- isc.config.ccsession.create_command(
- isc.config.ccsession.COMMAND_GET_STATISTICS_SPEC),
- 'ConfigManager')
- (answer, env) = self.cc_session.group_recvmsg(False, seq)
- if answer:
- (rcode, value) = isc.config.ccsession.parse_answer(answer)
- if rcode == 0:
- for mod in value:
- spec = { "module_name" : mod }
- if value[mod] and type(value[mod]) is list:
- spec["statistics"] = value[mod]
- modules[mod] = isc.config.module_spec.ModuleSpec(spec)
- else:
- raise StatsError("Updating module spec fails: " + str(value))
+ try:
+ value = self.mccs.rpc_call(isc.config.ccsession. \
+ COMMAND_GET_STATISTICS_SPEC,
+ 'ConfigManager')
+ except isc.config.RPCError as e:
+ raise StatsError("Updating module spec fails: " + str(e))
+ for mod in value:
+ spec = { "module_name" : mod }
+ if value[mod] and type(value[mod]) is list:
+ spec["statistics"] = value[mod]
+ modules[mod] = isc.config.module_spec.ModuleSpec(spec)
modules[self.module_name] = self.mccs.get_module_spec()
self.modules = modules
if name is not None:
param['name'] = name
try:
- seq = self.cc_session.group_sendmsg(
- isc.config.ccsession.create_command('show', param), 'Stats')
- (answer, env) = self.cc_session.group_recvmsg(False, seq)
- if answer:
- (rcode, value) = isc.config.ccsession.parse_answer(answer)
+ return self.mccs.rpc_call('show', 'Stats', params=param)
+ except isc.config.RPCError as e:
+ raise StatsHttpdDataError("Stats module: %s" % str(e))
except (isc.cc.session.SessionTimeout,
isc.cc.session.SessionError) as err:
raise StatsHttpdError("%s: %s" %
(err.__class__.__name__, err))
- else:
- if rcode == 0:
- return value
- else:
- raise StatsHttpdDataError("Stats module: %s" % str(value))
def get_stats_spec(self, owner=None, name=None):
"""Requests statistics data to the Stats daemon and returns
if name is not None:
param['name'] = name
try:
- seq = self.cc_session.group_sendmsg(
- isc.config.ccsession.create_command('showschema', param), 'Stats')
- (answer, env) = self.cc_session.group_recvmsg(False, seq)
- if answer:
- (rcode, value) = isc.config.ccsession.parse_answer(answer)
- if rcode == 0:
- return value
- else:
- raise StatsHttpdDataError("Stats module: %s" % str(value))
+ return self.mccs.rpc_call('showschema', 'Stats', params=param)
+ except isc.config.RPCError as e:
+ raise StatsHttpdDataError("Stats module: %s" % str(e))
except (isc.cc.session.SessionTimeout,
isc.cc.session.SessionError) as err:
raise StatsHttpdError("%s: %s" %