Beispiel #1
0
    def __init__(self):
        settings_files = []
        logger.debug("Looking for settings.yaml package config "
                     "using old style __file__")
        project_path = os.path.dirname(__file__)
        project_settings_file = os.path.join(project_path, 'settings.yaml')
        settings_files.append(project_settings_file)
        settings_files.append('/etc/nailgun/settings.yaml')

        test_config = os.environ.get('NAILGUN_CONFIG')
        if test_config:
            settings_files.append(test_config)

        self.config = {}
        for sf in settings_files:
            try:
                logger.debug("Trying to read config file %s" % sf)
                self.update_from_file(sf)
            except Exception as e:
                logger.error("Error while reading config file %s: %s" %
                             (sf, str(e)))

        self.config['VERSION']['api'] = self.config['API']
        self.config['VERSION']['feature_groups'] = \
            self.config['FEATURE_GROUPS']

        fuel_release = self.get_file_content(consts.FUEL_RELEASE_FILE)
        if fuel_release:
            self.config['VERSION']['release'] = fuel_release

        fuel_openstack_version = self.get_file_content(
            consts.FUEL_OPENSTACK_VERSION_FILE)
        if fuel_openstack_version:
            self.config['VERSION']['openstack_version'] = \
                fuel_openstack_version

        if int(self.config.get("DEVELOPMENT")):
            logger.info("DEVELOPMENT MODE ON:")
            here = os.path.abspath(
                os.path.join(os.path.dirname(__file__), '..')
            )
            self.config.update({
                'STATIC_DIR': os.path.join(here, 'static'),
                'TEMPLATE_DIR': os.path.join(here, 'static')
            })
            logger.info("Static dir is %s" % self.config.get("STATIC_DIR"))
            logger.info("Template dir is %s" % self.config.get("TEMPLATE_DIR"))

        loglevel = self.config.get("APP_LOGLEVEL")
        if isinstance(loglevel, six.string_types):
            logger.setLevel(getattr(logging, loglevel.upper()))
Beispiel #2
0
    def __init__(self):
        settings_files = []
        logger.debug("Looking for settings.yaml package config "
                     "using old style __file__")
        project_path = os.path.dirname(__file__)
        project_settings_file = os.path.join(project_path, 'settings.yaml')
        settings_files.append(project_settings_file)
        settings_files.append('/etc/nailgun/settings.yaml')

        test_config = os.environ.get('NAILGUN_CONFIG')
        if test_config:
            settings_files.append(test_config)

        self.config = {}
        for sf in settings_files:
            try:
                logger.debug("Trying to read config file %s" % sf)
                self.update_from_file(sf)
            except Exception as e:
                logger.error("Error while reading config file %s: %s" %
                             (sf, str(e)))

        self.config['VERSION']['api'] = self.config['API']
        self.config['VERSION']['feature_groups'] = \
            self.config['FEATURE_GROUPS']

        fuel_release = self.get_file_content(consts.FUEL_RELEASE_FILE)
        if fuel_release:
            self.config['VERSION']['release'] = fuel_release

        fuel_openstack_version = self.get_file_content(
            consts.FUEL_OPENSTACK_VERSION_FILE)
        if fuel_openstack_version:
            self.config['VERSION']['openstack_version'] = \
                fuel_openstack_version

        if int(self.config.get("DEVELOPMENT")):
            logger.info("DEVELOPMENT MODE ON:")
            here = os.path.abspath(
                os.path.join(os.path.dirname(__file__), '..'))
            self.config.update({
                'STATIC_DIR': os.path.join(here, 'static'),
                'TEMPLATE_DIR': os.path.join(here, 'static')
            })
            logger.info("Static dir is %s" % self.config.get("STATIC_DIR"))
            logger.info("Template dir is %s" % self.config.get("TEMPLATE_DIR"))

        loglevel = self.config.get("APP_LOGLEVEL")
        if isinstance(loglevel, six.string_types):
            logger.setLevel(getattr(logging, loglevel.upper()))
Beispiel #3
0
    def __init__(self):
        settings_files = []
        logger.debug("Looking for settings.yaml package config "
                     "using old style __file__")
        project_path = os.path.dirname(__file__)
        project_settings_file = os.path.join(project_path, 'settings.yaml')
        settings_files.append(project_settings_file)
        settings_files.append('/etc/nailgun/settings.yaml')

        version_paths = ["/etc/fuel/version.yaml",
                         "/etc/fuel/nailgun/version.yaml",
                         "/etc/nailgun/version.yaml"]
        for path in version_paths:
            if os.access(path, os.R_OK):
                settings_files.append(path)
                break
        else:
            logger.error("'version.yaml' config file is not found")

        test_config = os.environ.get('NAILGUN_CONFIG')
        if test_config:
            settings_files.append(test_config)

        self.config = {}
        for sf in settings_files:
            try:
                logger.debug("Trying to read config file %s" % sf)
                self.update_from_file(sf)
            except Exception as e:
                logger.error("Error while reading config file %s: %s" %
                             (sf, str(e)))

        if int(self.config.get("DEVELOPMENT")):
            logger.info("DEVELOPMENT MODE ON:")
            here = os.path.abspath(
                os.path.join(os.path.dirname(__file__), '..')
            )
            self.config.update({
                'STATIC_DIR': os.path.join(here, 'static'),
                'TEMPLATE_DIR': os.path.join(here, 'static')
            })
            logger.info("Static dir is %s" % self.config.get("STATIC_DIR"))
            logger.info("Template dir is %s" % self.config.get("TEMPLATE_DIR"))

        loglevel = self.config.get("APP_LOGLEVEL")
        if isinstance(loglevel, six.string_types):
            logger.setLevel(getattr(logging, loglevel.upper()))
