diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsGuestNetwork.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsGuestNetwork.py index c15e0062e68..43f209a5818 100644 --- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsGuestNetwork.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsGuestNetwork.py @@ -36,7 +36,16 @@ class CsGuestNetwork: return self.guest def get_dns(self): - return self.config.get_dns() + if not self.guest: + return self.config.get_dns() + # Can a router provide dhcp but not dns? + return [ self.data['router_guest_gateway'] ] + self.data['dns'].split(',') + + def set_dns(self, val): + self.data['dns'] = val + + def set_router(self, val): + self.data['router_guest_gateway'] = val def get_netmask(self): #We need to fix it properly. I just added the if, as Ian did in some other files, to avoid the exception. diff --git a/systemvm/test/python/TestCsGuestNetwork.py b/systemvm/test/python/TestCsGuestNetwork.py index 34dd329a2bc..ba774b8907f 100644 --- a/systemvm/test/python/TestCsGuestNetwork.py +++ b/systemvm/test/python/TestCsGuestNetwork.py @@ -12,5 +12,16 @@ class TestCsGuestNetwork(unittest.TestCase): csguestnetwork = CsGuestNetwork({}, {}) self.assertTrue(csguestnetwork is not None) + def test_get_dns(self): + csguestnetwork = CsGuestNetwork({}, {}) + csguestnetwork.guest = True + csguestnetwork.set_dns("1.1.1.1,2.2.2.2") + csguestnetwork.set_router("3.3.3.3") + dns = csguestnetwork.get_dns() + self.assertTrue(len(dns) == 3) + csguestnetwork.set_dns("1.1.1.1") + dns = csguestnetwork.get_dns() + self.assertTrue(len(dns) == 2) + if __name__ == '__main__': unittest.main()