コード例 #1
0
    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
    print "----- Test 1: lock of a ACS instance -----"
    print "Locking instance 3"
    instanceLocker.lock(3)
    printListOfLockFiles(prefix, suffix)
    print "Unlocking instance 3"
    instanceLocker.unlock(3)
    if printListOfLockFiles(prefix, suffix) != 0:
        print "ERROR: the folder should not contain any lock file at this stage!"
    print "----- Test 1 done -----"

    # Lock ALL possible instances
    print "----- Test 2: locking all possible instances -----"
    print "Locking all possible instances"
    for i in range(10):
        if instanceLocker.lock(i) != 0:
            print "ERROR locking instance", i
    if printListOfLockFiles(prefix, suffix) != 10:
        print "ERROR: some lock file is missing!"
    print "Freeing instances"
    for i in range(10):
        if instanceLocker.unlock(i) != 0:
コード例 #2
0
ファイル: acsInstanceLock.py プロジェクト: ACS-Community/ACS
        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___
コード例 #3
0
 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
 print "----- Test 1: lock of a ACS instance -----"
 print "Locking instance 3"
 instanceLocker.lock(3)
 printListOfLockFiles(prefix,suffix)
 print "Unlocking instance 3"
 instanceLocker.unlock(3)
 if printListOfLockFiles(prefix,suffix)!=0:
     print "ERROR: the folder should not contain any lock file at this stage!"
 print "----- Test 1 done -----"
 
 # Lock ALL possible instances
 print "----- Test 2: locking all possible instances -----"
 print "Locking all possible instances"
 for i in range(10):
     if instanceLocker.lock(i)!=0:
         print "ERROR locking instance",i
 if printListOfLockFiles(prefix,suffix)!=10:
     print "ERROR: some lock file is missing!"
 print "Freeing instances"
 for i in range(10):
     if instanceLocker.unlock(i)!=0:
コード例 #4
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___