Esempio n. 1
0
def BB_GetServerByName(pName, pType, pPrintOption=True):
    l_BufferSize = 512

    l_Name = bb.cvar("type", pName)
    l_Type = bb.cvar("type", pType)
    l_Size = bb.cvar("size", l_BufferSize)
    l_Buffer = bb.cvar("buffer", l_BufferSize)

    if (pPrintOption):
        print "%sBB_GetServerByName issued for name %s, type %s" % (
            os.linesep, pName, pType)
    rc = bb.api.BB_GetServerByName(l_Name, l_Type, l_Size, byref(l_Buffer))
    if (rc):
        raise BB_GetServerByNameError(rc)

    if (pPrintOption):
        bb.printLastErrorDetailsSummary()

    l_Temp = []
    for i in xrange(l_Size.value):
        if l_Buffer[i] != '\x00':
            l_Temp.append(l_Buffer[i])
        else:
            break
    l_Output = "".join(l_Temp)
    if (pPrintOption):
        print "%s Server: %s  Option: %s  Result: %s" % (os.linesep, pName,
                                                         pType, l_Output)

    return l_Output
Esempio n. 2
0
def BB_GetThrottleRate(pMountpoint):
    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)
    l_Rate = bb.cvar("rate", 0)

    l_NormalRCs = BB_GetThrottleRateError(BBError(Exception())).getNormalRCs()
    l_ToleratedErrorRCs = BB_GetThrottleRateError(BBError(
        Exception())).getToleratedErrorRCs()

    print "%sBB_GetThrottleRate issued for mountpoint %s" % (os.linesep,
                                                             pMountpoint)
    while (True):
        rc = bb.api.BB_GetThrottleRate(l_Mountpoint, byref(l_Rate))
        if (rc in (l_NormalRCs + l_ToleratedErrorRCs)):
            if (rc in l_ToleratedErrorRCs):
                print "Retrieving the throttle rate for mountpoint %s cannot be completed at this time.  Operation will be retried again in 10 seconds." % (
                    pMountpoint)
                time.sleep(10)
            else:
                break
        else:
            raise BB_GetThrottleRateError(rc)

    bb.printLastErrorDetailsSummary()
    print "Throttle rate for mountpoint %s is %d bytes/sec" % (pMountpoint,
                                                               l_Rate.value)

    return l_Rate.value
Esempio n. 3
0
def BB_GetLastErrorDetails(pBBError=None,
                           pFormat=BBERRORFORMAT["BBERRORJSON"]):
    l_Format = bb.cvar("errformat", pFormat)
    l_NumBytesAvailable = bb.cvar("numbytesavailable", 4095)
    l_BufferSize = bb.cvar("size", 0)
    while (l_NumBytesAvailable.value > l_BufferSize.value):
        l_BufferSize = bb.cvar("size", l_NumBytesAvailable.value + 1)
        l_Buffer = bb.cvar("buffer", l_BufferSize.value)
        rc = bb.api.BB_GetLastErrorDetails(l_Format,
                                           byref(l_NumBytesAvailable),
                                           l_BufferSize, byref(l_Buffer))
    if (rc):
        raise BB_GetLastErrorDetailsError(rc)

    l_Temp = []
    for i in xrange(l_BufferSize.value):
        if l_Buffer[i] != '\x00':
            l_Temp.append(l_Buffer[i])
        else:
            break
    l_Output = "".join(l_Temp)

    if (pBBError):
        lastErrorDetails = l_Output
    else:
        print "BB_GetLastErrorDetails: %s" % (l_Output)

    return l_Output
