src package¶
Submodules¶
src.flow_utils module¶
-
class
src.flow_utils.FlowExplorer(controller_ip, restconf_port, datastore, auth_token)[source]¶ Bases:
objectObject used to explore controller inventory flows, using the NB REST interface.
-
class
src.flow_utils.FlowProcessor(flow_template, url_template, auth_token)[source]¶ Bases:
objectHelper object used to add and remove flows based on predefined templates.
src.nb_gen module¶
NorthBound traffic generator
-
src.nb_gen.flow_master(args)[source]¶ Function executed by flow master thread. :param args: object containing ctrl_ip (controller IP), ctrl_port (controller RESTconf port), nflows (total number of flows to distribute), nworkers (number of worker threads to create), op_delay_ms (delay between thread operations (in milliseconds)), delete_flows_flag (whether to delete or not the added flows as part of the test), controller_restconf_user (controller RESTconf username), controller_restconf_password (controller RESTconf password) :returns: output_msg :rtype: str :type args: object of argparse.ArgumentParser()
src.nb_gen_utils module¶
Helper functions for NorthBound traffic generator
-
src.nb_gen_utils.create_workers(nworkers, flow_template, url_template, op_delay_ms, fpr, auth_token)[source]¶ Creates flow workers as separate processes along with their queues.
Parameters: - nworkers – number of workers to create
- flow_template – template from which flows are created
- url_template – url in which each worker will issue flows.
- op_delay_ms – delay between flow operations in each worker
(in milliseconds) :param auth_token: RESTconf authorization token (username/password tuple) :returns: worker queues (operational, result) and worker threads :rtype tuple<lst<multiprocessing.Queue()>> :type nworkers: int :type flow_template: str :type url_template: str :type op_delay_ms: int :type auth_token: tuple<str>
-
src.nb_gen_utils.distribute_workload(nflows, opqueues, operation, node_names)[source]¶ Creates operations of the form (operation, ‘target_switch’, uid, ‘IP_address’), one for each flow, and distributes them in a round robin fashion to the worker queues.
The operation can be a flow ADD or REMOVE. The target_switch is the switch on which the operation will be applied. The uid is a unique id for the operation. IP_adress is the IP address that will populate the destination IP of the flow created by a template.
Parameters: - nflows (int) – total number of flows to distribute
- opqueues (list<multiprocessing.Queue>) – workers operation queues
- operation (str) – operation to perform (Add ‘A’ or Delete ‘D’)
- node_names – array Name of each node in Opendaylight datastore.
-
src.nb_gen_utils.flow_transmission_start(opqueues, resqueues, wthr, nflows, ctrl_ip, ctrl_port, auth_token)[source]¶ Calculates transmission_interval, operation_time, failed_flow_ops :param opqueues: workers operation queues :param resqueues: workers result queues :param wthr: worker threads :param nflows: :param ctrl_ip: :param ctrl_port: :param auth_token: :returns (transmission_interval, operation_time, failed_flow_ops): transmission interval: time interval between requested flow operations operation time: total time failed flow operations: :rtype tuple<str> :type opqueues: list<multiprocessing.Queue()> :type resqueues: list<multiprocessing.Queue()> :type wthr: list<multiprocessing.Process()> :type nflows: int :type ctrl_ip: str :type ctrl_port: str :type auth_token: tuple<str>
-
src.nb_gen_utils.flow_worker_thread(wid, opqueue, resqueue, flow_template, url_template, op_delay_ms, fpr, auth_token)[source]¶ Function executed by flow worker thread
Parameters: - wid – worker id
- opqueue – queue where flow master will issue operations
:param resqueue:queue where flow master will issue operations :param flow_template: template from which flows are created :param url_template: template for the url of the REST call :param op_delay_ms: delay between thread operations (in milliseconds) :param auth_token: RESTconf authorization token (username/password tuple) :type wid: int :type opqueue: multiprocessing.Queue :type resqueue: multiprocessing.Queue :type flow_template: str :type url_template: str :type op_delay_ms: int :type auth_token: tuple<str>
-
src.nb_gen_utils.flows_transmission_run(flow_ops_params, op_delay_ms, node_names, url_template, flow_template, auth_token, fpr, delete_flows_flag=False)[source]¶ Function executed by flow_master method :param flow_ops_params: namedtuple [‘ctrl_ip’, ‘ctrl_port’, ‘nflows’, ‘nworkers’], (controller IP, controller RESTconf port, total number of flows to distribute, number of worker threads to create, deadline for flow discovery (in milliseconds) :param op_delay_ms: delay between thread operations (in milliseconds) :param node_names: list with node names registered in operational DS :param url_template: url for REST request to add/delete flows in controller’s operational DS :param flow_template: template of flow in json form to be added/deleted in controller’s operational DS :param auth_token: token containing restconf username/password used for REST requests in controller’s operational DS :param delete_flows_flag: whether to delete or not the added flows as part of the test :returns tuple with transmission_interval, operation_time, failed_flow_ops transmission interval: time interval between requested flow operations operation time: total time failed flow operations: :rtype: tuple: :type ctrl_ip: str :type ctrl_port: str :type nflows: int :type nworkers: int :type op_delay_ms: int :type node_names: list<str> :type url_template: str :type flow_template: str :type auth_token: tuple<str> :type delete_flows_flag: bool
-
src.nb_gen_utils.get_node_names(ctrl_ip, ctrl_port, auth_token)[source]¶ Fetch node names from the OpenDaylight operational DS
Parameters: - ctrl_ip (str) – controller IP
- ctrl_port (int) – controller RESTconf port
- auth_token (tuple<str>) – RESTconf authorization token (username/password tuple)
Returns: list with node names registered in operational DS
Return type: node_names: list<str>
-
src.nb_gen_utils.join_workers(opqueues, resqueues, wthr)[source]¶ Terminates all workers by sending a T operation.
Parameters: - opqueues – workers operation queues
- resqueues – workers result queues
- wthr – worker thread objects
Returns: failed_flow_ops
Return type: failed_flow_ops int
Type: opqueues list<multiprocessing.Queue>
Type: resqueues list<multiprocessing.Queue>
Type: wthr
src.run_handler module¶
Run handler of NorthBound traffic generator
-
src.run_handler.northbound_generator()[source]¶ - Command line arguments: 1. ctrl_ip: controller IP
- ctrl_port: controller RESTconf port
- nflows: total number of flows to distribute
- nworkers: number of worker threads to create
- op_delay_ms: delay between thread operations (in milliseconds)
6. delete_flows_flag: whether to delete or not the added flows as part of the test 7. controller_restconf_user: controller NorthBound RESTconf username 8. controller_restconf_password: controller NorthBound RESTconf password 9. flows-per-request, the number of flows that will be sent in a single request 10. logging_level: nb generator logging level (is passed from nstat orchestrator)