Support new plugin configuration schema 35/8335/2
authorMichal Skalski <mskalski@mirantis.com>
Thu, 28 Jan 2016 16:15:30 +0000 (17:15 +0100)
committerMichal Skalski <mskalski@mirantis.com>
Thu, 28 Jan 2016 17:05:01 +0000 (18:05 +0100)
In Fuel 8.0 it is possible to install many version of the same plugin.
Because of that there is additonal structurce in plugin configuration.
Assumption is that we only use one version of the plugin.

Change-Id: I50d5bc32dd6dab6fe2541748dd8404d887e336e0
Signed-off-by: Michal Skalski <mskalski@mirantis.com>
deploy/cloud/configure_settings.py

index 052634f..b60a60f 100644 (file)
@@ -54,12 +54,22 @@ class ConfigureSettings(object):
         backup(settings_yaml)
         settings = self.dea.get_property('settings')
         # Copy fuel defined plugin_id's to user defined settings
+        # From Fuel 8.0 chosen_id was added because it is now
+        # possible to install many version of the same plugin
+        # but we will install only one version
         for plugin in orig_dea['editable']:
-            if 'metadata' in orig_dea['editable'][plugin] and 'plugin_id' in orig_dea['editable'][plugin]['metadata']:
-                if not plugin in settings['editable']:
-                    settings['editable'][plugin] = orig_dea['editable'][plugin]
-                else:
-                    settings['editable'][plugin]["metadata"]["plugin_id"] = orig_dea['editable'][plugin]["metadata"]["plugin_id"]
+            if 'metadata' in orig_dea['editable'][plugin]:
+                if 'plugin_id' in orig_dea['editable'][plugin]['metadata']:
+                    if not plugin in settings['editable']:
+                        settings['editable'][plugin] = orig_dea['editable'][plugin]
+                    else:
+                        settings['editable'][plugin]["metadata"]["plugin_id"] = orig_dea['editable'][plugin]["metadata"]["plugin_id"]
+                elif 'chosen_id' in orig_dea['editable'][plugin]['metadata']:
+                    if not plugin in settings['editable']:
+                        settings['editable'][plugin] = orig_dea['editable'][plugin]
+                    else:
+                        settings['editable'][plugin]['metadata']['chosen_id'] = orig_dea['editable'][plugin]['metadata']['chosen_id']
+                        settings['editable'][plugin]['metadata']['versions'][0]['metadata']['plugin_id'] = orig_dea['editable'][plugin]['metadata']['versions'][0]['metadata']['plugin_id']
 
         with io.open(settings_yaml, 'w') as stream:
             yaml.dump(settings, stream, default_flow_style=False)