Esempio n. 4
0
def BB_RestartTransfers(pHostName, pHandle, pTransferDefs, pTransferDefsSize):
    l_NormalRCs = BB_RestartTransfersError(BBError(Exception())).getNormalRCs()
    l_ToleratedErrorRCs = BB_RestartTransfersError(BBError(Exception())).getToleratedErrorRCs()
    rc = l_ToleratedErrorRCs[0]

    l_HostName = bb.cvar("hostname", pHostName)
    l_Handle = bb.cvar("handle", pHandle)
    l_NumberOfRestartedTransferDefs = bb.cvar("numtransferdefs", 0)

    print '%sBB_RestartTransfers issued to restart transfer definitions using this criteria:  hostname %s, handle %d, transferdefs size %d, transferdefs %s' % (os.linesep, ValueMap.get(l_HostName.value, l_HostName.value), l_Handle.value, pTransferDefsSize.value, pTransferDefs.value)

    while (True):
        rc = bb.api.BB_RestartTransfers(l_HostName, l_Handle, byref(l_NumberOfRestartedTransferDefs), byref(pTransferDefs), pTransferDefsSize)
        if (rc in (l_NormalRCs + l_ToleratedErrorRCs)):
            if (rc in l_ToleratedErrorRCs):
                dummy = BBError()
                if ("Attempt to retry" in dummy.getLastErrorDetailsSummary()):
                    print "Restart transfers cannot be performed for handle %s because of a suspended condition.  This restart transfers request will be attempted again in three seconds." % (l_Handle)
                    time.sleep(3)
                else:
                    print "Restart transfers cannot be performed for handle %s. See error details." % (l_Handle)
                    break
            else:
                break
        else:
            raise BB_RestartTransfersError(rc)


    bb.printLastErrorDetailsSummary()
    print '%sBB_RestartTransfers completed' % (os.linesep)

    if (rc == 0):
        return l_NumberOfRestartedTransferDefs.value
Esempio n. 5
0
def BB_GetTransferList(pMatchStatus, pNumHandles):
    l_MatchStatus = bb.cvar("status", pMatchStatus)
    l_NumHandles = bb.cvar("numhandles", pNumHandles)
    l_Handles = create_string_buffer(sizeof(c_uint64 * pNumHandles))
    l_NumAvailHandles = bb.cvar("numavailhandles", 0)
    l_MatchStatusStr = BBSTATUS.get(pMatchStatus, ` pMatchStatus `)

    print "%sBB_GetTransferList issued with match status of %s" % (
        os.linesep, l_MatchStatusStr)
    rc = bb.api.BB_GetTransferList(l_MatchStatus, byref(l_NumHandles),
                                   byref(l_Handles), byref(l_NumAvailHandles))
    if (rc):
        raise BB_GetTransferListError(rc)

    l_HandleCount = min(pNumHandles, l_NumAvailHandles.value)
    l_HandleArray = (c_uint64 * l_HandleCount).from_address(
        addressof(l_Handles))
    l_Output = map(int, l_HandleArray)
    #    for i in xrange(l_HandleCount):
    #        l_Output.append(l_HandleArray[i])

    bb.printLastErrorDetailsSummary()
    print "BB_GetTransferList completed, %d handles available, %s" % (
        l_NumAvailHandles.value, l_Output)

    return (l_NumAvailHandles.value, l_Output)
Esempio n. 6
0
def BB_CreateLogicalVolume(pMountpoint, pSize, pFlags=DEFAULT_BBCREATEFLAGS):
    l_NormalRCs = BB_CreateLogicalVolumeError(BBError(Exception())).getNormalRCs()
    l_ToleratedErrorRCs = BB_CreateLogicalVolumeError(BBError(Exception())).getToleratedErrorRCs()
    rc = l_ToleratedErrorRCs[0]

    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)
    l_Size = bb.cvar("size_str", pSize)
    l_Flags = bb.cvar("flags", pFlags)

    print "%sBB_CreateLogicalVolume issued to create logical volume with size %s, directory %s mounted, file system flag %s" % (os.linesep, pSize, pMountpoint, BBCREATEFLAGS[l_Flags.value])

    while (True):
        rc = bb.api.BB_CreateLogicalVolume(l_Mountpoint, l_Size, l_Flags)
        if (rc in (l_NormalRCs + l_ToleratedErrorRCs)):
            if (rc in l_ToleratedErrorRCs):
                dummy = BBError()
                if ("Attempt to retry" in dummy.getLastErrorDetailsSummary()):
                    print "Logical volume cannot be created because of a suspended condition.  This create logical volume request will be attempted again in three seconds."
                    time.sleep(3)
                else:
                    print "Logical volume cannot be created now. See error details."
                    break
            else:
                break
        else:
            raise BB_CreateLogicalVolumeError(rc)

    bb.printLastErrorDetailsSummary()
    if (rc == 0):
        print "Logical volume created with size %s, directory %s mounted, file system flag %s" % (pSize, pMountpoint, BBCREATEFLAGS[l_Flags.value])

    return
