launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14101
[Merge] lp:~rvb/maas/mirror-settings-re-2 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/mirror-settings-re-2 into lp:maas with lp:~rvb/maas/mirror-settings-re as a prerequisite.
Commit message:
Add settings to configure the main archive, the ports archive and the cloud images archive.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/mirror-settings-re-2/+merge/133461
This branch removed the old (and unused) 'update_from' setting. It adds 3 new settings used to configure the main archive, the ports archive and the cloud images archive.
The new settings now include the complete path to the archive (e.g.: http://archive.ubuntu.com/ubuntu)
= Notes =
I changed a bit the UI compared to what Julian and I discussed during the pre-imp: on second thought, I think it's much clearer to have a 'pool' of archive urls and have the 3 settings use that pool.
Screenshot: http://people.canonical.com/~rvb/settings.png
--
https://code.launchpad.net/~rvb/maas/mirror-settings-re-2/+merge/133461
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/mirror-settings-re-2 into lp:maas.
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-11-08 14:14:23 +0000
+++ src/maasserver/forms.py 2012-11-08 14:14:23 +0000
@@ -637,11 +637,28 @@
def __init__(self, *args, **kwargs):
super(UbuntuForm, self).__init__(*args, **kwargs)
- # The field 'update_from' must be added dynamically because its
+ # The archive fields must be added dynamically because their
# 'choices' must be evaluated each time the form is instantiated.
- self.fields['update_from'] = forms.ChoiceField(
- label="Update from",
- choices=Config.objects.get_config('update_from_choice'))
+ self.fields['main_archive'] = forms.ChoiceField(
+ label="Main archive",
+ choices=Config.objects.get_config('archive_choices'),
+ help_text=(
+ "Archive used by nodes to retrieve packages (Intel "
+ "architectures)."
+ ))
+ self.fields['ports_archive'] = forms.ChoiceField(
+ label="Ports archive",
+ choices=Config.objects.get_config('archive_choices'),
+ help_text=(
+ "Archive used by the nodes to retrieve packages (ARM "
+ "architectures)."
+ ))
+ self.fields['cloud_images_archive'] = forms.ChoiceField(
+ label="Cloud images archive",
+ choices=Config.objects.get_config('archive_choices'),
+ help_text=(
+ "Archive used by the nodes to retrieve cloud images."
+ ))
# The list of fields has changed: load initial values.
self._load_initials()
@@ -659,7 +676,7 @@
def validate_hostname(value):
try:
validator = URLValidator(verify_exists=False)
- validator('http://%s' % value)
+ validator(value)
except ValidationError:
raise ValidationError(hostname_error_msg)
@@ -680,9 +697,9 @@
This implementation of `save` does not support the `commit` argument.
"""
archive_name = self.cleaned_data.get('archive_name')
- archives = Config.objects.get_config('update_from_choice')
+ archives = Config.objects.get_config('archive_choices')
archives.append([archive_name, archive_name])
- Config.objects.set_config('update_from_choice', archives)
+ Config.objects.set_config('archive_choices', archives)
class NodeGroupInterfaceForm(ModelForm):
=== modified file 'src/maasserver/models/config.py'
--- src/maasserver/models/config.py 2012-11-08 06:34:48 +0000
+++ src/maasserver/models/config.py 2012-11-08 14:14:23 +0000
@@ -45,9 +45,25 @@
'fallback_master_archive': False,
'keep_mirror_list_uptodate': False,
'fetch_new_releases': False,
- 'update_from': 'archive.ubuntu.com',
- 'update_from_choice': (
- [['archive.ubuntu.com', 'archive.ubuntu.com']]),
+ 'archive_choices': (
+ [
+ [
+ 'http://archive.ubuntu.com/ubuntu',
+ 'http://archive.ubuntu.com/ubuntu'
+ ],
+ [
+ 'http://ports.ubuntu.com/ubuntu-ports',
+ 'http://ports.ubuntu.com/ubuntu-ports'
+ ],
+ [
+ 'https://maas.ubuntu.com/images',
+ 'https://maas.ubuntu.com/images'
+ ],
+ ]
+ ),
+ 'main_archive': 'http://archive.ubuntu.com/ubuntu',
+ 'ports_archive': 'http://ports.ubuntu.com/ubuntu-ports',
+ 'cloud_images_archive': 'https://maas.ubuntu.com/images',
# Network section configuration.
'maas_name': gethostname(),
'enlistment_domain': b'local',
=== modified file 'src/maasserver/templates/maasserver/settings.html'
--- src/maasserver/templates/maasserver/settings.html 2012-11-08 14:14:23 +0000
+++ src/maasserver/templates/maasserver/settings.html 2012-11-08 14:14:23 +0000
@@ -98,15 +98,20 @@
{% with field=ubuntu_form.default_distro_series %}
{% include "maasserver/form_field.html" %}
{% endwith %}
- {% with field=ubuntu_form.update_from %}
+ {% with field=ubuntu_form.main_archive %}
+ {% include "maasserver/form_field.html" %}
+ {% endwith %}
+ {% with field=ubuntu_form.ports_archive %}
+ {% include "maasserver/form_field.html" %}
+ {% endwith %}
+ {% with field=ubuntu_form.cloud_images_archive %}
{% include "maasserver/form_field.html" %}
{% endwith %}
<li>
- <label>Custom archives</label>
<a href="{% url "settings-add-archive" %}">
<img src="{{ STATIC_URL }}img/inline_add.png"
alt="Add" class="icon" />
- Add archive for newly provisioned machines
+ Add custom archive
</a>
</li>
</ul>
=== modified file 'src/maasserver/tests/test_forms.py'
--- src/maasserver/tests/test_forms.py 2012-11-08 07:05:27 +0000
+++ src/maasserver/tests/test_forms.py 2012-11-08 14:14:23 +0000
@@ -515,9 +515,9 @@
class TestHostnameFormField(TestCase):
def test_validate_hostname_validates_valid_hostnames(self):
- self.assertIsNone(validate_hostname('host.example.com'))
- self.assertIsNone(validate_hostname('host.my-example.com'))
- self.assertIsNone(validate_hostname('my-example.com'))
+ self.assertIsNone(validate_hostname('http://host.example.com'))
+ self.assertIsNone(validate_hostname('http://host.my-example.com'))
+ self.assertIsNone(validate_hostname('http://my-example.com'))
# No ValidationError.
def test_validate_hostname_does_not_validate_invalid_hostnames(self):
@@ -527,10 +527,11 @@
self.assertRaises(ValidationError, validate_hostname, 'toolong' * 100)
def test_hostname_field_validation_cleaned_data_if_hostname_valid(self):
- form = FormWithHostname({'hostname': 'host.example.com'})
+ form = FormWithHostname({'hostname': 'http://host.example.com'})
self.assertTrue(form.is_valid())
- self.assertEqual('host.example.com', form.cleaned_data['hostname'])
+ self.assertEqual(
+ 'http://host.example.com', form.cleaned_data['hostname'])
def test_hostname_field_validation_error_if_invalid_hostname(self):
form = FormWithHostname({'hostname': 'invalid-host'})
=== modified file 'src/maasserver/tests/test_preseed.py'
--- src/maasserver/tests/test_preseed.py 2012-11-08 06:34:48 +0000
+++ src/maasserver/tests/test_preseed.py 2012-11-08 14:14:23 +0000
@@ -18,6 +18,7 @@
from django.conf import settings
from maasserver.enum import (
+ ARCHITECTURE,
NODE_STATUS,
PRESEED_TYPE,
)
@@ -41,6 +42,7 @@
from maasserver.testing.factory import factory
from maasserver.testing.testcase import TestCase
from maasserver.utils import map_enum
+from maastesting.matchers import ContainsAll
from testtools.matchers import (
AllMatch,
IsInstance,
@@ -367,6 +369,32 @@
self.assertIsInstance(preseed, str)
+class TestRenderPreseedArchives(TestCase):
+ """Test that the default preseed contains the default mirrors."""
+
+ def test_render_preseed_uses_default_archives_intel(self):
+ nodes = [
+ factory.make_node(architecture=ARCHITECTURE.i386),
+ factory.make_node(architecture=ARCHITECTURE.amd64),
+ ]
+ default_snippets = [
+ "d-i mirror/http/hostname string archive.ubuntu.com",
+ "d-i mirror/http/directory string /ubuntu",
+ ]
+ for node in nodes:
+ preseed = render_preseed(node, PRESEED_TYPE.DEFAULT, "precise")
+ self.assertThat(preseed, ContainsAll(default_snippets))
+
+ def test_render_preseed_uses_default_archives_arm(self):
+ node = factory.make_node(architecture=ARCHITECTURE.armhf_highbank)
+ default_snippets = [
+ "d-i mirror/http/hostname string ports.ubuntu.com",
+ "d-i mirror/http/directory string /ubuntu-ports",
+ ]
+ preseed = render_preseed(node, PRESEED_TYPE.DEFAULT, "precise")
+ self.assertThat(preseed, ContainsAll(default_snippets))
+
+
class TestPreseedMethods(TestCase):
"""Tests for `get_enlist_preseed` and `get_preseed`.
=== modified file 'src/maasserver/tests/test_views_settings.py'
--- src/maasserver/tests/test_views_settings.py 2012-11-08 14:14:23 +0000
+++ src/maasserver/tests/test_views_settings.py 2012-11-08 14:14:23 +0000
@@ -137,40 +137,48 @@
))
def test_settings_ubuntu_POST(self):
- choices = Config.objects.get_config('update_from_choice')
- new_update_from = factory.getRandomChoice(choices)
+ choices = Config.objects.get_config('archive_choices')
+ new_main_archive = factory.getRandomChoice(choices)
+ new_ports_archive = factory.getRandomChoice(choices)
+ new_cloud_images_archive = factory.getRandomChoice(choices)
new_default_distro_series = factory.getRandomEnum(DISTRO_SERIES)
response = self.client.post(
reverse('settings'),
get_prefixed_form_data(
prefix='ubuntu',
data={
- 'update_from': new_update_from,
+ 'main_archive': new_main_archive,
+ 'ports_archive': new_ports_archive,
+ 'cloud_images_archive': new_cloud_images_archive,
'default_distro_series': new_default_distro_series,
}))
- self.assertEqual(httplib.FOUND, response.status_code)
+ self.assertEqual(httplib.FOUND, response.status_code, response.content)
self.assertEqual(
(
- new_update_from,
+ new_main_archive,
+ new_ports_archive,
+ new_cloud_images_archive,
new_default_distro_series,
),
(
- Config.objects.get_config('update_from'),
+ Config.objects.get_config('main_archive'),
+ Config.objects.get_config('ports_archive'),
+ Config.objects.get_config('cloud_images_archive'),
Config.objects.get_config('default_distro_series'),
))
def test_settings_add_archive_POST(self):
- choices = Config.objects.get_config('update_from_choice')
+ choices = Config.objects.get_config('archive_choices')
response = self.client.post(
'/settings/archives/add/',
- data={'archive_name': 'my.hostname.com'}
+ data={'archive_name': 'http://my.hostname.com'}
)
- new_choices = Config.objects.get_config('update_from_choice')
+ new_choices = Config.objects.get_config('archive_choices')
- self.assertEqual(httplib.FOUND, response.status_code)
+ self.assertEqual(httplib.FOUND, response.status_code, response.content)
self.assertItemsEqual(
- choices + [['my.hostname.com', 'my.hostname.com']],
+ choices + [['http://my.hostname.com', 'http://my.hostname.com']],
new_choices)
def test_settings_kernelopts_POST(self):