Esempio n. 1
0
    def loadDaemonSettings(self):
        """Loads the settings for the daemon
        """

        self._current_builds = 0

        # daemon_check_interval
        try:
            self._interval = int(
                configmanager.get_prop("daemon_check_interval"))
        except TypeError:
            self._interval = DAEMON_DEFAULT_INTERVAL

        # daemon_max_containers
        try:
            self._max_containers = int(
                configmanager.get_prop("daemon_max_containers"))
        except TypeError:
            self._max_containers = DAEMON_DEFAULT_MAX_CONTAINERS

        # api_server
        self._api_server = configmanager.get_prop("api_server")

        # api_server_port
        try:
            self._api_server_port = int(
                configmanager.get_prop("api_server_port"))
        except TypeError:
            self._api_server_port = API_SERVER_DEFAULT_PORT
Esempio n. 2
0
    def addProjectListCommand(self):
        default_ip = configmanager.get_prop("api_client_default_ip")
        if not default_ip:
            default_ip = "127.0.0.1"

        default_port = 5555
        try:
            default_port = int(
                configmanager.get_prop("api_client_default_port"))
        except ValueError:
            pass

        cmd = self.cmdSubParser.add_parser(
            "project-list", aliases=["pl"], help="Retrieves a list of all projects on a " \
            "DapsEnv instance."
        )

        cmd.add_argument("--ip",
                         "-i",
                         action="store",
                         default=default_ip,
                         help="Sets the IP of the API server.")

        cmd.add_argument("--port",
                         "-p",
                         action="store",
                         default=default_port,
                         help="Sets the port of the API server.")
Esempio n. 3
0
    def addStatusCommand(self):
        default_ip = configmanager.get_prop("api_client_default_ip")
        if not default_ip:
            default_ip = "127.0.0.1"

        default_port = 5555
        try:
            default_port = int(
                configmanager.get_prop("api_client_default_port"))
        except ValueError:
            pass

        cmd = self.cmdSubParser.add_parser(
            "status", aliases=["s"], help="Queries a DapsEnv API server.")

        cmd.add_argument("--ip",
                         "-i",
                         action="store",
                         default=default_ip,
                         help="Sets the IP of the API server.")

        cmd.add_argument("--port",
                         "-p",
                         action="store",
                         default=default_port,
                         help="Sets the port of the API server.")
Esempio n. 4
0
    def addDaemonCommand(self):
        logmanager_ip = configmanager.get_prop("logmanager_ip")
        if not logmanager_ip:
            default_ip = "127.0.0.1"

        logserver_port = 5556
        try:
            logserver_port = int(configmanager.get_prop("logserver_port"))
        except ValueError:
            pass

        cmd = self.cmdSubParser.add_parser(
            "daemon", aliases=["d"], help="This command starts a daemon which takes care of " \
            "the documentation building process."
        )

        cmd.add_argument(
            "--use-irc", "-i", action="store_true", help="Connects to the IRC server what is " \
            "configured in the configuration file."
        )

        cmd.add_argument(
            "--use-logserver", "-l", action="store_true", help="Starts an HTTP server what " \
            "provides access to build log files."
        )

        cmd.add_argument(
            "--logserver-ip", action="store", default=logmanager_ip, help="The IP address the log " \
            "server should listen to."
        )

        cmd.add_argument(
            "--logserver-port", action="store", default=logserver_port, help="The IP address the log " \
            "server should listen to."
        )

        cmd.add_argument("--no-output",
                         "-n",
                         action="store_true",
                         help="Hides the daemon output.")

        cmd.add_argument(
            "--debug", "-d", action="store_true", help="Useful for developer to get more " \
            "information about the Daemon process."
        )

        cmd.add_argument(
            "--autobuild-config", "-a", action="store", help="Specifies a path to the " \
            "autobuild config file. This overrides the value in configuration files."
        )

        cmd.add_argument(
            "--development", action="store_true", help="Not relevant for the normal user and " \
            "should only be used by developers. This option forbids to start docker containers. " \
            "This is useful during development."
        )
Esempio n. 5
0
    def get_property(self, prop):
        """Displays the value of the wanted property

        :param string prop: The name of the property
        """

        value = configmanager.get_prop(prop, self._configtype, self._path)
        if value:
            print(configmanager.get_prop(prop, self._configtype, self._path))
        else:
            raise ConfigPropertyNotFoundException()
Esempio n. 6
0
def test_get(mock_get_user_config_path, mock_get_global_config_path,
             config_type, config_path, prop, expect):

    mock_get_global_config_path.return_value = config_path
    mock_get_user_config_path.return_value = config_path

    value = configmanager.get_prop(prop, config_type, config_path)
    assert value == expect
