@classmethod
    def getConfig(cls):
        """Generate config from command line arguments and config file."""

        # example_config = {
        #       "daemon": True,
        #       "run_once": False,
        #       "debug": False,
        #       "watchlist": [
        #           {"servers": [ {"host": "localhost", "port": 514} ],
        #            "watchfiles": [
        #               {"tag": "anaconda",
        #                "log_type": "anaconda",
        #                "files": ["/tmp/anaconda.log",
        #                   "/mnt/sysimage/root/install.log"]
        #                }
        #               ]
        #            }
        #           ]
        #       }

        default_config = {"daemon": True,
                          "run_once": False,
                          "debug": False,
                          "hostname": cls._getHostname(),
                          "watchlist": []
                          }
        # First use default config as running config.
        config = dict(default_config)
        # Get command line options and validate it.
        cmdline = cls.cmdlineParse()[0]
        # Check config file source and read it.
        if cmdline.config_file or cmdline.stdin_config:
            try:
                if cmdline.stdin_config is True:
                    fo = sys.stdin
                else:
                    fo = open(cmdline.config_file, 'r')
                parsed_config = json.load(fo)
                if cmdline.debug:
                    print(parsed_config)
            except IOError:  # Raised if IO operations failed.
                main_logger.error("Can not read config file %s\n" %
                                  cmdline.config_file)
                exit(1)
            except __HOLE__ as e:  # Raised if json parsing failed.
                main_logger.error("Can not parse config file. %s\n" %
                                  e.message)
                exit(1)
            #  Validate config from config file.
            cls.configValidate(parsed_config)
            # Copy gathered config from config file to running config
            # structure.
            for key, value in parsed_config.items():
                config[key] = value
        else:
            # If no config file specified use watchlist setting from
            # command line.
            watchlist = {"servers": [{"host": cmdline.host,
                                      "port": cmdline.port}],
                         "watchfiles": [{"tag": cmdline.tag,
                                         "log_type": cmdline.log_type,
                                         "files": cmdline.watchfiles}]}
            config['watchlist'].append(watchlist)

        # Apply behavioural command line options to running config.
        if cmdline.no_daemon:
            config["daemon"] = False
        if cmdline.run_once:
            config["run_once"] = True
        if cmdline.debug:
            config["debug"] = True
        return config
dataset/ETHPy150Open openstack/bareon/contrib/fuel_bootstrap/files/trusty/usr/bin/send2syslog.py/Config.getConfig