Ejemplo n.º 1
0
    def upload_pkg(self,
                   pkg_path,
                   upload_path=None,
                   update_checksum=False,
                   timeout=300):
        from autotest_lib.server import subcommand
        if upload_path:
            upload_path_list = [upload_path]
            self.upkeep(upload_path_list)
        elif len(self.upload_paths) > 0:
            self.upkeep()
            upload_path_list = self.upload_paths
        else:
            raise error.PackageUploadError("Invalid Upload Path specified")

        if update_checksum:
            # get the packages' checksum file and update it with the current
            # package's checksum
            self.update_checksum(pkg_path)

        commands = []
        for path in upload_path_list:
            commands.append(
                subcommand.subcommand(self.upload_pkg_parallel,
                                      (pkg_path, path, update_checksum)))

        results = subcommand.parallel(commands, timeout, return_results=True)
        for result in results:
            if result:
                print str(result)
Ejemplo n.º 2
0
 def upload_pkg_dir(self, dir_path, upload_path):
     '''
     Upload a full directory. Depending on the upload path, the appropriate
     method for that protocol is called. Currently this copies the whole
     tmp package directory to the target directory.
     This assumes that the web server is running on the same machine where
     the method is being called from. The upload_path's files are
     basically served by that web server.
     '''
     local_path = os.path.join(dir_path, "*")
     try:
         if upload_path.startswith('ssh://'):
             hostline, remote_path = parse_ssh_path(upload_path)
             try:
                 utils.run('scp %s %s:%s' %
                           (local_path, hostline, remote_path))
                 ssh_path = os.path.join(remote_path, "*")
                 utils.run("ssh %s 'chmod 644 %s'" % (hostline, ssh_path))
             except error.CmdError:
                 logging.error("Error uploading to repository: %s",
                               upload_path)
         else:
             utils.run("cp %s %s " % (local_path, upload_path))
             up_path = os.path.join(upload_path, "*")
             utils.run("chmod 644 %s" % up_path)
     except (IOError, os.error), why:
         raise error.PackageUploadError("Upload of %s to %s failed: %s" %
                                        (dir_path, upload_path, why))
Ejemplo n.º 3
0
def parse_ssh_path(repo):
    '''
    Parse ssh://xx@xx/path/to/ and return a tuple with host_line and
    remote path
    '''

    match = re.search('^ssh://(.*?)(/.*)$', repo)
    if match:
        return match.groups()
    else:
        raise error.PackageUploadError(
            "Incorrect SSH path in global_config: %s" % repo)