73 lines
2.8 KiB
Python
73 lines
2.8 KiB
Python
# Copyright 2016 VMware, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
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
|
|
|
|
PLUGIN_NAME = 'vmware_nsx.plugin.NsxVPlugin'
|
|
|
|
|
|
class DnsSearchDomainExtensionManager(object):
|
|
|
|
def get_resources(self):
|
|
return []
|
|
|
|
def get_actions(self):
|
|
return []
|
|
|
|
def get_request_extensions(self):
|
|
return []
|
|
|
|
def get_extended_resources(self, version):
|
|
return ext_dns_search_domain.get_extended_resources(version)
|
|
|
|
|
|
class DnsSearchDomainDBTestCase(test_db.NeutronDbPluginV2TestCase):
|
|
|
|
def setUp(self):
|
|
super(DnsSearchDomainDBTestCase, self).setUp()
|
|
self.session = db_api.get_writer_session()
|
|
|
|
def test_get_nsxv_subnet_ext_attributes_no_dns_search_domain(self):
|
|
with self.subnet() as sub:
|
|
sub_binding = nsxv_db.get_nsxv_subnet_ext_attributes(
|
|
session=self.session, subnet_id=sub['subnet']['id'])
|
|
self.assertIsNone(sub_binding)
|
|
|
|
def test_add_nsxv_subnet_ext_attributes_dns_search_domain(self):
|
|
with self.subnet() as sub:
|
|
nsxv_db.add_nsxv_subnet_ext_attributes(
|
|
session=self.session,
|
|
subnet_id=sub['subnet']['id'],
|
|
dns_search_domain='eng.vmware.com')
|
|
sub_binding = nsxv_db.get_nsxv_subnet_ext_attributes(
|
|
session=self.session, subnet_id=sub['subnet']['id'])
|
|
self.assertEqual('eng.vmware.com', sub_binding.dns_search_domain)
|
|
self.assertEqual(sub['subnet']['id'], sub_binding.subnet_id)
|
|
|
|
def test_update_nsxv_subnet_ext_attributes_dns_search_domain(self):
|
|
with self.subnet() as sub:
|
|
nsxv_db.add_nsxv_subnet_ext_attributes(
|
|
session=self.session,
|
|
subnet_id=sub['subnet']['id'],
|
|
dns_search_domain='eng.vmware.com')
|
|
sub_binding = nsxv_db.update_nsxv_subnet_ext_attributes(
|
|
session=self.session,
|
|
subnet_id=sub['subnet']['id'],
|
|
dns_search_domain='nsx.vmware.com')
|
|
self.assertEqual('nsx.vmware.com', sub_binding.dns_search_domain)
|