Esempio n. 7
0
def BB_GetServer(pType, pPrintOption=True):
    l_BufferSize = 512

    l_Type = bb.cvar("type", pType)
    l_Size = bb.cvar("size", l_BufferSize)
    l_Buffer = bb.cvar("buffer", l_BufferSize)

    if (pPrintOption):
        print "%sBB_GetServer issued for type %s" % (os.linesep, pType)
    rc = bb.api.BB_GetServer(l_Type, l_Size, byref(l_Buffer))
    if (rc):
        raise BB_GetServerError(rc)

    if (pPrintOption):
        bb.printLastErrorDetailsSummary()

    l_Temp = []
    for i in xrange(l_Size.value):
        if l_Buffer[i] != '\x00':
            l_Temp.append(l_Buffer[i])
        else:
            break
    l_Output = "".join(l_Temp)
    l_TypePrt = list(pType)
    l_TypePrt[0] = l_TypePrt[0].upper()
    if (pPrintOption):
        print "%s Server: %s" % ("".join(l_TypePrt), l_Output)

    return l_Output
Esempio n. 8
0
def BB_CancelTransfer(pHandle, pCancelScope=DEFAULT_BBCANCELSCOPE):
    l_NormalRCs = BB_CancelTransferError(BBError(Exception())).getNormalRCs()
    l_ToleratedErrorRCs = BB_CancelTransferError(BBError(
        Exception())).getToleratedErrorRCs()

    l_Handle = bb.cvar("handle", pHandle)
    l_CancelScope = bb.cvar("cancelscope", pCancelScope)

    print "%sBB_CancelTransfer issued to initiate cancel for handle %s, with cancel scope of %s" % (
        os.linesep, pHandle, BBCANCELSCOPE[l_CancelScope.value])
    rc = bb.api.BB_CancelTransfer(l_Handle, l_CancelScope)
    while ((rc not in l_NormalRCs) and (rc not in l_ToleratedErrorRCs)):
        dummy = BBError()
        FIND_INCORRECT_BBSERVER = re.compile(
            ".*A cancel request for an individual transfer definition must be directed to the bbServer servicing that jobid and contribid"
        )
        l_ErrorSummary = dummy.getLastErrorDetailsSummary()
        l_Success = FIND_INCORRECT_BBSERVER.search(l_ErrorSummary)
        if ((not l_Success) or (pCancelScope == DEFAULT_BBCANCELSCOPE)):
            raise BB_CancelTransferError(rc)
        else:
            # NOTE: This could be a 'normal' case where the cancel operation is running simultaneously with a failover operation
            #       to a new bbServer.  Retry the cancel operation...
            print "Cancel operation with a cancel scope of BBSCOPETRANSFER was issued to the incorrect bbServer due to concurrent failover processing.  Exception was tolerated and cancel operation will not be retried."
            rc = -2

    bb.printLastErrorDetailsSummary()
    print "Cancel initiated for handle %s, with cancel scope of %s" % (
        pHandle, l_CancelScope.value)

    return
