diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py index 799e999f45d..4fb4909bb42 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py @@ -35,7 +35,6 @@ from cs.CsNetfilter import CsNetfilters from cs.CsDhcp import CsDhcp from cs.CsRedundant import * from cs.CsFile import CsFile -from cs.CsAddress import CsAddress from cs.CsApp import CsApache, CsPasswdSvc, CsDnsmasq from cs.CsMonitor import CsMonitor from cs.CsLoadBalancer import CsLoadBalancer @@ -536,11 +535,12 @@ def main(argv): level=config.get_level(), format=config.get_format()) config.set_cl() + config.set_address() cl = config.get_cmdline() - address = CsAddress("ips", config) - address.compare() - address.process() + # IP configuration + config.address().compare() + config.address().process() password = CsPassword("vmpassword", config) password.process() @@ -560,7 +560,7 @@ def main(argv): vpns = CsSite2SiteVpn("site2sitevpn", config) vpns.process() - red = CsRedundant(config, address) + red = CsRedundant(config) red.set() nf = CsNetfilters() diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py index 81fab787868..d4d42a40067 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py @@ -43,6 +43,16 @@ class CsAddress(CsDataBag): ret.append(CsInterface(ip)) return ret + def get_guest_ip(self): + """ + Return the ip of the first guest interface + For use with routers not vpcrouters + """ + for ip in self.get_ips(): + if ip.is_guest(): + return ip.get_ip() + return None + def needs_vrrp(self, o): """ Returns if the ip needs to be managed by keepalived or not @@ -146,6 +156,11 @@ class CsInterface: return True return False + def is_guest(self): + if "nw_type" in self.address and self.address['nw_type'] in ['guest']: + return True + return False + def to_str(self): pprint(self.address) 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 93e10849613..ad6ede8cbd3 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py @@ -17,6 +17,7 @@ # under the License. from CsDatabag import CsCmdLine +from CsAddress import CsAddress import logging @@ -30,12 +31,19 @@ class CsConfig(object): def __init__(self, load=False): if load: - self.cl = self_set_cl() + self_set_cl() + self_set_address() self.fw = [] def set_cl(self): self.cl = CsCmdLine("cmdline") + def address(self): + return self.ips + + def set_address(self): + self.ips = CsAddress("ips", self) + def get_cmdline(self): return self.cl @@ -51,6 +59,9 @@ class CsConfig(object): def is_vpc(self): return self.cl.get_type() == "vpcrouter" + def is_router(self): + return self.cl.get_type() == "router" + def get_domain(self): return self.cl.get_domain() diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py index 5c6bdae3502..cb8c7808704 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py @@ -70,7 +70,10 @@ class CsDnsMasq(object): self.add_host("::1", "localhost ip6-localhost ip6-loopback") self.add_host("ff02::1", "ip6-allnodes") self.add_host("ff02::2", "ip6-allrouters") - self.add_host("127.0.0.1", CsHelper.get_hostname()) + if config.is_vpc(): + self.add_host("127.0.0.1", CsHelper.get_hostname()) + if config.is_router(): + self.add_host(self.config.address().get_guest_ip(), "%s data-server" % CsHelper.get_hostname()) def delete_leases(self, clist): try: diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py index c01a9d956c6..9641a5fd9a9 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py @@ -53,9 +53,9 @@ class CsRedundant(object): CONNTRACKD_LOCK = "/var/lock/conntrack.lock" CONNTRACKD_CONFIG = "/etc/conntrackd/conntrackd.conf" - def __init__(self, config, address): + def __init__(self, config): self.cl = config.get_cmdline() - self.address = address + self.address = config.address() def set(self): logging.debug("Router redundancy status is %s", self.cl.is_redundant()) diff --git a/systemvm/test/python/TestCsRedundant.py b/systemvm/test/python/TestCsRedundant.py index 77e542a215c..93a87d4c3f8 100644 --- a/systemvm/test/python/TestCsRedundant.py +++ b/systemvm/test/python/TestCsRedundant.py @@ -12,8 +12,9 @@ class TestCsRedundant(unittest.TestCase): def test_init(self): csconfig = CsConfig() csconfig.set_cl() + csconfig.set_address() - csredundant = CsRedundant(csconfig, "address") + csredundant = CsRedundant(csconfig) self.assertTrue(csredundant is not None) if __name__ == '__main__':