Merge "Enable propagate_task_deploy in Web UI"

This commit is contained in:
Jenkins 2016-10-21 10:44:52 +00:00 committed by Gerrit Code Review
commit ba61ca7670
4 changed files with 19 additions and 7 deletions

View File

@ -259,7 +259,10 @@ class ClusterAttributesHandler(BaseHandler):
force = utils.parse_bool(web.input(force='0').force)
data = self.checked_data(cluster=cluster, force=force)
objects.Cluster.patch_attributes(cluster, data)
try:
objects.Cluster.patch_attributes(cluster, data)
except errors.NailgunException as exc:
raise self.http(400, exc.message)
return {
'editable': objects.Cluster.get_editable_attributes(

View File

@ -1115,10 +1115,10 @@
type: "hidden"
propagate_task_deploy:
value: false
# label: "Propagate task based deployment."
# description: "Enables adaptation of granular tasks for task deployment."
label: "Propagate task based deployment."
description: "Enables adaptation of granular tasks for task deployment."
weight: 12
type: "hidden"
type: "checkbox"
public_network_assignment:
metadata:

View File

@ -83,7 +83,12 @@ class PluginManager(object):
enabled = container['enabled'] \
and plugin_id == container['chosen_id']
legacy_tasks_are_ignored = not get_in(
cluster.attributes.editable,
'common', 'propagate_task_deploy', 'value')
new_value = not get_in(
attributes, 'common', 'propagate_task_deploy', 'value')
if new_value is not None:
legacy_tasks_are_ignored = new_value
if (enabled and
Release.is_lcm_supported(cluster.release) and
legacy_tasks_are_ignored and
@ -91,7 +96,9 @@ class PluginManager(object):
wrap_plugin(Plugin.get_by_uid(plugin.id)))):
raise errors.InvalidData(
'Cannot enable plugin with legacy tasks unless '
'propagate_task_deploy attribute is set')
'propagate_task_deploy attribute is set. '
'Ensure tasks.yaml is empty and all tasks '
'has version >= 2.0.0.')
ClusterPlugin.set_attributes(
cluster.id, plugin.id, enabled=enabled,
attrs=attrs if enabled or default else None

View File

@ -306,9 +306,11 @@ class TestPluginsApi(BasePluginTest):
propagate_task_deploy=False,
expect_errors=True)
self.assertEqual(resp.status_code, 400)
self.assertEqual(resp.body,
self.assertEqual(resp.json_body['message'],
'Cannot enable plugin with legacy tasks unless '
'propagate_task_deploy attribute is set')
'propagate_task_deploy attribute is set. '
'Ensure tasks.yaml is empty and all tasks '
'has version >= 2.0.0.')
@mock.patch.object(PluginManager, '_list_plugins_on_fs')
@mock.patch('nailgun.plugins.loaders.files_manager.open', create=True)