Esempio n. 9
0
def BB_ChangeMode(pPathName, pMode):
    l_PathName = bb.cvar("pathname", pPathName)
    l_Mode = bb.cvar("mode", pMode)

    print "%sBB_ChangeMode issued to change the mode for path %s to %s" % (os.linesep, pPathName, oct(pMode))
    rc = bb.api.BB_ChangeMode(l_PathName, l_Mode)
    if (rc):
        raise BB_ChangeModeError(rc)

    bb.printLastErrorDetailsSummary()
    print "Mode for path %s changed to %s" % (pPathName, oct(pMode))

    return
Esempio n. 10
0
def BB_ChangeOwner(pPathName, pOwner, pGroup):
    l_PathName = bb.cvar("pathname", pPathName)
    l_Owner = bb.cvar("owner", pOwner)
    l_Group = bb.cvar("group", pGroup)

    print '%sBB_ChangeOwner issued to change the ownership of path %s to user "%s", group "%s"' % (os.linesep, pPathName, pOwner, pGroup)
    rc = bb.api.BB_ChangeOwner(l_PathName, l_Owner, l_Group)
    if (rc):
        raise BB_ChangeOwnerError(rc)

    bb.printLastErrorDetailsSummary()
    print 'Ownership of path %s changed to user "%s", group "%s"' % (pPathName, pOwner, pGroup)

    return
Esempio n. 11
0
def BB_SetServer(pType, pName):
    l_Type = bb.cvar("type", pType)
    l_Name = bb.cvar("name", pName)

    print "%sBB_SetServer issued for type %s, name %s" % (os.linesep, pType, pName)
    rc = bb.api.BB_SetServer(l_Type, l_Name)
    if (rc):
        raise BB_SetServerError(rc)

    bb.printLastErrorDetailsSummary()

    print "%sBB_SetServer completed for type %s, name %s" % (os.linesep, pType, pName)

    return
Esempio n. 12
0
def BB_ResizeMountPoint(pMountpoint, pSize, pFlags=DEFAULT_BBRESIZEFLAGS):
    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)
    l_Size = bb.cvar("size_str", pSize)
    l_Flags = bb.cvar("flags", pFlags)

    print "%sBB_ResizeMountPoint issued to have mountpoint %s resized with a size specification of %s and flags %s" % (os.linesep, pMountpoint, pSize, BBRESIZEFLAGS[l_Flags.value])
    rc = bb.api.BB_ResizeMountPoint(l_Mountpoint, l_Size, l_Flags)
    if (rc):
        raise BB_ResizeMountPointError(rc)

    bb.printLastErrorDetailsSummary()
    print "Mountpoint %s resized with a size specification of %s and flags %s" % (pMountpoint, pSize, BBRESIZEFLAGS[l_Flags.value])

    return