Beispiel #4
0
    def __init__(self):
        #构造配直文件位置
        settings_files = []
        logger.debug("Looking for settings.yaml package config "
                     "using old style __file__")
        project_path = os.path.dirname(__file__)
        project_settings_file = os.path.join(project_path, 'settings.yaml')
        settings_files.append(project_settings_file)
        settings_files.append('/etc/nailgun/settings.yaml')

        test_config = os.environ.get('NAILGUN_CONFIG')
        if test_config:
            settings_files.append(test_config)

        # If settings.yaml doesn't exist we should have default
        # config structure. Nailgun without settings is used
        # when we distribute source code to the workers for
        # distributed serialization
        self.config = {
            'VERSION': {},
            'DATABASE': {
                'engine': 'postgresql',
                'name': '',
                'host': '',
                'port': '0',
                'user': '',
                'passwd': ''
            }
        }
        #加载配直
        for sf in settings_files:
            try:
                logger.debug("Trying to read config file %s" % sf)
                self.update_from_file(sf)
            except Exception as e:
                logger.error("Error while reading config file %s: %s" %
                             (sf, str(e)))

        self.config['VERSION']['api'] = self.config.get('API')
        self.config['VERSION']['feature_groups'] = \
            self.config.get('FEATURE_GROUPS')

        fuel_release = self.get_file_content(consts.FUEL_RELEASE_FILE)
        if fuel_release:
            self.config['VERSION']['release'] = fuel_release

        fuel_openstack_version = self.get_file_content(
            consts.FUEL_OPENSTACK_VERSION_FILE)
        if fuel_openstack_version:
            self.config['VERSION']['openstack_version'] = \
                fuel_openstack_version

        if int(self.config.get("DEVELOPMENT", 0)):
            #检查发现开发模式被打开了
            logger.info("DEVELOPMENT MODE ON:")
            here = os.path.abspath(
                os.path.join(os.path.dirname(__file__), '..'))
            self.config.update({
                'STATIC_DIR': os.path.join(here, 'static'),
                'TEMPLATE_DIR': os.path.join(here, 'static')
            })
            logger.info("Static dir is %s" % self.config.get("STATIC_DIR"))
            logger.info("Template dir is %s" % self.config.get("TEMPLATE_DIR"))

        loglevel = self.config.get("APP_LOGLEVEL")
        if isinstance(loglevel, six.string_types):
            logger.setLevel(getattr(logging, loglevel.upper()))
Beispiel #5
0
    def __init__(self):
        settings_files = []
        logger.debug("Looking for settings.yaml package config "
                     "using old style __file__")
        project_path = os.path.dirname(__file__)
        project_settings_file = os.path.join(project_path, 'settings.yaml')
        settings_files.append(project_settings_file)
        settings_files.append('/etc/nailgun/settings.yaml')

        test_config = os.environ.get('NAILGUN_CONFIG')
        if test_config:
            settings_files.append(test_config)

        # If settings.yaml doesn't exist we should have default
        # config structure. Nailgun without settings is used
        # when we distribute source code to the workers for
        # distributed serialization
        self.config = {
            'VERSION': {},
            'DATABASE': {
                'engine': 'postgresql',
                'name': '',
                'host': '',
                'port': '0',
                'user': '',
                'passwd': ''
            }
        }
        for sf in settings_files:
            try:
                logger.debug("Trying to read config file %s" % sf)
                self.update_from_file(sf)
            except Exception as e:
                logger.error("Error while reading config file %s: %s" %
                             (sf, str(e)))

        self.config['VERSION']['api'] = self.config.get('API')
        self.config['VERSION']['feature_groups'] = \
            self.config.get('FEATURE_GROUPS')

        fuel_release = self.get_file_content(consts.FUEL_RELEASE_FILE)
        if fuel_release:
            self.config['VERSION']['release'] = fuel_release

        fuel_openstack_version = self.get_file_content(
            consts.FUEL_OPENSTACK_VERSION_FILE)
        if fuel_openstack_version:
            self.config['VERSION']['openstack_version'] = \
                fuel_openstack_version

        if int(self.config.get("DEVELOPMENT", 0)):
            logger.info("DEVELOPMENT MODE ON:")
            here = os.path.abspath(
                os.path.join(os.path.dirname(__file__), '..')
            )
            self.config.update({
                'STATIC_DIR': os.path.join(here, 'static'),
                'TEMPLATE_DIR': os.path.join(here, 'static')
            })
            logger.info("Static dir is %s" % self.config.get("STATIC_DIR"))
            logger.info("Template dir is %s" % self.config.get("TEMPLATE_DIR"))

        loglevel = self.config.get("APP_LOGLEVEL")
        if isinstance(loglevel, six.string_types):
            logger.setLevel(getattr(logging, loglevel.upper()))