system('acsKillProc -C ' + process) print "...done." print "" #Now everything should have been killed...let's try to cleanup $ACSDATA/tmp dir = getAcsTmpDirectoryPath() print "==> Cleaning up " + dir + " - removing ACS_INSTANCE temporary directories..." try: com = 'rm -rf ' + dir + '/ACS_INSTANCE*' system(com) print "...done." except: print "==> Failed to remove the ACS_INSTANCE directories from " + dir + "!" print " Please clean up this directory on your own!" if killJava==1: print "Killing all Java processes..." system('acsKillProc -C java') print "...done." print "Removing lock files" lockHelper=AcsInstanceLockHelper() lockHelper.cleanAll() print "...done." #release the lock so future invocations can be run if lock_file!=None: lock_file.close() remove(lock_file_name)
@return The list of locked instances ''' ret = [] acsdata = environ["ACSDATA"] lockFilesFolder = acsdata + "/tmp" for file in listdir(lockFilesFolder): if file.startswith(prefix) and file.endswith(suffix): s = file.split(prefix) s2 = s[1].split(suffix) ret.append(int(s2[0])) return ret if __name__ == "__main__": instanceLocker = AcsInstanceLockHelper() prefix = instanceLocker.lockFilenamePrefix suffix = instanceLocker.lockFilenameSuffix # Get the actual ACS_INSTANCE # None if ACS_INSTANCE not defined in the environment try: instance = environ['ACS_INSTANCE'] except: instance = None # There should be no lock file at the beginning of the test if printListOfLockFiles(prefix, suffix) != 0: print "ERROR: the folder should not contain any lock file at this stage!" # Lock a instance
(options, args) = parser.parse_args() selectedActions=0 if options.lock: selectedActions=selectedActions+1 if options.unlock: selectedActions=selectedActions+1 if options.clean: selectedActions=selectedActions+1 if selectedActions!=1: print "\nERROR: one and only one action must be present in the command line\n" parser.print_help() os.exit(-1) lockHelper = AcsInstanceLockHelper() if options.clean: ret=lockHelper.cleanAll() exit(ret) if options.baseport != None: # Use ACS_INSTANCE if options.lock: ret=lockHelper.lock(options.baseport) else: ret=lockHelper.unlock(options.baseport) else: if options.lock: ret=lockHelper.checkAndLock() else: ret=lockHelper.freeInstance()
Read ACSDATA/tmp to get the list of locked instances @return The list of locked instances ''' ret=[] acsdata=environ["ACSDATA"] lockFilesFolder=acsdata+"/tmp" for file in listdir(lockFilesFolder): if file.startswith(prefix) and file.endswith(suffix): s=file.split(prefix) s2=s[1].split(suffix) ret.append(int(s2[0])) return ret if __name__ == "__main__": instanceLocker = AcsInstanceLockHelper() prefix=instanceLocker.lockFilenamePrefix suffix=instanceLocker.lockFilenameSuffix # Get the actual ACS_INSTANCE # None if ACS_INSTANCE not defined in the environment try: instance=environ['ACS_INSTANCE'] except: instance=None # There should be no lock file at the beginning of the test if printListOfLockFiles(prefix,suffix)!=0: print "ERROR: the folder should not contain any lock file at this stage!" # Lock a instance
(options, args) = parser.parse_args() selectedActions = 0 if options.lock: selectedActions = selectedActions + 1 if options.unlock: selectedActions = selectedActions + 1 if options.clean: selectedActions = selectedActions + 1 if selectedActions != 1: print "\nERROR: one and only one action must be present in the command line\n" parser.print_help() os.exit(-1) lockHelper = AcsInstanceLockHelper() if options.clean: ret = lockHelper.cleanAll() exit(ret) if options.baseport != None: # Use ACS_INSTANCE if options.lock: ret = lockHelper.lock(options.baseport) else: ret = lockHelper.unlock(options.baseport) else: if options.lock: ret = lockHelper.checkAndLock() else: ret = lockHelper.freeInstance()