Merge lp:~rvb/maas/maas-fqdn into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3937
Proposed branch: lp:~rvb/maas/maas-fqdn
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 162 lines (+51/-13)
5 files modified
src/maasserver/api/tests/test_enlistment.py (+12/-3)
src/maasserver/api/tests/test_node.py (+10/-2)
src/maasserver/api/tests/test_nodes.py (+8/-2)
src/maasserver/models/node.py (+9/-5)
src/maasserver/models/tests/test_node.py (+12/-1)
To merge this branch: bzr merge lp:~rvb/maas/maas-fqdn
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+259940@code.launchpad.net

Commit message

Use the domain name from the cluster to compute the node's fqdn if the node doesn't have one.

Description of the change

The reasoning here is that all nodes should have a domain name part in the fqdn… but we still want to let people specify their own domain name on a per-node basis (might be useful if they are using an external DNS server, completely external to MAAS).

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (90.5 KiB)

The attempt to merge lp:~rvb/maas/maas-fqdn into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Get:2 http://security.ubuntu.com trusty-security Release [63.5 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [63.5 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [81.4 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:6 http://security.ubuntu.com trusty-security/universe Sources [25.2 kB]
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [272 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:8 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [205 kB]
Get:9 http://security.ubuntu.com trusty-security/universe amd64 Packages [104 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [117 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [524 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [280 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,738 kB in 3s (557 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-iscpy python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (90.6 KiB)

The attempt to merge lp:~rvb/maas/maas-fqdn into lp:maas failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Get:2 http://security.ubuntu.com trusty-security Release [63.5 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [63.5 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [81.4 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:6 http://security.ubuntu.com trusty-security/universe Sources [25.2 kB]
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [272 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [104 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [205 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [117 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [524 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [280 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,738 kB in 3s (526 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-iscpy python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python...

Revision history for this message
MAAS Lander (maas-lander) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/tests/test_enlistment.py'
2--- src/maasserver/api/tests/test_enlistment.py 2015-05-20 13:28:39 +0000
3+++ src/maasserver/api/tests/test_enlistment.py 2015-05-26 07:23:18 +0000
4@@ -71,7 +71,10 @@
5 self.assertEqual(httplib.OK, response.status_code)
6 parsed_result = json.loads(response.content)
7 self.assertIn('application/json', response['Content-Type'])
8- self.assertEqual('diane', parsed_result['hostname'])
9+ nodegroup = NodeGroup.objects.ensure_master()
10+ domain_name = nodegroup.name
11+ self.assertEqual(
12+ 'diane.%s' % domain_name, parsed_result['hostname'])
13 self.assertNotEqual(0, len(parsed_result.get('system_id')))
14 [diane] = Node.objects.filter(hostname='diane')
15 self.assertEqual(architecture, diane.architecture)
16@@ -140,7 +143,10 @@
17 self.assertEqual(httplib.OK, response.status_code)
18 parsed_result = json.loads(response.content)
19 self.assertIn('application/json', response['Content-Type'])
20- self.assertEqual('diane', parsed_result['hostname'])
21+ nodegroup = NodeGroup.objects.ensure_master()
22+ domain_name = nodegroup.name
23+ self.assertEqual(
24+ 'diane.%s' % domain_name, parsed_result['hostname'])
25 self.assertNotEqual(0, len(parsed_result.get('system_id')))
26 [diane] = Node.objects.filter(hostname='diane')
27 self.assertEqual(architecture, diane.architecture)
28@@ -163,7 +169,10 @@
29 self.assertEqual(httplib.OK, response.status_code)
30 parsed_result = json.loads(response.content)
31 self.assertIn('application/json', response['Content-Type'])
32- self.assertEqual('diane', parsed_result['hostname'])
33+ nodegroup = NodeGroup.objects.ensure_master()
34+ domain_name = nodegroup.name
35+ self.assertEqual(
36+ 'diane.%s' % domain_name, parsed_result['hostname'])
37 self.assertNotEqual(0, len(parsed_result.get('system_id')))
38 [diane] = Node.objects.filter(hostname='diane')
39 self.assertEqual(architecture, diane.architecture)
40
41=== modified file 'src/maasserver/api/tests/test_node.py'
42--- src/maasserver/api/tests/test_node.py 2015-05-20 13:51:22 +0000
43+++ src/maasserver/api/tests/test_node.py 2015-05-26 07:23:18 +0000
44@@ -39,6 +39,7 @@
45 MACAddress,
46 Node,
47 node as node_module,
48+ NodeGroup,
49 StaticIPAddress,
50 )
51 from maasserver.models.node import RELEASABLE_STATUSES
52@@ -150,7 +151,11 @@
53
54 self.assertEqual(httplib.OK, response.status_code)
55 parsed_result = json.loads(response.content)
56- self.assertEqual(node.hostname, parsed_result['hostname'])
57+ nodegroup = NodeGroup.objects.ensure_master()
58+ domain_name = nodegroup.name
59+ self.assertEqual(
60+ "%s.%s" % (node.hostname, domain_name),
61+ parsed_result['hostname'])
62 self.assertEqual(node.system_id, parsed_result['system_id'])
63
64 def test_GET_returns_associated_tag(self):
65@@ -620,7 +625,10 @@
66 parsed_result = json.loads(response.content)
67
68 self.assertEqual(httplib.OK, response.status_code)
69- self.assertEqual('francis', parsed_result['hostname'])
70+ nodegroup = NodeGroup.objects.ensure_master()
71+ domain_name = nodegroup.name
72+ self.assertEqual(
73+ 'francis.%s' % domain_name, parsed_result['hostname'])
74 self.assertEqual(0, Node.objects.filter(hostname='diane').count())
75 self.assertEqual(1, Node.objects.filter(hostname='francis').count())
76
77
78=== modified file 'src/maasserver/api/tests/test_nodes.py'
79--- src/maasserver/api/tests/test_nodes.py 2015-05-22 15:52:13 +0000
80+++ src/maasserver/api/tests/test_nodes.py 2015-05-26 07:23:18 +0000
81@@ -848,7 +848,10 @@
82 })
83 self.assertEqual(httplib.OK, response.status_code)
84 parsed_result = json.loads(response.content)
85- self.assertEqual(desired_node.hostname, parsed_result['hostname'])
86+ domain_name = desired_node.nodegroup.name
87+ self.assertEqual(
88+ "%s.%s" % (desired_node.hostname, domain_name),
89+ parsed_result['hostname'])
90
91 def test_POST_acquire_would_rather_fail_than_disobey_constraint(self):
92 # If "acquire" is passed a constraint, it won't return a node
93@@ -883,8 +886,11 @@
94 'name': node.hostname,
95 })
96 self.assertEqual(httplib.OK, response.status_code)
97+ nodegroup = NodeGroup.objects.ensure_master()
98+ domain_name = nodegroup.name
99 self.assertEqual(
100- node.hostname, json.loads(response.content)['hostname'])
101+ "%s.%s" % (node.hostname, domain_name),
102+ json.loads(response.content)['hostname'])
103
104 def test_POST_acquire_treats_unknown_name_as_resource_conflict(self):
105 # A name constraint naming an unknown node produces a resource
106
107=== modified file 'src/maasserver/models/node.py'
108--- src/maasserver/models/node.py 2015-05-21 19:32:24 +0000
109+++ src/maasserver/models/node.py 2015-05-26 07:23:18 +0000
110@@ -531,12 +531,16 @@
111 def fqdn(self):
112 """Fully qualified domain name for this node.
113
114- If MAAS manages DNS for this node, the domain part of the
115- hostname (if present), is replaced by the domain configured
116- on the cluster controller.
117- If not, simply return the node's hostname.
118+ If MAAS manages DNS for this node or if this node doesn't have a
119+ domain name set, replace or add the domain name configured
120+ on the cluster controller. Otherwise simply return the node's
121+ hostname.
122 """
123- if self.nodegroup.manages_dns():
124+ should_add_domain_name = (
125+ self.nodegroup.manages_dns() or
126+ self.hostname == strip_domain(self.hostname)
127+ )
128+ if should_add_domain_name:
129 return nodegroup_fqdn(self.hostname, self.nodegroup.name)
130 return self.hostname
131
132
133=== modified file 'src/maasserver/models/tests/test_node.py'
134--- src/maasserver/models/tests/test_node.py 2015-05-22 15:52:13 +0000
135+++ src/maasserver/models/tests/test_node.py 2015-05-26 07:23:18 +0000
136@@ -1661,7 +1661,7 @@
137 node.nodegroup = None
138 self.assertRaises(ValidationError, node.save)
139
140- def test_fqdn_returns_hostname_if_dns_not_managed(self):
141+ def test_fqdn_if_dns_not_managed_and_has_domain_name(self):
142 nodegroup = factory.make_NodeGroup(
143 name=factory.make_string(),
144 management=NODEGROUPINTERFACE_MANAGEMENT.DHCP)
145@@ -1671,6 +1671,17 @@
146 nodegroup=nodegroup, hostname=hostname_with_domain)
147 self.assertEqual(hostname_with_domain, node.fqdn)
148
149+ def test_fqdn_if_dns_not_managed_and_no_domain_name(self):
150+ domain = factory.make_name('domain')
151+ nodegroup = factory.make_NodeGroup(
152+ name=domain,
153+ management=NODEGROUPINTERFACE_MANAGEMENT.DHCP)
154+ hostname_without_domain = factory.make_string()
155+ node = factory.make_Node(
156+ nodegroup=nodegroup, hostname=hostname_without_domain)
157+ self.assertEqual(
158+ "%s.%s" % (hostname_without_domain, domain), node.fqdn)
159+
160 def test_fqdn_replaces_hostname_if_dns_is_managed(self):
161 hostname_without_domain = factory.make_name('hostname')
162 hostname_with_domain = '%s.%s' % (