Esempio n. 13
0
def BB_RetrieveTransfers(pHostHame,
                         pHandle,
                         pFlags=DEFAULT_BB_RTV_TRANSFERDEFS_FLAGS):
    l_HostName = bb.cvar("hostname", pHostHame)
    l_Handle = bb.cvar("handle", pHandle)
    l_Flags = bb.cvar("flags", pFlags)

    l_NumTransferDefs = bb.cvar("numtransferdefs", 0)
    l_NumBytesAvailable = bb.cvar("numbytesavailable", 16383)
    l_BufferSize = bb.cvar("size", 0)
    while (l_NumBytesAvailable.value > l_BufferSize.value):
        l_BufferSize = bb.cvar("size", l_NumBytesAvailable.value + 1)
        l_Buffer = bb.cvar("buffer", l_BufferSize.value)
        print '%sBB_RetrieveTransfers issued to retrieve transfer definitions using this criteria:  hostname %s, handle %d, flags %s, bytesavailable %d, bytesprovided %d' % (
            os.linesep, ValueMap.get(l_HostName.value, l_HostName.value),
            l_Handle.value, BB_RTV_TRANSFERDEFS_FLAGS[l_Flags.value],
            l_NumBytesAvailable.value, l_BufferSize.value)
        rc = bb.api.BB_RetrieveTransfers(l_HostName, l_Handle, l_Flags,
                                         byref(l_NumTransferDefs),
                                         byref(l_NumBytesAvailable),
                                         l_BufferSize, byref(l_Buffer))
        if (rc):
            raise BB_RetrieveTransfersError(rc)

    bb.printLastErrorDetailsSummary()
    #    print '%sBB_RetrieveTransfers completed the retrieval of transfer definitions using this criteria:  hostname %s, handle %d, flags %s, number of transferdefs %d, length of transferdefs %d, transferdefs |%s|' % (os.linesep, ValueMap.get(l_HostName.value, l_HostName.value), l_Handle.value, BB_RTV_TRANSFERDEFS_FLAGS[l_Flags.value], l_NumTransferDefs.value, l_NumBytesAvailable.value, l_Buffer.value)
    print '%sBB_RetrieveTransfers completed the retrieval of transfer definitions using this criteria:  hostname %s, handle %d, flags %s, number of transferdefs %d.' % (
        os.linesep, ValueMap.get(l_HostName.value,
                                 l_HostName.value), l_Handle.value,
        BB_RTV_TRANSFERDEFS_FLAGS[l_Flags.value], l_NumTransferDefs.value)

    return (l_NumTransferDefs.value, l_Buffer, l_NumBytesAvailable)
Esempio n. 14
0
def BB_StopTransfers(pHostName, pHandle, pTransferDefs, pTransferDefsSize):
    l_HostName = bb.cvar("hostname", pHostName)
    l_Handle = bb.cvar("handle", pHandle)
    l_NumStoppedTransferDefs = bb.cvar("numtransferdefs", 0)

    print '%sBB_StopTransfers issued to retrieve transfer definitions using this criteria:  hostname %s, handle %d, transferdefs size %d, transferdefs %s' % (os.linesep, ValueMap.get(l_HostName.value, l_HostName.value), l_Handle.value, pTransferDefsSize.value, pTransferDefs.value)

    rc = bb.api.BB_StopTransfers(l_HostName, l_Handle, byref(l_NumStoppedTransferDefs), byref(pTransferDefs), pTransferDefsSize)
    if (rc):
        raise BB_StopTransfersError(rc)

    bb.printLastErrorDetailsSummary()
    print '%sBB_StopTransfers completed' % (os.linesep)

    return l_NumStoppedTransferDefs.value
Esempio n. 15
0
def BB_AddKeys(pTransferDef, pKey, pValue):
    l_Key = bb.cvar("key", pKey)
    l_Value = bb.cvar("value", pValue)

    print "%sBB_AddKeys issued to add key %s, value %s to transfer definition %s" % (
        os.linesep, pKey, pValue, ` pTransferDef `)
    rc = bb.api.BB_AddKeys(pTransferDef, l_Key, l_Value)
    if (rc):
        raise BB_AddKeysError(rc)

    bb.printLastErrorDetailsSummary()
    print "Key '%s' with keyvalue '%s' added to transfer definition %s" % (
        pKey, pValue, ` pTransferDef `)

    return
Esempio n. 16
0
def BB_CancelTransfer(pHandle, pCancelScope=DEFAULT_BBCANCELSCOPE):
    l_Handle = bb.cvar("handle", pHandle)
    l_CancelScope = bb.cvar("cancelscope", pCancelScope)

    print "%sBB_CancelTransfer issued to initiate cancel for handle %s, with cancel scope of %s" % (
        os.linesep, pHandle, BBCANCELSCOPE[l_CancelScope.value])
    rc = bb.api.BB_CancelTransfer(l_Handle, l_CancelScope)
    if (rc):
        raise BB_CancelTransferError(rc)

    bb.printLastErrorDetailsSummary()
    print "Cancel initiated for handle %s, with cancel scope of %s" % (
        pHandle, l_CancelScope.value)

    return
