launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07089
[Merge] lp:~julian-edwards/maas/commissioning-script into lp:maas
Julian Edwards has proposed merging lp:~julian-edwards/maas/commissioning-script into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~julian-edwards/maas/commissioning-script/+merge/101674
Really trivial branch to pull the commissioning script from the filesystem instead of a hard-coded string.
--
https://code.launchpad.net/~julian-edwards/maas/commissioning-script/+merge/101674
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/maas/commissioning-script into lp:maas.
=== added file 'etc/maas/commissioning.sh'
--- etc/maas/commissioning.sh 1970-01-01 00:00:00 +0000
+++ etc/maas/commissioning.sh 2012-04-12 03:24:20 +0000
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "Hello world"
+
=== modified file 'src/maas/settings.py'
--- src/maas/settings.py 2012-04-10 12:25:23 +0000
+++ src/maas/settings.py 2012-04-12 03:24:20 +0000
@@ -262,5 +262,10 @@
# testing or demo purposes, MAAS will use an internal fake service.
USE_REAL_PSERV = True
+# The location of the commissioning script that is executed on nodes as
+# part of commissioning. Only override this if you know what you are
+# doing.
+COMMISSIONING_SCRIPT = 'etc/maas/commissioning.sh'
+
# Allow the user to override settings in maas_local_settings.
import_local_settings()
=== modified file 'src/maasserver/models.py'
--- src/maasserver/models.py 2012-04-11 08:32:10 +0000
+++ src/maasserver/models.py 2012-04-12 03:24:20 +0000
@@ -460,15 +460,6 @@
ADMIN = 'admin_node'
-# For the commissioning process, a node receives a minimal script as its
-# user_data through the metadata service. This is the content of that
-# script.
-commissioning_user_data = dedent("""
- #!/bin/sh
- echo "Hello world"
- """.lstrip('\n')).encode('ascii')
-
-
class Node(CommonInfo):
"""A `Node` represents a physical machine used by the MAAS Server.
@@ -625,6 +616,13 @@
# Avoid circular imports.
from metadataserver.models import NodeCommissionResult
+ path = settings.COMMISSIONING_SCRIPT
+ if not os.path.exists(path):
+ raise ValidationError(
+ "Commissioning script is missing: %s" % path)
+ with open(path, 'r') as f:
+ commissioning_user_data = f.read()
+
NodeCommissionResult.objects.clear_results(self)
self.status = NODE_STATUS.COMMISSIONING
self.owner = user
=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py 2012-04-11 09:25:35 +0000
+++ src/maasserver/tests/test_models.py 2012-04-12 03:24:20 +0000
@@ -32,7 +32,6 @@
NodeStateViolation,
)
from maasserver.models import (
- commissioning_user_data,
Config,
create_auth_token,
DEFAULT_CONFIG,
@@ -284,10 +283,22 @@
def test_start_commissioning_sets_user_data(self):
node = factory.make_node(status=NODE_STATUS.DECLARED)
node.start_commissioning(factory.make_admin())
+ path = settings.COMMISSIONING_SCRIPT
+ with open(path, 'r') as f:
+ commissioning_user_data = f.read()
self.assertEqual(
commissioning_user_data,
NodeUserData.objects.get_user_data(node))
+ def test_missing_commissioning_script(self):
+ self.patch(
+ settings, 'COMMISSIONING_SCRIPT',
+ '/etc/' + factory.getRandomString(10))
+ node = factory.make_node(status=NODE_STATUS.DECLARED)
+ self.assertRaises(
+ ValidationError,
+ node.start_commissioning, factory.make_admin())
+
def test_start_commissioning_clears_node_commissioning_results(self):
node = factory.make_node(status=NODE_STATUS.DECLARED)
NodeCommissionResult.objects.store_data(
Follow ups