def do_mounts(self, rootdir, mounts): if not mounts: return self.logger.info('New runroot') self.logger.info("Runroot mounts: %s" % mounts) fn = '%s/tmp/runroot_mounts' % rootdir fslog = open(fn, 'a') logfile = "%s/do_mounts.log" % self.workdir uploadpath = self.getUploadDir() error = None for dev, path, type, opts in mounts: if not path.startswith('/'): raise koji.GenericError("invalid mount point: %s" % path) mpoint = "%s%s" % (rootdir, path) if opts is None: opts = [] else: opts = opts.split(',') if 'bind' in opts: #make sure dir exists if not os.path.isdir(dev): error = koji.GenericError( "No such directory or mount: %s" % dev) break type = 'none' if 'bg' in opts: error = koji.GenericError( "bad config: background mount not allowed") break opts = ','.join(opts) cmd = ['mount', '-t', type, '-o', opts, dev, mpoint] self.logger.info("Mount command: %r" % cmd) koji.ensuredir(mpoint) if compat_mode: status = log_output(cmd[0], cmd, logfile, uploadpath, logerror=True, append=True) else: status = log_output(self.session, cmd[0], cmd, logfile, uploadpath, logerror=True, append=True) if not _isSuccess(status): error = koji.GenericError("Unable to mount %s: %s" \ % (mpoint, _parseStatus(status, cmd))) break fslog.write("%s\n" % mpoint) fslog.flush() fslog.close() if error is not None: self.undo_mounts(rootdir, fatal=False) raise error
def do_mounts(self, rootdir, mounts): if not mounts: return self.logger.info('New runroot') self.logger.info("Runroot mounts: %s" % mounts) fn = '%s/tmp/runroot_mounts' % rootdir fslog = file(fn, 'a') logfile = "%s/do_mounts.log" % self.workdir uploadpath = self.getUploadDir() error = None for dev,path,type,opts in mounts: if not path.startswith('/'): raise koji.GenericError("invalid mount point: %s" % path) mpoint = "%s%s" % (rootdir,path) if opts is None: opts = [] else: opts = opts.split(',') if 'bind' in opts: #make sure dir exists if not os.path.isdir(dev): error = koji.GenericError("No such directory or mount: %s" % dev) break type = 'none' if path is None: #shorthand for "same path" path = dev if 'bg' in opts: error = koji.GenericError("bad config: background mount not allowed") break opts = ','.join(opts) cmd = ['mount', '-t', type, '-o', opts, dev, mpoint] self.logger.info("Mount command: %r" % cmd) koji.ensuredir(mpoint) if compat_mode: status = log_output(cmd[0], cmd, logfile, uploadpath, logerror=True, append=True) else: status = log_output(self.session, cmd[0], cmd, logfile, uploadpath, logerror=True, append=True) if not _isSuccess(status): error = koji.GenericError("Unable to mount %s: %s" \ % (mpoint, _parseStatus(status, cmd))) break fslog.write("%s\n" % mpoint) fslog.flush() fslog.close() if error is not None: self.undo_mounts(rootdir, fatal=False) raise error