Rebase: Trim changes for obsoleted mirror patch
[armband.git] / patches / opnfv-fuel / 0011-deploy-config-honor-interfaces-and-transformations.patch
1 From a7a2e8ff1c3389063b4d73805d0bbdbd7376f090 Mon Sep 17 00:00:00 2001
2 From: Josep Puigdemont <josep.puigdemont@enea.com>
3 Date: Wed, 13 Jul 2016 18:29:05 +0200
4 Subject: [PATCH] deploy-config: honor interfaces and transformations
5
6 Currently all scenarios assume interfaces and transformations are the
7 same for all nodes in the POD, however some PODs may contain nodes that
8 have different hardware, or where the interfaces are configured
9 differently.
10
11 In this patch we honor the original interfaces and transformations if
12 they are present in the dea-override.yaml file. The way to add this
13 information in the dea-override is by having a "nodes:" section with
14 this information, ie:
15
16 nodes:
17 - id: 1
18   interfaces: interfaces_1
19   transformations: transformations_1
20 - id: 2
21   interfaces: interfaces_2
22   transformations: transformations_2
23 - id: 3
24   interfaces: interfaces_1
25   transformations: transformations_1
26
27 The node IDs is used to find out this information.
28
29 Change-Id: If6ff8ca28b42e043d1bdf91142a4a56ae36e4304
30 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
31 ---
32  deploy/deploy-config.py | 23 +++++++++++++++++++++++
33  1 file changed, 23 insertions(+)
34
35 diff --git a/deploy/deploy-config.py b/deploy/deploy-config.py
36 index 88a1111..5dfb863 100644
37 --- a/deploy/deploy-config.py
38 +++ b/deploy/deploy-config.py
39 @@ -167,6 +167,7 @@ dea_base_sha = sha_uri(kwargs["dea_base_uri"])
40  dea_base_comment = dea_base_conf['dea-base-config-metadata']['comment']
41  dea_base_conf.pop('dea-base-config-metadata')
42  final_dea_conf = dea_base_conf
43 +dea_pod_override_nodes = None
44  
45  # Fetch dea-pod-override, extract and purge meta-data, merge with previous dea data structure
46  print 'Parsing the dea-pod-override from: ' + kwargs["dea_pod_override_uri"] + "...."
47 @@ -180,6 +181,9 @@ if dea_pod_override_conf:
48      dea_pod_comment = dea_pod_override_conf['dea-pod-override-config-metadata']['comment']
49      print 'Merging dea-base and dea-pod-override configuration ....'
50      dea_pod_override_conf.pop('dea-pod-override-config-metadata')
51 +    # Copy the list of original nodes, which holds info on their transformations
52 +    if dea_pod_override_conf.has_key('nodes'):
53 +        dea_pod_override_nodes = list(dea_pod_override_conf['nodes'])
54      if dea_pod_override_conf:
55          final_dea_conf = dict(mergedicts(final_dea_conf, dea_pod_override_conf))
56  
57 @@ -245,6 +249,25 @@ if deploy_scenario_conf["stack-extensions"]:
58              dea_scenario_module_override_conf['settings']['editable'][module["module"]] = scenario_module_override_conf
59              final_dea_conf = dict(mergedicts(final_dea_conf, dea_scenario_module_override_conf))
60  
61 +def get_node_ifaces_and_trans(nodes, nid):
62 +    for node in nodes:
63 +        if node['id'] == nid:
64 +            if node.has_key('transformations') and node.has_key('interfaces'):
65 +                return (node['interfaces'], node['transformations'])
66 +            else:
67 +                return None
68 +
69 +    return None
70 +
71 +if dea_pod_override_nodes:
72 +    for node in final_dea_conf['nodes']:
73 +       data = get_node_ifaces_and_trans(dea_pod_override_nodes, node['id'])
74 +       if data:
75 +           print "Honoring original interfaces and transformations for " \
76 +                 "node %d to %s, %s" % (node['id'], data[0], data[1])
77 +           node['interfaces'] = data[0]
78 +           node['transformations'] = data[1]
79 +
80  # Dump final dea.yaml including configuration management meta-data to argument provided
81  # directory
82  if not os.path.exists(kwargs["output_path"]):
83 -- 
84 2.7.4
85