launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12158
[Merge] lp:~andreserl/maas/distro_series_support into lp:maas
Andres Rodriguez has proposed merging lp:~andreserl/maas/distro_series_support into lp:maas with lp:~andreserl/maas/add_node_distro_series as a prerequisite.
Requested reviews:
MAAS Maintainers (maas-maintainers)
Related bugs:
Bug #1013146 in MAAS: "MAAS currently only supports Ubuntu version 12.04 to be installed on the nodes."
https://bugs.launchpad.net/maas/+bug/1013146
For more details, see:
https://code.launchpad.net/~andreserl/maas/distro_series_support/+merge/125012
--
https://code.launchpad.net/~andreserl/maas/distro_series_support/+merge/125012
Your team MAAS Maintainers is requested to review the proposed merge of lp:~andreserl/maas/distro_series_support into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-09-18 16:00:45 +0000
+++ src/maasserver/api.py 2012-09-18 18:22:21 +0000
@@ -1353,14 +1353,17 @@
preseed_url = compose_preseed_url(node)
hostname = node.hostname
- # XXX JeroenVermeulen 2012-08-06 bug=1013146: Stop hard-coding this.
- release = 'precise'
+ if node is None or node.status == NODE_STATUS.COMMISSIONING:
+ series = Config.objects.get_config('commissioning_distro_series')
+ else:
+ series = node.get_distro_series()
+
purpose = get_boot_purpose(node)
domain = 'local.lan' # TODO: This is probably not enough!
server_address = get_maas_facing_server_address()
params = KernelParameters(
- arch=arch, subarch=subarch, release=release, purpose=purpose,
+ arch=arch, subarch=subarch, release=series, purpose=purpose,
hostname=hostname, domain=domain, preseed_url=preseed_url,
log_host=server_address, fs_host=server_address)
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-09-18 15:33:55 +0000
+++ src/maasserver/forms.py 2012-09-18 18:22:21 +0000
@@ -61,6 +61,8 @@
NODEGROUP_STATUS,
NODEGROUPINTERFACE_MANAGEMENT,
NODEGROUPINTERFACE_MANAGEMENT_CHOICES,
+ DISTRO_SERIES,
+ DISTRO_SERIES_CHOICES,
)
from maasserver.fields import MACAddressFormField
from maasserver.models import (
@@ -99,6 +101,9 @@
INVALID_ARCHITECTURE_MESSAGE = compose_invalid_choice_text(
'architecture', ARCHITECTURE_CHOICES)
+INVALID_DISTRO_SERIES_MESSAGE = compose_invalid_choice_text(
+ 'distro_series', DISTRO_SERIES_CHOICES)
+
class NodeForm(ModelForm):
after_commissioning_action = forms.TypedChoiceField(
@@ -106,6 +111,12 @@
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,
@@ -117,6 +128,7 @@
'hostname',
'after_commissioning_action',
'architecture',
+ 'distro_series',
)
@@ -156,6 +168,7 @@
'hostname',
'after_commissioning_action',
'architecture',
+ 'distro_series',
'power_type',
'power_parameters',
)
=== modified file 'src/maasserver/models/config.py'
--- src/maasserver/models/config.py 2012-09-05 13:30:21 +0000
+++ src/maasserver/models/config.py 2012-09-18 18:22:21 +0000
@@ -27,6 +27,7 @@
from django.db.models.signals import post_save
from maasserver import DefaultMeta
from maasserver.enum import (
+ DISTRO_SERIES,
DNS_DHCP_MANAGEMENT,
NODE_AFTER_COMMISSIONING_ACTION,
)
@@ -53,6 +54,8 @@
'enlistment_domain': b'local',
'dns_dhcp_management': DNS_DHCP_MANAGEMENT.NONE,
## /settings
+ 'default_distro_series': DISTRO_SERIES.precise,
+ 'commissioning_distro_series': DISTRO_SERIES.precise,
}
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2012-09-18 18:22:21 +0000
+++ src/maasserver/models/node.py 2012-09-18 18:22:21 +0000
@@ -359,6 +359,10 @@
max_length=10, choices=DISTRO_SERIES_CHOICES, null=True,
blank=True, default='')
+ distro_series = CharField(
+ max_length=10, choices=DISTRO_SERIES_CHOICES, null=True,
+ blank=True, default=None)
+
architecture = CharField(
max_length=10, choices=ARCHITECTURE_CHOICES, blank=False,
default=ARCHITECTURE.i386)
@@ -556,6 +560,13 @@
else:
return None
+ def get_distro_series(self):
+ """Return the distro series to install that node."""
+ if not self.distro_series or self.distro_series == DISTRO_SERIES.default:
+ return Config.objects.get_config('default_distro_series')
+ else:
+ return self.distro_series
+
def get_effective_power_parameters(self):
"""Return effective power parameters, including any defaults."""
if self.power_parameters:
=== modified file 'src/maasserver/preseed.py'
--- src/maasserver/preseed.py 2012-08-21 20:27:47 +0000
+++ src/maasserver/preseed.py 2012-09-18 18:22:21 +0000
@@ -30,6 +30,7 @@
)
from maasserver.server_address import get_maas_facing_server_host
from maasserver.utils import absolute_reverse
+from maasserver.models import Config
import tempita
@@ -54,28 +55,26 @@
return render_preseed(None, PRESEED_TYPE.ENLIST_USERDATA)
-# XXX: rvb 2012-06-21 bug=1013146: 'precise' is hardcoded here.
-def get_preseed(node, release="precise"):
+def get_preseed(node):
"""Return the preseed for a given node. Depending on the node's status
this will be a commissioning preseed (if the node is commissioning) or the
standard preseed (normal installation preseed).
:param node: The node to return preseed for.
:type node: :class:`maasserver.models.Node`
- :param release: The Ubuntu release to be used.
- :type release: basestring
:return: The rendered preseed string.
:rtype: basestring.
"""
if node.status == NODE_STATUS.COMMISSIONING:
return render_preseed(
- node, PRESEED_TYPE.COMMISSIONING, release=release)
+ node, PRESEED_TYPE.COMMISSIONING,
+ release=Config.objects.get_config('commissioning_distro_series'))
else:
- return render_preseed(node, PRESEED_TYPE.DEFAULT, release=release)
-
-
-# XXX: rvb 2012-06-14 bug=1013146: 'precise' is hardcoded here.
-def get_preseed_filenames(node, prefix='', release='precise', default=False):
+ return render_preseed(node, PRESEED_TYPE.DEFAULT,
+ release=node.get_distro_series())
+
+
+def get_preseed_filenames(node, prefix='', release='', default=False):
"""List possible preseed template filenames for the given node.
:param node: The node to return template preseed filenames for.
@@ -174,8 +173,7 @@
self.name = name
-# XXX: rvb 2012-06-18 bug=1013146: 'precise' is hardcoded here.
-def load_preseed_template(node, prefix, release="precise"):
+def load_preseed_template(node, prefix, release=''):
"""Find and load a `PreseedTemplate` for the given node.
:param node: See `get_preseed_filenames`.
@@ -201,8 +199,7 @@
return get_template(prefix, None, default=True)
-# XXX: rvb 2012-06-19 bug=1013146: 'precise' is hardcoded here.
-def get_preseed_context(node, release="precise"):
+def get_preseed_context(node, release=''):
"""Return the context dictionary to be used to render preseed templates
for this node.
@@ -236,8 +233,7 @@
return context
-# XXX: rvb 2012-06-19 bug=1013146: 'precise' is hardcoded here.
-def render_preseed(node, prefix, release="precise"):
+def render_preseed(node, prefix, release=''):
"""Find and load a `PreseedTemplate` for the given node.
:param node: See `get_preseed_filenames`.
=== modified file 'src/maasserver/templates/maasserver/snippets.html'
--- src/maasserver/templates/maasserver/snippets.html 2012-06-11 12:25:37 +0000
+++ src/maasserver/templates/maasserver/snippets.html 2012-09-18 18:22:21 +0000
@@ -20,6 +20,10 @@
{{ node_form.after_commissioning_action }}
</p>
<p>
+ <label for="id_distro_series">Release</label>
+ {{ node_form.distro_series }}
+ </p>
+ <p>
<label for="id_architecture">Architecture</label>
{{ node_form.architecture }}
</p>
=== modified file 'src/maasserver/tests/test_forms.py'
--- src/maasserver/tests/test_forms.py 2012-09-18 07:51:29 +0000
+++ src/maasserver/tests/test_forms.py 2012-09-18 18:22:21 +0000
@@ -226,6 +226,7 @@
'hostname',
'after_commissioning_action',
'architecture',
+ 'distro_series',
], list(form.fields))
def test_NodeForm_changes_node(self):
@@ -256,6 +257,7 @@
'hostname',
'after_commissioning_action',
'architecture',
+ 'distro_series',
'power_type',
'power_parameters',
],
Follow ups