예제 #1
0
def unmount_tape(robot, slot, drive):
    """
    Unmounts tape from drive into slot

    Args:
        robot: The device used to unmount the tape
        slot: Which slot to unload to
        drive: Which drive to load from
    """

    cmd = 'mtx -f %s unload %d %d' % (robot, slot, drive)
    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
    logger.debug('Unmounting tape from {drive} to {slot} using {robot}: {cmd}'.format(drive=drive, slot=slot, robot=robot, cmd=cmd))
    out, err = p.communicate()

    if p.returncode:
        if re.match('Data Transfer Element \d+ is Empty', err):
            logger.warn('Tried to unmount already unmounted tape from {drive} to {slot} using {robot}'.format(drive=drive, slot=slot, robot=robot))
            raise TapeUnmountedError(err)

        logger.error('Failed to unmount tape from {drive} to {slot} using {robot}, err: {err}, returncode: {rcode}'.format(drive=drive, slot=slot, robot=robot, err=err, rcode=p.returncode))
        raise RobotUnmountException('%s, return code: %s' % (err, p.returncode))

    logger.info('Unmounted tape from {drive} to {slot} using {robot}'.format(drive=drive, slot=slot, robot=robot))
    return out
예제 #2
0
def unmount_tape(robot, slot, drive):
    """
    Unmounts tape from drive into slot

    Args:
        robot: The device used to unmount the tape
        slot: Which slot to unload to
        drive: Which drive to load from
    """

    cmd = 'mtx -f %s unload %d %d' % (robot, slot, drive)
    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
    out, err = p.communicate()

    if p.returncode:
        raise RobotUnmountException('%s, return code: %s' %
                                    (err, p.returncode))

    return out