def install(self): result = 'FAILED' try: patch_files = self.get_patch_files(self.patch_path, self.filters) if not patch_files: logger.error('No files in %s' % self.patch_path) for absolute_path, relative_path in patch_files: # installed_path is full install path, # for example: /usr/lib/python2.7/dist-packages/nova/conductor/manager.py openstack_installed_file = os.path.join( self.openstack_install_path, relative_path) self.bak_patched_file(openstack_installed_file, relative_path) copy_dir = os.path.dirname(openstack_installed_file) if not os.path.isdir(copy_dir): AllInOneUsedCMD.mkdir(copy_dir) cp_result = AllInOneUsedCMD.cp_to(absolute_path, openstack_installed_file) if cp_result: logger.info('Success to copy source file:%s' % absolute_path) else: logger.info('Failed to copy source file:%s' % absolute_path) result = 'SUCCESS' except: logger.error( 'Exception occur when install patch: %s, Exception: %s' % (self.patch_path, traceback.format_exc())) return result
def install(self): result = 'FAILED' try: patch_files = self.get_patch_files(self.patch_path, self.filters) if not patch_files: logger.error('No files in %s' % self.patch_path) for absolute_path, relative_path in patch_files: # installed_path is full install path, # for example: /usr/lib/python2.7/dist-packages/nova/conductor/manager.py openstack_installed_file = os.path.join(self.openstack_install_path, relative_path) self.bak_patched_file(openstack_installed_file, relative_path) copy_dir = os.path.dirname(openstack_installed_file) if not os.path.isdir(copy_dir): AllInOneUsedCMD.mkdir(copy_dir) cp_result = AllInOneUsedCMD.cp_to(absolute_path, openstack_installed_file) if cp_result: logger.info('Success to copy source file:%s' % absolute_path) else: logger.info('Failed to copy source file:%s' % absolute_path) result = 'SUCCESS' except: logger.error('Exception occur when install patch: %s, Exception: %s' % (self.patch_path, traceback.format_exc())) return result
def config(self): try: self._config_etc_hostname() self._config_etc_hosts() AllInOneUsedCMD.reboot() except: logger.error('Exception occur when config hostname. EXCEPTION: %s' % traceback.format_exc())
def _config_rabbitmq_pwd(self): result = 'Failed' try: AllInOneUsedCMD.rabbitmq_changed_pwd() except: logger.error('Exception occur when config rabbitMQ. EXCEPTION: %s' % traceback.format_exc()) result = 'Failed' return result
def config(self): try: self._config_etc_hostname() self._config_etc_hosts() AllInOneUsedCMD.reboot() except: logger.error( 'Exception occur when config hostname. EXCEPTION: %s' % traceback.format_exc())
def _config_rabbitmq_pwd(self): result = 'Failed' try: AllInOneUsedCMD.rabbitmq_changed_pwd() except: logger.error( 'Exception occur when config rabbitMQ. EXCEPTION: %s' % traceback.format_exc()) result = 'Failed' return result
def _copy_self_define_ml2(self): result = False try: self_define_ml2_file = os.path.split(os.path.realpath(__file__))[0] +'/config/ml2_conf.ini' destiny = config.CONF.path_ml2_ini result = AllInOneUsedCMD.cp_to(self_define_ml2_file, str(destiny)) except: err_info = 'Exception occur when copy self define ml2 file. Exception: %s' % traceback.format_exc() print err_info logger.error(err_info) return result
def bak_cfg_file(self, bak_file_path, relative_path): """ :param patch_file: one file of patch's source code files, for example: /root/tricircle-master/juno-patches/nova/nova_scheduling_patch/nova/conductor/manager.py :param relative_path: for example: nova/conductor/manager.py :return: """ logger.info('Start bak cfg file, bak_file_path:%s, relative_path:%s' % (bak_file_path, relative_path)) # relative_path is relative to this path(self.patch_path), # for example: if self.patch_path = "/root/tricircle-master/juno-patches/nova/nova_scheduling_patch/" # then relative_path of manager.py is "/nova/nova_scheduling_patch/nova/conductor/manager.py" if not os.path.isdir(self.bak_openstack_path): AllInOneUsedCMD.mkdir(self.bak_openstack_path) bak_dir = os.path.join(self.bak_openstack_path, os.path.dirname(relative_path)) if not os.path.isdir(bak_dir): AllInOneUsedCMD.mkdir(bak_dir) if os.path.isfile(bak_file_path): AllInOneUsedCMD.cp_to(bak_file_path, bak_dir) else: info = 'file: <%s> is a new file, no need to bak.' % bak_file_path logger.info(info) logger.info('Success to bak cfg file, bak cfg file from %s to %s' % (bak_file_path, bak_dir))
def _copy_self_define_ml2(self): result = False try: self_define_ml2_file = os.path.split( os.path.realpath(__file__))[0] + '/config/ml2_conf.ini' destiny = config.CONF.path_ml2_ini result = AllInOneUsedCMD.cp_to(self_define_ml2_file, str(destiny)) except: err_info = 'Exception occur when copy self define ml2 file. Exception: %s' % traceback.format_exc( ) print err_info logger.error(err_info) return result