Upstream: decouple patches, Makefile
[armband.git] / patches / opnfv-fuel / 0002-deploy-Delete-old-Fuel-env-if-present.patch
1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Mon, 18 Jul 2016 17:42:48 +0200
3 Subject: [PATCH] deploy: Delete old Fuel env if present
4
5 In order to clean up old partitioning and boot entries on target
6 nodes, before removing the Fuel Master, try ssh-ing into it and
7 removing all environments/nodes.
8
9 This is especially important for EFI systems, where old boot
10 entries are left behind without a proper env delete, leading to
11 target nodes failing to PXE boot on Fuel Master re-install.
12
13 This change assumes that:
14 - all Fuel Master information is unchanged between old and new
15   deploy (fuel IP, password etc.);
16 - Fuel Master is up and running, in a sane state (target nodes
17   are also online), when deploy starts;
18
19 Closes: ARMBAND-51
20
21 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
22 ---
23  deploy/deploy.py | 15 +++++++++++++++
24  1 file changed, 15 insertions(+)
25
26 diff --git a/deploy/deploy.py b/deploy/deploy.py
27 index 48a53c3..184510f 100755
28 --- a/deploy/deploy.py
29 +++ b/deploy/deploy.py
30 @@ -110,6 +110,20 @@ class AutoDeploy(object):
31          self.iso_file = new_iso
32          self.install_iso()
33  
34 +    def delete_old_fuel_env(self):
35 +        log('Delete old Fuel Master environments if present')
36 +        try:
37 +            old_dep = CloudDeploy(self.dea, self.dha, self.fuel_conf['ip'],
38 +                                  self.fuel_username, self.fuel_password,
39 +                                  self.dea_file, self.fuel_plugins_conf_dir,
40 +                                  WORK_DIR, self.no_health_check,
41 +                                  self.deploy_timeout,
42 +                                  self.no_deploy_environment, self.deploy_log)
43 +            with old_dep.ssh:
44 +                old_dep.check_previous_installation()
45 +        except Exception as e:
46 +            log('Could not delete old env: %s' % str(e))
47 +
48      def install_iso(self):
49          fuel = InstallFuelMaster(self.dea_file, self.dha_file,
50                                   self.fuel_conf['ip'], self.fuel_username,
51 @@ -227,6 +241,7 @@ class AutoDeploy(object):
52      def deploy(self):
53          self.collect_fuel_info()
54          if not self.no_fuel:
55 +            self.delete_old_fuel_env()
56              self.setup_execution_environment()
57              self.create_tmp_dir()
58              self.install_fuel_master()