Esempio n. 17
0
def BB_SetThrottleRate(pMountpoint, pRate):
    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)
    l_Rate = bb.cvar("rate", pRate)

    print "%sBB_SetThrottleRate issued to set the throttle rate for mountpoint %s to %d bytes/sec" % (
        os.linesep, pMountpoint, pRate)
    rc = bb.api.BB_SetThrottleRate(l_Mountpoint, l_Rate)
    if (rc):
        raise BB_SetThrottleRateError(rc)

    bb.printLastErrorDetailsSummary()
    print "Throttle rate for mountpoint %s changed to %d bytes/sec" % (
        pMountpoint, pRate)

    return
Esempio n. 18
0
def BB_RemoveLogicalVolume(pMountpoint):
    l_NormalRCs = BB_RemoveLogicalVolumeError(BBError(
        Exception())).getNormalRCs()
    l_ToleratedErrorRCs = BB_RemoveLogicalVolumeError(BBError(
        Exception())).getToleratedErrorRCs()

    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)

    print "%sBB_RemoveLogicalVolume issued to remove the logical volume associated with mountpoint %s" % (
        os.linesep, pMountpoint)

    rc = bb.api.BB_RemoveLogicalVolume(l_Mountpoint)
    while ((rc not in l_NormalRCs) and (rc not in l_ToleratedErrorRCs)):
        dummy = BBError()
        if ("Device or resource busy"
                not in dummy.getLastErrorDetailsSummary()):
            raise BB_RemoveLogicalVolumeError(rc)
        else:
            # NOTE: This could be a 'normal' case where restart transfer definition has not completed before remove logical volume
            #       is attempted in the normal flow of operations from the original start transfer request.
            #       The restart transfer may take 'minutes' attempting to determine if the transfer definition is in a stopped state.
            print "Device or resource busy.  The remove logical volume for mountpoint %s request will be re-attempted in 30 seconds." % (
                pMountpoint)
            time.sleep(30)
            rc = bb.api.BB_RemoveLogicalVolume(l_Mountpoint)

    bb.printLastErrorDetailsSummary()
    if (rc in l_NormalRCs):
        print "Logical volume associated with mountpoint %s removed" % (
            pMountpoint)

    return
Esempio n. 19
0
def BB_StartTransfer(pTransferDef, pHandle):
    l_NormalRCs = BB_StartTransferError(BBError(Exception())).getNormalRCs()
    l_ToleratedErrorRCs = BB_StartTransferError(BBError(
        Exception())).getToleratedErrorRCs()

    l_Handle = bb.cvar("handle", pHandle)

    print "%sBB_StartTransfer issued to start the transfer %s for handle %s" % (
        os.linesep, ` pTransferDef `, pHandle)

    while (True):
        rc = bb.api.BB_StartTransfer(pTransferDef, l_Handle)
        if (rc in (l_NormalRCs + l_ToleratedErrorRCs)):
            if (rc in l_ToleratedErrorRCs):
                dummy = BBError()
                if ("Attempt to retry" in dummy.getLastErrorDetailsSummary()):
                    print "Transfer %s cannot be started for handle %s because of a suspended condition.  This start transfer request will be attempted again in three seconds." % (
                        ` pTransferDef `, pHandle)
                    time.sleep(3)
                else:
                    print "Transfer %s cannot be started for handle %s because of a suspended condition.  Restart logic will resubmit this start transfer operation." % (
                        ` pTransferDef `, pHandle)
                    break
            else:
                break
        else:
            raise BB_StartTransferError(rc)

    bb.printLastErrorDetailsSummary()
    if (rc == 0):
        print "Transfer %s started for handle %s" % ( ` pTransferDef
                                                      `, pHandle)

    return
