summaryrefslogtreecommitdiff
path: root/script/traffic_replay
diff options
context:
space:
mode:
Diffstat (limited to 'script/traffic_replay')
-rwxr-xr-xscript/traffic_replay58
1 files changed, 22 insertions, 36 deletions
diff --git a/script/traffic_replay b/script/traffic_replay
index 5adeec101de..d3f1c14d4f4 100755
--- a/script/traffic_replay
+++ b/script/traffic_replay
@@ -40,13 +40,12 @@ def print_err(*args, **kwargs):
def main():
- desc = ("Generates network traffic 'conversations' based on <summary-file>"
- " (which should be the output file produced by either traffic_learner"
- " or traffic_summary.pl). This traffic is sent to <dns-hostname>,"
+ desc = ("Generates network traffic 'conversations' based on a model generated"
+ " by script/traffic_learner. This traffic is sent to <dns-hostname>,"
" which is the full DNS hostname of the DC being tested.")
parser = optparse.OptionParser(
- "%prog [--help|options] <summary-file> <dns-hostname>",
+ "%prog [--help|options] <model-file> <dns-hostname>",
description=desc)
parser.add_option('--dns-rate', type='float', default=0,
@@ -76,9 +75,7 @@ def main():
model_group = optparse.OptionGroup(parser, 'Traffic Model Options',
'These options alter the traffic '
- 'generated when the summary-file is a '
- 'traffic-model (produced by '
- 'traffic_learner)')
+ 'generated by the model')
model_group.add_option('-S', '--scale-traffic', type='float', default=1.0,
help='Increase the number of conversations by '
'this factor')
@@ -131,10 +128,10 @@ def main():
# First ensure we have reasonable arguments
if len(args) == 1:
- summary = None
+ model_file = None
host = args[0]
elif len(args) == 2:
- summary, host = args
+ model_file, host = args
else:
parser.print_usage()
return
@@ -158,14 +155,14 @@ def main():
traffic.clean_up_accounts(ldb, opts.instance_id)
exit(0)
- if summary:
- if not os.path.exists(summary):
- logger.error("Summary file %s doesn't exist" % summary)
+ if model_file:
+ if not os.path.exists(model_file):
+ logger.error("Model file %s doesn't exist" % model_file)
sys.exit(1)
- # the summary-file can be ommitted for --generate-users-only and
+ # the model-file can be ommitted for --generate-users-only and
# --cleanup-up, but it should be specified in all other cases
elif not opts.generate_users_only:
- logger.error("No summary-file specified to replay traffic from")
+ logger.error("No model file specified to replay traffic from")
sys.exit(1)
if not opts.fixed_password:
@@ -241,33 +238,17 @@ def main():
if duration is None:
duration = 60.0
- # ingest the model or traffic summary
- if summary:
+ # ingest the model
+ if model_file:
try:
- conversations, interval, duration, dns_counts = \
- traffic.ingest_summaries([summary])
-
- logger.info(("Using conversations from the traffic summary "
- "file specified"))
-
- # honour the specified duration if it's different to the
- # capture duration
- if opts.duration is not None:
- duration = opts.duration
-
- except ValueError as e:
- if not str(e).startswith('need more than'):
- raise
-
model = traffic.TrafficModel()
try:
- model.load(summary)
+ model.load(model_file)
except ValueError:
- logger.error(("Could not parse %s. The summary file "
- "should be the output from either the "
- "traffic_summary.pl or "
- "traffic_learner scripts.") % summary)
+ logger.error(("Could not parse %s. The model file "
+ "should be generated by the "
+ "traffic_learner script.") % model_file)
sys.exit()
logger.info(("Using the specified model file to "
@@ -276,6 +257,11 @@ def main():
conversations = model.generate_conversations(opts.scale_traffic,
duration,
opts.replay_rate)
+ except ValueError:
+ logger.error(("Could not parse %s, which does not seem to be "
+ "a model generated by script/traffic_learner."
+ % model_file))
+ sys.exit(1)
else:
conversations = []