def mount_tape(robot, slot, drive): """ Mounts tape from slot into drive Args: robot: The device used to mount the tape slot: Which slot to load from drive: Which drive to load to """ cmd = 'mtx -f %s load %d %d' % (robot, slot, drive) p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) logger.debug('Mounting tape from {slot} to {drive} using {robot}: {cmd}'.format(slot=slot, drive=drive, robot=robot, cmd=cmd)) out, err = p.communicate() if p.returncode: if re.match('Drive \d+ Full \(Storage Element \d+ loaded\)', err): logger.warn('Tried to mount already mounted tape from {slot} to {drive} using {robot}'.format(slot=slot, drive=drive, robot=robot)) raise TapeMountedError(err) logger.error('Failed to mount tape from {slot} to {drive} using {robot}, err: {err}, returncode: {rcode}'.format(slot=slot, drive=drive, robot=robot, err=err, rcode=p.returncode)) raise RobotMountException('%s, return code: %s' % (err, p.returncode)) logger.info('Mounted tape from {slot} to {drive} using {robot}'.format(slot=slot, drive=drive, robot=robot)) return out
def mount_tape(robot, slot, drive): """ Mounts tape from slot into drive Args: robot: The device used to mount the tape slot: Which slot to load from drive: Which drive to load to """ cmd = 'mtx -f %s load %d %d' % (robot, slot, drive) p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) out, err = p.communicate() if p.returncode: raise RobotMountException('%s, return code: %s' % (err, p.returncode)) return out