launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12882
[Merge] lp:~smoser/maas/preserve-sources-list into lp:maas
Scott Moser has proposed merging lp:~smoser/maas/preserve-sources-list into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~smoser/maas/preserve-sources-list/+merge/127825
--
https://code.launchpad.net/~smoser/maas/preserve-sources-list/+merge/127825
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~smoser/maas/preserve-sources-list into lp:maas.
=== modified file 'contrib/preseeds_v2/generic'
--- contrib/preseeds_v2/generic 2012-10-02 19:08:05 +0000
+++ contrib/preseeds_v2/generic 2012-10-03 16:41:20 +0000
@@ -27,7 +27,6 @@
{{def preseed}}
{{preseed_data}}
-cloud-init cloud-init/local-cloud-config string manage_etc_hosts: localhost
{{enddef}}
{{def post_scripts}}
=== modified file 'src/maasserver/compose_preseed.py'
--- src/maasserver/compose_preseed.py 2012-08-16 13:38:51 +0000
+++ src/maasserver/compose_preseed.py 2012-10-03 16:41:20 +0000
@@ -29,12 +29,20 @@
'oauth_token_secret': token.secret,
})
+ local_config_yaml = yaml.safe_dump({
+ "manage_etc_hosts": "localhost",
+ "preserve_sources_list": True,
+ })
+ # this is debconf escaping
+ local_config = local_config_yaml.replace("\\", "\\\\").replace("\n", "\\n")
+
# Preseed data to send to cloud-init. We set this as MAAS_PRESEED in
# ks_meta, and it gets fed straight into debconf.
- metadata_preseed_items = [
+ preseed_items = [
('datasources', 'multiselect', 'MAAS'),
('maas-metadata-url', 'string', absolute_reverse('metadata')),
('maas-metadata-credentials', 'string', credentials),
+ ('local-cloud-config', 'string', local_config)
]
return '\n'.join(
@@ -43,7 +51,7 @@
item_type,
item_value,
)
- for item_name, item_type, item_value in metadata_preseed_items)
+ for item_name, item_type, item_value in preseed_items)
def compose_commissioning_preseed(token):
=== modified file 'src/maasserver/tests/test_compose_preseed.py'
--- src/maasserver/tests/test_compose_preseed.py 2012-08-16 13:57:02 +0000
+++ src/maasserver/tests/test_compose_preseed.py 2012-10-03 16:41:20 +0000
@@ -68,3 +68,29 @@
self.assertEqual(token.consumer.key, maas_dict['consumer_key'])
self.assertEqual(token.key, maas_dict['token_key'])
self.assertEqual(token.secret, maas_dict['token_secret'])
+
+ def test_compose_preseed_valid_local_cloud_config(self):
+ node = factory.make_node(status=NODE_STATUS.READY)
+ preseed = compose_preseed(node)
+ token = NodeKey.objects.get_token_for_node(node)
+
+ keyname = "cloud-init/local-cloud-config"
+ self.assertIn(keyname, preseed)
+
+ # expected input is 'cloud-init/local-cloud-config string VALUE'
+ # where one or more spaces in between tokens, and VALUE ending at newline
+ value = preseed[preseed.find(keyname) + len(keyname):]
+ value = value[value.find("string") + len("string"):].lstrip()
+ if "\n" in value:
+ value = value[:value.find("\n")]
+
+ # now debconf-unescape it
+ value = value.replace("\\n", "\n").replace("\\\\", "\\")
+
+ # at this point it should be valid yaml
+ data = yaml.safe_load(value)
+
+ self.assertIn("manage_etc_hosts", data)
+ self.assertEqual(data["manage_etc_hosts"], "localhost")
+ self.assertIn("preserve_sources_list", data)
+ self.assertEqual(data["preserve_sources_list"], True)
Follow ups