Updated armband
[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      |  7 ++++---
18  deploy/transplant_fuel_settings.py | 20 +++++++++++++++++++-
19  2 files changed, 23 insertions(+), 4 deletions(-)
20
21 diff --git a/deploy/install_fuel_master.py b/deploy/install_fuel_master.py
22 index 5adccef..adadcb5 100644
23 --- a/deploy/install_fuel_master.py
24 +++ b/deploy/install_fuel_master.py
25 @@ -84,14 +84,15 @@ 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          self.ssh_exec_cmd('kill %s' % fuel_menu_pid, False)
37  
38          log('Wait until installation is complete')
39 +        time.sleep(60)
40          self.wait_until_installation_completed()
41  
42          log('Waiting for one minute for Fuel to stabilize')
43 @@ -181,7 +182,7 @@ class InstallFuelMaster(object):
44              ret = self.ssh.exec_cmd(cmd, check=check)
45          return ret
46  
47 -    def inject_own_astute_yaml(self):
48 +    def inject_own_astute_and_bootstrap_yaml(self):
49          with self.ssh as s:
50              s.exec_cmd('rm -rf %s' % self.work_dir, False)
51              s.exec_cmd('mkdir %s' % self.work_dir)
52 diff --git a/deploy/transplant_fuel_settings.py b/deploy/transplant_fuel_settings.py
53 index 9a65cf6..8684d57 100644
54 --- a/deploy/transplant_fuel_settings.py
55 +++ b/deploy/transplant_fuel_settings.py
56 @@ -22,6 +22,7 @@ from common import (
57  )
58  
59  ASTUTE_YAML = '/etc/fuel/astute.yaml'
60 +FUEL_BOOTSTRAP_CLI_YAML = '/opt/opnfv/fuel_bootstrap_cli.yaml'
61  
62  
63  def usage():
64 @@ -81,9 +82,19 @@ def transplant(dea, astute):
65      return astute
66  
67  
68 +def transplant_bootstrap(astute, fuel_bootstrap_cli):
69 +    if 'BOOTSTRAP' in astute:
70 +        for skey in astute['BOOTSTRAP'].iterkeys():
71 +            # FIXME: astute.yaml repos point to public ones instead of
72 +            # local mirrors, this filter should be removed when in sync
73 +            if skey != 'repos':
74 +                fuel_bootstrap_cli[skey] = astute['BOOTSTRAP'][skey]
75 +    return fuel_bootstrap_cli
76 +
77  def main():
78      dea_file = parse_arguments()
79      check_file_exists(ASTUTE_YAML)
80 +    check_file_exists(FUEL_BOOTSTRAP_CLI_YAML)
81      dea = DeploymentEnvironmentAdapter(dea_file)
82      log('Reading astute file %s' % ASTUTE_YAML)
83      with io.open(ASTUTE_YAML) as stream:
84 @@ -92,7 +103,14 @@ def main():
85      transplant(dea, astute)
86      with io.open(ASTUTE_YAML, 'w') as stream:
87          yaml.dump(astute, stream, default_flow_style=False)
88 -    log('Transplant done')
89 +    log('Transplant done for astute.yaml')
90 +    # Update bootstrap config yaml with info from DEA/astute.yaml
91 +    with io.open(FUEL_BOOTSTRAP_CLI_YAML) as stream:
92 +        fuel_bootstrap_cli = yaml.load(stream)
93 +    transplant_bootstrap(astute, fuel_bootstrap_cli)
94 +    with io.open(FUEL_BOOTSTRAP_CLI_YAML, 'w') as stream:
95 +        yaml.dump(fuel_bootstrap_cli, stream, default_flow_style=False)
96 +    log('Transplant done for fuel_bootstrap_cli.yaml')
97  
98  
99  if __name__ == '__main__':