FIX for temporary ISO directory cleanup 65/1765/1
authorSzilard Cserey <szilard.cserey@ericsson.com>
Fri, 18 Sep 2015 10:13:46 +0000 (12:13 +0200)
committerSzilard Cserey <szilard.cserey@ericsson.com>
Fri, 18 Sep 2015 15:21:02 +0000 (17:21 +0200)
Move plugin installation in Fuel installer

Change-Id: Ibb24da448681fb70686a1f59738bd9fdda12e9d0
Signed-off-by: Szilard Cserey <szilard.cserey@ericsson.com>
fuel/deploy/cloud/deploy.py
fuel/deploy/deploy.py
fuel/deploy/deploy_env.py
fuel/deploy/install_fuel_master.py

index 1534f0b..705dda5 100644 (file)
@@ -35,11 +35,9 @@ ArgParser = common.ArgParser
 
 class Deploy(object):
 
-    def __init__(self, dea_file, blade_node_file, plugins_dir,
-                 no_health_check):
+    def __init__(self, dea_file, blade_node_file, no_health_check):
         self.dea = DeploymentEnvironmentAdapter(dea_file)
         self.blade_node_file = blade_node_file
-        self.plugins_dir = plugins_dir
         self.no_health_check = no_health_check
         self.macs_per_blade = {}
         self.blades = self.dea.get_node_ids()
@@ -74,19 +72,8 @@ class Deploy(object):
                          self.node_roles_dict, self.no_health_check)
         dep.deploy()
 
-    def install_plugins(self):
-        log('Installing Fuel Plugins')
-        if self.plugins_dir and os.path.isdir(self.plugins_dir):
-            for f in glob.glob('%s/*.rpm' % self.plugins_dir):
-                log('Found plugin %s, installing ...' % f)
-                r, c = exec_cmd('fuel plugins --install %s' % f, False)
-                if c > 0 and 'does not update installed package' not in r:
-                    err('Installation of Fuel Plugin %s failed' % f)
-
     def deploy(self):
 
-        self.install_plugins()
-
         self.get_blade_node_mapping()
 
         self.assign_roles_to_cluster_node_ids()
@@ -105,20 +92,15 @@ def parse_arguments():
                         help='Deployment Environment Adapter: dea.yaml')
     parser.add_argument('blade_node_file', action='store',
                         help='Blade Node mapping: blade_node.yaml')
-    parser.add_argument('plugins_dir', nargs='?', action='store',
-                        help='Plugins directory')
     args = parser.parse_args()
     check_file_exists(args.dea_file)
     check_file_exists(args.blade_node_file)
-    return (args.dea_file, args.blade_node_file, args.plugins_dir,
-            args.no_health_check)
+    return (args.dea_file, args.blade_node_file, args.no_health_check)
 
 
 def main():
-
-    dea_file, blade_node_file, plugins_dir, no_health_check = parse_arguments()
-
-    deploy = Deploy(dea_file, blade_node_file, plugins_dir, no_health_check)
+    dea_file, blade_node_file, no_health_check = parse_arguments()
+    deploy = Deploy(dea_file, blade_node_file, no_health_check)
     deploy.deploy()
 
 if __name__ == '__main__':
index 1acce42..75cc6cb 100644 (file)
@@ -102,7 +102,8 @@ class AutoDeploy(object):
         fuel = InstallFuelMaster(self.dea_file, self.dha_file,
                                  self.fuel_conf['ip'], self.fuel_username,
                                  self.fuel_password, self.fuel_node_id,
-                                 self.iso_file, WORK_DIR)
+                                 self.iso_file, WORK_DIR,
+                                 self.fuel_plugins_dir)
         fuel.install()
 
     def patch_iso(self, new_iso):
@@ -158,8 +159,7 @@ class AutoDeploy(object):
     def deploy_env(self):
         dep = CloudDeploy(self.dea, self.dha, self.fuel_conf['ip'],
                           self.fuel_username, self.fuel_password,
-                          self.dea_file, self.fuel_plugins_dir, WORK_DIR,
-                          self.no_health_check)
+                          self.dea_file, WORK_DIR, self.no_health_check)
         return dep.deploy()
 
     def setup_execution_environment(self):
index 4953bde..fb3cf12 100644 (file)
@@ -30,20 +30,18 @@ RO = common.RO
 
 CLOUD_DEPLOY_FILE = 'deploy.py'
 BLADE_RESTART_TIMES = 3
-PLUGINS_DIR = '~/plugins'
 
 
 class CloudDeploy(object):
 
     def __init__(self, dea, dha, fuel_ip, fuel_username, fuel_password,
-                 dea_file, fuel_plugins_dir, work_dir, no_health_check):
+                 dea_file, work_dir, no_health_check):
         self.dea = dea
         self.dha = dha
         self.fuel_ip = fuel_ip
         self.fuel_username = fuel_username
         self.fuel_password = fuel_password
         self.dea_file = dea_file
-        self.fuel_plugins_dir = fuel_plugins_dir
         self.work_dir = work_dir
         self.no_health_check = no_health_check
         self.file_dir = os.path.dirname(os.path.realpath(__file__))
@@ -66,14 +64,6 @@ class CloudDeploy(object):
             for f in glob.glob('%s/cloud/*' % self.file_dir):
                 s.scp_put(f, self.work_dir)
 
-    def upload_plugin_files(self):
-        with self.ssh as s:
-            s.exec_cmd('rm -rf %s' % PLUGINS_DIR, False)
-            s.exec_cmd('mkdir %s' % PLUGINS_DIR)
-            if self.fuel_plugins_dir:
-                for f in glob.glob('%s/*.rpm' % self.fuel_plugins_dir):
-                    s.scp_put(f, PLUGINS_DIR)
-
     def power_off_nodes(self):
         for node_id in self.node_ids:
             self.dha.node_power_off(node_id)
