43 import setfilters26
as setfilters
80 HalfLongRoundtrip = LongRoundtrip/2
81 HalfShortRoundtrip = ShortRoundtrip/2
105 BandSettings.SetDelayAmount(A_Band, LANA_to_LANB, HalfShortRoundtrip)
106 BandSettings.SetDelayAmount(A_Band, LANB_to_LANA, HalfShortRoundtrip)
107 BandSettings.SetDelayReorder(A_Band, LANA_to_LANB,
False)
108 BandSettings.SetDelayReorder(A_Band, LANB_to_LANA,
False)
109 BandSettings.SetRateLimit(A_Band, LANA_to_LANB, OneMegabit)
110 BandSettings.SetRateLimit(A_Band, LANB_to_LANA, OneMegabit)
113 BandSettings.SetDelayAmount(B_Band, LANA_to_LANB, HalfLongRoundtrip)
114 BandSettings.SetDelayAmount(B_Band, LANB_to_LANA, HalfLongRoundtrip)
115 BandSettings.SetDelayReorder(B_Band, LANA_to_LANB,
False)
116 BandSettings.SetDelayReorder(B_Band, LANB_to_LANA,
False)
117 BandSettings.SetRateLimit(B_Band, LANA_to_LANB, OneKilobit)
118 BandSettings.SetRateLimit(B_Band, LANB_to_LANA, OneKilobit)
127 Jobs.AddRequest(
"Establish Baseline - 100ms RT delay, 1,000,000 bit/sec rate limit", mm_hostname, 0,
128 BandSettings, Filt_ToBandA, Filt_ToBandA)
138 for secs
in range(interval, items_per_group*num_groups*interval, items_per_group*interval):
139 Jobs.AddRequest(
"Job %u: 1000ms RT delay, 100,000 bit/sec rate limit" % \
140 secs, mm_hostname, secs,
None, Filt_ToBandB, Filt_ToBandB)
141 nxtsecs = secs + interval
142 Jobs.AddRequest(
"Job %u: 100ms RT delay, 1,000,000 bit/sec rate limit" % \
143 nxtsecs, mm_hostname, nxtsecs,
None, Filt_ToBandA, Filt_ToBandA)
150 TeamName =
"TEAM UNKNOWN" 153 datetime.datetime.now().isoformat()
154 msg = datetime.datetime.now().isoformat() \
155 +
' "' + TeamName +
'" ' \
159 syslog.syslog(syslog.LOG_INFO, msg)
173 def __init__(self, interval, function, *args, **kwargs):
202 def __init__(self, reqname, mm2host, dowhen, bands, a2b_filtmap, b2a_filtmap):
204 @param reqname: The name of the request, a single line of text. 205 @type reqname: String 206 @param mm2host: The name or IP address of the target host. 207 @type mm2host: String 208 @param dowhen: A datetime object indicating when to do perform this request. 209 @type dowhen: datetime 210 @param bands: A mm2client.Bands object containing the desired impairment settings. 212 @type bands: mm2client.Bands 213 @param a2b_filtmap: A sequence of setfilters.FiltSetting objects containing the desired LanA to LanB filters settings. 214 May be an empty sequence. 215 @type a2b_filtmap: A sequence of setfilters.FiltSetting objects. 216 @param b2a_filtmap: A sequence of setfilters.FiltSetting objects containing the desired LanB to LanA filters settings. 217 May be an empty sequence. 218 @type b2a_filtmap: A sequence of setfilters.FiltSetting objects. 229 return self.
__DoWhen < other.__DoWhen
232 return self.
__DoWhen <= other.__DoWhen
235 return self.
__DoWhen == other.__DoWhen
238 return self.
__DoWhen != other.__DoWhen
241 return self.
__DoWhen > other.__DoWhen
244 return self.
__DoWhen <= other.__DoWhen
292 global AllFilterNames
305 if (skipsecs
is not None)
and (skipsecs > 0):
308 def AddRequest(self, reqname, mm2host, startsec, bands,
309 a2b_filtmap, b2a_filtmap):
310 dowhen = self.
__StartTime + datetime.timedelta(0, startsec)
311 self.__WorkList.append(
DoRequest(reqname, mm2host, dowhen, bands,
312 a2b_filtmap, b2a_filtmap))
313 self.__WorkList.sort()
323 if req.IsReadyToGo(nowtime):
327 except Exception, err:
328 ShowMessage(
"Exception in Task \"%s\" - %s" % (req.Name, str(err)))
336 return datetime.datetime.now()
346 def SetMM(mm_hostname, bands, a2bfilt_vals, b2afilt_vals, all_filter_names):
348 if bands
is not None:
350 if (a2bfilt_vals
is not None)
or (b2afilt_vals
is not None):
361 AllFilterNames =
None 366 pvt = platform.python_version_tuple()
367 if (int(pvt[0]) == 2)
and (int(pvt[1]) < 7):
369 return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
372 return td.total_seconds()
379 global AllFilterNames
386 Jobs.RunNextRequest(datetime.datetime.now())
392 parser = argparse.ArgumentParser(description=
"Start impairment pattern.")
394 parser.add_argument(
"-s",
"--skip", type=int,
395 help=
"Skip ahead: start at N seconds.")
397 parser.add_argument(
"-C",
"--do_not_use_initial_defaults", action=
"store_true",
398 dest=
"no_initial_defaults",
399 help=
"Do not establish defaults before running scheduled tasks.")
401 parser.add_argument(
"-D",
"--initial_defaults_then_exit", action=
"store_true",
402 dest=
"initial_defaults_only",
403 help=
"Establish defaults and then exit, supersedes -C.")
405 parser.add_argument(
"-l",
"--loop", action=
"store_true",
406 help=
"Loop/Cycle forever.")
408 parser.add_argument(
"-S",
"--syslog", action=
"store_true",
409 help=
"Send reports to the system defined syslog server (level LOG_INFO).")
411 parser.add_argument(
"-T",
"--team", required=
True, metavar=
"<team name>",
414 parser.add_argument(
"mm_hostname", metavar=
"<Mini Maxwell host name or IP address>",
415 help=
'The host name or IP address of the Mini Maxwell/Maxwell G.')
417 pargs = parser.parse_args()
419 TeamName = pargs.team
423 mm_hostname = pargs.mm_hostname
425 do_initial_defaults_only = pargs.initial_defaults_only
426 do_no_initial_defaults = pargs.no_initial_defaults
427 do_skipsecs = pargs.skip
431 parser = optparse.OptionParser(
"""usage: %prog [-h] [-s SKIP] [-C] [-D] [-l] [-S] -T <team name> 432 <Mini Maxwell host name or IP address>""")
434 parser.add_option(
"-s",
"--skip", type=int,
435 help=
"Skip ahead: start at N seconds.")
437 parser.add_option(
"-C",
"--do_not_use_initial_defaults", action=
"store_true",
438 dest=
"no_initial_defaults",
439 help=
"Do not establish defaults before running scheduled tasks.")
441 parser.add_option(
"-D",
"--initial_defaults_then_exit", action=
"store_true",
442 dest=
"initial_defaults_only",
443 help=
"Establish defaults and then exit, supersedes -C.")
445 parser.add_option(
"-l",
"--loop", action=
"store_true",
446 help=
"Loop/Cycle forever.")
448 parser.add_option(
"-S",
"--syslog", action=
"store_true",
449 help=
"Send reports to the system defined syslog server (level LOG_INFO).")
451 parser.add_option(
"-T",
"--team", metavar=
"<team name>",
454 (options, args) = parser.parse_args()
456 TeamName = options.team
458 parser.error(
"Team name must be supplied.")
464 mm_hostname = args[0]
466 parser.error(
"Mini Maxwell host name or IP address must be supplied.")
468 do_initial_defaults_only = options.initial_defaults_only
469 if do_initial_defaults_only
is None:
470 do_initial_defaults_only =
False 472 do_no_initial_defaults = options.no_initial_defaults
473 if do_no_initial_defaults
is None:
474 do_no_initial_defaults =
False 476 do_skipsecs = options.skip
478 do_loop = options.loop
482 if AllFilterNames
is None:
488 if do_initial_defaults_only:
490 ShowMessage(
"Coercing filters and impairments to default state, then exiting")
498 if do_no_initial_defaults:
502 ShowMessage(
"Coercing filters and impairments to default state")
505 skipsecs = do_skipsecs
518 StartTime = datetime.datetime.now()
520 Jobs =
RunList(StartTime, skipsecs)
526 ShowMessage(
"Running initial and skipped tasks to establish state.")
527 while Jobs.RunNextRequest(StartTime):
535 sleepsecs =
TotalSeconds(Jobs.LastRequestStartTime - datetime.datetime.now()) + 5
540 ShowMessage(
"Start running for %u seconds." % sleepsecs)
541 time.sleep(sleepsecs)
555 if __name__ ==
"__main__":
559 except Exception, err:
561 traceback.print_exc()
563 except KeyboardInterrupt:
def GetAllFilterNames(mm_hostname)
def __init__(self, now, skipsecs)
def __init__(self, reqname, mm2host, dowhen, bands, a2b_filtmap, b2a_filtmap)
def SetupJobs(Jobs, mm_hostname)
def RunNextRequest(self, nowtime)
def __init__(self, interval, function, args, kwargs)
def SetMM(mm_hostname, bands, a2bfilt_vals, b2afilt_vals, all_filter_names)
def ChangeBandsOnMM(bandsobj, mm2host)
def LastRequestStartTime(self)
def IsReadyToGo(self, now)
def AddRequest(self, reqname, mm2host, startsec, bands, a2b_filtmap, b2a_filtmap)
def SetFiltMap(mm2host, a2bfilt_vals, b2afilt_vals, all_filter_names=None)