Merge ~freyes/maas:lp1880495 into maas:2.3

Proposed by Felipe Reyes
Status: Rejected
Rejected by: Adam Collard
Proposed branch: ~freyes/maas:lp1880495
Merge into: maas:2.3
Diff against target: 25 lines (+13/-1)
1 file modified
src/maasserver/migrations/builtin/maasserver/0011_domain_data.py (+13/-1)
Reviewer Review Type Date Requested Status
Adam Collard (community) Needs Fixing
MAAS Lander Approve
Review via email: mp+384587@code.launchpad.net

Description of the change

I'm proposing this change to get feedback, I understand that I'll need to first propose it against master and then backport it to previous releases.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1880495 lp:~freyes/maas/+git/maas into -b 2.3 lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 6c45d678beb67db8a1c5b0e1836e99a45c3dabb8

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

Hi, change looks good.

To remove dependencies on model code, these imports should also br dropped:

import maasserver.models.dnsresource
from maasserver.models.domain import DEFAULT_DOMAIN_NAME
import maasserver.models.node

DEFAULT_DOMAIN_NAME can be just defined locally with the same value, the others are actually unused.

Note that the patch is at a different location in master (src/maasserver/migrations/maasserver/0011_domain_data.py), but other than that the change should apply cleanly.

Thanks!

Revision history for this message
Adam Collard (adam-collard) :
review: Needs Fixing

Unmerged commits

6c45d67... by Felipe Reyes

LP: #1880495 - Use get_or_create() in migration step

The function get_default_domain() sets the ttl which during the migration
step 0011 is not present in the database yet. This patch uses get_or_create()
instead to get the 'maas' domain object with the same defaults that
get_default_domain() uses.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/migrations/builtin/maasserver/0011_domain_data.py b/src/maasserver/migrations/builtin/maasserver/0011_domain_data.py
index 7e965d6..30a7cba 100644
--- a/src/maasserver/migrations/builtin/maasserver/0011_domain_data.py
+++ b/src/maasserver/migrations/builtin/maasserver/0011_domain_data.py
@@ -106,7 +106,19 @@ def migrate_staticipaddress_hostname(apps, schema_editor):
106 if len(domains):106 if len(domains):
107 domain_id = domains.pop().id107 domain_id = domains.pop().id
108 else:108 else:
109 domain_id = maasserver.models.dnsresource.get_default_domain()109 now = datetime.datetime.now()
110 domain, _ = Domain.objects.get_or_create(
111 id=0,
112 defaults={
113 'id': 0,
114 'name': DEFAULT_DOMAIN_NAME,
115 'authoritative': True,
116 'created': now,
117 'updated': now,
118 }
119 )
120 domain_id = domain.id
121
110 now = datetime.datetime.now()122 now = datetime.datetime.now()
111 dnsrr, _ = DNSResource.objects.get_or_create(123 dnsrr, _ = DNSResource.objects.get_or_create(
112 name=hostname,124 name=hostname,

Subscribers

People subscribed via source and target branches