]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge "Use database session from the context in N1kv plugin"
authorJenkins <jenkins@review.openstack.org>
Wed, 5 Mar 2014 00:09:37 +0000 (00:09 +0000)
committerGerrit Code Review <review@openstack.org>
Wed, 5 Mar 2014 00:09:37 +0000 (00:09 +0000)
1  2 
neutron/plugins/cisco/db/n1kv_db_v2.py
neutron/tests/unit/cisco/n1kv/test_n1kv_db.py

index a9673a977398ca8845431a6be23a9dae5ac2110e,886cfb8b81218481e740c97ebd00181599a0a34a..3299d0cb73d90bfe6eb7f8353f4702752729cef5
@@@ -939,15 -939,18 +939,18 @@@ def get_policy_profile(db_session, id)
          raise c_exc.PolicyProfileIdNotFound(profile_id=id)
  
  
- def create_profile_binding(tenant_id, profile_id, profile_type):
+ def create_profile_binding(db_session, tenant_id, profile_id, profile_type):
      """Create Network/Policy Profile association with a tenant."""
+     db_session = db_session or db.get_session()
      if profile_type not in ["network", "policy"]:
 -        raise q_exc.NeutronException(_("Invalid profile type"))
 +        raise n_exc.NeutronException(_("Invalid profile type"))
  
-     if _profile_binding_exists(tenant_id, profile_id, profile_type):
-         return get_profile_binding(tenant_id, profile_id)
+     if _profile_binding_exists(db_session,
+                                tenant_id,
+                                profile_id,
+                                profile_type):
+         return get_profile_binding(db_session, tenant_id, profile_id)
  
-     db_session = db.get_session()
      with db_session.begin(subtransactions=True):
          binding = n1kv_models_v2.ProfileBinding(profile_type=profile_type,
                                                  profile_id=profile_id,