+ # The "built-in" flow template
+ flow_mode_template = {
+ u'flow': [
+ {
+ u'hard-timeout': 65000,
+ u'idle-timeout': 65000,
+ u'cookie_mask': 4294967295,
+ u'flow-name': u'FLOW-NAME-TEMPLATE',
+ u'priority': 2,
+ u'strict': False,
+ u'cookie': 0,
+ u'table_id': 0,
+ u'installHw': False,
+ u'id': u'FLOW-ID-TEMPLATE',
+ u'match': {
+ u'ipv4-destination': u'0.0.0.0/32',
+ u'ethernet-match': {
+ u'ethernet-type': {
+ u'type': 2048
+ }
+ }
+ },
+ u'instructions': {
+ u'instruction': [
+ {
+ u'order': 0,
+ u'apply-actions': {
+ u'action': [
+ {
+ u'drop-action': {},
+ u'order': 0
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+
+ class FcbStats(object):
+ """
+ FlowConfigBlaster Statistics: a class that stores and further processes
+ statistics collected by Blaster worker threads during their execution.
+ """
+ def __init__(self):
+ self.ok_rqst_rate = Counter(0.0)
+ self.total_rqst_rate = Counter(0.0)
+ self.ok_flow_rate = Counter(0.0)
+ self.total_flow_rate = Counter(0.0)
+ self.ok_rqsts = Counter(0)
+ self.total_rqsts = Counter(0)
+ self.ok_flows = Counter(0)
+ self.total_flows = Counter(0)
+
+ def process_stats(self, rqst_stats, flow_stats, elapsed_time):
+ """
+ Calculates the stats for RESTCONF request and flow programming
+ throughput, and aggregates statistics across all Blaster threads.
+ """
+ ok_rqsts = rqst_stats[200] + rqst_stats[204]
+ total_rqsts = sum(rqst_stats.values())
+ ok_flows = flow_stats[200] + flow_stats[204]
+ total_flows = sum(flow_stats.values())
+
+ ok_rqst_rate = ok_rqsts / elapsed_time
+ total_rqst_rate = total_rqsts / elapsed_time
+ ok_flow_rate = ok_flows / elapsed_time
+ total_flow_rate = total_flows / elapsed_time
+
+ self.ok_rqsts.increment(ok_rqsts)
+ self.total_rqsts.increment(total_rqsts)
+ self.ok_flows.increment(ok_flows)
+ self.total_flows.increment(total_flows)
+
+ self.ok_rqst_rate.increment(ok_rqst_rate)
+ self.total_rqst_rate.increment(total_rqst_rate)
+ self.ok_flow_rate.increment(ok_flow_rate)
+ self.total_flow_rate.increment(total_flow_rate)
+
+ return ok_rqst_rate, total_rqst_rate, ok_flow_rate, total_flow_rate
+
+ def get_ok_rqst_rate(self):
+ return self.ok_rqst_rate.value
+
+ def get_total_rqst_rate(self):
+ return self.total_rqst_rate.value
+
+ def get_ok_flow_rate(self):
+ return self.ok_flow_rate.value
+
+ def get_total_flow_rate(self):
+ return self.total_flow_rate.value
+
+ def get_ok_rqsts(self):
+ return self.ok_rqsts.value
+
+ def get_total_rqsts(self):
+ return self.total_rqsts.value
+
+ def get_ok_flows(self):
+ return self.ok_flows.value
+
+ def get_total_flows(self):
+ return self.total_flows.value
+
+ def __init__(self, host, port, ncycles, nthreads, fpr, nnodes, nflows, startflow, auth, flow_mod_template=None):