Пример #1
0
    def _force_single_ec2_node():
        buildvars = read_from_current_host()

        new_vars = buildvars.copy()
        new_vars[field] = value
        _update_remote_bvars(stackname, new_vars)
        LOG.info("updated bvars %s", new_vars)
Пример #2
0
def _retrieve_build_vars():
    """wrapper around `read_from_current_host` with integrity checks. returns buildvars for the current instance.
    raises AssertionError on bad data."""
    try:
        buildvars = read_from_current_host()
        LOG.debug('build vars: %s', buildvars)

        # buildvars exist
        ensure(
            isinstance(buildvars, dict),
            'build vars not found (%s). use `./bldr buildvars.fix` to attempt to fix this.'
            % buildvars)

        # nothing important is missing
        missing_keys = core_utils.missingkeys(
            buildvars, ['stackname', 'instance_id', 'branch', 'revision'])
        ensure(
            len(missing_keys) == 0,
            'build vars are not valid: missing keys %s. use `./bldr buildvars.fix` to attempt to fix this.'
            % missing_keys)

        return buildvars

    except (ValueError, AssertionError, JSONDecodeError) as ex:
        LOG.exception(ex)
        raise
Пример #3
0
    def _force_single_ec2_node():
        buildvars = read_from_current_host()

        new_vars = buildvars.copy()
        new_vars[field] = value
        _update_remote_bvars(stackname, new_vars)
        LOG.info("updated bvars %s", new_vars)
Пример #4
0
    def _force_single_ec2_node():
        # do not validate build vars.
        # this way it can be used to repair buildvars when they are missing some field.
        #buildvars = _validate()
        buildvars = read_from_current_host()

        new_vars = buildvars.copy()
        new_vars[field] = value
        _update_remote_bvars(stackname, new_vars)
        LOG.info("updated bvars %s", new_vars)
Пример #5
0
def _retrieve_build_vars():
    """wrapper around `read_from_current_host` with integrity checks. returns buildvars for the current instance.
    raises AssertionError on bad data."""
    try:
        buildvars = read_from_current_host()
        LOG.debug('build vars: %s', buildvars)

        # buildvars exist
        ensure(isinstance(buildvars, dict), 'build vars not found (%s). use `./bldr buildvars.fix` to attempt to fix this.' % buildvars)

        # nothing important is missing
        missing_keys = core_utils.missingkeys(buildvars, ['stackname', 'instance_id', 'branch', 'revision'])
        ensure(
            len(missing_keys) == 0,
            'build vars are not valid: missing keys %s. use `./bldr buildvars.fix` to attempt to fix this.' % missing_keys
        )

        return buildvars

    except (ValueError, AssertionError) as ex:
        LOG.exception(ex)
        raise
Пример #6
0
def _validate():
    "returns a pair of (type, build data) for the given instance. type is either 'old', 'abbrev' or 'full'"
    try:
        buildvars = read_from_current_host()
        LOG.debug('build vars: %s', buildvars)
        core_utils.ensure(
            isinstance(buildvars, dict),
            'build vars not found (%s). use `./bldr buildvars.fix` to attempt to fix this.',
            buildvars)
        missing_keys = core_utils.missingkeys(buildvars, [
            'stackname', 'instance_id', 'branch', 'revision',
            'is_prod_instance'
        ])
        core_utils.ensure(
            len(missing_keys) == 0,
            'build vars are not valid: missing keys %s. use `./bldr buildvars.fix` to attempt to fix this.'
            % missing_keys)
        return buildvars

    except (ValueError, AssertionError) as ex:
        LOG.exception(ex)
        raise
Пример #7
0
def read(stackname):
    "returns the unencoded build variables found on given instance"
    return stack_all_ec2_nodes(stackname, lambda: pprint(read_from_current_host()), username=BOOTSTRAP_USER)
Пример #8
0
def read(stackname):
    "returns the unencoded build variables found on given instance"
    return stack_all_ec2_nodes(stackname,
                               lambda: pprint(read_from_current_host()),
                               username=BOOTSTRAP_USER)