Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
 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)