From: Jenkins Date: Wed, 5 Mar 2014 00:09:37 +0000 (+0000) Subject: Merge "Use database session from the context in N1kv plugin" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f18558f72cb196c9127c5582aaa94e45e4cf4fff;p=openstack-build%2Fneutron-build.git Merge "Use database session from the context in N1kv plugin" --- f18558f72cb196c9127c5582aaa94e45e4cf4fff diff --cc neutron/plugins/cisco/db/n1kv_db_v2.py index a9673a977,886cfb8b8..3299d0cb7 --- a/neutron/plugins/cisco/db/n1kv_db_v2.py +++ b/neutron/plugins/cisco/db/n1kv_db_v2.py @@@ -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,