Esempio n. 7
0
    def addViewLogCommand(self):
        default_ip = configmanager.get_prop("api_client_default_ip")
        if not default_ip:
            default_ip = "127.0.0.1"

        default_port = 5555
        try:
            default_port = int(
                configmanager.get_prop("api_client_default_port"))
        except ValueError:
            pass

        cmd = self.cmdSubParser.add_parser(
            "view-log",
            aliases=["vl"],
            help="Shows the log result of a failed build.")

        cmd.add_argument("--ip",
                         "-i",
                         action="store",
                         default=default_ip,
                         help="Sets the IP of the API server.")

        cmd.add_argument("--port",
                         "-p",
                         action="store",
                         default=default_port,
                         help="Sets the port of the API server.")

        cmd.add_argument("--format",
                         "-f",
                         action="store",
                         required=True,
                         choices=["html", "single_html", "pdf"],
                         help="Format of the documentation.")

        cmd.add_argument("DC-FILE",
                         nargs=1,
                         action="store",
                         help="Name of the DC-File.")
Esempio n. 8
0
    def addTriggerBuildCommand(self):
        default_ip = configmanager.get_prop("api_client_default_ip")
        if not default_ip:
            default_ip = "127.0.0.1"

        default_port = 5555
        try:
            default_port = int(
                configmanager.get_prop("api_client_default_port"))
        except ValueError:
            pass

        cmd = self.cmdSubParser.add_parser(
            "trigger-build",
            aliases=["tb"],
            help="Triggers a build on a DapsEnv instance.")

        cmd.add_argument("--ip",
                         "-i",
                         action="store",
                         default=default_ip,
                         help="Sets the IP of the API server.")

        cmd.add_argument("--port",
                         "-p",
                         action="store",
                         default=default_port,
                         help="Sets the port of the API server.")

        cmd.add_argument("--projects",
                         "-r",
                         nargs="+",
                         action="store",
                         help="Schedules builds for the given projects.")

        cmd.add_argument("--dcfiles",
                         "-d",
                         nargs="+",
                         action="store",
                         help="Schedules builds for the given DC-Files.")
Esempio n. 9
0
 def loadIRCBotConfig(self):
     self._irc_config["irc_server"] = configmanager.get_prop("irc_server")
     self._irc_config["irc_server_port"] = int(
         configmanager.get_prop("irc_server_port"))
     self._irc_config["irc_channel"] = "#{}".format(
         configmanager.get_prop("irc_channel"))
     self._irc_config["irc_bot_nickname"] = configmanager.get_prop(
         "irc_bot_nickname")
     self._irc_config["irc_bot_username"] = configmanager.get_prop(
         "irc_bot_username")
     self._irc_config["irc_inform_build_success"] = True if \
         configmanager.get_prop("irc_inform_build_success") == "true" else False
     self._irc_config["irc_inform_build_fail"] = True if \
         configmanager.get_prop("irc_inform_build_fail") == "true" else False
     self._irc_config["irc_channel_messages"] = True if \
         configmanager.get_prop("irc_channel_messages") == "true" else False
Esempio n. 10
0
    def _preperation(self):
        """Loads all settings and prepares the daemon
        """

        self._useirc = self._args["use_irc"]
        self._noout = self._args["no_output"]
        self._debug = self._args["debug"]
        self._logserver = self._args["use_logserver"]
        self._logserver_ip = self._args["logserver_ip"]
        self._logserver_port = self._args["logserver_port"]
        self._irc_config = {}
        self._ircbot = None
        self._logserver_httpd = None
        self._hostname = gethostname()
        self._auth = DaemonAuth(DAEMON_AUTH_PATH)

        self._daemon_info = {
            "jobs": [],
            "scheduled_builds": 0,
            "running_builds": 0
        }

        # create locks for thread-safe communications
        self._irclock = threading.Lock()
        self._daemon_info_lock = threading.Lock()

        # load daemon settings
        self.loadDaemonSettings()

        # load irc bot config
        self.loadIRCBotConfig()

        # load auto build configuration file
        if self._args["autobuild_config"]:
            self._autoBuildConfigFile = self._args["autobuild_config"]
        else:
            self._autoBuildConfigFile = configmanager.get_prop(
                "daps_autobuild_config")

        self.autoBuildConfig = self.loadAutoBuildConfig(
            self._autoBuildConfigFile)

        # fetch all projects
        try:
            self.projects = self.autoBuildConfig.fetchProjects()
        except GitInvalidRepoException as e:
            log.error("Configuration error in auto build config '%s'! %s", \
                self._autoBuildConfigFile, e.message)
            sys.exit(E_INVALID_GIT_REPO)