示例#1
0
def disassociate_all(context, specs_id):
    """Disassociate qos_specs from all entities."""
    try:
        db.qos_specs_disassociate_all(context, specs_id)
    except db_exc.DBError as e:
        LOG.exception(_('DB error: %s') % e)
        LOG.warn(_('Failed to disassociate qos specs %s.') % specs_id)
        raise exception.QoSSpecsDisassociateFailed(specs_id=specs_id,
                                                   type_id=None)
示例#2
0
def disassociate_all(context, specs_id):
    """Disassociate qos_specs from all entities."""
    try:
        get_qos_specs(context, specs_id)
        db.qos_specs_disassociate_all(context, specs_id)
    except db_exc.DBError:
        LOG.exception(_LE("DB error:"))
        LOG.warning(_LW("Failed to disassociate qos specs %s."), specs_id)
        raise exception.QoSSpecsDisassociateFailed(specs_id=specs_id, type_id=None)
示例#3
0
def disassociate_all(context, specs_id):
    """Disassociate qos_specs from all entities."""
    try:
        db.qos_specs_disassociate_all(context, specs_id)
    except db_exc.DBError as e:
        LOG.exception(_('DB error: %s') % e)
        LOG.warn(_('Failed to disassociate qos specs %s.') % specs_id)
        raise exception.QoSSpecsDisassociateFailed(specs_id=specs_id,
                                                   type_id=None)
示例#4
0
def disassociate_all(context, specs_id):
    """Disassociate qos_specs from all entities."""
    try:
        get_qos_specs(context, specs_id)
        db.qos_specs_disassociate_all(context, specs_id)
    except db_exc.DBError:
        LOG.exception('DB error:')
        LOG.warning('Failed to disassociate qos specs %s.', specs_id)
        raise exception.QoSSpecsDisassociateFailed(specs_id=specs_id,
                                                   type_id=None)
示例#5
0
    def destroy(self, force=False):
        """Deletes the QoS spec.

        :param force: when force is True, all volume_type mappings for this QoS
                      are deleted.  When force is False and volume_type
                      mappings still exist, a QoSSpecsInUse exception is thrown
        """
        if self.volume_types:
            if not force:
                raise exception.QoSSpecsInUse(specs_id=self.id)
            else:
                # remove all association
                db.qos_specs_disassociate_all(self._context, self.id)
        db.qos_specs_delete(self._context, self.id)
示例#6
0
    def test_qos_specs_disassociate_all(self):
        specs_id = self._create_qos_specs('FakeQos')
        type1_id = volume_types.create(self.ctxt, 'Type1Name')['id']
        type2_id = volume_types.create(self.ctxt, 'Type2Name')['id']
        type3_id = volume_types.create(self.ctxt, 'Type3Name')['id']
        db.volume_type_qos_associate(self.ctxt, type1_id, specs_id)
        db.volume_type_qos_associate(self.ctxt, type2_id, specs_id)
        db.volume_type_qos_associate(self.ctxt, type3_id, specs_id)

        res = db.qos_specs_associations_get(self.ctxt, specs_id)
        self.assertEqual(len(res), 3)

        db.qos_specs_disassociate_all(self.ctxt, specs_id)
        res = db.qos_specs_associations_get(self.ctxt, specs_id)
        self.assertEqual(len(res), 0)
示例#7
0
    def test_qos_specs_disassociate_all(self):
        specs_id = self._create_qos_specs('FakeQos')
        type1_id = volume_types.create(self.ctxt, 'Type1Name')['id']
        type2_id = volume_types.create(self.ctxt, 'Type2Name')['id']
        type3_id = volume_types.create(self.ctxt, 'Type3Name')['id']
        db.volume_type_qos_associate(self.ctxt, type1_id, specs_id)
        db.volume_type_qos_associate(self.ctxt, type2_id, specs_id)
        db.volume_type_qos_associate(self.ctxt, type3_id, specs_id)

        res = db.qos_specs_associations_get(self.ctxt, specs_id)
        self.assertEqual(3, len(res))

        db.qos_specs_disassociate_all(self.ctxt, specs_id)
        res = db.qos_specs_associations_get(self.ctxt, specs_id)
        self.assertEqual(0, len(res))
示例#8
0
    def destroy(self, force=False):
        """Deletes the QoS spec.

        :param force: when force is True, all volume_type mappings for this QoS
                      are deleted.  When force is False and volume_type
                      mappings still exist, a QoSSpecsInUse exception is thrown
        """
        if self.volume_types:
            if not force:
                raise exception.QoSSpecsInUse(specs_id=self.id)
            # remove all association
            db.qos_specs_disassociate_all(self._context, self.id)
        updated_values = db.qos_specs_delete(self._context, self.id)
        self.update(updated_values)
        self.obj_reset_changes(updated_values.keys())
示例#9
0
    def test_qos_specs_disassociate_all(self):
        specs_id = self._create_qos_specs("FakeQos")
        type1_id = volume_types.create(self.ctxt, "Type1Name")["id"]
        type2_id = volume_types.create(self.ctxt, "Type2Name")["id"]
        type3_id = volume_types.create(self.ctxt, "Type3Name")["id"]
        db.volume_type_qos_associate(self.ctxt, type1_id, specs_id)
        db.volume_type_qos_associate(self.ctxt, type2_id, specs_id)
        db.volume_type_qos_associate(self.ctxt, type3_id, specs_id)

        res = db.qos_specs_associations_get(self.ctxt, specs_id)
        self.assertEqual(len(res), 3)

        db.qos_specs_disassociate_all(self.ctxt, specs_id)
        res = db.qos_specs_associations_get(self.ctxt, specs_id)
        self.assertEqual(len(res), 0)
示例#10
0
def delete(context, qos_specs_id, force=False):
    """Marks qos specs as deleted.

    'force' parameter is a flag to determine whether should destroy
    should continue when there were entities associated with the qos specs.
    force=True indicates caller would like to mark qos specs as deleted
    even if there was entities associate with target qos specs.
    Trying to delete a qos specs still associated with entities will
    cause QoSSpecsInUse exception if force=False (default).
    """
    if qos_specs_id is None:
        msg = _("id cannot be None")
        raise exception.InvalidQoSSpecs(reason=msg)

    # check if there is any entity associated with this qos specs
    res = db.qos_specs_associations_get(context, qos_specs_id)
    if res and not force:
        raise exception.QoSSpecsInUse(specs_id=qos_specs_id)
    elif res and force:
        # remove all association
        db.qos_specs_disassociate_all(context, qos_specs_id)

    db.qos_specs_delete(context, qos_specs_id)
示例#11
0
def delete(context, qos_specs_id, force=False):
    """Marks qos specs as deleted.

    'force' parameter is a flag to determine whether should destroy
    should continue when there were entities associated with the qos specs.
    force=True indicates caller would like to mark qos specs as deleted
    even if there was entities associate with target qos specs.
    Trying to delete a qos specs still associated with entities will
    cause QoSSpecsInUse exception if force=False (default).
    """
    if qos_specs_id is None:
        msg = _("id cannot be None")
        raise exception.InvalidQoSSpecs(reason=msg)

    # check if there is any entity associated with this qos specs
    res = db.qos_specs_associations_get(context, qos_specs_id)
    if res and not force:
        raise exception.QoSSpecsInUse(specs_id=qos_specs_id)
    elif res and force:
        # remove all association
        db.qos_specs_disassociate_all(context, qos_specs_id)

    db.qos_specs_delete(context, qos_specs_id)