Merge lp:~rvb/maas/bug-1064210-dns 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: | 1233 | ||||
Proposed branch: | lp:~rvb/maas/bug-1064210-dns | ||||
Merge into: | lp:~maas-committers/maas/trunk | ||||
Diff against target: |
88 lines (+38/-1) 2 files modified
src/maasserver/models/dhcplease.py (+10/-1) src/maasserver/tests/test_dhcplease.py (+28/-0) |
||||
To merge this branch: | bzr merge lp:~rvb/maas/bug-1064210-dns | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email:
|
Commit message
Strip out the domain part of the hostnames used to write out the DNS config files.
Description of the change
This branch is a band aid fix: strip out the domain part of the hostnames used to write out the DNS config files. Note that we can't really remove the domain part of the hostnames altogether because we need to be able to name nodes like 'hostname.local'.
To post a comment you must log in.
Besides the miscellaneous code notes (see below), I do have to wonder where we use the domain name that's in Node.hostname at all. We also ignore the domain name in pxeconfig(), using the nodegroup's domain instead. Giving users the option to edit the domain name isn't much good if it doesn't go anywhere!
The only use I can find for the domain is in get_preseed_ filenames, and I'm not sure it's essential there. So maybe we should either leave the domain name out of Node.hostname altogether, or make it optional (and by default either leave it out, or use the nodegroup's domain).
.
In src/maasserver/ models/ dhcplease. py, around l.30:
8 +def strip_out_ domain( hostname) :
9 + """Remove the domain part of a hostname, if any."""
10 + return hostname.split('.', 1)[0]
I'd omit the “out” from the name — just “strip” has a clear meaning in python, well established by convention. Saying “strip out” instead makes me think you may mean something different, such as returning the domain instead of the host part.
To follow the conventions even more, maybe the docstring could say “Return `hostname` with the domain part removed”?
.
In src/maasserver/ models/ dhcplease. py, l.144 or so:
28 - return dict(cursor. fetchall( )) out_domain( hostname) , ip)
29 + return dict([
30 + (strip_
31 + for hostname, ip in cursor.fetchall()
32 + ])
You don't need the square brackets.
Jeroen