示例#1
0
文件: api.py 项目: lhcxx/sahara
def terminate_cluster(id):
    context.set_current_cluster_id(id)
    cluster = g.change_cluster_status(id, "Deleting")

    OPS.terminate_cluster(id)
    sender.notify(context.ctx(), cluster.id, cluster.name, cluster.status,
                  "delete")
示例#2
0
def change_cluster_status(cluster, status, status_description=None):
    ctx = context.ctx()

    # Update cluster status. Race conditions with deletion are still possible,
    # but this reduces probability at least.
    cluster = conductor.cluster_get(ctx, cluster) if cluster else None

    if status_description is not None:
        change_cluster_status_description(cluster, status_description)

    # 'Deleting' is final and can't be changed
    if cluster is None or cluster.status == 'Deleting':
        return cluster

    update_dict = {"status": status}
    cluster = conductor.cluster_update(ctx, cluster, update_dict)
    conductor.cluster_provision_progress_update(ctx, cluster.id)

    LOG.info(
        _LI("Cluster status has been changed: id={id}, New status="
            "{status}").format(id=cluster.id, status=cluster.status))

    sender.notify(ctx, cluster.id, cluster.name, cluster.status, "update")

    return cluster
示例#3
0
def terminate_cluster(id):
    context.set_current_cluster_id(id)
    cluster = g.change_cluster_status(id, "Deleting")

    OPS.terminate_cluster(id)
    sender.notify(context.ctx(), cluster.id, cluster.name, cluster.status,
                  "delete")
示例#4
0
def change_cluster_status(cluster, status, status_description=None):
    ctx = context.ctx()

    # Update cluster status. Race conditions with deletion are still possible,
    # but this reduces probability at least.
    cluster = conductor.cluster_get(ctx, cluster) if cluster else None

    if status_description is not None:
        change_cluster_status_description(cluster, status_description)

    # 'Deleting' is final and can't be changed
    if cluster is None or cluster.status == CLUSTER_STATUS_DELETING:
        return cluster

    update_dict = {"status": status}
    cluster = conductor.cluster_update(ctx, cluster, update_dict)
    conductor.cluster_provision_progress_update(ctx, cluster.id)

    LOG.info(_LI("Cluster status has been changed. New status="
                 "{status}").format(status=cluster.status))

    sender.notify(ctx, cluster.id, cluster.name, cluster.status,
                  "update")

    return cluster
示例#5
0
def change_cluster_status(cluster, status, status_description=None):
    ctx = context.ctx()

    # Update cluster status. Race conditions with deletion are still possible,
    # but this reduces probability at least.
    cluster = conductor.cluster_get(ctx, cluster) if cluster else None

    # 'Deleting' is final and can't be changed
    if cluster is None or cluster.status == 'Deleting':
        return cluster

    update_dict = {"status": status}
    if status_description:
        update_dict["status_description"] = status_description

    cluster = conductor.cluster_update(ctx, cluster, update_dict)

    LOG.info(
        _LI("Cluster status has been changed: id=%(id)s, New status="
            "%(status)s"), {
                'id': cluster.id,
                'status': cluster.status
            })

    sender.notify(ctx, cluster.id, cluster.name, cluster.status, "update")

    return cluster
示例#6
0
def terminate_cluster(id):
    context.set_current_cluster_id(id)
    cluster = c_u.change_cluster_status(id, c_u.CLUSTER_STATUS_DELETING)

    if cluster is None:
        return

    OPS.terminate_cluster(id)
    sender.notify(context.ctx(), cluster.id, cluster.name, cluster.status,
                  "delete")
示例#7
0
文件: api.py 项目: crobby/sahara
def terminate_cluster(id):
    context.set_current_cluster_id(id)
    cluster = c_u.change_cluster_status(id, c_u.CLUSTER_STATUS_DELETING)

    if cluster is None:
        return

    OPS.terminate_cluster(id)
    sender.notify(context.ctx(), cluster.id, cluster.name, cluster.status,
                  "delete")
示例#8
0
    def _make_sample(self):
        ctx = context.ctx()

        self.ctx = ctx
        self.cluster_id = 'someId'
        self.cluster_name = 'someName'
        self.cluster_status = 'someStatus'

        sender.notify(ctx, self.cluster_id, self.cluster_name,
                      self.cluster_status, "update")

        self.create_mock('update')
示例#9
0
    def _make_sample(self):
        ctx = context.ctx()

        self.ctx = ctx
        self.cluster_id = 'someId'
        self.cluster_name = 'someName'
        self.cluster_status = 'someStatus'

        sender.notify(ctx, self.cluster_id, self.cluster_name,
                      self.cluster_status, "update")

        self.create_mock('update')
示例#10
0
def change_cluster_status(cluster, status, status_description=None):
    if cluster is None:
        return None

    update_dict = {"status": status}
    if status_description:
        update_dict["status_description"] = status_description

    cluster = conductor.cluster_update(context.ctx(), cluster, update_dict)

    LOG.info(_LI("Cluster status has been changed: id=%(id)s, New status="
                 "%(status)s"), {'id': cluster.id, 'status': cluster.status})

    sender.notify(context.ctx(), cluster.id, cluster.name, cluster.status,
                  "update")

    return cluster
