How to use the dcicutils.env_utils.is_fourfront_env function in dcicutils

To help you get started, we’ve selected a few dcicutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 4dn-dcic / foursight / chalicelib / checks / deployment_checks.py View on Github external
def _deploy_indexer(e, version):
        if is_fourfront_env(e):
            description = try_to_describe_indexer_env(FF_ENV_INDEXER)
        else:
            description = try_to_describe_indexer_env(CGAP_ENV_INDEXER)
        if description is not None:
            check.status = 'ERROR'
            check.summary = 'Tried to spin up indexer env for %s when one already exists for this portal' % e
            return False
        else:
            return EBDeployer.deploy_indexer(e, version)
github 4dn-dcic / foursight / chalicelib / checks / system_checks.py View on Github external
def snapshot_rds(connection, **kwargs):
    from ..utils import get_stage_info
    check = CheckResult(connection, 'snapshot_rds')
    if get_stage_info()['stage'] != 'prod':
        check.summary = check.description = 'This check only runs on Foursight prod'
        return check
    # XXX: must be updated when cgap-blue/cgap-green come to fruition -will 4-1-2020
    rds_name = 'fourfront-production' if (env_utils.is_fourfront_env(connection.ff_env) and env_utils.is_stg_or_prd_env(connection.ff_env)) else connection.ff_env
    # snapshot ID can only have letters, numbers, and hyphens
    snap_time = datetime.datetime.strptime(kwargs['uuid'], "%Y-%m-%dT%H:%M:%S.%f").strftime("%Y-%m-%dT%H-%M-%S")
    snapshot_name = 'foursight-snapshot-%s-%s' % (rds_name, snap_time)
    res = beanstalk_utils.create_db_snapshot(rds_name, snapshot_name)
    if res == 'Deleting':  # XXX: How this^ function works should be changed - Will 6/2/2020
        check.status = 'FAIL'
        check.summary = check.description = 'Something went wrong during snaphot creation'
    else:
        check.status = 'PASS'
        # there is a datetime in the response that must be str formatted
        res['DBSnapshot']['InstanceCreateTime'] = str(res['DBSnapshot']['InstanceCreateTime'])
        check.full_output = res
        check.summary = 'Snapshot successfully created'
        check.description = 'Snapshot succesfully created with name: %s' % snapshot_name
    return check
github 4dn-dcic / foursight / chalicelib / checks / deployment_checks.py View on Github external
'Get this information from the EB Console.'
        return check

    def _deploy_indexer(e, version):
        if is_fourfront_env(e):
            description = try_to_describe_indexer_env(FF_ENV_INDEXER)
        else:
            description = try_to_describe_indexer_env(CGAP_ENV_INDEXER)
        if description is not None:
            check.status = 'ERROR'
            check.summary = 'Tried to spin up indexer env for %s when one already exists for this portal' % e
            return False
        else:
            return EBDeployer.deploy_indexer(e, version)

    if is_cgap_env(env) or is_fourfront_env(env):
        success = _deploy_indexer(env, application_version)
        if success:
            check.status = 'PASS'
            check.summary = 'Successfully triggered indexer-server provision for environment %s' % env
        else:
            check.status = 'ERROR'
            check.summary = 'An error occurred on deployment. Check the AWS EB Console.'
    else:
        check.status = 'FAIL'
        check.summary = 'Gave an unknown environment: %s' % env

    return check
github 4dn-dcic / foursight / chalicelib / checks / deployment_checks.py View on Github external
def indexer_server_status(connection, **kwargs):
    """ Checks the status of index servers (if any are up) """
    check = CheckResult(connection, 'indexer_server_status')
    check.action = 'terminate_indexer_server'
    env = kwargs.get('env')
    indexer_env = FF_ENV_INDEXER if is_fourfront_env(env) else CGAP_ENV_INDEXER
    description = try_to_describe_indexer_env(indexer_env)  # verify an indexer is online
    if description is None:
        check.status = 'ERROR'
        check.summary = 'Did not locate corresponding indexer env: ' \
                        'given env %s does not have indexer %s' % (env, indexer_env)
        check.allow_action = False
        return check

    try:
        indexing_finished, counts = is_indexing_finished(env)
    except Exception as e:  # XXX: This should be handled in dcicutils -Will 5/18/2020
        check.status = 'ERROR'
        check.summary = 'Failed to get indexing status of given env: %s' % str(e)
        check.allow_action = False
        return check