mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
get_dns via guest network returns blank dns servers
fixed and added unit test
This commit is contained in:
parent
84ba06b87d
commit
fb094ecafd
@ -36,7 +36,16 @@ class CsGuestNetwork:
|
|||||||
return self.guest
|
return self.guest
|
||||||
|
|
||||||
def get_dns(self):
|
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):
|
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.
|
#We need to fix it properly. I just added the if, as Ian did in some other files, to avoid the exception.
|
||||||
|
|||||||
@ -12,5 +12,16 @@ class TestCsGuestNetwork(unittest.TestCase):
|
|||||||
csguestnetwork = CsGuestNetwork({}, {})
|
csguestnetwork = CsGuestNetwork({}, {})
|
||||||
self.assertTrue(csguestnetwork is not None)
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user