?????????? 2?????????????????

????????????????е????????????? RTC ?д洢????????"IWD Pattern"??Σ?????洢???????????????????????????? RTC RESTAPI ?????????????????????? IWD ???????й??? (Command Line Tool) ???? RESTAPI ?????? IWD ???????????????????????

????IWD ?????????й?????????? IWD ???????????????

? 5. IWD ??????????????й??????????

? 6. IWD ?????й???????????

????IWD ?????й???????? python ??????? IWD RESTAPI ?????幦?????????е? readme ???????????????ε??? python ??????????????????ο??????????????????ε??á??????????? python ??????????????????????????м??????????????????????? IWD ???????У?????????????????????????????????????????

?????嵥 2. ?? IWD ???????????????????????

#
# For each pattern returned?? the name of the pattern is presented
#
import ConfigParser
import threading?? time?? csv?? random

# get all the vsystems associated with a pattern
# this emulates the user clicking on the "Systems" selection in the tree view
def get_systems(pattern?? fname?? fhandle):
    nsystems = 0
    start = time.time()
    nSystems = len(pattern.virtualsystems)
    for cnt in range (nSystems):
        try:
            system = pattern.virtualsystems[cnt]
        except:
            break      
    finish = time.time()
    fname.writerow([time.strftime("%m/%d/%Y")?? time.strftime("%H:%M:%S")??'system'??
                     nSystems?? (finish-start)])
    fhandle.flush()
  
# get all the patterns
# this emulates the user clicking on the "Patterns" selection in the tree view
def get_patterns(fname?? fhandle):
    start = time.time()
    patterns = deployer.patterns
    finish = time.time()
    fname.writerow([time.strftime("%m/%d/%Y")?? time.strftime("%H:%M:%S")??'pattern'??
                   len(patterns)?? (finish-start)])
    fhandle.flush()
  
    for pattern in patterns:
        if (len(pattern.virtualsystems) > 0):
            time.sleep(random.randint(1?? 10))          
            get_systems(pattern?? fname?? fhandle)

######
config = ConfigParser.RawConfigParser()
config.read('listPatterns.cfg')

try:
    output = '%s_%s.csv' % (config.get('Main'?? 'outfile')??time.strftime("%Y%m%d@%H%M%S"))
    interval = config.getint('Main'?? 'interval')
    duration = config.getint('Main'?? 'duration')
except ConfigParser.Error:
    print "Error reading config file"
    sys.exit

fhandle = open(output?? 'w')
fname = csv.writer(fhandle?? delimiter='??')
fname.writerow(['date'?? 'time'?? 'type'?? 'number'??'duration'])
fhandle.flush()

print 'Running ...'
print 'Output File: %s Duration: %d Interval: %d' % (output?? duration?? interval)

end_time = time.time()+(60*duration)
while (end_time > time.time()):
    start = time.time()
    time.sleep(random.randint(1?? 10))
    get_patterns(fname?? fhandle)
  
    # only sleep the remainder of the interval
    time.sleep((time.time()+interval) - start)
  
print 'Completed on %s at %s' % (time.strftime("%m/%d/%Y")?? time.strftime("%H:%M:%S"))
fhandle.close()