예제 #1
0
파일: periodic.py 프로젝트: RogerFed/sahara
    def terminate_unneeded_clusters(self, ctx):
        LOG.debug('Terminating unneeded clusters')
        ctx = context.get_admin_context()
        context.set_ctx(ctx)
        for cluster in conductor.cluster_get_all(ctx, status='Active'):
            if not cluster.is_transient:
                continue

            jc = conductor.job_execution_count(ctx,
                                               end_time=None,
                                               cluster_id=cluster.id)

            if jc > 0:
                continue

            cluster_updated_at = timeutils.normalize_time(
                timeutils.parse_isotime(cluster.updated_at))
            current_time = timeutils.utcnow()
            spacing = timeutils.delta_seconds(cluster_updated_at, current_time)
            if spacing < CONF.min_transient_cluster_active_time:
                continue

            if CONF.use_identity_api_v3:
                trusts.use_os_admin_auth_token(cluster)
                api.terminate_cluster(cluster.id)
                LOG.debug('Terminated cluster %s with id %s' %
                          (cluster.name, cluster.id))
            else:
                if cluster.status != 'AwaitingTermination':
                    conductor.cluster_update(
                        ctx,
                        cluster,
                        {'status': 'AwaitingTermination'})
        context.set_ctx(None)
예제 #2
0
def terminate_cluster(ctx, cluster, description):
    if CONF.use_identity_api_v3:
        trusts.use_os_admin_auth_token(cluster)

        LOG.debug('Terminating {description} cluster {cluster} '
                  'in "{status}" state with id {id}'
                  .format(cluster=cluster.name,
                          id=cluster.id,
                          status=cluster.status,
                          description=description))

        try:
            ops.terminate_cluster(cluster.id)
        except Exception as e:
            LOG.warning(_LW('Failed to terminate {description} cluster '
                            '{cluster} in "{status}" state with id {id}: '
                            '{error}.').format(cluster=cluster.name,
                                               id=cluster.id,
                                               error=six.text_type(e),
                                               status=cluster.status,
                                               description=description))

    else:
        if cluster.status != 'AwaitingTermination':
            conductor.cluster_update(
                ctx,
                cluster,
                {'status': 'AwaitingTermination'})
예제 #3
0
def terminate_cluster(ctx, cluster, description):
    if CONF.use_identity_api_v3:
        trusts.use_os_admin_auth_token(cluster)

        LOG.debug(
            'Terminating %(description)s cluster %(cluster)s '
            'in "%(status)s" state with id %(id)s', {
                'cluster': cluster.name,
                'id': cluster.id,
                'status': cluster.status,
                'description': description
            })

        try:
            ops.terminate_cluster(cluster.id)
        except Exception as e:
            LOG.warn(
                _LW('Failed to terminate %(description)s cluster '
                    '%(cluster)s in "%(status)s" state with id %(id)s: '
                    '%(error)s.'), {
                        'cluster': cluster.name,
                        'id': cluster.id,
                        'error': six.text_type(e),
                        'status': cluster.status,
                        'description': description
                    })

    else:
        if cluster.status != 'AwaitingTermination':
            conductor.cluster_update(ctx, cluster,
                                     {'status': 'AwaitingTermination'})
예제 #4
0
        def terminate_unneeded_clusters(self, ctx):
            LOG.debug('Terminating unneeded transient clusters')
            ctx = context.get_admin_context()
            context.set_ctx(ctx)
            for cluster in conductor.cluster_get_all(ctx, status='Active'):
                if not cluster.is_transient:
                    continue

                jc = conductor.job_execution_count(ctx,
                                                   end_time=None,
                                                   cluster_id=cluster.id)

                if jc > 0:
                    continue

                cluster_updated_at = timeutils.normalize_time(
                    timeutils.parse_isotime(cluster.updated_at))
                current_time = timeutils.utcnow()
                spacing = timeutils.delta_seconds(cluster_updated_at,
                                                  current_time)
                if spacing < CONF.min_transient_cluster_active_time:
                    continue

                if CONF.use_identity_api_v3:
                    trusts.use_os_admin_auth_token(cluster)

                    LOG.info(
                        _LI('Terminating transient cluster %(cluster)s '
                            'with id %(id)s'), {
                                'cluster': cluster.name,
                                'id': cluster.id
                            })

                    try:
                        ops.terminate_cluster(cluster.id)
                    except Exception as e:
                        LOG.info(
                            _LI('Failed to terminate transient cluster '
                                '%(cluster)s with id %(id)s: %(error)s.'), {
                                    'cluster': cluster.name,
                                    'id': cluster.id,
                                    'error': six.text_type(e)
                                })

                else:
                    if cluster.status != 'AwaitingTermination':
                        conductor.cluster_update(
                            ctx, cluster, {'status': 'AwaitingTermination'})
            context.set_ctx(None)
