def _provision_cluster(cluster_id): ctx, cluster, plugin = _prepare_provisioning(cluster_id) cluster = _update_sahara_info(ctx, cluster) if CONF.use_identity_api_v3 and cluster.is_transient: trusts.create_trust_for_cluster(cluster) # updating cluster infra cluster = g.change_cluster_status(cluster, "InfraUpdating") plugin.update_infra(cluster) # creating instances and configuring them cluster = conductor.cluster_get(ctx, cluster_id) INFRA.create_cluster(cluster) # configure cluster cluster = g.change_cluster_status(cluster, "Configuring") plugin.configure_cluster(cluster) # starting prepared and configured cluster cluster = g.change_cluster_status(cluster, "Starting") plugin.start_cluster(cluster) # cluster is now up and ready cluster = g.change_cluster_status(cluster, "Active") # schedule execution pending job for cluster for je in conductor.job_execution_get_all(ctx, cluster_id=cluster.id): job_manager.run_job(je.id)
def _provision_cluster(cluster_id): ctx, cluster, plugin = _prepare_provisioning(cluster_id) cluster = _update_sahara_info(ctx, cluster) if CONF.use_identity_api_v3 and cluster.is_transient: trusts.create_trust_for_cluster(cluster) # updating cluster infra cluster = g.change_cluster_status(cluster, "InfraUpdating") plugin.update_infra(cluster) # creating instances and configuring them cluster = conductor.cluster_get(ctx, cluster_id) INFRA.create_cluster(cluster) # configure cluster cluster = g.change_cluster_status(cluster, "Configuring") plugin.configure_cluster(cluster) # starting prepared and configured cluster cluster = g.change_cluster_status(cluster, "Starting") plugin.start_cluster(cluster) # cluster is now up and ready cluster = g.change_cluster_status(cluster, "Active") # schedule execution pending job for cluster for je in conductor.job_execution_get_all(ctx, cluster_id=cluster.id): job_manager.run_job(je.id)
def _provision_cluster(cluster_id): ctx, cluster, plugin = _prepare_provisioning(cluster_id) if CONF.use_identity_api_v3 and cluster.is_transient: trusts.create_trust_for_cluster(cluster) # updating cluster infra cluster = g.change_cluster_status(cluster, "InfraUpdating") plugin.update_infra(cluster) # creating instances and configuring them cluster = conductor.cluster_get(ctx, cluster_id) INFRA.create_cluster(cluster) if not g.check_cluster_exists(cluster): LOG.info(g.format_cluster_deleted_message(cluster)) return # configure cluster cluster = g.change_cluster_status(cluster, "Configuring") try: plugin.configure_cluster(cluster) except Exception as ex: if not g.check_cluster_exists(cluster): LOG.info(g.format_cluster_deleted_message(cluster)) return LOG.exception( _LE("Can't configure cluster '%(name)s' (reason: %(reason)s)"), {'name': cluster.name, 'reason': ex}) g.change_cluster_status(cluster, "Error") return if not g.check_cluster_exists(cluster): LOG.info(g.format_cluster_deleted_message(cluster)) return # starting prepared and configured cluster cluster = g.change_cluster_status(cluster, "Starting") try: plugin.start_cluster(cluster) except Exception as ex: if not g.check_cluster_exists(cluster): LOG.info(g.format_cluster_deleted_message(cluster)) return LOG.exception( _LE("Can't start services for cluster '%(name)s' (reason: " "%(reason)s)"), {'name': cluster.name, 'reason': ex}) g.change_cluster_status(cluster, "Error") return if not g.check_cluster_exists(cluster): LOG.info(g.format_cluster_deleted_message(cluster)) return # cluster is now up and ready cluster = g.change_cluster_status(cluster, "Active") # schedule execution pending job for cluster for je in conductor.job_execution_get_all(ctx, cluster_id=cluster.id): job_manager.run_job(je.id)
def _prepare_provisioning(cluster_id): ctx = context.ctx() cluster = conductor.cluster_get(ctx, cluster_id) plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name) for nodegroup in cluster.node_groups: update_dict = {} update_dict["image_username"] = INFRA.get_node_group_image_username( nodegroup) conductor.node_group_update(ctx, nodegroup, update_dict) if CONF.use_identity_api_v3: trusts.create_trust_for_cluster(cluster, expires=not cluster.is_transient) trusts.use_os_admin_auth_token(cluster) cluster = conductor.cluster_get(ctx, cluster_id) return ctx, cluster, plugin
def _prepare_provisioning(cluster_id): ctx = context.ctx() cluster = conductor.cluster_get(ctx, cluster_id) plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name) for nodegroup in cluster.node_groups: update_dict = {} update_dict["image_username"] = INFRA.get_node_group_image_username( nodegroup) conductor.node_group_update(ctx, nodegroup, update_dict) if CONF.use_identity_api_v3: trusts.create_trust_for_cluster(cluster, expires=not cluster.is_transient) trusts.use_os_admin_auth_token(cluster) cluster = conductor.cluster_get(ctx, cluster_id) return ctx, cluster, plugin
def test_create_trust_for_cluster(self, context_current, auth_for_admin, create_trust, cluster_update): self.override_config('admin_tenant_name', 'admin_project', group='keystone_authtoken') trustor_auth = mock.Mock() ctx = mock.Mock(roles="role_names", auth_plugin=trustor_auth) context_current.return_value = ctx trustee_auth = mock.Mock() auth_for_admin.return_value = trustee_auth create_trust.return_value = 'trust_id' trusts.create_trust_for_cluster("cluster") auth_for_admin.assert_called_with(project_name='admin_project') create_trust.assert_called_with(trustor=trustor_auth, trustee=trustee_auth, role_names='role_names', expires=True) cluster_update.assert_called_with(ctx, "cluster", {"trust_id": "trust_id"})
def test_create_trust_for_cluster(self, context_current, auth_for_admin, create_trust, cluster_update, cl_get): self.override_config('project_name', 'admin_project', group='trustee') trustor_auth = mock.Mock() fake_cluster = mock.Mock(trust_id=None) cl_get.return_value = fake_cluster ctx = mock.Mock(roles="role_names", auth_plugin=trustor_auth) context_current.return_value = ctx trustee_auth = mock.Mock() auth_for_admin.return_value = trustee_auth create_trust.return_value = 'trust_id' trusts.create_trust_for_cluster("cluster") auth_for_admin.assert_called_with(project_name='admin_project') create_trust.assert_called_with(trustor=trustor_auth, trustee=trustee_auth, role_names='role_names', allow_redelegation=True) cluster_update.assert_called_with(ctx, fake_cluster, {"trust_id": "trust_id"})
def test_create_trust_for_cluster(self, m_current, m_cluster_update, m_client, m_client_for_admin): ctx = mock.Mock(roles="role_names") trustee = mock.Mock(user_id="trustee_id") trustor = self._trustor() m_current.return_value = ctx m_client_for_admin.return_value = trustee m_client.return_value = trustor trusts.create_trust_for_cluster("cluster") trustor.trusts.create.assert_called_with( trustor_user="******", trustee_user="******", impersonation=True, role_names="role_names", project="tenant_id", expires_at=mock.ANY ) m_cluster_update.assert_called_with(ctx, "cluster", {"trust_id": "trust_id"})
def _setup_trust_for_cluster(cluster): cluster = conductor.cluster_get(context.ctx(), cluster) trusts.create_trust_for_cluster(cluster) trusts.use_os_admin_auth_token(cluster)
def _setup_trust_for_cluster(cluster): cluster = conductor.cluster_get(context.ctx(), cluster) trusts.create_trust_for_cluster(cluster) trusts.use_os_admin_auth_token(cluster)