72 HalfLongRoundtrip = LongRoundtrip/2
73 HalfShortRoundtrip = ShortRoundtrip/2
97 BandSettings.SetDelayAmount(A_Band, LANA_to_LANB, HalfShortRoundtrip)
98 BandSettings.SetDelayAmount(A_Band, LANB_to_LANA, HalfShortRoundtrip)
99 BandSettings.SetDelayReorder(A_Band, LANA_to_LANB,
False)
100 BandSettings.SetDelayReorder(A_Band, LANB_to_LANA,
False)
101 BandSettings.SetRateLimit(A_Band, LANA_to_LANB, OneMegabit)
102 BandSettings.SetRateLimit(A_Band, LANB_to_LANA, OneMegabit)
105 BandSettings.SetDelayAmount(B_Band, LANA_to_LANB, HalfLongRoundtrip)
106 BandSettings.SetDelayAmount(B_Band, LANB_to_LANA, HalfLongRoundtrip)
107 BandSettings.SetDelayReorder(B_Band, LANA_to_LANB,
False)
108 BandSettings.SetDelayReorder(B_Band, LANB_to_LANA,
False)
109 BandSettings.SetRateLimit(B_Band, LANA_to_LANB, OneKilobit)
110 BandSettings.SetRateLimit(B_Band, LANB_to_LANA, OneKilobit)
119 Jobs.AddRequest(
"Establish Baseline - 100ms RT delay, 1,000,000 bit/sec rate limit", mm_hostname, 0,
120 BandSettings, Filt_ToBandA, Filt_ToBandA)
130 for secs
in range(interval, items_per_group*num_groups*interval, items_per_group*interval):
131 Jobs.AddRequest(
"Job %u: 1000ms RT delay, 100,000 bit/sec rate limit" % \
132 secs, mm_hostname, secs,
None, Filt_ToBandB, Filt_ToBandB)
133 nxtsecs = secs + interval
134 Jobs.AddRequest(
"Job %u: 100ms RT delay, 1,000,000 bit/sec rate limit" % \
135 nxtsecs, mm_hostname, nxtsecs,
None, Filt_ToBandA, Filt_ToBandA)
142 TeamName =
"TEAM UNKNOWN" 145 datetime.datetime.now().isoformat()
146 msg = datetime.datetime.now().isoformat() \
147 +
' "' + TeamName +
'" ' \
151 syslog.syslog(syslog.LOG_INFO, msg)
165 def __init__(self, interval, function, *args, **kwargs):
194 def __init__(self, reqname, mm2host, dowhen, bands, a2b_filtmap, b2a_filtmap):
196 @param reqname: The name of the request, a single line of text. 197 @type reqname: String 198 @param mm2host: The name or IP address of the target host. 199 @type mm2host: String 200 @param dowhen: A datetime object indicating when to do perform this request. 201 @type dowhen: datetime 202 @param bands: A mm2client.Bands object containing the desired impairment settings. 204 @type bands: mm2client.Bands 205 @param a2b_filtmap: A sequence of setfilters.FiltSetting objects containing the desired LanA to LanB filters settings. 206 May be an empty sequence. 207 @type a2b_filtmap: A sequence of setfilters.FiltSetting objects. 208 @param b2a_filtmap: A sequence of setfilters.FiltSetting objects containing the desired LanB to LanA filters settings. 209 May be an empty sequence. 210 @type b2a_filtmap: A sequence of setfilters.FiltSetting objects. 221 return self.
__DoWhen < other.__DoWhen
224 return self.
__DoWhen <= other.__DoWhen
227 return self.
__DoWhen == other.__DoWhen
230 return self.
__DoWhen != other.__DoWhen
233 return self.
__DoWhen > other.__DoWhen
236 return self.
__DoWhen <= other.__DoWhen
284 global AllFilterNames
297 if (skipsecs
is not None)
and (skipsecs > 0):
300 def AddRequest(self, reqname, mm2host, startsec, bands,
301 a2b_filtmap, b2a_filtmap):
302 dowhen = self.
__StartTime + datetime.timedelta(0, startsec)
303 self.__WorkList.append(
DoRequest(reqname, mm2host, dowhen, bands,
304 a2b_filtmap, b2a_filtmap))
305 self.__WorkList.sort()
315 if req.IsReadyToGo(nowtime):
319 except Exception, err:
320 ShowMessage(
"Exception in Task \"%s\" - %s" % (req.Name, str(err)))
328 return datetime.datetime.now()
338 def SetMM(mm_hostname, bands, a2bfilt_vals, b2afilt_vals, all_filter_names):
340 if bands
is not None:
342 if (a2bfilt_vals
is not None)
or (b2afilt_vals
is not None):
353 AllFilterNames =
None 360 global AllFilterNames
367 Jobs.RunNextRequest(datetime.datetime.now())
372 parser = argparse.ArgumentParser(description=
"Start impairment pattern.")
374 parser.add_argument(
"-s",
"--skip", type=int,
375 help=
"Skip ahead: start at N seconds.")
377 parser.add_argument(
"-C",
"--do_not_use_initial_defaults", action=
"store_true",
378 dest=
"no_initial_defaults",
379 help=
"Do not establish defaults before running scheduled tasks.")
381 parser.add_argument(
"-D",
"--initial_defaults_then_exit", action=
"store_true",
382 dest=
"initial_defaults_only",
383 help=
"Establish defaults and then exit, supersedes -C.")
385 parser.add_argument(
"-l",
"--loop", action=
"store_true",
386 help=
"Loop/Cycle forever.")
388 parser.add_argument(
"-S",
"--syslog", action=
"store_true",
389 help=
"Send reports to the system defined syslog server (level LOG_INFO).")
391 parser.add_argument(
"-T",
"--team", required=
True, metavar=
"<team name>",
394 parser.add_argument(
"mm_hostname", metavar=
"<Mini Maxwell host name or IP address>",
395 help=
'The host name or IP address of the Mini Maxwell/Maxwell G.')
397 pargs = parser.parse_args()
399 TeamName = pargs.team
403 mm_hostname = pargs.mm_hostname
405 if AllFilterNames
is None:
411 if pargs.initial_defaults_only:
413 ShowMessage(
"Coercing filters and impairments to default state, then exiting")
421 if pargs.no_initial_defaults:
425 ShowMessage(
"Coercing filters and impairments to default state")
428 skipsecs = pargs.skip
441 StartTime = datetime.datetime.now()
443 Jobs =
RunList(StartTime, skipsecs)
449 ShowMessage(
"Running initial and skipped tasks to establish state.")
450 while Jobs.RunNextRequest(StartTime):
457 sleepsecs = (Jobs.LastRequestStartTime - datetime.datetime.now()).total_seconds() + 5
462 ShowMessage(
"Start running for %u seconds." % sleepsecs)
463 time.sleep(sleepsecs)
477 if __name__ ==
"__main__":
481 except Exception, err:
483 traceback.print_exc()
485 except KeyboardInterrupt:
def LastRequestStartTime(self)
def GetAllFilterNames(mm_hostname)
def IsReadyToGo(self, now)
def SetupJobs(Jobs, mm_hostname)
def __init__(self, reqname, mm2host, dowhen, bands, a2b_filtmap, b2a_filtmap)
def AddRequest(self, reqname, mm2host, startsec, bands, a2b_filtmap, b2a_filtmap)
def RunNextRequest(self, nowtime)
def __init__(self, interval, function, args, kwargs)
def ChangeBandsOnMM(bandsobj, mm2host)
def __init__(self, now, skipsecs)
def SetMM(mm_hostname, bands, a2bfilt_vals, b2afilt_vals, all_filter_names)
def SetFiltMap(mm2host, a2bfilt_vals, b2afilt_vals, all_filter_names=None)