예제 #5
0
파일: periodic.py 프로젝트: a9261/sahara
        def terminate_unneeded_clusters(self, ctx):
            LOG.debug('Terminating unneeded transient clusters')
            ctx = context.get_admin_context()
            context.set_ctx(ctx)
            for cluster in conductor.cluster_get_all(ctx, status='Active'):
                if not cluster.is_transient:
                    continue

                jc = conductor.job_execution_count(ctx,
                                                   end_time=None,
                                                   cluster_id=cluster.id)

                if jc > 0:
                    continue

                cluster_updated_at = timeutils.normalize_time(
                    timeutils.parse_isotime(cluster.updated_at))
                current_time = timeutils.utcnow()
                spacing = timeutils.delta_seconds(cluster_updated_at,
                                                  current_time)
                if spacing < CONF.min_transient_cluster_active_time:
                    continue

                if CONF.use_identity_api_v3:
                    trusts.use_os_admin_auth_token(cluster)

                    LOG.info(_LI('Terminating transient cluster %(cluster)s '
                                 'with id %(id)s'),
                             {'cluster': cluster.name, 'id': cluster.id})

                    try:
                        ops.terminate_cluster(cluster.id)
                    except Exception as e:
                        LOG.info(_LI('Failed to terminate transient cluster '
                                 '%(cluster)s with id %(id)s: %(error)s.'),
                                 {'cluster': cluster.name,
                                  'id': cluster.id,
                                  'error': six.text_type(e)})

                else:
                    if cluster.status != 'AwaitingTermination':
                        conductor.cluster_update(
                            ctx,
                            cluster,
                            {'status': 'AwaitingTermination'})
            context.set_ctx(None)
예제 #6
0
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
예제 #7
0
파일: ops.py 프로젝트: modin/sahara
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
예제 #8
0
파일: periodic.py 프로젝트: ekasitk/sahara
def terminate_cluster(ctx, cluster, description):
    if CONF.use_identity_api_v3 and cluster.trust_id:
        trusts.use_os_admin_auth_token(cluster)
        context.set_current_cluster_id(cluster.id)

        LOG.debug('Terminating {description} cluster '
                  'in "{status}" state'.format(status=cluster.status,
                                               description=description))

        try:
            ops.terminate_cluster(cluster.id)
        except Exception as e:
            LOG.warning(
                _LW('Failed to terminate {description} cluster in "{status}" '
                    'state: {error}.').format(error=six.text_type(e),
                                              status=cluster.status,
                                              description=description))

    else:
        if cluster.status != 'AwaitingTermination':
            conductor.cluster_update(ctx, cluster,
                                     {'status': 'AwaitingTermination'})
예제 #9
0
파일: periodic.py 프로젝트: stackhpc/sahara
def terminate_cluster(ctx, cluster, description):
    if CONF.use_identity_api_v3 and cluster.trust_id:
        trusts.use_os_admin_auth_token(cluster)
        context.set_current_cluster_id(cluster.id)

        LOG.debug('Terminating {description} cluster '
                  'in "{status}" state'.format(status=cluster.status,
                                               description=description))

        try:
            api.terminate_cluster(cluster.id)
        except Exception as e:
            LOG.warning(
                'Failed to terminate {description} cluster in "{status}" '
                'state: {error}.'.format(error=six.text_type(e),
                                         status=cluster.status,
                                         description=description))

    else:
        if (cluster.status != c_u.CLUSTER_STATUS_AWAITINGTERMINATION):
            conductor.cluster_update(
                ctx, cluster,
                {'status': c_u.CLUSTER_STATUS_AWAITINGTERMINATION})
예제 #10
0
def terminate_cluster(ctx, cluster, description):
    if CONF.use_identity_api_v3 and cluster.trust_id:
        trusts.use_os_admin_auth_token(cluster)
        context.set_current_cluster_id(cluster.id)

        LOG.debug('Terminating {description} cluster '
                  'in "{status}" state'.format(status=cluster.status,
                                               description=description))

        try:
            api.terminate_cluster(cluster.id)
        except Exception as e:
            LOG.warning(
                'Failed to terminate {description} cluster in "{status}" '
                'state: {error}.'.format(error=six.text_type(e),
                                         status=cluster.status,
                                         description=description))

    else:
        if (cluster.status !=
                c_u.CLUSTER_STATUS_AWAITINGTERMINATION):
            conductor.cluster_update(
                ctx, cluster,
                {'status': c_u.CLUSTER_STATUS_AWAITINGTERMINATION})
예제 #11
0
def terminate_cluster(ctx, cluster, description):
    if CONF.use_identity_api_v3:
        trusts.use_os_admin_auth_token(cluster)
        context.set_current_cluster_id(cluster.id)

        LOG.debug('Terminating {description} cluster '
                  'in "{status}" state'.format(status=cluster.status,
                                               description=description))

        try:
            ops.terminate_cluster(cluster.id)
        except Exception as e:
            LOG.warning(_LW(
                'Failed to terminate {description} cluster in "{status}" '
                'state: {error}.').format(error=six.text_type(e),
                                          status=cluster.status,
                                          description=description))

    else:
        if cluster.status != 'AwaitingTermination':
            conductor.cluster_update(
                ctx,
                cluster,
                {'status': 'AwaitingTermination'})
예제 #12
0
파일: ops.py 프로젝트: openstack/sahara
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)
예제 #13
0
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)