コード例 #1
0
 def test_change_status_description(self):
     ctx = context.ctx()
     cluster = self._make_sample()
     cluster_id = cluster.id
     cluster = cluster_utils.change_cluster_status_description(
         cluster, "desc")
     self.assertEqual('desc', cluster.status_description)
     self.api.cluster_destroy(ctx, cluster)
     cluster = cluster_utils.change_cluster_status_description(
         cluster_id, "desc")
     self.assertIsNone(cluster)
コード例 #2
0
ファイル: test_cluster.py プロジェクト: Imperat/sahara
 def test_change_status_description(self):
     ctx = context.ctx()
     cluster = self._make_sample()
     cluster_id = cluster.id
     cluster = cluster_utils.change_cluster_status_description(
         cluster, "desc")
     self.assertEqual('desc', cluster.status_description)
     self.api.cluster_destroy(ctx, cluster)
     cluster = cluster_utils.change_cluster_status_description(
         cluster_id, "desc")
     self.assertIsNone(cluster)
コード例 #3
0
ファイル: ops.py プロジェクト: uladz/sahara
        def wrapper(cluster_id, *args, **kwds):
            ctx = context.ctx()
            try:
                # Clearing status description before executing
                c_u.change_cluster_status_description(cluster_id, "")
                f(cluster_id, *args, **kwds)
            except Exception as ex:
                # something happened during cluster operation
                cluster = conductor.cluster_get(ctx, cluster_id)
                # check if cluster still exists (it might have been removed)
                if (cluster is None
                        or cluster.status == c_u.CLUSTER_STATUS_DELETING):
                    LOG.debug("Cluster was deleted or marked for deletion. "
                              "Canceling current operation.")
                    return

                msg = six.text_type(ex)
                LOG.exception(
                    _LE("Error during operating on cluster (reason: "
                        "{reason})").format(reason=msg))

                try:
                    # trying to rollback
                    desc = description.format(reason=msg)
                    if _rollback_cluster(cluster, ex):
                        c_u.change_cluster_status(cluster,
                                                  c_u.CLUSTER_STATUS_ACTIVE,
                                                  desc)
                    else:
                        c_u.change_cluster_status(cluster,
                                                  c_u.CLUSTER_STATUS_ERROR,
                                                  desc)
                except Exception as rex:
                    cluster = conductor.cluster_get(ctx, cluster_id)
                    # check if cluster still exists (it might have been
                    # removed during rollback)
                    if (cluster is None
                            or cluster.status == c_u.CLUSTER_STATUS_DELETING):
                        LOG.debug("Cluster was deleted or marked for deletion."
                                  " Canceling current operation.")
                        return

                    LOG.exception(
                        _LE("Error during rollback of cluster (reason:"
                            " {reason})").format(reason=six.text_type(rex)))
                    desc = "{0}, {1}".format(msg, six.text_type(rex))
                    c_u.change_cluster_status(cluster,
                                              c_u.CLUSTER_STATUS_ERROR,
                                              description.format(reason=desc))
コード例 #4
0
ファイル: ops.py プロジェクト: openstack/sahara
        def wrapper(cluster_id, *args, **kwds):
            ctx = context.ctx()
            try:
                # Clearing status description before executing
                c_u.change_cluster_status_description(cluster_id, "")
                f(cluster_id, *args, **kwds)
            except Exception as ex:
                # something happened during cluster operation
                cluster = conductor.cluster_get(ctx, cluster_id)
                # check if cluster still exists (it might have been removed)
                if (cluster is None or
                        cluster.status == c_u.CLUSTER_STATUS_DELETING):
                    LOG.debug("Cluster was deleted or marked for deletion. "
                              "Canceling current operation.")
                    return

                msg = six.text_type(ex)
                LOG.exception("Error during operating on cluster (reason: "
                              "{reason})".format(reason=msg))

                try:
                    # trying to rollback
                    desc = description.format(reason=msg)
                    if _rollback_cluster(cluster, ex):
                        c_u.change_cluster_status(
                            cluster, c_u.CLUSTER_STATUS_ACTIVE, desc)
                    else:
                        c_u.change_cluster_status(
                            cluster, c_u.CLUSTER_STATUS_ERROR, desc)
                except Exception as rex:
                    cluster = conductor.cluster_get(ctx, cluster_id)
                    # check if cluster still exists (it might have been
                    # removed during rollback)
                    if (cluster is None or
                            cluster.status == c_u.CLUSTER_STATUS_DELETING):
                        LOG.debug("Cluster was deleted or marked for deletion."
                                  " Canceling current operation.")
                        return

                    LOG.exception(
                        "Error during rollback of cluster (reason:"
                        " {reason})".format(reason=six.text_type(rex)))
                    desc = "{0}, {1}".format(msg, six.text_type(rex))
                    c_u.change_cluster_status(
                        cluster, c_u.CLUSTER_STATUS_ERROR,
                        description.format(reason=desc))