예제 #1
0
    def config(self):
        result = 'FAILED'
        try:
            config_files = self._get_all_config_files()
            if not config_files:
                logger.info('There is no config file in %s ' %
                            self.absolute_path_of_patch)
                return 'No config file, no need to config.'
            for absolute_path, relative_path in config_files:
                user_config = ConfigCommon(absolute_path)
                openstack_config_file = os.path.join(os.path.sep,
                                                     relative_path)
                self.bak_cfg_file(openstack_config_file, relative_path)
                sys_config = ConfigCommon(openstack_config_file)
                default_options = user_config.get_options_dict_of_default()
                for key, value in default_options.items():
                    value = self.replace_value_for_sysconfig(key, value)
                    sys_config.set_default(key, value)

                user_sections = user_config.get_sections()
                for section in user_sections:
                    section_options = user_config.get_options_dict_of_section(
                        section)
                    for key, value in section_options.items():
                        value = self.replace_value_for_sysconfig(key, value)
                        sys_config.set_option(section, key, value)

                sys_config.write_commit()
            result = 'SUCCESS'
        except:
            logger.error('Exception occur when config : %s, Exception: %s' %
                         (self.absolute_path_of_patch, traceback.format_exc()))
        return result
예제 #2
0
    def config(self):
        result = 'FAILED'
        try:
            config_files = self._get_all_config_files()
            if not config_files:
                logger.info('There is no config file in %s ' % self.absolute_path_of_patch)
                return 'No config file, no need to config.'
            for absolute_path, relative_path in config_files:
                user_config = ConfigCommon(absolute_path)
                openstack_config_file = os.path.join(os.path.sep, relative_path)
                self.bak_cfg_file(openstack_config_file, relative_path)
                sys_config = ConfigCommon(openstack_config_file)
                default_options = user_config.get_options_dict_of_default()
                for key, value in default_options.items():
                    value = self.replace_value_for_sysconfig(key, value)
                    sys_config.set_default(key, value)

                user_sections = user_config.get_sections()
                for section in user_sections:
                    section_options = user_config.get_options_dict_of_section(section)
                    for key, value in section_options.items():
                        value = self.replace_value_for_sysconfig(key, value)
                        sys_config.set_option(section, key, value)

                sys_config.write_commit()
            result = 'SUCCESS'
        except:
            logger.error('Exception occur when config : %s, Exception: %s' %
                                (self.absolute_path_of_patch, traceback.format_exc()))
        return result
예제 #3
0
 def _config_ml2_ini(self):
     result = False
     try:
         ml2_section_ovf = 'ovs'
         option_local_ip = 'local_ip'
         config_common = ConfigCommon(config.CONF.path_ml2_ini)
         config_common.set_option(ml2_section_ovf, option_local_ip, config.CONF.sysconfig.ml2_local_ip)
         config_common.write_commit()
         result = True
     except:
         err_info = 'Exception occur when config ml2_conf.ini. Exception: %s' % traceback.format_exc()
         print err_info
         logger.error(err_info)
     return result
예제 #4
0
 def _config_ml2_ini(self):
     result = False
     try:
         ml2_section_ovf = 'ovs'
         option_local_ip = 'local_ip'
         config_common = ConfigCommon(config.CONF.path_ml2_ini)
         config_common.set_option(ml2_section_ovf, option_local_ip,
                                  config.CONF.sysconfig.ml2_local_ip)
         config_common.write_commit()
         result = True
     except:
         err_info = 'Exception occur when config ml2_conf.ini. Exception: %s' % traceback.format_exc(
         )
         print err_info
         logger.error(err_info)
     return result