Esempio n. 1
0
    def _init_outdir(self, discovery=False):
        """
        Helper function for 'configure()' that creates the output directory and various of its
        sub-direcories.
        """

        if not self.outdir:
            self.outdir = FSHelpers.mktemp(prefix="stats-collect-",
                                           proc=self._proc)
            self._outdir_created = True
            _LOG.debug("created output directory '%s'%s", self.outdir,
                       self._proc.hostmsg)
        else:
            try:
                FSHelpers.mkdir(self.outdir, parents=True, proc=self._proc)
            except ErrorExists:
                pass
            else:
                self._outdir_created = True

        self._logsdir = self.outdir / "logs"
        FSHelpers.mkdir(self._logsdir, exist_ok=True, proc=self._proc)

        if discovery:
            # The statistics collected during discovery belong to the logs.
            self._statsdir = self._logsdir / "discovery-stats"
        else:
            self._statsdir = self.outdir / "stats"
        FSHelpers.mkdir(self._statsdir, exist_ok=True, proc=self._proc)
Esempio n. 2
0
def deploy_command(args):
    """Implements the 'deploy' command for the 'wult' and 'ndl' tools."""

    args.stmpdir = None # Temporary directory on the SUT.
    args.ctmpdir = None # Temporary directory on the controller (local host).

    if not FSHelpers.which("rsync", default=None):
        raise Error("please, install the 'rsync' tool")

    if not args.timeout:
        args.timeout = 8
    else:
        args.timeout = Trivial.str_to_num(args.timeout)
    if not args.username:
        args.username = "******"

    if args.privkey and not args.privkey.is_file():
        raise Error(f"path '{args.privkey}' does not exist or it is not a file")

    if args.pyhelpers:
        # Local temporary directory is only needed for creating stand-alone version of python
        # helpers.
        args.ctmpdir = FSHelpers.mktemp(prefix=f"{args.toolname}-")

    with contextlib.closing(ToolsCommon.get_proc(args, args.hostname)) as proc:
        if not FSHelpers.which("make", default=None, proc=proc):
            raise Error(f"please, install the 'make' tool{proc.hostmsg}")

        if proc.is_remote or not args.ctmpdir:
            args.stmpdir = FSHelpers.mktemp(prefix=f"{args.toolname}-", proc=proc)
        else:
            args.stmpdir = args.ctmpdir

        success = True
        try:
            _deploy_drivers(args, proc)
            _deploy_helpers(args, proc)
        except:
            success = False
            raise
        finally:
            _remove_deploy_tmpdir(args, proc, success=success)