def launch_instances(self, ctx, cluster, target_count): # create all instances cluster = g.change_cluster_status(cluster, self.STAGES[0]) tmpl = heat.ClusterTemplate(cluster) self._configure_template(ctx, tmpl, cluster, target_count) stack = tmpl.instantiate(update_existing=self.UPDATE_STACK) heat.wait_stack_completion(stack.heat_stack) self.inst_ids = self._populate_cluster(ctx, cluster, stack) # wait for all instances are up and networks ready cluster = g.change_cluster_status(cluster, self.STAGES[1]) instances = g.get_instances(cluster, self.inst_ids) self._await_networks(cluster, instances) if not g.check_cluster_exists(cluster): LOG.info(g.format_cluster_deleted_message(cluster)) return # prepare all instances cluster = g.change_cluster_status(cluster, self.STAGES[2]) instances = g.get_instances(cluster, self.inst_ids) volumes.mount_to_instances(instances) self._configure_instances(cluster)
def launch_instances(self, cluster, target_count): # create all instances cluster = g.change_cluster_status(cluster, self.STAGES[0]) tmpl = heat.ClusterTemplate(cluster) self._configure_template(tmpl, cluster, target_count) stack = tmpl.instantiate(update_existing=self.UPDATE_STACK, disable_rollback=self.DISABLE_ROLLBACK) heat.wait_stack_completion(stack.heat_stack) self.inst_ids = self._populate_cluster(cluster, stack) # wait for all instances are up and networks ready cluster = g.change_cluster_status(cluster, self.STAGES[1]) instances = g.get_instances(cluster, self.inst_ids) self._await_networks(cluster, instances) # prepare all instances cluster = g.change_cluster_status(cluster, self.STAGES[2]) instances = g.get_instances(cluster, self.inst_ids) volumes.mount_to_instances(instances) self._configure_instances(cluster)
def create_instances(self, cluster, target_count): tmpl = heat.ClusterTemplate(cluster) self._configure_template(tmpl, cluster, target_count) stack = tmpl.instantiate(update_existing=self.UPDATE_STACK, disable_rollback=self.DISABLE_ROLLBACK) heat.wait_stack_completion(stack.heat_stack) self.inst_ids = self._populate_cluster(cluster, stack)
def create_instances(self, cluster, target_count): tmpl = ht.ClusterTemplate(cluster) self._configure_template(tmpl, cluster, target_count) stack = tmpl.instantiate(update_existing=self.UPDATE_STACK, disable_rollback=self.DISABLE_ROLLBACK) heat.wait_stack_completion(stack.heat_stack) self.inst_ids = self._populate_cluster(cluster, stack)
def _create_instances(self, cluster, target_count, update_stack=False, disable_rollback=True): stack = ht.ClusterStack(cluster) self._update_instance_count(stack, cluster, target_count) stack.instantiate(update_existing=update_stack, disable_rollback=disable_rollback) heat.wait_stack_completion(stack.heat_stack) return self._populate_cluster(cluster, stack)
def _create_instances(self, cluster, target_count, update_stack=False, disable_rollback=True): stack = ht.ClusterStack(cluster) self._update_instance_count(stack, cluster, target_count) stack.instantiate(update_existing=update_stack, disable_rollback=disable_rollback) heat.wait_stack_completion( cluster, is_update=update_stack, last_updated_time=stack.last_updated_time) return self._populate_cluster(cluster, stack)
def _create_instances(self, cluster, target_count, update_stack=False, disable_rollback=True, instances_to_delete=None): stack = ht.ClusterStack(cluster) self._update_instance_count(stack, cluster, target_count, instances_to_delete) stack.instantiate(update_existing=update_stack, disable_rollback=disable_rollback) heat.wait_stack_completion( cluster, is_update=update_stack, last_updated_time=stack.last_updated_time) return self._populate_cluster(cluster, stack)
def shutdown_cluster(self, cluster): """Shutdown specified cluster and all related resources.""" try: heat.client().stacks.delete(cluster.name) stack = heat.get_stack(cluster.name) heat.wait_stack_completion(stack) except heat_exc.HTTPNotFound: LOG.warn(_LW('Did not found stack for cluster %s') % cluster.name) self._clean_job_executions(cluster) ctx = context.ctx() instances = g.get_instances(cluster) for inst in instances: conductor.instance_remove(ctx, inst)
def shutdown_cluster(self, cluster): """Shutdown specified cluster and all related resources.""" try: b.execute_with_retries(heat.client().stacks.delete, cluster.name) stack = heat.get_stack(cluster.name) heat.wait_stack_completion(stack) except heat_exc.HTTPNotFound: LOG.warning(_LW('Did not find stack for cluster. Trying to delete ' 'cluster manually.')) # Stack not found. Trying to delete cluster like direct engine # do it self._shutdown_instances(cluster) self._delete_aa_server_group(cluster) self._clean_job_executions(cluster) self._remove_db_objects(cluster)
def shutdown_cluster(self, cluster): """Shutdown specified cluster and all related resources.""" try: b.execute_with_retries(heat.client().stacks.delete, cluster.name) stack = heat.get_stack(cluster.name) heat.wait_stack_completion(stack) except heat_exc.HTTPNotFound: LOG.warning( _LW('Did not find stack for cluster. Trying to delete ' 'cluster manually.')) # Stack not found. Trying to delete cluster like direct engine # do it self._shutdown_instances(cluster) self._delete_aa_server_group(cluster) self._clean_job_executions(cluster) self._remove_db_objects(cluster)
def test_wait_completion(self, _): stack = FakeHeatStack('CREATE_IN_PROGRESS', 'CREATE_COMPLETE') h.wait_stack_completion(stack) stack = FakeHeatStack('UPDATE_IN_PROGRESS', 'UPDATE_COMPLETE') h.wait_stack_completion(stack) stack = FakeHeatStack('DELETE_IN_PROGRESS', 'DELETE_COMPLETE') h.wait_stack_completion(stack) stack = FakeHeatStack('CREATE_IN_PROGRESS', 'CREATE_FAILED') with testtools.ExpectedException( ex.HeatStackException, value_re="Heat stack failed with status CREATE_FAILED"): h.wait_stack_completion(stack)
def test_wait_completion(self, _): stack = FakeHeatStack('CREATE_IN_PROGRESS', 'CREATE_COMPLETE') h.wait_stack_completion(stack) stack = FakeHeatStack('UPDATE_IN_PROGRESS', 'UPDATE_COMPLETE') h.wait_stack_completion(stack) stack = FakeHeatStack('DELETE_IN_PROGRESS', 'DELETE_COMPLETE') h.wait_stack_completion(stack) stack = FakeHeatStack('CREATE_IN_PROGRESS', 'CREATE_FAILED') with testtools.ExpectedException( ex.HeatStackException, value_re=("Heat stack failed with status " "CREATE_FAILED\nError ID: .*")): h.wait_stack_completion(stack)
def test_wait_completion(self, sleep, client): cl = mock.Mock(stack_name='cluster') client.side_effect = [ stack('CREATE_IN_PROGRESS'), stack('CREATE_COMPLETE') ] h.wait_stack_completion(cl) self.assertEqual(2, client.call_count) client.side_effect = [ stack('UPDATE_IN_PROGRESS'), stack('UPDATE_COMPLETE') ] h.wait_stack_completion(cl) self.assertEqual(4, client.call_count) client.side_effect = [ stack('DELETE_IN_PROGRESS'), stack('DELETE_COMPLETE') ] h.wait_stack_completion(cl) self.assertEqual(6, client.call_count) client.side_effect = [ stack('CREATE_COMPLETE'), stack('CREATE_COMPLETE'), stack('UPDATE_IN_PROGRESS'), stack('UPDATE_COMPLETE', 1) ] h.wait_stack_completion(cl, is_update=True) self.assertEqual(10, client.call_count) client.side_effect = [ stack('UPDATE_COMPLETE'), stack('UPDATE_IN_PROGRESS'), stack('UPDATE_COMPLETE', 1) ] h.wait_stack_completion(cl, is_update=True) self.assertEqual(13, client.call_count) client.side_effect = [ stack('CREATE_IN_PROGRESS'), stack('CREATE_FAILED') ] with testtools.ExpectedException( ex.HeatStackException, value_re=("Heat stack failed with status " "CREATE_FAILED\nError ID: .*")): h.wait_stack_completion(cl)
def test_wait_completion(self, sleep, client): cl = mock.Mock(stack_name='cluster') client.side_effect = [stack( 'CREATE_IN_PROGRESS'), stack('CREATE_COMPLETE')] h.wait_stack_completion(cl) self.assertEqual(2, client.call_count) client.side_effect = [ stack('UPDATE_IN_PROGRESS'), stack('UPDATE_COMPLETE')] h.wait_stack_completion(cl) self.assertEqual(4, client.call_count) client.side_effect = [ stack('DELETE_IN_PROGRESS'), stack('DELETE_COMPLETE')] h.wait_stack_completion(cl) self.assertEqual(6, client.call_count) client.side_effect = [ stack('CREATE_COMPLETE'), stack('CREATE_COMPLETE'), stack('UPDATE_IN_PROGRESS'), stack('UPDATE_COMPLETE', 1)] h.wait_stack_completion(cl, is_update=True) self.assertEqual(10, client.call_count) client.side_effect = [stack('UPDATE_COMPLETE'), stack( 'UPDATE_IN_PROGRESS'), stack('UPDATE_COMPLETE', 1)] h.wait_stack_completion(cl, is_update=True) self.assertEqual(13, client.call_count) client.side_effect = [ stack('CREATE_IN_PROGRESS'), stack('CREATE_FAILED')] with testtools.ExpectedException( ex.HeatStackException, value_re=("Heat stack failed with status " "CREATE_FAILED\nError ID: .*")): h.wait_stack_completion(cl)