Esempio n. 1
0
 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)
Esempio n. 2
0
 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)
Esempio n. 3
0
    def infoXDRStatistics(self):
        """
        Get statistics for XDR

        Returns:
        dict -- {stat_name : stat_value, ...}
        """
        return util.info_to_dict(self.xdrInfo('statistics'))
Esempio n. 4
0
    def infoXDRStatistics(self):
        """
        Get statistics for XDR

        Returns:
        dict -- {stat_name : stat_value, ...}
        """
        return util.info_to_dict(self.xdrInfo('statistics'))
Esempio n. 5
0
    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))
Esempio n. 6
0
    def infoStatistics(self):
        """
        Get statistics for this node. asinfo -v "statistics"

        Returns:
        dictionary -- statistic name -> value
        """

        return util.info_to_dict(self.info("statistics"))
Esempio n. 7
0
    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))
Esempio n. 8
0
    def infoStatistics(self):
        """
        Get statistics for this node. asinfo -v "statistics"

        Returns:
        dictionary -- statistic name -> value
        """

        return util.info_to_dict(self.info("statistics"))
Esempio n. 9
0
    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
Esempio n. 10
0
    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
Esempio n. 11
0
    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
Esempio n. 12
0
    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
Esempio n. 13
0
 def infoSIndex(self):
     return [util.info_to_dict(v, ':')
             for v in util.info_to_list(self.info("sindex"))[:-1]]
Esempio n. 14
0
 def infoXDRGetConfig(self):
     result = self.xdrInfo('get-config')
     result = {'xdr':util.info_to_dict(result)}
     return result
Esempio n. 15
0
 def infoSIndex(self):
     return [util.info_to_dict(v, ':')
             for v in util.info_to_list(self.info("sindex"))[:-1]]
Esempio n. 16
0
 def infoXDRGetConfig(self):
     result = self.xdrInfo('get-config')
     result = {'xdr':util.info_to_dict(result)}
     return result