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/4afb007f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4afb007f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4afb007f

Branch: refs/heads/feature/systemvm-persistent-config
Commit: 4afb007fae7c337e620896e141a1f0852bc1eae3
Parents: 43c9a25
Author: Ian Southam <[email protected]>
Authored: Mon Jan 19 17:25:17 2015 +0100
Committer: wilderrodrigues <[email protected]>
Committed: Mon Feb 16 16:08:35 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/4afb007f/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/4afb007f/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()

Reply via email to