1
Origin: upstream, https://github.com/openstack/nova/commit/6415999523d26f1680265e5ca438020b7d6542c6
2
Bug: https://bugs.launchpad.net/nova/+bug/854614
3
From 6415999523d26f1680265e5ca438020b7d6542c6 Mon Sep 17 00:00:00 2001
4
From: Scott Moser <smoser@ubuntu.com>
5
Date: Fri, 23 Sep 2011 16:44:44 -0400
6
Subject: [PATCH] put fully qualified domain name in local-hostname
8
make metadata service return fully qualified domain name (fqdn) in
9
the local-hostname field. (bug 854614)
11
Also, move the dhcp_domain flag from being in nova.network.linux_net to be
12
in the more common nova.network.manager. Since it is being used for
13
something more generic, it shouldnt be stuck in linux_net.
16
Change-Id: Ieab3cb1b7b0b78aff8df25bbc35b96924a8e7e60
18
nova/api/ec2/cloud.py | 3 ++-
19
nova/network/linux_net.py | 3 ---
20
nova/network/manager.py | 3 +++
21
nova/tests/test_metadata.py | 8 ++++++++
22
4 files changed, 13 insertions(+), 4 deletions(-)
24
--- a/nova/api/ec2/cloud.py
25
+++ b/nova/api/ec2/cloud.py
26
@@ -52,6 +52,7 @@ from nova.image import s3
30
+flags.DECLARE('dhcp_domain', 'nova.network.manager')
31
flags.DECLARE('service_down_time', 'nova.scheduler.driver')
33
LOG = logging.getLogger("nova.api.cloud")
34
@@ -326,7 +327,7 @@ class CloudController(object):
35
instance_ref = db.instance_get(ctxt, instance_ref[0]['id'])
37
mpi = self._get_mpi_data(ctxt, instance_ref['project_id'])
38
- hostname = instance_ref['hostname']
39
+ hostname = "%s.%s" % (instance_ref['hostname'], FLAGS.dhcp_domain)
40
host = instance_ref['host']
41
availability_zone = self._get_availability_zone_by_host(ctxt, host)
42
floating_ip = db.instance_get_floating_address(ctxt,
43
--- a/nova/network/linux_net.py
44
+++ b/nova/network/linux_net.py
45
@@ -42,9 +42,6 @@ FLAGS = flags.FLAGS
46
flags.DEFINE_string('dhcpbridge_flagfile',
47
'/etc/nova/nova-dhcpbridge.conf',
48
'location of flagfile for dhcpbridge')
49
-flags.DEFINE_string('dhcp_domain',
51
- 'domain to use for building the hostnames')
52
flags.DEFINE_string('networks_path', '$state_path/networks',
53
'Location to keep network config files')
54
flags.DEFINE_string('public_interface', 'eth0',
55
--- a/nova/network/manager.py
56
+++ b/nova/network/manager.py
57
@@ -112,6 +112,9 @@ flags.DEFINE_bool('fake_call', False,
58
'If True, skip using the queue and make local calls')
59
flags.DEFINE_bool('force_dhcp_release', False,
60
'If True, send a dhcp release on instance termination')
61
+flags.DEFINE_string('dhcp_domain',
63
+ 'domain to use for building the hostnames')
66
class AddressAlreadyAllocated(exception.Error):
67
--- a/nova/tests/test_metadata.py
68
+++ b/nova/tests/test_metadata.py
69
@@ -24,12 +24,16 @@ import httplib
72
from nova import exception
73
+from nova import flags
76
from nova.api.ec2 import metadatarequesthandler
77
from nova.db.sqlalchemy import api
81
+flags.DECLARE('dhcp_domain', 'nova.network.manager')
83
USER_DATA_STRING = ("This is an encoded string")
84
ENCODE_USER_DATA_STRING = base64.b64encode(USER_DATA_STRING)
86
@@ -119,3 +123,7 @@ class MetadataTestCase(test.TestCase):
87
response = request.get_response(self.app)
88
self.assertEqual(response.status_int, 200)
89
self.assertEqual(response.body, USER_DATA_STRING)
91
+ def test_local_hostname_fqdn(self):
92
+ self.assertEqual(self.request('/meta-data/local-hostname'),
93
+ "%s.%s" % (self.instance['hostname'], FLAGS.dhcp_domain))