Пример #1
0
    def __init__(self, cli_args=None):
        """
        The Application implementation.
        """
        self._execution_dir_path = os.getcwd()
        self._working_dir_path = os.path.join(
            self._execution_dir_path, '{0}-behave-working-dir'.format(
                os.path.basename(self._execution_dir_path)))
        self._working_dir = None
        self._behave_runner = None

        if not cli_args.cli_config_path:
            cli_args.cli_config_path = CTFCliConfig.find_cli_config(
                self._execution_dir_path)
        self._cli_conf = CTFCliConfig(cli_args)

        # If no Dockerfile passed on the cli, try to use one from the execution directory
        if not self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME,
                                  CTFCliConfig.CONFIG_DOCKERFILE):
            local_file = os.path.join(self._execution_dir_path, 'Dockerfile')
            if not os.path.isfile(local_file):
                raise CTFCliError(
                    "No Dockerfile passed on the cli and no Dockerfile "
                    "is present in the current directory!")
            logger.debug("Using Dockerfile from the current directory.")
            self._cli_conf.set(CTFCliConfig.GLOBAL_SECTION_NAME,
                               CTFCliConfig.CONFIG_DOCKERFILE, local_file)

        # TODO: Remove this or rework, once more types are implemented
        if self._cli_conf.get(CTFCliConfig.GLOBAL_SECTION_NAME,
                              CTFCliConfig.CONFIG_EXEC_TYPE) != 'ansible':
            raise CTFCliError(
                "Wrong ExecType configured. Currently only 'ansible' is supported!"
            )
Пример #2
0
    def __init__(self, cli_args=None):
        """
        The Application implementation.
        """
        self._execution_dir_path = os.getcwd()
        self._working_dir_path = os.path.join(self._execution_dir_path,
                                              'workdir')

        self._working_dir = None
        self._behave_runner = None

        if not cli_args.cli_config_path:
            cli_args.cli_config_path = CTFCliConfig.find_cli_config(self._execution_dir_path)
        self._cli_conf = CTFCliConfig(cli_args)