def delete(self): with db_api.autonested_transaction(self.obj_context.session): for object_type, model in self.binding_models.items(): binding_db_obj = obj_db_api.get_object(self.obj_context, model, policy_id=self.id) if binding_db_obj: raise exceptions.QosPolicyInUse( policy_id=self.id, object_type=object_type, object_id=binding_db_obj['%s_id' % object_type]) super(QosPolicy, self).delete()
def delete(self): with db_api.autonested_transaction(self.obj_context.session): for object_type, obj_class in self.binding_models.items(): pager = base_db.Pager(limit=1) binding_obj = obj_class.get_objects(self.obj_context, policy_id=self.id, _pager=pager) if binding_obj: raise exceptions.QosPolicyInUse( policy_id=self.id, object_type=object_type, object_id=binding_obj[0]['%s_id' % object_type]) super(QosPolicy, self).delete()
def delete(self): models = (('network', self.network_binding_model), ('port', self.port_binding_model)) with db_api.autonested_transaction(self._context.session): for object_type, model in models: binding_db_obj = db_api.get_object(self._context, model, policy_id=self.id) if binding_db_obj: raise exceptions.QosPolicyInUse( policy_id=self.id, object_type=object_type, object_id=binding_db_obj['%s_id' % object_type]) super(QosPolicy, self).delete()