def create_policy_port_binding(context, policy_id, port_id): try: with context.session.begin(subtransactions=True): db_obj = models.QosPortPolicyBinding(policy_id=policy_id, port_id=port_id) context.session.add(db_obj) except oslo_db_exception.DBReferenceError: raise n_exc.PortQosBindingNotFound(port_id=port_id, policy_id=policy_id)
def delete_policy_port_binding(context, policy_id, port_id): try: with context.session.begin(subtransactions=True): db_object = (db.model_query(context, models.QosPortPolicyBinding) .filter_by(policy_id=policy_id, port_id=port_id).one()) context.session.delete(db_object) except orm_exc.NoResultFound: raise n_exc.PortQosBindingNotFound(port_id=port_id, policy_id=policy_id)
def detach_port(self, port_id): deleted = binding.QosPolicyPortBinding.delete_objects(self.obj_context, port_id=port_id) if not deleted: raise exceptions.PortQosBindingNotFound(port_id=port_id, policy_id=self.id)