Ejemplo n.º 1
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)

    # make sure qos_specs_id is valid
    get_qos_specs(context, qos_specs_id)
    for key in keys:
        db.qos_specs_item_delete(context, qos_specs_id, key)
Ejemplo n.º 2
0
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if "specs_keys_removed" in updates.keys():
                for specs_key_to_remove in updates["specs_keys_removed"]:
                    db.qos_specs_item_delete(self._context, self.id, specs_key_to_remove)
                del updates["specs_keys_removed"]
            db.qos_specs_update(self._context, self.id, updates)

        self.obj_reset_changes()
Ejemplo n.º 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)

    # make sure qos_specs_id is valid
    get_qos_specs(context, qos_specs_id)
    for key in keys:
        db.qos_specs_item_delete(context, qos_specs_id, key)
Ejemplo n.º 4
0
    def save(self):
        updates = self.cinder_obj_get_changes()
        if updates:
            if 'specs_keys_removed' in updates.keys():
                for specs_key_to_remove in updates['specs_keys_removed']:
                    db.qos_specs_item_delete(self._context, self.id,
                                             specs_key_to_remove)
                del updates['specs_keys_removed']
            db.qos_specs_update(self._context, self.id, updates)

        self.obj_reset_changes()
Ejemplo n.º 5
0
    def test_qos_specs_item_delete(self):
        name = str(int(time.time()))
        value = dict(consumer="front-end", foo="Foo", bar="Bar")
        specs_id = self._create_qos_specs(name, value)

        del value["consumer"]
        del value["foo"]
        expected = {"name": name, "id": specs_id, "consumer": "front-end", "specs": value}
        db.qos_specs_item_delete(self.ctxt, specs_id, "foo")
        specs = db.qos_specs_get_by_name(self.ctxt, name)
        self.assertDictMatch(specs, expected)
Ejemplo n.º 6
0
    def test_qos_specs_item_delete(self):
        name = str(int(time.time()))
        value = dict(foo='Foo', bar='Bar')
        specs_id = self._create_qos_specs(name, 'front-end', value)

        del value['foo']
        expected = {'name': name,
                    'id': specs_id,
                    'consumer': 'front-end',
                    'specs': value}
        db.qos_specs_item_delete(self.ctxt, specs_id, 'foo')
        specs = db.qos_specs_get(self.ctxt, specs_id)
        self.assertDictEqual(expected, specs)
Ejemplo n.º 7
0
    def test_qos_specs_item_delete(self):
        name = str(int(time.time()))
        value = dict(consumer='front-end',
                     foo='Foo', bar='Bar')
        specs_id = self._create_qos_specs(name, value)

        del value['consumer']
        del value['foo']
        expected = {'name': name,
                    'id': specs_id,
                    'consumer': 'front-end',
                    'specs': value}
        db.qos_specs_item_delete(self.ctxt, specs_id, 'foo')
        specs = db.qos_specs_get_by_name(self.ctxt, name)
        self.assertDictMatch(specs, expected)
Ejemplo n.º 8
0
    def test_qos_specs_item_delete(self):
        name = str(int(time.time()))
        value = dict(foo='Foo', bar='Bar')
        specs_id = self._create_qos_specs(name, 'front-end', value)

        del value['foo']
        expected = {
            'name': name,
            'id': specs_id,
            'consumer': 'front-end',
            'specs': value
        }
        db.qos_specs_item_delete(self.ctxt, specs_id, 'foo')
        specs = db.qos_specs_get(self.ctxt, specs_id)
        expected['created_at'] = specs['created_at']
        self.assertDictEqual(expected, specs)