# If the number of objects in the old list is above 10K 
	# we would like to create a 2 min pause between subsequent
	# requests
	old_list_count=len(OBJECT_LIST_FILE)
        if old_list_count > 10000 :
	    # Now find the time since that last update 
	    # to the object list file
            file_change_time=os.path.getmtime(OBJECT_LIST_FILE)
	    curr_time=time.time()
	    time_diff = curr_time - file_change_time
            # Check if time difference is less than 120 sec 
	    # then sleep for the remaining seconds
	    logger.info('Last time till update : %d s', time_diff)
	    if time_diff < 120 :
		# Create the lock file
		mgmt_lib.acquire_lock(LOCK_FILE)
		sleep_time = 120 - time_diff
		syslog.syslog(syslog.LOG_NOTICE, "Object List Creation for Namespace "+NAMESPACE+" : Pausing "+sleep_time+" seconds")
		time.sleep(sleep_time)
		logger.info('Sleeping for %d...', sleep_time)
	
    # Create the lock file
    mgmt_lib.acquire_lock(LOCK_FILE)

    # Remove the old list file
    if os.path.exists(OBJECT_LIST_FILE):
        os.remove(OBJECT_LIST_FILE)
    if os.path.exists(RAM_OBJECT_LIST_FILE):
	os.remove(RAM_OBJECT_LIST_FILE)

numobjects = '0'
	    # Get the active disk list
	    A_DISKS = cache_disk_lib.get_active_disks()
			    
	    #Get the object path alone
	    OBJ_DIR_PATH = os.path.dirname(OBJ_PATTERN)
	    #Canonicalize the path
	    OBJ_DIR = os.path.abspath(OBJ_DIR_PATH) 
    #lock start
    #Lock for single object display. This set of commands call the ramcache action directly, display
    #the output and delete the temp files.Don't allow two commands to call this set of commands immediately.
    #If lock is present, display the error message for the command trying to acquire the lock.
	    if mgmt_lib.is_lock_valid(SINGLE_LOCK_FILE):
		print "The task is already in progress. Please retry after few minutes"
		sys.exit()
	    else:
		mgmt_lib.acquire_lock(SINGLE_LOCK_FILE)
		#BUG FIX:10727.
		#If file  for single object exists remove this and then open a new one.
		#This is to handle the case where in the previous listing  had script error due to some invalid exp
		#The cleanup is handled here to ensure only the object  is listed only once.
		#Issue: The single object file was not getting cleanedup and the new query was appending the new list to old list
		#resulting in multiple entry display.
		if os.path.exists(GREPED_SINGLE_OBJECT_LIST_FILE):
		    os.remove(GREPED_SINGLE_OBJECT_LIST_FILE)
		
		if os.path.exists(SINGLE_OBJECT_LIST_FILE):
		    os.remove(SINGLE_OBJECT_LIST_FILE)

		logger.info('Querying ramcache for object list')
		#Get ramcache list and search
		query = "/opt/tms/bin/mdreq -s -q action "+TM_RAMCACHE_ACTION+" namespace string "+NAMESPACE+" uid string "+NS_UID+" filename string "+SINGLE_OBJECT_LIST_FILE
    if mgmt_lib.is_lock_valid(OBJ_BUILD_LOCK_FILE):
        print NAMESPACE + " : Object list generation is already in progress.Please try after sometime."
        sys.exit()

    # Check if a delete is already in progress
    #Moved this check here as files are created only for a pattern or delete all
    if mgmt_lib.is_lock_valid(LOCK_FILE):
        print NAMESPACE+" : Deletion of objects for this namespace already"+ \
        " in progress"
        print "Issue this command only after the earlier one has completed"
        print "Check log for status of deletion"
        sys.exit()
    else:
        # Psuedo lock so that multiple deletes are not kicked in
        # Simply touch the object file
        mgmt_lib.acquire_lock(LOCK_FILE)

    #form the obj pattern here,
    if wild_card:
        OBJ_PATTERN = mgmt_lib.get_python_pattern(OBJ_PATTERN)
    else:
        OBJ_PATTERN = ".*"

    # Now run the script that builds the whole object list in the background
    #TODO,Pass the pattern to the list
    #Get the PID of the lidt process

    #PR 797343
    #If a previous delete was aborted,
    #old list file might still exist
    #and the new del might use the old
Example #4
0
            # Get the active disk list
            A_DISKS = cache_disk_lib.get_active_disks()

            #Get the object path alone
            OBJ_DIR_PATH = os.path.dirname(OBJ_PATTERN)
            #Canonicalize the path
            OBJ_DIR = os.path.abspath(OBJ_DIR_PATH)
            #lock start
            #Lock for single object display. This set of commands call the ramcache action directly, display
            #the output and delete the temp files.Don't allow two commands to call this set of commands immediately.
            #If lock is present, display the error message for the command trying to acquire the lock.
            if mgmt_lib.is_lock_valid(SINGLE_LOCK_FILE):
                print "The task is already in progress. Please retry after few minutes"
                sys.exit()
            else:
                mgmt_lib.acquire_lock(SINGLE_LOCK_FILE)
                #BUG FIX:10727.
                #If file  for single object exists remove this and then open a new one.
                #This is to handle the case where in the previous listing  had script error due to some invalid exp
                #The cleanup is handled here to ensure only the object  is listed only once.
                #Issue: The single object file was not getting cleanedup and the new query was appending the new list to old list
                #resulting in multiple entry display.
                if os.path.exists(GREPED_SINGLE_OBJECT_LIST_FILE):
                    os.remove(GREPED_SINGLE_OBJECT_LIST_FILE)

                if os.path.exists(SINGLE_OBJECT_LIST_FILE):
                    os.remove(SINGLE_OBJECT_LIST_FILE)

                logger.info('Querying ramcache for object list')
                #Get ramcache list and search
                query = "/opt/tms/bin/mdreq -s -q action " + TM_RAMCACHE_ACTION + " namespace string " + NAMESPACE + " uid string " + NS_UID + " filename string " + SINGLE_OBJECT_LIST_FILE