launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12613
[Merge] lp:~rvb/maas/do-not-require-name into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/do-not-require-name into lp:maas.
Commit message:
This branch relaxes the constraint on Nodegroup.name so that the form can override an empty value when it sees one to use a default value ('master').
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/do-not-require-name/+merge/126871
This change goes hand in hand with the branch https://code.launchpad.net/~allenap/maas/dns-zone-sharing/+merge/126682 that remove the uniqueness of this field on the model.
--
https://code.launchpad.net/~rvb/maas/do-not-require-name/+merge/126871
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/do-not-require-name into lp:maas.
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-09-28 05:11:12 +0000
+++ src/maasserver/forms.py 2012-09-28 07:36:21 +0000
@@ -694,6 +694,10 @@
"the information needed to initialize an interface.")
+# The zone name used for nodegroups when none is explicitly provided.
+DEFAULT_ZONE_NAME = 'master'
+
+
class NodeGroupWithInterfacesForm(ModelForm):
"""Create a NodeGroup with unmanaged interfaces."""
@@ -710,6 +714,13 @@
super(NodeGroupWithInterfacesForm, self).__init__(*args, **kwargs)
self.status = status
+ def clean_name(self):
+ data = self.cleaned_data['name']
+ if data == '':
+ return DEFAULT_ZONE_NAME
+ else:
+ return data
+
def clean_interfaces(self):
data = self.cleaned_data['interfaces']
# Stop here if the data is empty.
=== modified file 'src/maasserver/models/nodegroup.py'
--- src/maasserver/models/nodegroup.py 2012-09-27 08:26:33 +0000
+++ src/maasserver/models/nodegroup.py 2012-09-28 07:36:21 +0000
@@ -118,7 +118,7 @@
# A node group's name is also used for the group's DNS zone.
name = CharField(
- max_length=80, unique=True, editable=True, blank=False, null=False)
+ max_length=80, unique=True, editable=True, blank=True, null=False)
status = IntegerField(
choices=NODEGROUP_STATUS_CHOICES, editable=False,
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-09-28 05:11:12 +0000
+++ src/maasserver/tests/test_api.py 2012-09-28 07:36:21 +0000
@@ -59,6 +59,7 @@
)
from maasserver.exceptions import Unauthorized
from maasserver.fields import mac_error_msg
+from maasserver.forms import DEFAULT_ZONE_NAME
from maasserver.models import (
BootImage,
Config,
@@ -2811,6 +2812,19 @@
MatchesStructure.byEquality(**interface))
self.assertEqual(NODEGROUP_STATUS.ACCEPTED, master.status)
+ def test_register_nodegroup_uses_default_zone_name(self):
+ uuid = factory.getRandomUUID()
+ self.client.post(
+ reverse('nodegroups_handler'),
+ {
+ 'op': 'register',
+ 'uuid': uuid,
+ })
+ master = NodeGroup.objects.ensure_master()
+ self.assertEqual(
+ (NODEGROUP_STATUS.ACCEPTED, DEFAULT_ZONE_NAME),
+ (master.status, master.name))
+
def test_register_accepts_only_one_managed_interface(self):
self.create_configured_master()
name = factory.make_name('name')