summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Patil <tushar.vitthal.patil@gmail.com>2011-09-07 13:10:05 -0700
committerTushar Patil <tushar.vitthal.patil@gmail.com>2011-09-07 13:10:05 -0700
commita158d5721c18902b290a42bb3874b34e54dbcd7b (patch)
tree332b478a813c8435de86171794a620c100364430
parent53357516226a1c00217c742eb512b7efc0f574b2 (diff)
downloadnova-a158d5721c18902b290a42bb3874b34e54dbcd7b.tar.gz
nova-a158d5721c18902b290a42bb3874b34e54dbcd7b.tar.xz
nova-a158d5721c18902b290a42bb3874b34e54dbcd7b.zip
exclude net tag from host_dhcp if use_single_default_gateway flag is set to false
-rwxr-xr-xnova/network/linux_net.py17
-rwxr-xr-xnova/tests/test_linux_net.py6
2 files changed, 18 insertions, 5 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index affdde701..7d89b2bcc 100755
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -672,11 +672,18 @@ def _host_dhcp_network(fixed_ip_ref):
def _host_dhcp(fixed_ip_ref):
"""Return a host string for an address in dhcp-host format."""
instance_ref = fixed_ip_ref['instance']
- return '%s,%s.%s,%s,%s' % (fixed_ip_ref['virtual_interface']['address'],
- instance_ref['hostname'],
- FLAGS.dhcp_domain,
- fixed_ip_ref['address'],
- "net:" + _host_dhcp_network(fixed_ip_ref))
+ vif = fixed_ip_ref['virtual_interface']
+ if FLAGS.use_single_default_gateway:
+ return '%s,%s.%s,%s,%s' % (vif['address'],
+ instance_ref['hostname'],
+ FLAGS.dhcp_domain,
+ fixed_ip_ref['address'],
+ "net:" + _host_dhcp_network(fixed_ip_ref))
+ else:
+ return '%s,%s.%s,%s' % (vif['address'],
+ instance_ref['hostname'],
+ FLAGS.dhcp_domain,
+ fixed_ip_ref['address'])
def _host_dhcp_opts(fixed_ip_ref):
diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py
index 4c72f1e0f..6d0a2b6bd 100755
--- a/nova/tests/test_linux_net.py
+++ b/nova/tests/test_linux_net.py
@@ -337,3 +337,9 @@ class LinuxNetworkTestCase(test.TestCase):
expected = "NW-i00000000-0,3"
actual = self.driver._host_dhcp_opts(fixed_ips[0])
self.assertEquals(actual, expected)
+
+ def test_host_dhcp_without_default_gateway_network(self):
+ self.flags(use_single_default_gateway=False)
+ expected = ("10.0.0.1,fake_instance00.novalocal,192.168.0.100")
+ actual = self.driver._host_dhcp(fixed_ips[0])
+ self.assertEquals(actual, expected)