Merge lp:~rvb/maas/metadata-fix-hostname into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 1351
Proposed branch: lp:~rvb/maas/metadata-fix-hostname
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 51 lines (+15/-5)
2 files modified
src/metadataserver/api.py (+1/-1)
src/metadataserver/tests/test_api.py (+14/-4)
To merge this branch: bzr merge lp:~rvb/maas/metadata-fix-hostname
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+134302@code.launchpad.net

Commit message

Return node.fqdn instead of node.hostname in the metadataservice.

Description of the change

Return node.fqdn instead of node.hostname in the metadataservice.

= Notes =

I've tested that this fixes the problem described in the bug on my HP microservers.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :
Revision history for this message
Raphaël Badin (rvb) wrote :

I had to create another proposal for the 1.2 branch (I targeted the wrong branch), here is the right MP: https://code.launchpad.net/~rvb/maas/metadata-fix-hostname-1.2/+merge/134305

Revision history for this message
Julian Edwards (julian-edwards) wrote :

I hate it that these base properties are exposed - it results in bugs like this. Is there any way we can encapsulate these in another properly, e.g. hostname_for_external_use? We should then make the other properties private.

I realise this is not really possible right now though :(

(I will land this now as I want to use it)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/metadataserver/api.py'
2--- src/metadataserver/api.py 2012-11-08 06:34:48 +0000
3+++ src/metadataserver/api.py 2012-11-14 14:40:28 +0000
4@@ -310,7 +310,7 @@
5
6 def local_hostname(self, node, version, item):
7 """Produce local-hostname attribute."""
8- return make_text_response(node.hostname)
9+ return make_text_response(node.fqdn)
10
11 def instance_id(self, node, version, item):
12 """Produce instance-id attribute."""
13
14=== modified file 'src/metadataserver/tests/test_api.py'
15--- src/metadataserver/tests/test_api.py 2012-10-05 14:11:43 +0000
16+++ src/metadataserver/tests/test_api.py 2012-11-14 14:40:28 +0000
17@@ -20,7 +20,11 @@
18 from django.conf import settings
19 from django.core.exceptions import PermissionDenied
20 from django.core.urlresolvers import reverse
21-from maasserver.enum import NODE_STATUS
22+from maasserver.enum import (
23+ NODE_STATUS,
24+ NODEGROUP_STATUS,
25+ NODEGROUPINTERFACE_MANAGEMENT,
26+ )
27 from maasserver.exceptions import (
28 MAASAPINotFound,
29 Unauthorized,
30@@ -220,13 +224,19 @@
31 producers = map(handler.get_attribute_producer, handler.fields)
32 self.assertNotIn(None, producers)
33
34- def test_meta_data_local_hostname_returns_hostname(self):
35+ def test_meta_data_local_hostname_returns_fqdn(self):
36+ nodegroup = factory.make_node_group(
37+ status=NODEGROUP_STATUS.ACCEPTED,
38+ management=NODEGROUPINTERFACE_MANAGEMENT.DHCP_AND_DNS)
39 hostname = factory.getRandomString()
40- client = self.make_node_client(factory.make_node(hostname=hostname))
41+ domain = factory.getRandomString()
42+ node = factory.make_node(
43+ hostname='%s.%s' % (hostname, domain), nodegroup=nodegroup)
44+ client = self.make_node_client(node)
45 url = reverse('metadata-meta-data', args=['latest', 'local-hostname'])
46 response = client.get(url)
47 self.assertEqual(
48- (httplib.OK, hostname),
49+ (httplib.OK, node.fqdn),
50 (response.status_code, response.content.decode('ascii')))
51 self.assertIn('text/plain', response['Content-Type'])
52