コード例 #1
0
def handle_set_pool_value(request, service):
    """Sets an arbitrary pool value.

    :param request: dict of request operations and params
    :param service: The ceph client to run the command under.
    :returns: dict. exit-code and reason if not 0
    """
    # Set arbitrary pool values
    params = {'pool': request.get('name'),
              'key': request.get('key'),
              'value': request.get('value')}
    if params['key'] not in POOL_KEYS:
        msg = "Invalid key '{}'".format(params['key'])
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    # Get the validation method
    validator_params = POOL_KEYS[params['key']]
    if len(validator_params) is 1:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0])
    else:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0], validator_params[1])

    # Set the value
    pool_set(service=service, pool_name=params['pool'], key=params['key'],
             value=params['value'])
コード例 #2
0
def handle_set_pool_value(request, service):
    # Set arbitrary pool values
    params = {
        'pool': request.get('name'),
        'key': request.get('key'),
        'value': request.get('value')
    }
    if params['key'] not in POOL_KEYS:
        msg = "Invalid key '%s'" % params['key']
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    # Get the validation method
    validator_params = POOL_KEYS[params['key']]
    if len(validator_params) is 1:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0])
    else:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0], validator_params[1])

    # Set the value
    pool_set(service=service,
             pool_name=params['pool'],
             key=params['key'],
             value=params['value'])
コード例 #3
0
def handle_set_pool_value(request, service):
    """Sets an arbitrary pool value.

    :param request: dict of request operations and params
    :param service: The ceph client to run the command under.
    :returns: dict. exit-code and reason if not 0
    """
    # Set arbitrary pool values
    params = {'pool': request.get('name'),
              'key': request.get('key'),
              'value': request.get('value')}
    if params['key'] not in POOL_KEYS:
        msg = "Invalid key '{}'".format(params['key'])
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    # Get the validation method
    validator_params = POOL_KEYS[params['key']]
    if len(validator_params) is 1:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0])
    else:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0], validator_params[1])

    # Set the value
    pool_set(service=service, pool_name=params['pool'], key=params['key'],
             value=params['value'])
コード例 #4
0
ファイル: ceph_ops.py プロジェクト: openstack/charm-ceph-mon
def set_pool():
    """
    Sets an arbitrary key key in a Ceph pool.

    Sets the key specified by the action parameter 'key' to the value
    specified in the action parameter 'value' for the pool specified
    by the action parameter 'pool_name' using the charmhelpers
    'pool_set' function.
    """
    key = action_get("key")
    value = action_get("value")
    pool_name = action_get("pool_name")
    pool_set(service='ceph', pool_name=pool_name, key=key, value=value)
コード例 #5
0
def set_pool():
    """
    Sets an arbitrary key key in a Ceph pool.

    Sets the key specified by the action parameter 'key' to the value
    specified in the action parameter 'value' for the pool specified
    by the action parameter 'pool_name' using the charmhelpers
    'pool_set' function.
    """
    key = action_get("key")
    value = action_get("value")
    pool_name = action_get("pool_name")
    pool_set(service='ceph', pool_name=pool_name, key=key, value=value)
コード例 #6
0
def handle_set_pool_value(request, service, coerce=False):
    """Sets an arbitrary pool value.

    :param request: dict of request operations and params
    :param service: The ceph client to run the command under.
    :param coerce: Try to parse/coerce the value into the correct type.
                   Used by the action code that only gets Str from Juju
    :returns: dict. exit-code and reason if not 0
    """
    # Set arbitrary pool values
    params = {
        'pool': request.get('name'),
        'key': request.get('key'),
        'value': request.get('value')
    }
    if params['key'] not in POOL_KEYS:
        msg = "Invalid key '{}'".format(params['key'])
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    # Get the validation method
    validator_params = POOL_KEYS[params['key']]
    # BUG: #1838650 - the function needs to try to coerce the value param to
    # the type required for the validator to pass.  Note, if this blows, then
    # the param isn't parsable to the correct type.
    if coerce:
        try:
            params['value'] = validator_params[0](params['value'])
        except ValueError:
            raise RuntimeError("Value {} isn't of type {}".format(
                params['value'], validator_params[0]))
    # end of BUG: #1838650
    if len(validator_params) == 1:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0])
    else:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0], validator_params[1])

    # Set the value
    pool_set(service=service,
             pool_name=params['pool'],
             key=params['key'],
             value=params['value'])
コード例 #7
0
ファイル: ceph_broker.py プロジェクト: dosaboy/charm-ceph
def handle_set_pool_value(request, service):
    # Set arbitrary pool values
    params = {'pool': request.get('name'),
              'key': request.get('key'),
              'value': request.get('value')}
    if params['key'] not in POOL_KEYS:
        msg = "Invalid key '%s'" % params['key']
        log(msg, level=ERROR)
        return {'exit-code': 1, 'stderr': msg}

    # Get the validation method
    validator_params = POOL_KEYS[params['key']]
    if len(validator_params) is 1:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0])
    else:
        # Validate that what the user passed is actually legal per Ceph's rules
        validator(params['value'], validator_params[0], validator_params[1])
    # Set the value
    pool_set(service=service, pool_name=params['pool'], key=params['key'],
             value=params['value'])
コード例 #8
0
def set_pool():
    key = action_get("key")
    value = action_get("value")
    pool_name = action_get("pool_name")
    pool_set(service='ceph', pool_name=pool_name, key=key, value=value)
コード例 #9
0
def set_pool():
    key = action_get("key")
    value = action_get("value")
    pool_name = action_get("pool_name")
    pool_set(service='ceph', pool_name=pool_name, key=key, value=value)