Beispiel #1
0
def _get_cluster_hosts_information(host, cluster):
    for clust in conductor.cluster_get_all(context.ctx()):
        if clust.id == cluster.id:
            continue

        for i in u.get_instances(clust):
            if i.instance_name == host:
                return g.generate_etc_hosts(clust)

    return None
Beispiel #2
0
def _get_cluster_hosts_information(host, cluster):
    for clust in conductor.cluster_get_all(context.ctx()):
        if clust.id == cluster.id:
            continue

        for i in u.get_instances(clust):
            if i.instance_name == host:
                return g.generate_etc_hosts(clust)

    return None
Beispiel #3
0
    def _configure_instances(self, cluster):
        """Configure active instances.

        * generate /etc/hosts
        * setup passwordless login
        * etc.
        """
        hosts_file = g.generate_etc_hosts(cluster)

        with context.ThreadGroup() as tg:
            for node_group in cluster.node_groups:
                for instance in node_group.instances:
                    tg.spawn("configure-instance-%s" % instance.instance_name,
                             self._configure_instance, instance, hosts_file)
Beispiel #4
0
    def _configure_instances(self, cluster):
        """Configure active instances.

        * generate /etc/hosts
        * setup passwordless login
        * etc.
        """
        hosts_file = g.generate_etc_hosts(cluster)
        cpo.add_provisioning_step(
            cluster.id, _("Configure instances"), g.count_instances(cluster))

        with context.ThreadGroup() as tg:
            for node_group in cluster.node_groups:
                for instance in node_group.instances:
                    with context.set_current_instance_id(instance.instance_id):
                        tg.spawn(
                            "configure-instance-%s" % instance.instance_name,
                            self._configure_instance, instance, hosts_file)
Beispiel #5
0
    def _configure_instances(self, cluster):
        """Configure active instances.

        * generate /etc/hosts
        * setup passwordless login
        * etc.
        """
        hosts_file = g.generate_etc_hosts(cluster)
        cpo.add_provisioning_step(cluster.id, _("Configure instances"),
                                  g.count_instances(cluster))

        with context.ThreadGroup() as tg:
            for node_group in cluster.node_groups:
                for instance in node_group.instances:
                    with context.set_current_instance_id(instance.instance_id):
                        tg.spawn(
                            "configure-instance-%s" % instance.instance_name,
                            self._configure_instance, instance, hosts_file)
Beispiel #6
0
 def test_generate_etc_hosts(self):
     cluster = self._make_sample()
     ctx = context.ctx()
     idx = 0
     for ng in cluster.node_groups:
         for i in range(ng.count):
             idx += 1
             self.api.instance_add(ctx, ng, {
                 'instance_id': str(idx),
                 'instance_name': str(idx),
                 'internal_ip': str(idx),
             })
     cluster = self.api.cluster_get(ctx, cluster)
     value = general.generate_etc_hosts(cluster)
     expected = ("127.0.0.1 localhost\n"
                 "1 1.novalocal 1\n"
                 "2 2.novalocal 2\n"
                 "3 3.novalocal 3\n"
                 "4 4.novalocal 4\n")
     self.assertEqual(expected, value)