Exemplo n.º 1
0
    def get_namespace(self, flip=True, nodes='all', for_mods=[]):
        namespaces = util.Future(self.cluster.info_namespaces, nodes=nodes).start().result()
        namespaces = namespaces.values()
        namespace_set = set()

        for namespace in namespaces:
            if isinstance(namespace, Exception):
                continue

            namespace_set.update(namespace)

        namespace_list = util.filter_list(list(namespace_set), for_mods)
        ns_configs = {}

        for index, namespace in enumerate(namespace_list):
            node_configs = util.Future(self.cluster.info_get_config, stanza='namespace', namespace=namespace, namespace_id=index, nodes=nodes).start().result()
            for node, node_config in node_configs.items():
                if not node_config or isinstance(node_config, Exception) or not namespace in node_config:
                    continue

                if node not in ns_configs:
                    ns_configs[node] = {}

                ns_configs[node][namespace] = node_config[namespace]

        if flip:
            ns_configs = util.flip_keys(ns_configs)

        return ns_configs
Exemplo n.º 2
0
    def get_racks(self, flip=True, nodes='all'):

        configs = util.Future(self.cluster.info_racks, nodes=nodes).start()

        configs = configs.result()
        rack_configs = {}
        for node, config in configs.iteritems():
            if not config or isinstance(config, Exception):
                continue

            rack_configs[node] = config

        if flip:
            rack_configs = util.flip_keys(rack_configs)

        return rack_configs
Exemplo n.º 3
0
    def get_dc(self, flip=True, nodes='all'):
        configs = self.cluster.info_dc_get_config(nodes=nodes)
        for node in configs:
            if isinstance(configs[node], Exception):
                configs[node] = {}

        dc_configs = {}
        for node, node_config in configs.iteritems():
            if not node_config or isinstance(node_config, Exception):
                continue

            dc_configs[node] = node_config

        if flip:
            dc_configs = util.flip_keys(dc_configs)

        return dc_configs
Exemplo n.º 4
0
    def get_namespace(self, flip=True, nodes='all'):
        configs = self.cluster.info_get_config(nodes=nodes, stanza='namespace')
        for node in configs:
            if isinstance(configs[node], Exception):
                configs[node] = {}

        ns_configs = {}
        for node, node_config in configs.iteritems():
            if not node_config or isinstance(node_config, Exception):
                continue

            ns_configs[node] = node_config

        if flip:
            ns_configs = util.flip_keys(ns_configs)

        return ns_configs
Exemplo n.º 5
0
    def get_roster(self, flip=True, nodes='all'):

        configs = util.Future(self.cluster.info_roster, nodes=nodes).start()

        configs = configs.result()
        roster_configs = {}
        if configs:
            for node, config in configs.iteritems():
                if not config or isinstance(config, Exception):
                    continue

                roster_configs[node] = config

            if flip:
                roster_configs = util.flip_keys(roster_configs)

        return roster_configs
Exemplo n.º 6
0
    def get_dc(self, flip=True, nodes='all'):
        configs = self.cluster.info_dc_get_config(nodes=nodes)
        for node in configs:
            if isinstance(configs[node], Exception):
                configs[node] = {}

        dc_configs = {}
        for node, node_config in configs.iteritems():
            if not node_config or isinstance(node_config, Exception):
                continue

            dc_configs[node] = node_config

        if flip:
            dc_configs = util.flip_keys(dc_configs)

        return dc_configs
Exemplo n.º 7
0
    def _fetch_from_cinfo_log(self, type="", stanza="", flip=False):
        res_dict = {}

        if not type:
            return res_dict

        for timestamp in sorted(self.selected_cinfo_logs.keys()):
            try:
                out = self.selected_cinfo_logs[timestamp].get_data(type=type, stanza=stanza)
                if flip:
                    out = util.flip_keys(out)

                res_dict[timestamp] = out

            except Exception:
                continue

        return res_dict
Exemplo n.º 8
0
    def _fetch_from_cinfo_log(self, type="", stanza="", flip=False):
        res_dict = {}

        if not type:
            return res_dict

        for timestamp in sorted(self.selected_cinfo_logs.keys()):
            try:
                out = self.selected_cinfo_logs[timestamp].get_data(
                    type=type, stanza=stanza)
                if flip:
                    out = util.flip_keys(out)

                res_dict[timestamp] = out

            except Exception:
                continue

        return res_dict
Exemplo n.º 9
0
    def get_namespace(self, flip=True, nodes='all', for_mods=[]):
        namespaces = util.Future(self.cluster.info_namespaces,
                                 nodes=nodes).start().result()
        namespaces = namespaces.values()
        namespace_set = set()

        for namespace in namespaces:
            if isinstance(namespace, Exception):
                continue

            namespace_set.update(namespace)

        namespace_list = util.filter_list(list(namespace_set), for_mods)
        ns_configs = {}

        for index, namespace in enumerate(namespace_list):
            node_configs = util.Future(self.cluster.info_get_config,
                                       stanza='namespace',
                                       namespace=namespace,
                                       namespace_id=index,
                                       nodes=nodes).start().result()
            for node, node_config in node_configs.items():
                if not node_config or isinstance(
                        node_config,
                        Exception) or not namespace in node_config:
                    continue

                if node not in ns_configs:
                    ns_configs[node] = {}

                ns_configs[node][namespace] = node_config[namespace]

        if flip:
            ns_configs = util.flip_keys(ns_configs)

        return ns_configs