@@ -98,10 +88,9 @@ class CloudDeploy(object):
         blade_node_file = '%s/%s' % (
             self.work_dir, os.path.basename(self.blade_node_file))
         with self.ssh as s:
-            status = s.run('python %s %s %s %s %s'
+            status = s.run('python %s %s %s %s'
                            % (('-nh' if self.no_health_check else ''),
-                              deploy_app, dea_file, blade_node_file,
-                              PLUGINS_DIR))
+                              deploy_app, dea_file, blade_node_file))
         return status
 
     def check_supported_release(self):
@@ -253,6 +242,4 @@ class CloudDeploy(object):
 
         self.upload_cloud_deployment_files()
 
-        self.upload_plugin_files()
-
         return self.run_cloud_deploy(CLOUD_DEPLOY_FILE)
index 9a2599c..7ace713 100644 (file)
@@ -11,6 +11,7 @@
 import common
 import time
 import os
+import glob
 from ssh_client import SSHClient
 from dha_adapters.libvirt_adapter import LibvirtAdapter
 
@@ -22,12 +23,14 @@ delete = common.delete
 TRANSPLANT_FUEL_SETTINGS = 'transplant_fuel_settings.py'
 BOOTSTRAP_ADMIN = '/usr/local/sbin/bootstrap_admin_node'
 FUEL_CLIENT_CONFIG = '/etc/fuel/client/config.yaml'
+PLUGINS_DIR = '~/plugins'
 
 
 class InstallFuelMaster(object):
 
     def __init__(self, dea_file, dha_file, fuel_ip, fuel_username,
-                 fuel_password, fuel_node_id, iso_file, work_dir):
+                 fuel_password, fuel_node_id, iso_file, work_dir,
+                 fuel_plugins_dir):
         self.dea_file = dea_file
         self.dha = LibvirtAdapter(dha_file)
         self.fuel_ip = fuel_ip
@@ -37,6 +40,7 @@ class InstallFuelMaster(object):
         self.iso_file = iso_file
         self.iso_dir = os.path.dirname(self.iso_file)
         self.work_dir = work_dir
+        self.fuel_plugins_dir = fuel_plugins_dir
         self.file_dir = os.path.dirname(os.path.realpath(__file__))
         self.ssh = SSHClient(self.fuel_ip, self.fuel_username,
                              self.fuel_password)
@@ -51,7 +55,11 @@ class InstallFuelMaster(object):
 
         self.dha.node_set_boot_order(self.fuel_node_id, ['disk', 'iso'])
 
-        self.proceed_with_installation()
+        try:
+            self.proceed_with_installation()
+        except Exception as e:
+            self.post_install_cleanup()
+            err(e)
 
     def proceed_with_installation(self):
         log('Eject ISO')
@@ -83,10 +91,31 @@ class InstallFuelMaster(object):
 
         self.delete_deprecated_fuel_client_config_from_fuel_6_1()
 
+        self.upload_plugin_files()
+
+        self.install_plugins()
+
         self.post_install_cleanup()
 
         log('Fuel Master installed successfully !')
 
+    def upload_plugin_files(self):
+        with self.ssh as s:
+            s.exec_cmd('mkdir %s' % PLUGINS_DIR)
+            if self.fuel_plugins_dir:
+                for f in glob.glob('%s/*.rpm' % self.fuel_plugins_dir):
+                    s.scp_put(f, PLUGINS_DIR)
+
+    def install_plugins(self):
+        log('Installing Fuel Plugins')
+        with self.ssh as s:
+            r = s.exec_cmd('find %s -type f -name \'*.rpm\'' % PLUGINS_DIR)
+            for f in r.splitlines():
+                log('Found plugin %s, installing ...' % f)
+                r, e = s.exec_cmd('fuel plugins --install %s' % f, False)
+                if e and 'does not update installed package' not in r:
+                    raise('Installation of Fuel Plugin %s failed' % f)
+
     def wait_for_node_up(self):
         WAIT_LOOP = 60
         SLEEP_TIME = 10
@@ -104,7 +133,7 @@ class InstallFuelMaster(object):
                 self.ssh.close()
 
         if not success:
-            err('Could not SSH into Fuel VM %s' % self.fuel_ip)
+            raise('Could not SSH into Fuel VM %s' % self.fuel_ip)
 
     def wait_until_fuel_menu_up(self):
         WAIT_LOOP = 60
@@ -121,7 +150,7 @@ class InstallFuelMaster(object):
                 else:
                     break
         if not fuel_menu_pid:
-            err('Could not find the Fuel Menu Process ID')
+            raise('Could not find the Fuel Menu Process ID')
         return fuel_menu_pid
 
     def get_fuel_menu_pid(self, printout, search):
@@ -164,8 +193,7 @@ class InstallFuelMaster(object):
                     time.sleep(SLEEP_TIME)
 
         if not install_completed:
-            self.post_install_cleanup()
-            err('Fuel installation did not complete')
+            raise('Fuel installation did not complete')
 
     def post_install_cleanup(self):
         log('Eject ISO file %s' % self.iso_file)
@@ -183,23 +211,3 @@ class InstallFuelMaster(object):
             log('Delete deprecated fuel client config %s' % FUEL_CLIENT_CONFIG)
             with self.ssh as s:
                 s.exec_cmd('rm %s' % FUEL_CLIENT_CONFIG, False)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-