예제 #1
0
파일: api.py 프로젝트: dingboopt/neutron-x
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)
예제 #2
0
파일: api.py 프로젝트: dingboopt/neutron-x
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)
예제 #3
0
 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)