示例#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_dhcp_agent(self):
        """
        config /etc/neutron/dhcp_agent.ini,
        set following:
        #vi /etc/neutron/dhcp_agent.ini
        [DEFAULT]
        dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
        use_namespaces = False

        :return:
        """
        result = False
        try:
            option_dhcp_driver = 'dhcp_driver'
            value_dhcp_driver = 'neutron.agent.linux.dhcp.Dnsmasq'
            option_use_namespaces = 'use_namespace'
            value_use_namespaces = 'False'
            common_config = ConfigCommon(config.CONF.path_dhcp_agent_ini)
            common_config.set_default(option_dhcp_driver, value_dhcp_driver)
            common_config.set_default(option_use_namespaces,
                                      value_use_namespaces)
            common_config.write_commit()
            result = True
        except:
            err_info = 'Exception occur when config dhcp_agent.ini. Exception: %s' % traceback.format_exc(
            )
            logger.error(err_info)
            print(err_info)

        return result
示例#3
0
    def _config_metadata_agent(self):
        """
        # vi /etc/neutron/metadata_agent.ini
        [DEFAULT]
        nova_metadata_ip = 162.3.110.71
        metadata_proxy_shared_secret = openstack

        :return:
        """
        result = True
        try:
            option_nova_metadata_ip = 'nova_metadata_ip'
            value_nova_metadata_ip = config.CONF.sysconfig.local_host_ip
            option_metadata_proxy_shared_secret = 'metadata_proxy_shared_secret'
            value_metadata_proxy_shared_secret = 'openstack'
            config_common = ConfigCommon(config.CONF.path_metadata_agent_ini)
            config_common.set_default(option_nova_metadata_ip,
                                      value_nova_metadata_ip)
            config_common.set_default(option_metadata_proxy_shared_secret,
                                      value_metadata_proxy_shared_secret)
            config_common.write_commit()

            result = True
        except:
            err_info = 'Exception occur when config dhcp_agent.ini. Exception: %s' % traceback.format_exc(
            )
            logger.error(err_info)
            print(err_info)

        return result
    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
    def _config_metadata_agent(self):
        """
        # vi /etc/neutron/metadata_agent.ini
        [DEFAULT]
        nova_metadata_ip = 162.3.110.71
        metadata_proxy_shared_secret = openstack

        :return:
        """
        result = True
        try:
            option_nova_metadata_ip = 'nova_metadata_ip'
            value_nova_metadata_ip = config.CONF.sysconfig.local_host_ip
            option_metadata_proxy_shared_secret = 'metadata_proxy_shared_secret'
            value_metadata_proxy_shared_secret = 'openstack'
            config_common = ConfigCommon(config.CONF.path_metadata_agent_ini)
            config_common.set_default(option_nova_metadata_ip,
                                     value_nova_metadata_ip)
            config_common.set_default(option_metadata_proxy_shared_secret,
                                     value_metadata_proxy_shared_secret)
            config_common.write_commit()

            result = True
        except:
            err_info = 'Exception occur when config dhcp_agent.ini. Exception: %s' % traceback.format_exc()
            logger.error(err_info)
            print(err_info)

        return result
    def _config_dhcp_agent(self):
        """
        config /etc/neutron/dhcp_agent.ini,
        set following:
        #vi /etc/neutron/dhcp_agent.ini
        [DEFAULT]
        dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
        use_namespaces = False

        :return:
        """
        result = False
        try:
            option_dhcp_driver = 'dhcp_driver'
            value_dhcp_driver = 'neutron.agent.linux.dhcp.Dnsmasq'
            option_use_namespaces = 'use_namespace'
            value_use_namespaces = 'False'
            common_config = ConfigCommon(config.CONF.path_dhcp_agent_ini)
            common_config.set_default(option_dhcp_driver, value_dhcp_driver)
            common_config.set_default(option_use_namespaces, value_use_namespaces)
            common_config.write_commit()
            result = True
        except:
            err_info = 'Exception occur when config dhcp_agent.ini. Exception: %s' % traceback.format_exc()
            logger.error(err_info)
            print(err_info)

        return result
 def _config_tenant_id_in_neutron_conf(self, path_neutron_conf):
     option_nova_admin_tenant_id = 'nova_admin_tenant_id'
     # get tenant id
     value_nova_admin_tenant_id = RefServices().get_tenant_id_for_service()
     logger.info('tenant id of service is <%s>' % (value_nova_admin_tenant_id))
     config_common = ConfigCommon(path_neutron_conf)
     config_common.set_default(option_nova_admin_tenant_id, value_nova_admin_tenant_id)
     config_common.write_commit()
示例#8
0
 def _config_tenant_id_in_neutron_conf(self, path_neutron_conf):
     option_nova_admin_tenant_id = 'nova_admin_tenant_id'
     # get tenant id
     value_nova_admin_tenant_id = RefServices().get_tenant_id_for_service()
     logger.info('tenant id of service is <%s>' %
                 (value_nova_admin_tenant_id))
     config_common = ConfigCommon(path_neutron_conf)
     config_common.set_default(option_nova_admin_tenant_id,
                               value_nova_admin_tenant_id)
     config_common.write_commit()
 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
示例#10
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
示例#11
0
    def _config_nova_conf(self):
        result = False
        try:
            vncserver_listen = '0.0.0.0'
            path_nova_conf_file = config.CONF.path_nova_conf

            config_common = ConfigCommon(path_nova_conf_file)
            config_common.set_default('vncserver_listen', vncserver_listen)
            config_common.set_default('service_metadata_proxy', 'False')
            config_common.set_default('metadata_proxy_shared_secret', 'openstack')
            config_common.write_commit()
            result = True
        except:
            logger.error('Exception occur when config nova.conf. EXCEPTION: %s' % traceback.format_exc())

        return result
示例#12
0
    def _config_nova_conf(self):
        result = False
        try:
            vncserver_listen = '0.0.0.0'
            path_nova_conf_file = config.CONF.path_nova_conf

            config_common = ConfigCommon(path_nova_conf_file)
            config_common.set_default('vncserver_listen', vncserver_listen)
            config_common.set_default('service_metadata_proxy', 'False')
            config_common.set_default('metadata_proxy_shared_secret',
                                      'openstack')
            config_common.write_commit()
            result = True
        except:
            logger.error(
                'Exception occur when config nova.conf. EXCEPTION: %s' %
                traceback.format_exc())

        return result