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
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
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
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
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
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
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)
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
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
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)
def BB_FreeTransferDef(pTransferDef): print "%sBB_FreeTransferDef issued for %s" % (os.linesep, ` pTransferDef `) rc = bb.api.BB_FreeTransferDef(pTransferDef) if (rc): raise BB_FreeTransferDefError(rc) bb.printLastErrorDetailsSummary() print "Transfer definition %s freed" % ( ` pTransferDef `) return
def BB_RemoveJobInfo(): print "%sBB_RemoveJobInfo issued" % (os.linesep) rc = bb.api.BB_RemoveJobInfo() if (rc): raise BB_RemoveJobInfoError(rc) bb.printLastErrorDetailsSummary() print "BB_RemoveJobInfo completed" return
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
def BB_CreateTransferDef(): l_TransferDef = POINTER(c_uint32)() print "%sBB_CreateTransferDef issued" % (os.linesep) rc = bb.api.BB_CreateTransferDef(byref(l_TransferDef)) if (rc): raise BB_CreateTransferDefError(rc) bb.printLastErrorDetailsSummary() print "Transfer definition %s created" % ( ` l_TransferDef `) return l_TransferDef
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
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
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
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
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
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
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
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
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
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
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
def BB_GetDeviceUsage(pDeviceNum): l_DeviceNum = bb.cvar("devicenum", pDeviceNum) l_DeviceUsage = create_string_buffer(sizeof(BBDeviceUsage_t)) print "%sBB_GetDeviceUsage issued for device number %d" % (os.linesep, pDeviceNum) rc = bb.api.BB_GetDeviceUsage(l_DeviceNum, byref(l_DeviceUsage)) if (rc): raise BB_GetDeviceUsageError(rc) l_ReturnStruct = BBDeviceUsage_t.from_buffer_copy(l_DeviceUsage) bb.printLastErrorDetailsSummary() print "Estimated percentage of life used for device number %d is %d%%" % ( pDeviceNum, getattr(l_ReturnStruct, "percentage_used")) return l_ReturnStruct
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
def BB_GetTransferInfo(pHandle): l_Handle = bb.cvar("handle", pHandle) l_Info = create_string_buffer(sizeof(BBTransferInfo_t)) print "%sBB_GetTransferInfo issued for handle %s" % (os.linesep, pHandle) rc = bb.api.BB_GetTransferInfo(l_Handle, byref(l_Info)) if (rc): raise BB_GetTransferInfoError(rc) l_ReturnStruct = BBTransferInfo_t.from_buffer_copy(l_Info) bb.printLastErrorDetailsSummary() print "BB_GetTransferInfo completed%s Handle: %12d -> Status (Local:Overall) (%13s:%13s) Transfer Size in bytes (Local:Total) (%s : %s)" % ( os.linesep, l_ReturnStruct.handle, BBSTATUS[l_ReturnStruct.localstatus], BBSTATUS[l_ReturnStruct.status], '{:,}'.format(l_ReturnStruct.localTransferSize), '{:,}'.format( l_ReturnStruct.totalTransferSize)) return l_ReturnStruct
def BB_SetUsageLimit(pMountpoint, pUsage): l_Mountpoint = bb.cvar("mountpoint", pMountpoint) print "%sBB_SetUsageLimit issued to set the usage limit for mountpoint %s to %d" % ( os.linesep, pMountpoint, pUsage) rc = bb.api.BB_SetUsage(l_Mountpoint, byref(pUsage)) if (rc): raise BB_SetUsageError(rc) bb.printLastErrorDetailsSummary() print "For mount point %s, the following usage limits were set:" % ( pMountpoint) print " Total bytes read = %d, Total bytes written = %d" % (getattr( pUsage, "totalBytesRead"), getattr(pUsage, "totalBytesWritten")) print " Local bytes read = %d, Local bytes written = %d" % (getattr( pUsage, "localBytesRead"), getattr(pUsage, "localBytesWritten")) print " Burst bytes read = %d, Burst bytes written = %d" % (getattr( pUsage, "burstBytesRead"), getattr(pUsage, "burstBytesWritten")) return
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