示例#1
0
    def make_inventory(self, cluster, servers, hints):
        groups = self.get_inventory_groups(cluster, servers, hints)
        inventory = {"_meta": {"hostvars": {}}}
        all_servers = server.ServerModel.cluster_servers(cluster.model_id)

        for name, group_servers in groups.items():
            for srv in group_servers:
                inventory.setdefault(name, []).append(srv.ip)

                hostvars = inventory["_meta"]["hostvars"].setdefault(
                    srv.ip, {})
                hostvars["ansible_user"] = srv.username
                hostvars["monitor_interface"] = networkutils.get_public_network_if(  # NOQA
                    srv, all_servers)

                if hints["collocation"]:
                    hostvars["devices"] = diskutils.get_devices(srv)
                else:
                    hostvars["devices"] = []
                    hostvars["raw_journal_devices"] = []
                    for pair in diskutils.get_data_journal_pairs_iter(srv):
                        hostvars["devices"].append(pair["data"])
                        hostvars["raw_journal_devices"].append(pair["journal"])

        return inventory
示例#2
0
def test_get_devices(dev_prefix, new_server_with_facts):
    devices = diskutils.get_devices(new_server_with_facts, dev_prefix)
    devices = sorted(devices)

    if dev_prefix:
        assert devices == ["/dev/vdb", "/dev/vdc", "/dev/vdd", "/dev/vde"]
    else:
        assert devices == ["vdb", "vdc", "vdd", "vde"]
示例#3
0
    def make_inventory(self, cluster, servers):
        groups = self.get_inventory_groups(cluster, servers)
        inventory = {"_meta": {"hostvars": {}}}
        all_servers = server.ServerModel.cluster_servers(cluster.model_id)

        for name, group_servers in groups.items():
            for srv in group_servers:
                inventory.setdefault(name, []).append(srv.ip)

                hostvars = inventory["_meta"]["hostvars"].setdefault(
                    srv.ip, {})
                hostvars["monitor_interface"] = networkutils.get_public_network_if(  # NOQA
                    srv, all_servers)
                hostvars["devices"] = diskutils.get_devices(srv)
                hostvars["ansible_user"] = srv.username

        return inventory
示例#4
0
    def make_inventory(self, cluster, servers, hints, global_vars):
        groups = self.get_inventory_groups(servers, hints)
        inventory = {"_meta": {"hostvars": {}}}

        for name, group_servers in groups.items():
            inventory[name] = [srv.ip for srv in group_servers]

        for srv in servers:
            hostvars = inventory["_meta"]["hostvars"].setdefault(srv.ip, {})
            hostvars["ansible_user"] = srv.username
            hostvars["monitor_address"] = networkutils.get_public_network_ip(
                srv, servers)

            if hints["collocation"]:
                hostvars["devices"] = diskutils.get_devices(srv)
            else:
                hostvars["devices"] = []
                hostvars["raw_journal_devices"] = []
                for pair in diskutils.get_data_journal_pairs_iter(
                        srv, int(global_vars["journal_size"])):
                    hostvars["devices"].append(pair["data"])
                    hostvars["raw_journal_devices"].append(pair["journal"])

        return inventory