Example #1
0
def GetWaitForReplyCount(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Attempts = 0
        l_Continue = 1
        l_PrevServer = None
        l_PrevValue = None
        l_PrintOption = False
        while (l_Continue > 0):
            l_ActiveServer = BB_GetServer("active", False)
            if (l_ActiveServer != ""):
                if (l_Attempts % 120 == 0):
                    l_PrintOption = True
                l_Value = int(
                    BB_GetServerByName(l_ActiveServer, "waitforreplycount",
                                       l_PrintOption))
                time.sleep(0.25)

            l_PrintOption = False
            if (l_PrevServer != l_ActiveServer or l_PrevValue != l_Value):
                l_PrintOption = True
                l_PrevServer = l_ActiveServer
                l_PrevValue = l_Value
                l_Attempts = 0
            l_Attempts += 1
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #2
0
def ListHandles(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        bb.getHandles()
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #3
0
def CreateLogicalVolume_Direct(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        BB_CreateLogicalVolume(pEnv["MOUNT"], pEnv["SIZE"])
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #4
0
def RemoveJobInfo(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        BB_RemoveJobInfo()
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #5
0
def GetUsage(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Mount = pEnv["MOUNT"]
        BB_GetUsage(l_Mount)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #6
0
def OpenServer(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        l_Name = pEnv["name"]

        BB_OpenServer(l_Name)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #7
0
def StageOutStart(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Args = pEnv["procedure_args"].split(",")
        Coral_StageOutStart(l_Args[0])
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #8
0
def ResizeMountPoint(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Args = pEnv["procedure_args"].split(",")
        BB_ResizeMountPoint(l_Args[0], l_Args[1], int(l_Args[2]))
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #9
0
def CreateLogicalVolume(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Args = pEnv["procedure_args"].split(",")
        BB_CreateLogicalVolume(l_Args[0], l_Args[1], int(l_Args[2]))
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #10
0
def RemoveDirectory(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Args = pEnv["procedure_args"].split(",")
        BB_RemoveDirectory(l_Args[0])
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #11
0
def Suspend(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        l_HostName = pEnv["hostname"]

        BB_Suspend(l_HostName)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #12
0
def ChangeOwner(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Args = pEnv["procedure_args"].split(",")
        BB_ChangeOwner(l_Args[0], l_Args[1], l_Args[2])
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #13
0
def GetHandle(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Contrib = pEnv["contrib"]
        l_Handle = BB_GetTransferHandle(pEnv["tag"], len(l_Contrib), l_Contrib)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #14
0
def RemoveLogicalVolume(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        l_Mountpoint = pEnv["MOUNT"]

        BB_RemoveLogicalVolume(l_Mountpoint)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #15
0
def GetServer(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        l_Type = pEnv["type"]

        BB_GetServer(l_Type)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #16
0
def SetServer(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        l_Type = pEnv["type"]
        l_Name = pEnv["name"]

        BB_SetServer(l_Type, l_Name)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #17
0
def GetTransferInfo(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Handle = pEnv["handle"]
        l_Info = BB_GetTransferInfo(l_Handle)
        bb.printStruct(l_Info)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #18
0
def RemoveLogicalVolume(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        if (pEnv["procedure_args"] == ""):
            l_Mountpoint = pEnv["MOUNT"]
        else:
            l_Mountpoint = pEnv["procedure_args"]

        BB_RemoveLogicalVolume(l_Mountpoint)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #19
0
def RetrieveTransfers(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)
        l_HostName = pEnv["hostname"]
        l_Handle = pEnv["handle"]
        l_Flags = DEFAULT_BB_RTV_TRANSFERDEFS_FLAGS
        if pEnv.has_key("FLAGS"):
            l_Flags = BB_RTV_TRANSFERDEFS_FLAGS.get(pEnv["FLAGS"], DEFAULT_BB_RTV_TRANSFERDEFS_FLAGS)

        (l_NumberOfTranferDefs, l_TransferDefs, l_BytesForTransferDefs) = BB_RetrieveTransfers(l_HostName, l_Handle, l_Flags)
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #20
0
def ListTransfers(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_Handles = bb.getHandles()
        for l_Handle in l_Handles:
            try:
                BB_GetTransferInfo(l_Handle)
            except BBError as error:
                error.handleError()

    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #21
0
def CancelTransfers(pEnv):
    rc = 0

    try:
        bb.initEnv(pEnv)

        l_TargetHandle = pEnv["handle"]
        l_Handles = bb.getHandles()
        for l_Handle in l_Handles:
            try:
                if (l_TargetHandle == bb.NO_HANDLE
                        or l_TargetHandle == l_Handle):
                    BB_CancelTransfer(l_Handle)
            except BBError as error:
                error.handleError()
    except BBError as error:
        error.handleError()
        rc = error.rc

    return rc
Example #22
0
def BasicTransfers2(pEnv):
    rc = 0
    l_FuncName = sys._getframe().f_code.co_name

    print "   >>>>> Start: %s.%s..." % (__name__, l_FuncName)

    l_Owner = pEnv.get("OWNER", None)
    l_Group = pEnv.get("GROUP", None)
    l_Mode = int(pEnv.get("MODE", 0755))
    l_LVSize = pEnv.get("SIZE", "1G")

    l_OrgSrc = pEnv["ORGSRC"]
    l_Mountpoint = pEnv["MOUNT"]
    l_Target = pEnv["TARGET"]

    l_FileAttrs = (
        ("file1", 256 * 1024),
        ("file2", 0),
        ("file3", 1024 * 1024),
        ("file4", 4 * 1024 * 1024),
        ("file5", 16 * 1024 * 1024),
    )
    l_SourceFiles = (
        (os.path.join(l_OrgSrc, "file1"), ),
        (os.path.join(l_Mountpoint, "file1"), ),
    )
    l_TargetFiles = (
        (os.path.join(l_Mountpoint, "file1"), ),
        (os.path.join(l_Target, "file1"), ),
    )
    l_FileFlags = (
        ("None", ),
        ("None", ),
    )

    l_Tag = 0  # The first tag to use will be 1...
    l_Contrib = pEnv["contrib"]
    l_NumHandles = 16

    # NOTE: Any non-zero return code that is returned from any of the BB_* api calls
    #       will cause an exception to be thrown and caught in the handler below.
    #       The return code is available as exception data...
    try:
        # Print out the environment to setup...
        bb.printEnv(pEnv)

        # Cleanup any prior running of this variation and setup to run this time...
        rc = bb.initEnv(pEnv, None, None)

        if (rc == 0):
            # Create the files to be transferred
            print "%sGenerating files with randfile..." % (os.linesep)
            for l_File, l_FileSize in (l_FileAttrs):
                bb.createRandomFile(pEnv, (os.path.join(l_OrgSrc, l_File)),
                                    l_FileSize)

            # Remove/Create the necessary directories...
            sudo_RemoveDirectory(pEnv, l_Target)
            sudo_CreateDirectory(pEnv, l_Target)
            sudo_ChangeOwner(pEnv, l_Target, l_Owner, l_Group)
            sudo_ChangeMode(pEnv, l_Target, l_Mode)

            # Run the testcase...
            for l_VarNum in xrange(0, len(l_SourceFiles)):
                print "      >>>>> Start: Variation %d..." % (l_VarNum)

                l_TransferDef = BB_CreateTransferDef()
                for l_FileNum in xrange(len(l_SourceFiles[l_VarNum])):
                    BB_AddFiles(l_TransferDef,
                                l_SourceFiles[l_VarNum][l_FileNum],
                                l_TargetFiles[l_VarNum][l_FileNum],
                                BBFILEFLAGS[l_FileFlags[l_VarNum][l_FileNum]])

                l_Tag += 1
                l_Handle = BB_GetTransferHandle(l_Tag, len(l_Contrib),
                                                l_Contrib)
                BB_StartTransfer(l_TransferDef, l_Handle)

                if l_VarNum + 1 == len(l_SourceFiles):
                    # Last variation, so we are doing the stageout processing.
                    # NOTE: This isn't required, but included for test purposes.
                    sudo_StageOutStart(pEnv, l_Mountpoint)

                l_Handles = bb.getHandles(BBSTATUS["BBALL"])
                l_AllFullSuccess = bb.waitForCompletion(pEnv, l_Handles)

                BB_FreeTransferDef(l_TransferDef)

                print "      >>>>>   End: Variation %d..." % (l_VarNum)

                if not l_AllFullSuccess:
                    raise BBError(
                        rc=-1,
                        text="Not all transfers had a status of BBFULLSUCCESS")

            bb.checkFiles(l_SourceFiles, l_TargetFiles)

    except BBError as error:
        rc = error.rc
        # NOTE: BB_GetLastErrorDetails() output is contained within the error object
        #       and pertinant information is printed out from that data...
        print ` error `

    print "   >>>>>   End: %s.%s..." % (__name__, l_FuncName)

    return rc
Example #23
0
def RestartTransfers(pEnv):
    rc = 0
    l_ResumeCN_Host = False
    l_NumStoppedTransferDefs = 0

    try:
        bb.initEnv(pEnv)
        l_HostName = pEnv["hostname"]
        l_Handle = pEnv["handle"]
        l_Flags = DEFAULT_BB_RTV_TRANSFERDEFS_FLAGS
        if pEnv.has_key("FLAGS"):
            l_Flags = BB_RTV_TRANSFERDEFS_FLAGS.get(
                pEnv["FLAGS"], DEFAULT_BB_RTV_TRANSFERDEFS_FLAGS)

        l_ActiveServer = BB_GetServer("active")
        if (l_ActiveServer != ""):
            BB_Suspend(l_HostName)
            l_ResumeCN_Host = True

            if (pEnv["IO_FAILOVER"]):
                # New ESS, set up that environment
                l_PrimaryServer = BB_GetServer("primary")
                l_BackupServer = BB_GetServer("backup")

                if (l_ActiveServer == l_PrimaryServer):
                    l_NewServer = l_BackupServer
                else:
                    l_NewServer = l_PrimaryServer

                if (l_NewServer.upper() in ("NONE", )):
                    raise BBError(
                        rc=-1,
                        text="There is no definied backup for this bbServer")

                try:
                    BB_OpenServer(l_NewServer)
                except BBError as error:
                    if not error.handleError():
                        raise
                '''
                # Don't do this as it causes a window...  'activate' makes the swap atomically between the two servers...
                try:
                    BB_SetServer("offline", l_ActiveServer)
                except BBError as error:
                    if not error.handleError():
                        raise
                '''

                try:
                    BB_SetServer("activate", l_NewServer)
                except BBError as error:
                    if not error.handleError():
                        raise

            # NOTE: We do not want to close the connection to the previouly active server until we have
            #       stopped any transfers that may still be running on that server
            (l_NumberOfTranferDefs, l_TransferDefs,
             l_BytesForTransferDefs) = BB_RetrieveTransfers(
                 l_HostName, l_Handle, l_Flags)
            if (l_NumberOfTranferDefs > 0):
                if (not (l_Flags == BB_RTV_TRANSFERDEFS_FLAGS[
                        "ONLY_DEFINITIONS_WITH_STOPPED_FILES"])):
                    l_NumStoppedTransferDefs = BB_StopTransfers(
                        l_HostName, l_Handle, l_TransferDefs,
                        l_BytesForTransferDefs)
                    print "%d transfer definition(s) were found already stopped or were stopped by the previous operation" % (
                        l_NumStoppedTransferDefs)
                else:
                    l_NumStoppedTransferDefs = l_NumberOfTranferDefs
                    print "Additional transfer definition(s) are not being stopped because the option passed on the retrieve transfer operation indicated %s" % (
                        BB_RTV_TRANSFERDEFS_FLAGS[l_Flags])
            else:
                print "No transfer definition(s) were found given the provided input criteria.  An operation to stop transfers will not be attempted."

            if (pEnv["IO_FAILOVER"]):
                # Now, close the connection to the previously active bbServer
                try:
                    # First, make sure we have no waiters...
                    while (int(
                            BB_GetServerByName(l_ActiveServer,
                                               "waitforreplycount")) != 0):
                        time.sleep(1)
                    # Close the connection to the 'old' server
                    BB_CloseServer(l_ActiveServer)
                except BBError as error:
                    if not error.handleError():
                        raise

            elif (0 == 1 and pEnv["CN_FAILOVER"]):
                # New CN, set up that environment
                # Not ready for prime time...

                l_Mountpoint = pEnv["MOUNT"]
                l_Owner = pEnv.get("OWNER", None)
                l_Group = pEnv.get("GROUP", None)
                l_Mode = int(pEnv.get("MODE", 0755))
                l_LVSize = pEnv.get("SIZE", "1G")
                sudo_CreateDirectory(pEnv, l_Mountpoint)
                sudo_ChangeOwner(pEnv, l_Mountpoint, l_Owner, l_Group)
                sudo_ChangeMode(pEnv, l_Mountpoint, l_Mode)
                sudo_CreateLogicalVolume(pEnv, l_Mountpoint, l_LVSize)

            if (l_ResumeCN_Host):
                l_ResumeCN_Host = False
                try:
                    # NOTE:  This resume will ensure that the new
                    #        bbServer is 'resumed' from any prior
                    #        suspend activity.  If the new bbServer
                    #        is not suspended, it is a tolerated exception.
                    #        This resume will also, via the async request file,
                    #        resume the old bbServer for this CN hostname.
                    #        However, any transfers on the old bbServer
                    #        have been stopped, and thus, have been removed
                    #        from any transfer queues.
                    BB_Resume(l_HostName)
                except BBError as error:
                    if not error.handleError():
                        raise

            # NOTE: Even if no transfer definitions were stopped, we still need to issue the restart.
            #       The stop transfer(s) could have actually been performed on other bbServers via
            #       the async request file...
            if (l_NumberOfTranferDefs > 0):
                # Restart the transfers
                l_NumRestartedTransferDefs = BB_RestartTransfers(
                    l_HostName, l_Handle, l_TransferDefs,
                    l_BytesForTransferDefs)
            else:
                print "%sNo transfer definition(s) were found given the provided input criteria.  An operation to restart transfers will not be attempted." % (
                    os.linesep)

            l_ActiveServer = BB_GetServer("active")
        else:
            rc = -1
            print "Initial request for the active server came back as an empty string"

    except BBError as error:
        error.handleError()
        rc = error.rc

    # If we need to resume the active bbServer, do so now...
    if (l_ResumeCN_Host):
        l_ResumeCN_Host = False
        BB_Resume(l_HostName)

    return rc
Example #24
0
def Resize(pEnv):
    rc = 0
    l_FuncName = sys._getframe().f_code.co_name

    print "   >>>>> Start: %s.%s..." % (__name__, l_FuncName)

    l_Owner = pEnv.get("OWNER", None)
    l_Group = pEnv.get("GROUP", None)
    l_Mode = int(pEnv.get("MODE", 0755))
    l_LVSize = "16M"

    l_OrgSrc = "%s" % pEnv["ORGSRC"]
    l_Mountpoint = "%s" % pEnv["MOUNT"]
    l_Target = "%s" % pEnv["TARGET"]

    # NOTE: Any non-zero return code that is returned from any of the BB_* api calls
    #       will cause an exception to be thrown and caught in the handler below.
    #       The return code is available as exception data...
    try:
        # Print out the environment to setup...
        bb.printEnv(pEnv)

        # Cleanup any prior running of this variation and setup to run this time...
        rc = bb.initEnv(pEnv, l_Mountpoint, (l_Target, ))

        if (rc == 0):
            # Create the necessary directories...
            BB_CreateDirectory(l_Mountpoint)
            BB_ChangeOwner(l_Mountpoint, l_Owner, l_Group)
            BB_ChangeMode(l_Mountpoint, l_Mode)

            # Create the logical volume for the mountpoint...
            BB_CreateLogicalVolume(l_Mountpoint, l_LVSize)
            bb.runCmd("lsblk")
            bb.runCmd("ls -lar %s" % (l_Mountpoint))

            # Testcase variations

            # Relative specifictions to increase size- all successful

            print "%sIncrease by 512 bytes" % (os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "+512B", "BB_NONE")
            bb.runCmd("lsblk")
            print "%sIncrease by 512 sectors" % (os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "+512S", "BB_NONE")
            bb.runCmd("lsblk")
            print "%sIncrease by 64K" % (os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "+64K", "BB_NONE")
            bb.runCmd("lsblk")
            print "%sIncrease by 128M" % (os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "+128M", "BB_NONE")
            bb.runCmd("lsblk")
            print "%sIncrease by 0.25G" % (os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "+0.25G", "BB_NONE")
            bb.runCmd("lsblk")

            # Absolute specifiction to increase size - successful

            print "%sIncrease to 2G" % (os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "2G", "BB_NONE")
            bb.runCmd("lsblk")

            # Invalid resize specifications

            print "%sERROR - Invalid mountpoint" % (os.linesep)
            try:
                BB_ResizeMountPoint("JUST/A/BUNCH/OF/JUNK", "2.1G", "BB_NONE")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            print "%sERROR - Invalid size" % (os.linesep)
            try:
                BB_ResizeMountPoint(l_Mountpoint, "ABC", "BB_NONE")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            print "%sERROR - Invalid flags" % (os.linesep)
            try:
                BB_ResizeMountPoint(l_Mountpoint, "2.1G", "MORE_JUNK")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            print "%sERROR - Invalid size suffix of 'X'" % (os.linesep)
            try:
                BB_ResizeMountPoint(l_Mountpoint, "2X", "BB_NONE")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            # Attempt to decrease size (relative size) and preserve file system
            print "%sERROR - Cannot decrease size (relative size) and preserve XFS file system" % (
                os.linesep)
            try:
                BB_ResizeMountPoint(l_Mountpoint, "-256M", "BB_NONE")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            # Attempt to decrease size (absolute size) and preserve file system
            print "%sERROR - Cannot decrease size (absolute size) and preserve XFS file system" % (
                os.linesep)
            try:
                BB_ResizeMountPoint(l_Mountpoint, "1G", "BB_NONE")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            # Successful resize and do not preserve file system

            # Decrease size and do not preserve file system
            print "%sDecrease size by 5M and do not preserve XFS file system" % (
                os.linesep)
            BB_ResizeMountPoint(l_Mountpoint, "-5M", "BB_DO_NOT_PRESERVE_FS")
            bb.runCmd("lsblk")
            try:
                bb.runCmd("ls -lar %s" % (l_Mountpoint))
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            # Attempt to access the mountpoint
            print "%sERROR - Mountpoint no longer mounted" % (os.linesep)
            try:
                BB_ResizeMountPoint(l_Mountpoint, "1G", "BB_NONE")
            except BBError as error:
                print ` error `
            bb.runCmd("lsblk")

            # Cleanup...
            BB_RemoveLogicalVolume(l_Mountpoint)
            BB_RemoveDirectory(l_Mountpoint)

    except BBError as error:
        rc = error.rc
        print ` error `

    print "   >>>>>   End: %s.%s..." % (__name__, l_FuncName)

    return rc
Example #25
0
def BasicTransfers3(pEnv):
    rc = 0
    l_FuncName = sys._getframe().f_code.co_name

    print "   >>>>> Start: %s.%s..." % (__name__, l_FuncName)

    l_Owner = pEnv.get("OWNER", None)
    l_Group = pEnv.get("GROUP", None)
    l_Mode = int(pEnv.get("MODE", 0755))
    l_LVSize = "8G"

    l_OrgSrc = pEnv["ORGSRC"]
    l_Mountpoint = pEnv["MOUNT"]
    l_Target = pEnv["TARGET"]

    l_FileAttrs = (
        ("file1", 256 * 1024),
        ("file2", 0),
        ("file3", 512 * 1024 * 1024),
        ("file4", 768 * 1024 * 1024),
        ("file5", 1024 * 1024 * 1024),
    )
    l_SourceFiles = (
        (),
        (os.path.join(l_OrgSrc, "file1"), ),
        (os.path.join(l_Mountpoint, "file1"), ),
        (os.path.join(l_Mountpoint, "file1b"), ),
        (
            os.path.join(l_OrgSrc, "file2"),
            os.path.join(l_OrgSrc, "file3"),
            os.path.join(l_OrgSrc, "file4"),
            os.path.join(l_OrgSrc, "file5"),
        ),
        (
            os.path.join(l_Mountpoint, "file1"),
            os.path.join(l_Mountpoint, "file2"),
            os.path.join(l_Mountpoint, "file3"),
            os.path.join(l_Mountpoint, "file4"),
            os.path.join(l_Mountpoint, "file5"),
        ),
    )
    l_TargetFiles = (
        (),
        (os.path.join(l_Mountpoint, "file1"), ),
        (os.path.join(l_Mountpoint, "file1b"), ),
        (os.path.join(l_Target, "file1b"), ),
        (
            os.path.join(l_Mountpoint, "file2"),
            os.path.join(l_Mountpoint, "file3"),
            os.path.join(l_Mountpoint, "file4"),
            os.path.join(l_Mountpoint, "file5"),
        ),
        (
            os.path.join(l_Target, "file1"),
            os.path.join(l_Target, "file2"),
            os.path.join(l_Target, "file3"),
            os.path.join(l_Target, "file4"),
            os.path.join(l_Target, "file5"),
        ),
    )
    l_FileFlags = (
        ("None", ),
        ("None", ),
        ("None", ),
        ("None", ),
        (
            "BBTestStageIn",
            "BBTestStageIn",
            "BBTestStageIn",
            "BBTestStageIn",
        ),
        (
            "BBTestStageOut",
            "BBTestStageOut",
            "BBTestStageOut",
            "BBTestStageOut",
            "BBTestStageOut",
        ),
    )
    l_Tag = 0
    l_Contrib = pEnv["contrib"]
    l_NumHandles = 16

    # NOTE: Any non-zero return code that is returned from any of the BB_* api calls
    #       will cause an exception to be thrown and caught in the handler below.
    #       The return code is available as exception data...
    try:
        # Print out the environment to setup...
        bb.printEnv(pEnv)

        # Cleanup any prior running of this variation and setup to run this time...
        rc = bb.initEnv(pEnv, l_Mountpoint, l_Target)

        if (rc == 0):
            # Create the files to be transferred
            print "%sGenerating files with randfile..." % (os.linesep)
            for l_File, l_FileSize in (l_FileAttrs):
                bb.createRandomFile(pEnv, (os.path.join(l_OrgSrc, l_File)),
                                    l_FileSize)

            # Create the necessary directories...
            sudo_CreateDirectory(pEnv, l_Target)
            sudo_ChangeOwner(pEnv, l_Target, l_Owner, l_Group)
            sudo_ChangeMode(pEnv, l_Target, l_Mode)
            sudo_CreateDirectory(pEnv, l_Mountpoint)
            sudo_ChangeOwner(pEnv, l_Mountpoint, l_Owner, l_Group)
            sudo_ChangeMode(pEnv, l_Mountpoint, l_Mode)

            # This should fail because the logical volume has not yet been created.
            #
            # This error should be handled, as handleError() will tolerate all
            # exceptions where the rc is -2.  If rc is not -2, then the exception
            # is raised again to the outermost exception handler.
            #
            # The error is always printed out, with pertinent information taken
            # from BB_GetLastErrorDetails().
            #
            # NOTE: This is included here to show how to easily handle/tolerate
            #       bb exceptions...
            """
            try:
                print "%sThe following BB_GetTransferHandle() is expected to fail with a rc=-2" % (os.linesep)
                l_Handle = BB_GetTransferHandle(l_Tag, len(l_Contrib), l_Contrib)
            except BBError as error:
                if not error.handleError():
                    raise
            """

            for i in xrange(1, 100):

                # Create the logical volume for the mountpoint...
                sudo_CreateLogicalVolume(pEnv, l_Mountpoint, l_LVSize)

                # Run the testcase...
                for l_VarNum in xrange(0, len(l_SourceFiles)):
                    print "      >>>>> Start: Variation %d..." % (l_VarNum)

                    l_TransferDef = BB_CreateTransferDef()
                    for l_FileNum in xrange(len(l_SourceFiles[l_VarNum])):
                        BB_AddFiles(
                            l_TransferDef, l_SourceFiles[l_VarNum][l_FileNum],
                            l_TargetFiles[l_VarNum][l_FileNum],
                            BBFILEFLAGS[l_FileFlags[l_VarNum][l_FileNum]])

                    l_Tag += 1
                    l_Handle = BB_GetTransferHandle(l_Tag, len(l_Contrib),
                                                    l_Contrib)
                    BB_StartTransfer(l_TransferDef, l_Handle)
                    """
                    if l_VarNum+1 == len(l_SourceFiles):
                        # Last variation, so we are doing the stageout processing.
                        # NOTE: This isn't required, but included for test purposes.
                        sudo_StageOutStart(pEnv, l_Mountpoint)
                    """

                    l_Handles = bb.getHandles(BBSTATUS["BBALL"])
                    l_AllFullSuccess = bb.waitForCompletion(pEnv, l_Handles)

                    BB_FreeTransferDef(l_TransferDef)

                    print "      >>>>>   End: Variation %d..." % (l_VarNum)

                    if not l_AllFullSuccess:
                        raise BBError(
                            rc=-1,
                            text=
                            "Not all transfers had a status of BBFULLSUCCESS")

                bb.checkFiles(l_SourceFiles, l_TargetFiles)

                # Cleanup...

                sudo_RemoveLogicalVolume(pEnv, l_Mountpoint)
                if (len(l_Contrib) == 1):
                    sudo_RemoveJobInfo(pEnv)
                elif (pEnv["contribid"] == 0):
                    time.sleep(5)
                    sudo_RemoveJobInfo(pEnv)

            sudo_RemoveDirectory(pEnv, l_Mountpoint)

    except BBError as error:
        rc = error.rc
        # NOTE: BB_GetLastErrorDetails() output is contained within the error object
        #       and pertinant information is printed out from that data...
        print ` error `

    print "   >>>>>   End: %s.%s..." % (__name__, l_FuncName)

    return rc