Esempio n. 20
0
def Coral_GetVar(pVariable, pPrintValue=PRINT_VALUE):
    l_Variable = bb.cvar("variable", pVariable)
    l_Value = bb.api.Coral_GetVar(l_Variable)
    if pPrintValue:
        print "===> Variable %s = %d" % (pVariable, l_Value)

    return l_Value
Esempio n. 21
0
def BB_AddFiles(pTransferDef, pSource, pTarget, pFlags=DEFAULT_BBFILEFLAG):
    l_Source = bb.cvar("source", pSource)
    l_Target = bb.cvar("target", pTarget)
    l_Flags = bb.cvar("flags", pFlags)

    print "%sBB_AddFiles issued to add source file %s and target file %s with flag %s to transfer definition %s" % (
        os.linesep, pSource, pTarget, BBFILEFLAGS[l_Flags.value], `
        pTransferDef `)
    rc = bb.api.BB_AddFiles(pTransferDef, l_Source, l_Target, l_Flags)
    if (rc):
        raise BB_AddFilesError(rc)

    bb.printLastErrorDetailsSummary()
    print "Source file %s and target file %s with flag %s added to transfer definition %s" % (
        pSource, pTarget, BBFILEFLAGS[l_Flags.value], ` pTransferDef `)

    return
Esempio n. 22
0
def Coral_StageOutStart(pMountpoint):
    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)

    print "%sCoral_StageOutStart issued for mountpoint %s" % (os.linesep, pMountpoint)
    rc = bb.api.Coral_StageOutStart(l_Mountpoint)
    if (rc):
        raise Coral_StageOutStartError(rc)

    return
Esempio n. 23
0
def Coral_ChangeServer(pMountpoint):
    l_Mountpoint = bb.cvar("mountpoint", pMountpoint)

    print "%sCoral_ChangeServer issued for mountpoint %s" % (os.linesep, pMountpoint)
    rc = bb.api.Coral_ChangeServer(l_Mountpoint)
    if (rc):
        raise Coral_ChangeServerError(rc)

    return
Esempio n. 24
0
def BB_GetTransferHandle(pTag, pNumContrib, pContrib):
    l_Tag = bb.cvar("tag", pTag)
    l_NumContrib = bb.cvar("numcontrib", pNumContrib)
    Contrib = c_uint32 * pNumContrib
    l_Contrib = Contrib(*pContrib)
    l_Handle = bb.cvar("handle", 0)

    print "%sBB_GetTransferHandle issued for job (%d,%d), tag %d, numcontrib %d, contrib %s" % (
        os.linesep, bb.getJobId(), bb.getJobStepId(), pTag, pNumContrib, `
        pContrib `)
    rc = bb.api.BB_GetTransferHandle(l_Tag, l_NumContrib, l_Contrib,
                                     byref(l_Handle))
    if (rc):
        raise BB_GetTransferHandleError(rc)

    bb.printLastErrorDetailsSummary()
    print "Transfer handle %s obtained, for job (%d,%d), tag %d, numcontrib %d, contrib %s" % (
        l_Handle.value, bb.getJobId(), bb.getJobStepId(), pTag, pNumContrib, `
        pContrib `)

    return l_Handle.value
Esempio n. 25
0
def BB_CreateDirectory(pNewPathName):
    l_NewPathName = bb.cvar("newpathname", pNewPathName)

    print "%sBB_CreateDirectory issued to create directory %s" % (os.linesep, pNewPathName)
    rc = bb.api.BB_CreateDirectory(l_NewPathName)
    if (rc):
        raise BB_CreateDirectoryError(rc)

    bb.printLastErrorDetailsSummary()
    print "Directory %s created" % (pNewPathName)

    return
Esempio n. 26
0
def BB_RemoveDirectory(pPathName):
    l_PathName = bb.cvar("pathname", pPathName)

    print "%sBB_RemoveDirectory issued to remove directory %s" % (os.linesep, pPathName)
    rc = bb.api.BB_RemoveDirectory(l_PathName)
    if (rc):
        raise BB_RemoveDirectoryError(rc)

    bb.printLastErrorDetailsSummary()
    print "Directory %s removed" % (pPathName)

    return
