get_dns via guest network returns blank dns servers fixed and added unit test
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ee868a00 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ee868a00 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ee868a00 Branch: refs/heads/feature/systemvm-persistent-config Commit: ee868a003e0c03f908f3c25661f5b1624c2f5a61 Parents: b45aa8d Author: Ian Southam <[email protected]> Authored: Mon Jan 19 17:25:17 2015 +0100 Committer: wilderrodrigues <[email protected]> Committed: Wed Feb 4 18:47:07 2015 +0100 ---------------------------------------------------------------------- .../debian/config/opt/cloud/bin/cs/CsGuestNetwork.py | 11 ++++++++++- systemvm/test/python/TestCsGuestNetwork.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee868a00/systemvm/patches/debian/config/opt/cloud/bin/cs/CsGuestNetwork.py ---------------------------------------------------------------------- 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 c15e006..43f209a 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. http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ee868a00/systemvm/test/python/TestCsGuestNetwork.py ---------------------------------------------------------------------- diff --git a/systemvm/test/python/TestCsGuestNetwork.py b/systemvm/test/python/TestCsGuestNetwork.py index 34dd329..ba774b8 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()
