def testInfoToDict(self): value = "a=1;b=@;c=c;d=1@" expected = {'a': '1', 'b': '@', 'c': 'c', 'd': '1@'} result = util.info_to_dict(value) self.assertEqual(result, expected) value = ":".join(value.split(";")) result = util.info_to_dict(value, ':') self.assertEqual(result, expected)
def testInfoToDict(self): value = "a=1;b=@;c=c;d=1@" expected = {'a':'1', 'b':'@', 'c':'c', 'd':'1@'} result = util.info_to_dict(value) self.assertEqual(result, expected) value = ":".join(value.split(";")) result = util.info_to_dict(value, ':') self.assertEqual(result, expected)
def infoXDRStatistics(self): """ Get statistics for XDR Returns: dict -- {stat_name : stat_value, ...} """ return util.info_to_dict(self.xdrInfo('statistics'))
def infoNamespaceStatistics(self, namespace): """ Get statistics for a namespace. Returns: dict -- {stat_name : stat_value, ...} """ return util.info_to_dict(self.info("namespace/%s"%namespace))
def infoStatistics(self): """ Get statistics for this node. asinfo -v "statistics" Returns: dictionary -- statistic name -> value """ return util.info_to_dict(self.info("statistics"))
def infoGetConfig(self, stanza = "", namespace = ""): """ Get the complete config for a node. This should include the following stanzas: Service, Network, XDR, and Namespace Sadly it seems Service and Network are not seperable. Returns: dict -- stanza --> [namespace] --> param --> value """ config = {} if stanza == 'namespace': if namespace != "": config[stanza] = {namespace:util.info_to_dict( self.info("get-config:context=namespace;id=%s"%namespace))} else: namespace_configs = {} namespaces = self.infoNamespaces() for namespace in namespaces: namespace_config = self.infoGetConfig('namespace', namespace) namespace_config = namespace_config['namespace'][namespace] namespace_configs[namespace] = namespace_config config['namespace'] = namespace_configs elif stanza == '': config['service'] = util.info_to_dict(self.info("get-config:")) elif stanza != 'all': config[stanza] = util.info_to_dict( self.info("get-config:context=%s"%stanza)) elif stanza == "all": namespace_configs = {} namespaces = self.infoNamespaces() for namespace in namespaces: namespace_config = self.infoGetConfig('namespace', namespace) namespace_config = namespace_config['namespace'][namespace] namespace_configs[namespace] = namespace_config config['namespace'] = namespace_configs config['service'] = self.infoGetConfig("service") # Server lumps this with service # config["network"] = self.infoGetConfig("network") return config
def infoBinStatistics(self): stats = util.info_to_list(self.info("bins")) stats.pop() stats = [value.split(':') for value in stats] stat_dict = {} for stat in stats: values = util.info_to_list(stat[1], ',') values = ";".join(filter(lambda v: '=' in v, values)) values = util.info_to_dict(values) stat_dict[stat[0]] = values return stat_dict
def infoSIndex(self): return [util.info_to_dict(v, ':') for v in util.info_to_list(self.info("sindex"))[:-1]]
def infoXDRGetConfig(self): result = self.xdrInfo('get-config') result = {'xdr':util.info_to_dict(result)} return result