Merge lp:~newell-jensen/maas/fix-1687487 into lp:~maas-committers/maas/trunk

Proposed by Newell Jensen
Status: Merged
Approved by: Blake Rouse
Approved revision: 6036
Merged at revision: 6039
Proposed branch: lp:~newell-jensen/maas/fix-1687487
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 23 lines (+5/-2)
1 file modified
src/maasserver/models/bmc.py (+5/-2)
To merge this branch: bzr merge lp:~newell-jensen/maas/fix-1687487
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+323643@code.launchpad.net

Commit message

Change hostname uniqueness check to use Node instead of Machine so that region, racks, etc. are checked for a potential conflicting hostname when adding a Pod.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Unit tests for this are already checking against a Node object!

Revision history for this message
Lee Trager (ltrager) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/bmc.py'
2--- src/maasserver/models/bmc.py 2017-04-24 20:56:23 +0000
3+++ src/maasserver/models/bmc.py 2017-05-04 22:05:15 +0000
4@@ -46,7 +46,10 @@
5 get_iscsi_target,
6 ISCSIBlockDevice,
7 )
8-from maasserver.models.node import Machine
9+from maasserver.models.node import (
10+ Machine,
11+ Node,
12+)
13 from maasserver.models.physicalblockdevice import PhysicalBlockDevice
14 from maasserver.models.podhints import PodHints
15 from maasserver.models.staticipaddress import StaticIPAddress
16@@ -563,7 +566,7 @@
17 discovered_machine.hostname = None
18 break
19 if discovered_machine.hostname:
20- if Machine.objects.filter(
21+ if Node.objects.filter(
22 hostname=discovered_machine.hostname).exists():
23 discovered_machine.hostname = None
24