Esempio n. 27
0
def main(pArgs):
    l_Env = {}
    processArgs(l_Env, pArgs)

    # Build the ctypes interfaces to the BB APIs...
    bb.api = buildLibraryWrapper(l_Env)

    # We only print out the shared library information for the main routine...
    if (len(l_Env["procedure_args"]) == 0):
        print "Shared library:  %s" % (l_Env["LIB"])

    l_Contribid = bb.cvar("contribid", l_Env)

    l_Size = bb.cvar("size", 256)
    l_API_Version = ctypes.create_string_buffer(256)
    rc = BB_GetVersion(l_Size, l_API_Version)

    if (rc == 0):
        if (l_Env["TESTCASE"] != "None"):
            if l_Env.has_key("CONFIG") or l_Env.has_key("UNIXPATH"):
                l_Config = ctypes.c_char_p(l_Env.get("CONFIG", NOCONFIG))
                l_UnixPath = ctypes.c_char_p(l_Env.get("UNIXPATH", NOUNIXPATH))
                rc = Coral_InitLibrary(l_Contribid, l_API_Version, l_Config,
                                       l_UnixPath)
            else:
                rc = BB_InitLibrary(l_Contribid, l_API_Version)

            if (rc == 0):
                setSysPath(l_Env)
                l_TestCase = importlib.import_module(l_Env["TESTCASE"])
                rc = l_TestCase.main(l_Env)
                print "bbapi_main.main(): rc = %d" % (rc)
            else:
                print "BB_InitLibrary():  rc = %d" % (rc)

            BB_TerminateLibrary()
    else:
        print "BB_GetVersion():  rc = %d" % (rc)

    return rc
Esempio n. 28
0
def BB_CloseServer(pName):
    l_Name = bb.cvar("name", pName)

    print "%sBB_CloseServer issued for name %s" % (os.linesep, pName)
    rc = bb.api.BB_CloseServer(l_Name)
    if (rc):
        raise BB_CloseServerError(rc)

    bb.printLastErrorDetailsSummary()

    print "%sBB_CloseServer completed for name %s" % (os.linesep, pName)

    return
Esempio n. 29
0
def Coral_SetVar(pVariable, pValue):
    try:
        l_Value = int(pValue)
        if (l_Value < 0):
            raise ValueError

    except ValueError:
        l_Value = None

    if (l_Value != None):
        l_Variable = bb.cvar("variable", pVariable)
        l_Value = bb.cvar("value", pValue)
        l_PreviousValue = Coral_GetVar(pVariable)
#        print "===> The value for variable '%s' is being changed from %d to %s" % (pVariable, l_PreviousValue, pValue)
        l_Value = bb.api.Coral_SetVar(l_Variable, l_Value)
        l_CurrentValue = Coral_GetVar(pVariable, False)
        if (int(pValue) != l_CurrentValue):
            print "===> Coral_SetVar Error:  Variable %s could not be set to a value of %s" % (pVariable, pValue)
    else:
        print "===> Coral_SetVar Error:  Input value of %s not 0 or a positive value" % (pValue)

    return
Esempio n. 30
0
def BB_Suspend(pHostHame):
    l_HostName = bb.cvar("hostname", pHostHame)

    print '%sBB_Suspend issued for hostname %s' % (os.linesep, ValueMap.get(l_HostName.value, l_HostName.value))

    rc = bb.api.BB_Suspend(l_HostName)
    if (rc):
        raise BB_SuspendError(rc)

    bb.printLastErrorDetailsSummary()
    print '%sBB_Suspend completed for hostname %s' % (os.linesep, ValueMap.get(l_HostName.value, l_HostName.value))

    return