def _create_instances(self, cluster): ctx = context.ctx() cluster = self._create_auto_security_groups(cluster) aa_group = None if cluster.anti_affinity: aa_group = self._create_aa_server_group(cluster) cpo.add_provisioning_step( cluster.id, _("Run instances"), c_u.count_instances(cluster)) for node_group in cluster.node_groups: count = node_group.count conductor.node_group_update(ctx, node_group, {'count': 0}) for idx in six.moves.xrange(1, count + 1): self._start_instance( cluster, node_group, idx, aa_group=aa_group)
def _configure_instances(self, cluster): """Configure active instances. * generate /etc/hosts * change /etc/resolv.conf * setup passwordless login * etc. """ cpo.add_provisioning_step(cluster.id, _("Configure instances"), cluster_utils.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-{}".format( instance.instance_name), self._configure_instance, instance, cluster)
def _configure_instances(self, cluster): """Configure active instances. * generate /etc/hosts * setup passwordless login * etc. """ hosts_file = cluster_utils.generate_etc_hosts(cluster) cpo.add_provisioning_step( cluster.id, _("Configure instances"), cluster_utils.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)
def _configure_instances(self, cluster): """Configure active instances. * generate /etc/hosts * change /etc/resolv.conf * setup passwordless login * etc. """ cpo.add_provisioning_step( cluster.id, _("Configure instances"), cluster_utils.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-{}".format( instance.instance_name), self._configure_instance, instance, cluster )
def test_count_instances(self): cluster = self._make_sample() self.assertEqual(4, cluster_utils.count_instances(cluster))