launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07027
[Merge] lp:~jtv/maas/commissioning-metadata-is-yaml into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/commissioning-metadata-is-yaml into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/commissioning-metadata-is-yaml/+merge/101033
Bonus branch. As rightly suggested by Gavin and agreed with Scott, produce the commissioning preseed, which is YAML, by dumping the input data (of the right structure, naturally) as YAML. It does need the #cloud-config header.
--
https://code.launchpad.net/~jtv/maas/commissioning-metadata-is-yaml/+merge/101033
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/commissioning-metadata-is-yaml into lp:maas.
=== modified file 'src/maasserver/provisioning.py'
--- src/maasserver/provisioning.py 2012-04-05 16:33:27 +0000
+++ src/maasserver/provisioning.py 2012-04-05 20:25:37 +0000
@@ -34,6 +34,7 @@
NODE_STATUS,
)
from provisioningserver.enum import PSERV_FAULT
+import yaml
# Presentation templates for various provisioning faults.
PRESENTATIONS = {
@@ -214,21 +215,16 @@
def compose_commissioning_preseed(token):
"""Compose the preseed value for a Commissioning node."""
- template = dedent("""
- #cloud-config
- datasource:
- MAAS:
- metadata_url: %s
- consumer_key: %s
- token_key: %s
- token_secret: %s
- """.lstrip('\n'))
- return template % (
- get_metadata_server_url(),
- token.consumer.key,
- token.key,
- token.secret,
- )
+ return "#cloud-config\n%s" % yaml.dump({
+ 'datasource': {
+ 'MAAS': {
+ 'metadata_url': get_metadata_server_url(),
+ 'consumer_key': token.consumer.key,
+ 'token_key': token.key,
+ 'token_secret': token.secret,
+ }
+ }
+ })
def compose_preseed(node):
=== modified file 'src/maasserver/tests/test_provisioning.py'
--- src/maasserver/tests/test_provisioning.py 2012-04-05 17:42:01 +0000
+++ src/maasserver/tests/test_provisioning.py 2012-04-05 20:25:37 +0000
@@ -46,7 +46,10 @@
)
from provisioningserver.testing.factory import ProvisioningFakeFactory
from testtools.deferredruntest import AsynchronousDeferredRunTest
-from testtools.matchers import KeysEqual
+from testtools.matchers import (
+ KeysEqual,
+ StartsWith,
+ )
from testtools.testcase import ExpectedException
from twisted.internet.defer import inlineCallbacks
import yaml
@@ -78,6 +81,10 @@
KeysEqual(
'metadata_url', 'consumer_key', 'token_key', 'token_secret'))
+ def test_compose_preseed_for_commissioning_node_has_header(self):
+ node = factory.make_node(status=NODE_STATUS.COMMISSIONING)
+ self.assertThat(compose_preseed(node), StartsWith("#cloud-config\n"))
+
def test_compose_preseed_includes_metadata_url(self):
node = factory.make_node(status=NODE_STATUS.READY)
self.assertIn(get_metadata_server_url(), compose_preseed(node))