예제 #1
0
def return_qos_specs_delete_keys(context, id, keys):
    if id == fake.WILL_NOT_BE_FOUND_ID:
        raise exception.QoSSpecsNotFound(specs_id=id)

    if 'foo' in keys:
        raise exception.QoSSpecsKeyNotFound(specs_id=id,
                                            specs_key='foo')
예제 #2
0
def return_qos_specs_delete_keys(context, id, keys):
    if id == "777":
        raise exception.QoSSpecsNotFound(specs_id=id)

    if 'foo' in keys:
        raise exception.QoSSpecsKeyNotFound(specs_id=id,
                                            specs_key='foo')
예제 #3
0
def delete_keys(context, qos_specs_id, keys):
    """Marks specified key of target qos specs as deleted."""
    if qos_specs_id is None:
        msg = _("id cannot be None")
        raise exception.InvalidQoSSpecs(reason=msg)

    qos_spec = objects.QualityOfServiceSpecs.get_by_id(context, qos_specs_id)

    # Previous behavior continued to delete keys until it hit first unset one,
    # so for now will mimic that. In the future it would be useful to have all
    # or nothing deletion of keys (or at least delete all set keys),
    # especially since order of keys from CLI to API is not preserved currently
    try:
        for key in keys:
            try:
                del qos_spec.specs[key]
            except KeyError:
                raise exception.QoSSpecsKeyNotFound(specs_key=key,
                                                    specs_id=qos_specs_id)
    finally:
        qos_spec.save()
예제 #4
0
 def fake_db_qos_delete_key(context, id, key):
     if key == 'NotFound':
         raise exception.QoSSpecsKeyNotFound(specs_id=id, specs_key=key)
     else:
         pass