if instance == None: expectedInstance = 0 else: expectedInstance = int(instance) print "Locking ACS_INSTANCE", instance lockedInstance = instanceLocker.checkAndLock() if lockedInstance == -1: print "ERROR locking ACS_INSTANCE" else: print "Instance locked", lockedInstance if expectedInstance != lockedInstance: print "ERROR: instance locked", lockedInstance, "expected", expectedInstance if printListOfLockFiles(prefix, suffix) != 1: print "ERROR: the folder should contain one and only one lock file at this stage!" # Free the instance if instanceLocker.freeInstance() != 0: print "Error freeing ACS_INSTANCE" if printListOfLockFiles(prefix, suffix) != 0: print "ERROR: the folder should not contain any lock file at this stage!" print "----- Test 4 done -----" # Try to lock a already locked instance print "----- Test 5: test to lock a locked instance -----" print "Locking instance 5" if instanceLocker.lock(5) != 0: print "ERROR: locking instance 5" if printListOfLockFiles(prefix, suffix) != 1: print "ERROR: the folder should contain one and only one lock file at this stage!" # try to lock twice the same instance print "Locking again instance 5" if instanceLocker.lock(5) == 0:
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() exit(ret) # ___oOo___
if instance==None: expectedInstance=0 else: expectedInstance=int(instance) print "Locking ACS_INSTANCE",instance lockedInstance=instanceLocker.checkAndLock() if lockedInstance==-1: print "ERROR locking ACS_INSTANCE" else: print "Instance locked",lockedInstance if expectedInstance!=lockedInstance: print "ERROR: instance locked",lockedInstance,"expected",expectedInstance if printListOfLockFiles(prefix,suffix)!=1: print "ERROR: the folder should contain one and only one lock file at this stage!" # Free the instance if instanceLocker.freeInstance()!=0: print "Error freeing ACS_INSTANCE" if printListOfLockFiles(prefix,suffix)!=0: print "ERROR: the folder should not contain any lock file at this stage!" print "----- Test 4 done -----" # Try to lock a already locked instance print "----- Test 5: test to lock a locked instance -----" print "Locking instance 5" if instanceLocker.lock(5)!=0: print "ERROR: locking instance 5" if printListOfLockFiles(prefix,suffix)!=1: print "ERROR: the folder should contain one and only one lock file at this stage!" # try to lock twice the same instance print "Locking again instance 5" if instanceLocker.lock(5)==0:
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() exit(ret) # ___oOo___