deploy: Allow DEA to override bootstrap config
[armband.git] / patches / opnfv-fuel / 0039-deploy-Allow-DEA-to-override-bootstrap-config.patch
1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Tue, 26 Jul 2016 18:07:55 +0200
3 Subject: [PATCH] deploy: Allow DEA to override bootstrap config
4
5 This commit does not change the current behavior in OPNFV, the
6 preconfigured fuel_bootstrap_cli.yaml from OPNFV ISO is still
7 used to replace the default settings / fuel-menu bootstrap cfg.
8
9 The only addition is the possibility to override the preconfigured
10 fuel_bootstrap_cli.yaml info using DEA.
11
12 JIRA: FUEL-155
13
14 Change-Id: I4e66b789fdf0a5b1af512a3efc84fedb72ce3b05
15 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
16 ---
17  deploy/install_fuel_master.py      |  6 +++---
18  deploy/transplant_fuel_settings.py | 17 +++++++++++++++++
19  2 files changed, 20 insertions(+), 3 deletions(-)
20
21 diff --git a/deploy/install_fuel_master.py b/deploy/install_fuel_master.py
22 index 5adccef..808d0b1 100644
23 --- a/deploy/install_fuel_master.py
24 +++ b/deploy/install_fuel_master.py
25 @@ -84,8 +84,8 @@ class InstallFuelMaster(object):
26          log('Wait until Fuel menu is up')
27          fuel_menu_pid = self.wait_until_fuel_menu_up()
28  
29 -        log('Inject our own astute.yaml settings')
30 -        self.inject_own_astute_yaml()
31 +        log('Inject our own astute.yaml and fuel_bootstrap_cli.yaml settings')
32 +        self.inject_own_astute_and_bootstrap_yaml()
33  
34          log('Let the Fuel deployment continue')
35          log('Found FUEL menu as PID %s, now killing it' % fuel_menu_pid)
36 @@ -181,7 +181,7 @@ class InstallFuelMaster(object):
37              ret = self.ssh.exec_cmd(cmd, check=check)
38          return ret
39  
40 -    def inject_own_astute_yaml(self):
41 +    def inject_own_astute_and_bootstrap_yaml(self):
42          with self.ssh as s:
43              s.exec_cmd('rm -rf %s' % self.work_dir, False)
44              s.exec_cmd('mkdir %s' % self.work_dir)
45 diff --git a/deploy/transplant_fuel_settings.py b/deploy/transplant_fuel_settings.py
46 index e57a4fb..318c633 100644
47 --- a/deploy/transplant_fuel_settings.py
48 +++ b/deploy/transplant_fuel_settings.py
49 @@ -18,6 +18,7 @@ from common import (
50  )
51  
52  ASTUTE_YAML = '/etc/fuel/astute.yaml'
53 +FUEL_BOOTSTRAP_CLI_YAML = '/opt/opnfv/fuel_bootstrap_cli.yaml'
54  
55  
56  def usage():
57 @@ -47,18 +48,35 @@ def transplant(dea, astute):
58      return astute
59  
60  
61 +def transplant_bootstrap(astute, fuel_bootstrap_cli):
62 +    if 'BOOTSTRAP' in astute:
63 +        for skey in astute['BOOTSTRAP'].iterkeys():
64 +            # FIXME: astute.yaml repos point to public ones instead of
65 +            # local mirrors, this filter should be removed when in sync
66 +            if skey != 'repos':
67 +                fuel_bootstrap_cli[skey] = astute['BOOTSTRAP'][skey]
68 +    return fuel_bootstrap_cli
69 +
70  def main():
71      dea_file = parse_arguments()
72      check_file_exists(ASTUTE_YAML)
73 +    check_file_exists(FUEL_BOOTSTRAP_CLI_YAML)
74      dea = DeploymentEnvironmentAdapter(dea_file)
75      log('Reading astute file %s' % ASTUTE_YAML)
76      with io.open(ASTUTE_YAML) as stream:
77          astute = yaml.load(stream)
78      log('Initiating transplant')
79      transplant(dea, astute)
80      with io.open(ASTUTE_YAML, 'w') as stream:
81          yaml.dump(astute, stream, default_flow_style=False)
82 -    log('Transplant done')
83 +    log('Transplant done for astute.yaml')
84 +    # Update bootstrap config yaml with info from DEA/astute.yaml
85 +    with io.open(FUEL_BOOTSTRAP_CLI_YAML) as stream:
86 +        fuel_bootstrap_cli = yaml.load(stream)
87 +    transplant_bootstrap(astute, fuel_bootstrap_cli)
88 +    with io.open(FUEL_BOOTSTRAP_CLI_YAML, 'w') as stream:
89 +        yaml.dump(fuel_bootstrap_cli, stream, default_flow_style=False)
90 +    log('Transplant done for fuel_bootstrap_cli.yaml')
91  
92  
93  if __name__ == '__main__':