def TakeSnapshotPy(copyToLocalPath=None, view='Flow Statistics', osPlatform='windows'): """ Take a snapshot of the selected stat view and transfer the file to the local file system where the script was executed. Parameters copyToLocalPath: The local path to save the CSV stat file. view: The stat view to take snapshot of. osPlatform: The IxNetwork API server OS: windows|linux """ if osPlatform == 'windows': # This directory will hold the snapshot on the Windows filesystem. # If the folder does not exists, it will be created. path = 'C:\\Results' if osPlatform == 'linux': path = '/home/ixia_logs' stats = ixNet.getRoot() + '/statistics' csvFileName = view.replace(' ', '_') listOfTrafficStats = [view] opts = ixNet.execute('GetDefaultSnapshotSettings') filePathToChange = 'Snapshot.View.Csv.Location: '+ path print '\ntakeSnapshot src file path:%s' % (filePathToChange) opts[1] = filePathToChange generatingModeToChange= 'Snapshot.View.Csv.GeneratingMode: "kOverwriteCSVFile"' opts[2] = generatingModeToChange fileNameToAppend = 'Snapshot.View.Csv.Name: '+ csvFileName ;# Flow_Statistics opts.append(fileNameToAppend) ixNet.execute('TakeViewCSVSnapshot', listOfTrafficStats, opts) if copyToLocalPath is None: copyToLocalPath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if osPlatform == 'windows': readPath = path + '\\' + csvFileName + '.csv' writePath = '%s/%s_%s.csv' % (copyToLocalPath, csvFileName, timestamp) if osPlatform == 'linux': readPath = '%s/%s.csv' %s (path, csvFileName) writePath = '%s/%s_%s.csv' % (copyToLocalPath, csvFileName, timestamp) print '\ntakeSnapshot: Saving file to: %s' % (writePath) ixNet.execute('copyFile', ixNet.readFrom(readPath, '-ixNetRelative'), ixNet.writeTo(writePath, '-overwrite'))