From 7fd2619e0df370fa832eeff00790bcaa52dc4ffc Mon Sep 17 00:00:00 2001
From: Jonas Bjurel <jonas.bjurel@ericsson.com>
Date: Tue, 29 Dec 2015 22:16:57 +0100
Subject: A simple method to separate configuration for base fuel, plugins,
 PODs and deployment/test scenarios

READY TO MERGE!

Replaces: https://gerrit.opnfv.org/gerrit/#/c/3995/

Abstract
--------
This deployment framework relies on a configuration structure,
providing base installer configuration, per POD specific configuration,
plugin configuration, and deployment scenario configuration.
- The base installer configuration resembles the least common denominator
  of all HW/POD environment and deployment scenarios (These configurations
  are normally carried by the the installer projects in this case (fuel@OPNFV).
- Per POD specific configuration specifies POD unique parameters, the POD
  parameter possible to alter is governed by the Fuel@OPNFV project.
- Plugin configuration - providing configuration of a specific plugin.
  these configurations maintain there own namespace and are normally maintained
  by collaborative projects building Fuel@OPNFV plugins
- Deployment scenario configuration - provides a high level, POD/HW environment
  independent scenario configuration for a specific deployment. It defines what
  features/plugins that shall be deployed - as well needed overrides of the
  plugin config as well as the base installer-, POD/HW environment-
  configurations. Objects allowed to override
  is governed by the Fuel@OPNFV project.

Executing a deployment
----------------------
deploy.sh must be executed locally at the target lab/pod/jumpserver
A lab configuration structure must be provided - see the section below.
It is straight forward to execute a deployment task - as an example:
sudo deploy.sh -b file:///home/jenkins/config -l ericsson-1 -p pod-2
-s os_odl-l2_no-ha -i file:///home/jenkins/MyIso.iso

-b and -i arguments should be expressed in URI style. The resources can thus be
local or remote.

Feedback
--------
Please give feed-back before I'm going to far on a wrong tangent

Implemented scenarios so far:
-----------------------------
- os_ha
- os_no-ha
- os_odl-l3_ha
- os_odl-l3_no-ha
- os_odl-l2_ha
- os_odl-l2_no-ha
- os_onos_ha
- os_onos_no-ha
- os_kvm_ha
- os_kvm_no-ha
- os_ovs_ha
- os_ovs_no-ha
- os_kvm_ovs_ha
- os_kvm_ovs_no-ha

VERIFIED
READY TO MERGE

JIRA: FUEL-35

Change-Id: I94a9b477d8ed4ee8057c16d8f20fe543f7ecc20d
Signed-off-by: Jonas Bjurel <jonas.bjurel@ericsson.com>
---
 deploy/cloud/configure_nodes.py    | 13 +++++++++++--
 deploy/cloud/configure_settings.py | 12 +++++++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

(limited to 'deploy/cloud')

diff --git a/deploy/cloud/configure_nodes.py b/deploy/cloud/configure_nodes.py
index a456679ab..46121df62 100644
--- a/deploy/cloud/configure_nodes.py
+++ b/deploy/cloud/configure_nodes.py
@@ -30,9 +30,18 @@ class ConfigureNodes(object):
 
     def config_nodes(self):
         log('Configure nodes')
+
+        # Super dirty fix since Fuel 7 requires user defined roles to be
+        # assigned before anything else (BUG fixed in Fuel 8)!
+        for node_id, roles_blade in self.node_id_roles_dict.iteritems():
+            if "opendaylight" in roles_blade[0] or "onos" in roles_blade[0] or "contrail" in roles_blade[0]:
+                exec_cmd('fuel node set --node-id %s --role %s --env %s'
+                         % (node_id, roles_blade[0], self.env_id))
+
         for node_id, roles_blade in self.node_id_roles_dict.iteritems():
-            exec_cmd('fuel node set --node-id %s --role %s --env %s'
-                     % (node_id, roles_blade[0], self.env_id))
+            if "opendaylight" not in roles_blade[0] and "onos" not in roles_blade[0] and "contrail" not in roles_blade[0]:
+                exec_cmd('fuel node set --node-id %s --role %s --env %s'
+                         % (node_id, roles_blade[0], self.env_id))
 
         self.download_deployment_config()
         for node_id, roles_blade in self.node_id_roles_dict.iteritems():
diff --git a/deploy/cloud/configure_settings.py b/deploy/cloud/configure_settings.py
index c773e1b61..052634f99 100644
--- a/deploy/cloud/configure_settings.py
+++ b/deploy/cloud/configure_settings.py
@@ -47,9 +47,19 @@ class ConfigureSettings(object):
         settings_yaml = ('%s/settings_%s.yaml'
                          % (self.yaml_config_dir, self.env_id))
         check_file_exists(settings_yaml)
-        backup(settings_yaml)
 
+        with io.open(settings_yaml, 'r') as stream:
+            orig_dea = yaml.load(stream)
+
+        backup(settings_yaml)
         settings = self.dea.get_property('settings')
+        # Copy fuel defined plugin_id's to user defined settings
+        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"]
 
         with io.open(settings_yaml, 'w') as stream:
             yaml.dump(settings, stream, default_flow_style=False)
-- 
cgit