Merge "use get reader/writer session from neutron-lib"
This commit is contained in:
commit
956e2e6015
@ -17,6 +17,7 @@
|
||||
import six
|
||||
from sqlalchemy.orm import exc
|
||||
|
||||
from neutron_lib.db import api as db_api
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
@ -45,14 +46,14 @@ def _apply_filters_to_query(query, model, filters, like_filters=None):
|
||||
|
||||
|
||||
def get_network_bindings(session, network_id):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsx_models.TzNetworkBinding).
|
||||
filter_by(network_id=network_id).
|
||||
all())
|
||||
|
||||
|
||||
def get_network_bindings_by_phy_uuid(session, phy_uuid):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsx_models.TzNetworkBinding).
|
||||
filter_by(phy_uuid=phy_uuid).
|
||||
all())
|
||||
@ -60,7 +61,7 @@ def get_network_bindings_by_phy_uuid(session, phy_uuid):
|
||||
|
||||
def get_network_bindings_by_vlanid_and_physical_net(session, vlan_id,
|
||||
phy_uuid):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsx_models.TzNetworkBinding).
|
||||
filter_by(vlan_id=vlan_id, phy_uuid=phy_uuid).
|
||||
all())
|
||||
|
@ -14,11 +14,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import neutron.db.api as db
|
||||
|
||||
import decorator
|
||||
from neutron_lib.api.definitions import portbindings as pbin
|
||||
from neutron_lib import constants as lib_const
|
||||
from neutron_lib.db import api as db_api
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
@ -104,7 +103,7 @@ def get_nsxv_router_bindings_by_edge(session, edge_id):
|
||||
@warn_on_binding_status_error
|
||||
def get_nsxv_router_bindings(session, filters=None,
|
||||
like_filters=None):
|
||||
session = db.get_reader_session()
|
||||
session = db_api.get_reader_session()
|
||||
query = session.query(nsxv_models.NsxvRouterBinding)
|
||||
return nsx_db._apply_filters_to_query(query, nsxv_models.NsxvRouterBinding,
|
||||
filters, like_filters).all()
|
||||
@ -535,7 +534,7 @@ def get_nsx_vnic_id(session, neutron_id):
|
||||
|
||||
|
||||
def get_network_bindings(session, network_id):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsxv_models.NsxvTzNetworkBinding).
|
||||
filter_by(network_id=network_id).
|
||||
all())
|
||||
@ -543,7 +542,7 @@ def get_network_bindings(session, network_id):
|
||||
|
||||
def get_network_bindings_by_vlanid_and_physical_net(session, vlan_id,
|
||||
phy_uuid):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsxv_models.NsxvTzNetworkBinding).
|
||||
filter_by(vlan_id=vlan_id, phy_uuid=phy_uuid).
|
||||
all())
|
||||
@ -555,7 +554,7 @@ def get_network_bindings_by_ids(session, vlan_id, phy_uuid):
|
||||
|
||||
|
||||
def get_network_bindings_by_physical_net(session, phy_uuid):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsxv_models.NsxvTzNetworkBinding).
|
||||
filter_by(phy_uuid=phy_uuid).
|
||||
all())
|
||||
@ -563,7 +562,7 @@ def get_network_bindings_by_physical_net(session, phy_uuid):
|
||||
|
||||
def get_network_bindings_by_physical_net_and_type(session, phy_uuid,
|
||||
binding_type):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsxv_models.NsxvTzNetworkBinding).
|
||||
filter_by(phy_uuid=phy_uuid,
|
||||
binding_type=binding_type).
|
||||
@ -584,7 +583,7 @@ def add_network_binding(session, network_id, binding_type, phy_uuid, vlan_id):
|
||||
|
||||
|
||||
def get_network_bindings_by_vlanid(session, vlan_id):
|
||||
session = session or db.get_reader_session()
|
||||
session = session or db_api.get_reader_session()
|
||||
return (session.query(nsxv_models.NsxvTzNetworkBinding).
|
||||
filter_by(vlan_id=vlan_id).
|
||||
all())
|
||||
@ -666,7 +665,7 @@ def get_spoofguard_policy_id(session, network_id):
|
||||
|
||||
def get_nsxv_spoofguard_policy_network_mappings(session, filters=None,
|
||||
like_filters=None):
|
||||
session = db.get_reader_session()
|
||||
session = db_api.get_reader_session()
|
||||
query = session.query(nsxv_models.NsxvSpoofGuardPolicyNetworkMapping)
|
||||
return nsx_db._apply_filters_to_query(
|
||||
query, nsxv_models.NsxvSpoofGuardPolicyNetworkMapping,
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
import mock
|
||||
|
||||
import neutron.db.api as db
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db
|
||||
from neutron_lib.db import api as db_api
|
||||
|
||||
from vmware_nsx.db import nsxv_db
|
||||
from vmware_nsx.extensions import dhcp_mtu as ext_dhcp_mtu
|
||||
@ -126,7 +126,7 @@ class DhcpMtuDBTestCase(test_db.NeutronDbPluginV2TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(DhcpMtuDBTestCase, self).setUp()
|
||||
self.session = db.get_writer_session()
|
||||
self.session = db_api.get_writer_session()
|
||||
|
||||
def test_get_nsxv_subnet_ext_attributes_no_dhcp_mtu(self):
|
||||
with self.subnet() as sub:
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
import mock
|
||||
|
||||
import neutron.db.api as db
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db
|
||||
from neutron_lib.db import api as db_api
|
||||
|
||||
from vmware_nsx.db import nsxv_db
|
||||
from vmware_nsx.extensions import dns_search_domain as ext_dns_search_domain
|
||||
@ -85,7 +85,7 @@ class DnsSearchDomainDBTestCase(test_db.NeutronDbPluginV2TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(DnsSearchDomainDBTestCase, self).setUp()
|
||||
self.session = db.get_writer_session()
|
||||
self.session = db_api.get_writer_session()
|
||||
|
||||
def test_get_nsxv_subnet_ext_attributes_no_dns_search_domain(self):
|
||||
with self.subnet() as sub:
|
||||
|
@ -16,7 +16,6 @@ import contextlib
|
||||
|
||||
import mock
|
||||
from neutron.api import extensions
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import db_base_plugin_v2
|
||||
from neutron import quota
|
||||
from neutron.tests import base
|
||||
@ -24,6 +23,7 @@ from neutron.tests.unit.api import test_extensions
|
||||
from neutron.tests.unit.api.v2 import test_base
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_plugin
|
||||
from neutron_lib import context
|
||||
from neutron_lib.db import api as db_api
|
||||
from neutron_lib.plugins import constants
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from neutron.db import api as db_api
|
||||
from neutron.tests import base
|
||||
from neutron_lib.api.definitions import multiprovidernet as mpnet_apidef
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.db import api as db_api
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from vmware_nsx.api_client import exception as api_exc
|
||||
|
Loading…
Reference in New Issue
Block a user