示例#11
0
文件: api.py 项目: degorenko/sahara
def create_cluster(values):
    ctx = context.ctx()
    cluster = conductor.cluster_create(ctx, values)
    sender.notify(ctx, cluster.id, cluster.name, "New",
                  "create")
    plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)

    # validating cluster
    try:
        cluster = g.change_cluster_status(cluster, "Validating")
        plugin.validate(cluster)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            g.change_cluster_status(cluster, "Error",
                                    status_description=six.text_type(e))

    OPS.provision_cluster(cluster.id)

    return cluster
示例#12
0
文件: api.py 项目: vennie1988/sahara
def create_cluster(values):
    ctx = context.ctx()
    cluster = conductor.cluster_create(ctx, values)
    sender.notify(ctx, cluster.id, cluster.name, "New",
                  "create")
    plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)

    # validating cluster
    try:
        cluster = g.change_cluster_status(cluster, "Validating")
        plugin.validate(cluster)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            g.change_cluster_status(cluster, "Error",
                                    status_description=six.text_type(e))

    OPS.provision_cluster(cluster.id)

    return cluster
示例#13
0
文件: api.py 项目: lhcxx/sahara
def create_cluster(values):
    ctx = context.ctx()
    cluster = conductor.cluster_create(ctx, values)
    context.set_current_cluster_id(cluster.id)
    sender.notify(ctx, cluster.id, cluster.name, "New", "create")
    plugin = plugin_base.PLUGINS.get_plugin(cluster.plugin_name)
    _add_ports_for_auto_sg(ctx, cluster, plugin)

    # validating cluster
    try:
        cluster = g.change_cluster_status(cluster, "Validating")
        quotas.check_cluster(cluster)
        plugin.validate(cluster)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            g.change_cluster_status(cluster, "Error", six.text_type(e))

    OPS.provision_cluster(cluster.id)

    return cluster
示例#14
0
def change_cluster_status(cluster, status, status_description=None):
    if cluster is None:
        return None

    update_dict = {"status": status}
    if status_description:
        update_dict["status_description"] = status_description

    cluster = conductor.cluster_update(context.ctx(), cluster, update_dict)

    LOG.info(
        _LI("Cluster status has been changed: id=%(id)s, New status="
            "%(status)s"), {
                'id': cluster.id,
                'status': cluster.status
            })

    sender.notify(context.ctx(), cluster.id, cluster.name, cluster.status,
                  "update")

    return cluster
示例#15
0
def _cluster_create(values, plugin):
    ctx = context.ctx()
    cluster = conductor.cluster_create(ctx, values)
    context.set_current_cluster_id(cluster.id)
    sender.notify(ctx, cluster.id, cluster.name, "New", "create")
    _add_ports_for_auto_sg(ctx, cluster, plugin)

    # validating cluster
    try:
        plugin.recommend_configs(cluster)
        cluster = c_u.change_cluster_status(cluster,
                                            c_u.CLUSTER_STATUS_VALIDATING)
        quotas.check_cluster(cluster)
        plugin.validate(cluster)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            c_u.change_cluster_status(cluster, c_u.CLUSTER_STATUS_ERROR,
                                      six.text_type(e))

    OPS.provision_cluster(cluster.id)

    return cluster
示例#16
0
文件: api.py 项目: modin/sahara
def _cluster_create(values, plugin):
    ctx = context.ctx()
    cluster = conductor.cluster_create(ctx, values)
    context.set_current_cluster_id(cluster.id)
    sender.notify(ctx, cluster.id, cluster.name, "New",
                  "create")
    _add_ports_for_auto_sg(ctx, cluster, plugin)

    # validating cluster
    try:
        plugin.recommend_configs(cluster)
        cluster = g.change_cluster_status(cluster, "Validating")
        quotas.check_cluster(cluster)
        plugin.validate(cluster)
    except Exception as e:
        with excutils.save_and_reraise_exception():
            g.change_cluster_status(cluster, "Error",
                                    six.text_type(e))

    OPS.provision_cluster(cluster.id)

    return cluster
示例#17
0
def change_cluster_status(cluster, status, status_description=None):
    ctx = context.ctx()

    # Update cluster status. Race conditions with deletion are still possible,
    # but this reduces probability at least.
    cluster = conductor.cluster_get(ctx, cluster) if cluster else None

    # 'Deleting' is final and can't be changed
    if cluster is None or cluster.status == 'Deleting':
        return cluster

    update_dict = {"status": status}
    if status_description:
        update_dict["status_description"] = status_description

    cluster = conductor.cluster_update(ctx, cluster, update_dict)

    LOG.info(_LI("Cluster status has been changed: id=%(id)s, New status="
                 "%(status)s"), {'id': cluster.id, 'status': cluster.status})

    sender.notify(ctx, cluster.id, cluster.name, cluster.status,
                  "update")

    return cluster