← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/improv-settings into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/improv-settings into lp:maas.

Commit message:
This branch adds the ability to change the value of the config settings default_distro_series and commissioning_distro_series on the settings page.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/improv-settings/+merge/126689

This branch adds the ability to change the value of the config settings default_distro_series and commissioning_distro_series on the settings page.
-- 
https://code.launchpad.net/~rvb/maas/improv-settings/+merge/126689
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/improv-settings into lp:maas.
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py	2012-09-26 16:30:00 +0000
+++ src/maasserver/forms.py	2012-09-27 13:54:20 +0000
@@ -55,7 +55,6 @@
 from maasserver.enum import (
     ARCHITECTURE,
     ARCHITECTURE_CHOICES,
-    DISTRO_SERIES,
     DISTRO_SERIES_CHOICES,
     NODE_AFTER_COMMISSIONING_ACTION,
     NODE_AFTER_COMMISSIONING_ACTION_CHOICES,
@@ -121,12 +120,6 @@
         choices=NODE_AFTER_COMMISSIONING_ACTION_CHOICES, required=False,
         empty_value=NODE_AFTER_COMMISSIONING_ACTION.DEFAULT)
 
-    distro_series = forms.ChoiceField(
-        choices=DISTRO_SERIES_CHOICES, required=False,
-        initial=DISTRO_SERIES.default,
-        label="Release",
-        error_messages={'invalid_choice': INVALID_DISTRO_SERIES_MESSAGE})
-
     architecture = forms.ChoiceField(
         choices=ARCHITECTURE_CHOICES, required=True,
         initial=ARCHITECTURE.i386,
@@ -576,6 +569,10 @@
     after_commissioning = forms.ChoiceField(
         choices=NODE_AFTER_COMMISSIONING_ACTION_CHOICES,
         label="After commissioning")
+    commissioning_distro_series = forms.ChoiceField(
+        choices=DISTRO_SERIES_CHOICES, required=False,
+        label="Default distro series used for commissioning",
+        error_messages={'invalid_choice': INVALID_DISTRO_SERIES_MESSAGE})
 
 
 class UbuntuForm(ConfigForm):
@@ -583,6 +580,10 @@
     fallback_master_archive = forms.BooleanField(
         label="Fallback to Ubuntu master archive",
         required=False)
+    default_distro_series = forms.ChoiceField(
+        choices=DISTRO_SERIES_CHOICES, required=False,
+        label="Default distro series used for deployment",
+        error_messages={'invalid_choice': INVALID_DISTRO_SERIES_MESSAGE})
     keep_mirror_list_uptodate = forms.BooleanField(
         label="Keep mirror list up to date",
         required=False)

=== modified file 'src/maasserver/models/config.py'
--- src/maasserver/models/config.py	2012-09-19 14:07:52 +0000
+++ src/maasserver/models/config.py	2012-09-27 13:54:20 +0000
@@ -51,9 +51,9 @@
         # Network section configuration.
         'maas_name': gethostname(),
         'enlistment_domain': b'local',
-        ## /settings
         'default_distro_series': DISTRO_SERIES.precise,
         'commissioning_distro_series': DISTRO_SERIES.precise,
+        ## /settings
         }
 
 

=== modified file 'src/maasserver/templates/maasserver/settings.html'
--- src/maasserver/templates/maasserver/settings.html	2012-08-03 16:36:26 +0000
+++ src/maasserver/templates/maasserver/settings.html	2012-09-27 13:54:20 +0000
@@ -90,6 +90,9 @@
         {% with field=ubuntu_form.update_from %}
           {% include "maasserver/form_field.html" %}
         {% endwith %}
+        {% with field=ubuntu_form.default_distro_series %}
+          {% include "maasserver/form_field.html" %}
+        {% endwith %}
         <li>
           <label>Custom archives</label>
           <a href="{% url "settings-add-archive" %}">

=== modified file 'src/maasserver/tests/test_views_settings.py'
--- src/maasserver/tests/test_views_settings.py	2012-09-18 16:36:51 +0000
+++ src/maasserver/tests/test_views_settings.py	2012-09-27 13:54:20 +0000
@@ -18,7 +18,10 @@
 from django.contrib.auth.models import User
 from django.core.urlresolvers import reverse
 from lxml.html import fromstring
-from maasserver.enum import NODE_AFTER_COMMISSIONING_ACTION
+from maasserver.enum import (
+    DISTRO_SERIES,
+    NODE_AFTER_COMMISSIONING_ACTION,
+    )
 from maasserver.models import (
     Config,
     UserProfile,
@@ -96,6 +99,7 @@
         new_after_commissioning = factory.getRandomEnum(
             NODE_AFTER_COMMISSIONING_ACTION)
         new_check_compatibility = factory.getRandomBoolean()
+        new_commissioning_distro_series = factory.getRandomEnum(DISTRO_SERIES)
         response = self.client.post(
             '/settings/',
             get_prefixed_form_data(
@@ -103,15 +107,22 @@
                 data={
                     'after_commissioning': new_after_commissioning,
                     'check_compatibility': new_check_compatibility,
+                    'commissioning_distro_series':
+                        new_commissioning_distro_series,
                 }))
 
         self.assertEqual(httplib.FOUND, response.status_code)
         self.assertEqual(
-            new_after_commissioning,
-            Config.objects.get_config('after_commissioning'))
-        self.assertEqual(
-            new_check_compatibility,
-            Config.objects.get_config('check_compatibility'))
+            (
+                new_after_commissioning,
+                new_check_compatibility,
+                new_commissioning_distro_series,
+            ),
+            (
+                Config.objects.get_config('after_commissioning'),
+                Config.objects.get_config('check_compatibility'),
+                Config.objects.get_config('commissioning_distro_series'),
+            ))
 
     def test_settings_ubuntu_POST(self):
         new_fallback_master_archive = factory.getRandomBoolean()
@@ -119,6 +130,7 @@
         new_fetch_new_releases = factory.getRandomBoolean()
         choices = Config.objects.get_config('update_from_choice')
         new_update_from = factory.getRandomChoice(choices)
+        new_default_distro_series = factory.getRandomEnum(DISTRO_SERIES)
         response = self.client.post(
             '/settings/',
             get_prefixed_form_data(
@@ -128,20 +140,25 @@
                     'keep_mirror_list_uptodate': new_keep_mirror_list_uptodate,
                     'fetch_new_releases': new_fetch_new_releases,
                     'update_from': new_update_from,
+                    'default_distro_series': new_default_distro_series,
                 }))
 
         self.assertEqual(httplib.FOUND, response.status_code)
         self.assertEqual(
-            new_fallback_master_archive,
-            Config.objects.get_config('fallback_master_archive'))
-        self.assertEqual(
-            new_keep_mirror_list_uptodate,
-            Config.objects.get_config('keep_mirror_list_uptodate'))
-        self.assertEqual(
-            new_fetch_new_releases,
-            Config.objects.get_config('fetch_new_releases'))
-        self.assertEqual(
-            new_update_from, Config.objects.get_config('update_from'))
+            (
+                new_fallback_master_archive,
+                new_keep_mirror_list_uptodate,
+                new_fetch_new_releases,
+                new_update_from,
+                new_default_distro_series,
+            ),
+            (
+                Config.objects.get_config('fallback_master_archive'),
+                Config.objects.get_config('keep_mirror_list_uptodate'),
+                Config.objects.get_config('fetch_new_releases'),
+                Config.objects.get_config('update_from'),
+                Config.objects.get_config('default_distro_series'),
+            ))
 
     def test_settings_add_archive_POST(self):
         choices = Config.objects.get_config('update_from_choice')


Follow ups