From 8cca87ed98de69c18d6a03a7c29a396256b29be7 Mon Sep 17 00:00:00 2001 From: Gary Kotton <gkotton@vmware.com> Date: Mon, 12 Dec 2016 04:28:23 -0800 Subject: [PATCH] NSX|V: add configuration variable for dns_search_domain Enable a admin to configure a global search domain. That is, if a subnet is not created with a search domain (commit d9f3ee826acf3fc5a1c436361790940237ef9784) then is a domain is defined in the configuration file then we can use that one. In the nsxv section there will be a new variable - dns_search_domain Change-Id: I112a00dbc89b1c7702e82ecfa6ec974b7b9cce8d --- ...ch-domain-configuration-a134af0ef028282c.yaml | 9 +++++++++ vmware_nsx/common/config.py | 3 +++ vmware_nsx/plugins/nsx_v/vshield/edge_utils.py | 16 ++++++++++------ 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/dns-search-domain-configuration-a134af0ef028282c.yaml diff --git a/releasenotes/notes/dns-search-domain-configuration-a134af0ef028282c.yaml b/releasenotes/notes/dns-search-domain-configuration-a134af0ef028282c.yaml new file mode 100644 index 0000000000..9ad70ec02c --- /dev/null +++ b/releasenotes/notes/dns-search-domain-configuration-a134af0ef028282c.yaml @@ -0,0 +1,9 @@ +--- +prelude: > + Enable an admin to configure a global search domain. + This is used if no search domain is configured on a + subnet. +features: + - A new configuration variable in the nsxv section will + enable the admin to configure a search domain. The new + variable is dns_search_domain. diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index db2ba93436..f91bcb7034 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -580,6 +580,9 @@ nsxv_opts = [ "exclusive_router_appliance_size will be picked up if " "--router-size parameter is not specified while doing " "neutron router-create")), + cfg.StrOpt('dns_search_domain', + help=_("(Optional) Use this search domain if there is no " + "search domain configured on the subnet.")), cfg.ListOpt('nameservers', default=[], help=_('List of nameservers to configure for the DHCP binding ' diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py index cfa67ecb11..479e8a9a08 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py @@ -912,12 +912,16 @@ class EdgeManager(object): sub_binding = nsxv_db.get_nsxv_subnet_ext_attributes( context.session, subnet_id) - if sub_binding: - if sub_binding.dns_search_domain is not None: - static_config['domainName'] = sub_binding.dns_search_domain - if sub_binding.dhcp_mtu: - static_config = self.add_mtu_on_static_binding( - static_config, sub_binding.dhcp_mtu) + dns_search_domain = None + if sub_binding and sub_binding.dns_search_domain: + dns_search_domain = sub_binding.dns_search_domain + elif cfg.CONF.nsxv.dns_search_domain: + dns_search_domain = cfg.CONF.nsxv.dns_search_domain + if dns_search_domain: + static_config['domainName'] = dns_search_domain + if sub_binding and sub_binding.dhcp_mtu: + static_config = self.add_mtu_on_static_binding( + static_config, sub_binding.dhcp_mtu) self.handle_meta_static_route( context, subnet_id, [static_config])