From 748bf4353052c1a1d30e043253298694cd58526e Mon Sep 17 00:00:00 2001 From: Ronald van Zantvoort Date: Fri, 13 May 2016 17:23:04 +0200 Subject: [PATCH] VR CsConfig: Add is_router(), is_dns(), has_dns(), has_metadata(), use_extdns(), fix get_dns() with use_extdns() --- .../config/opt/cloud/bin/cs/CsConfig.py | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py index a35a54514df..f3de9772420 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py @@ -58,25 +58,35 @@ class CsConfig(object): return self.__LOG_LEVEL def is_vpc(self): - return self.cl.get_type() == "vpcrouter" + return self.cl.get_type() == 'vpcrouter' def is_router(self): - return self.cl.get_type() == "router" + return self.cl.get_type() == 'router' + + def is_dhcp(self): + return self.cl.get_type() == 'dhcpsrvr' + + def has_dns(self): + return not self.use_extdns() + + def has_metadata(self): + return any((self.is_vpc(), self.is_router(), self.is_dhcp())) def get_domain(self): return self.cl.get_domain() + def use_extdns(self): + return self.cmdline().idata().get('useextdns', 'false') == 'true' + def get_dns(self): + conf = self.cmdline().idata() dns = [] - if not self.cl.get_use_ext_dns(): - if not self.is_vpc() and self.cl.is_redundant(): - dns.append(self.cl.get_guest_gw()) - else: - dns.append(self.address().get_guest_ip()) - names = ["dns1", "dns2"] - for name in names: - if name in self.cmdline().idata(): - dns.append(self.cmdline().idata()[name]) + if not self.use_extdns(): + dns.append(self.address().get_guest_ip()) + + for name in ('dns1', 'dns2'): + if name in conf: + dns.append(conf[name]) return dns def get_format(self):