def create_policy_network_binding(context, policy_id, network_id): try: with context.session.begin(subtransactions=True): db_obj = models.QosNetworkPolicyBinding(policy_id=policy_id, network_id=network_id) context.session.add(db_obj) except oslo_db_exception.DBReferenceError: raise n_exc.NetworkQosBindingNotFound(net_id=network_id, policy_id=policy_id)
def delete_policy_network_binding(context, policy_id, network_id): try: with context.session.begin(subtransactions=True): db_object = (db.model_query(context, models.QosNetworkPolicyBinding) .filter_by(policy_id=policy_id, network_id=network_id).one()) context.session.delete(db_object) except orm_exc.NoResultFound: raise n_exc.NetworkQosBindingNotFound(net_id=network_id, policy_id=policy_id)
def detach_network(self, network_id): deleted = binding.QosPolicyNetworkBinding.delete_objects( self.obj_context, network_id=network_id) if not deleted: raise exceptions.NetworkQosBindingNotFound(net_id=network_id, policy_id=self.id)