def create_sff(sffname): """ This function creates a SFF on-the-fly when it receives a PUT request from ODL. The SFF runs on a separate thread. If a SFF thread with same name already exist it is killed before a new one is created. This happens when a SFF is modified or recreated :param sffname: SFF name :type sffname: str """ if not flask.request.json: flask.abort(400) logger.info("Received request from ODL to create SFF ...") local_sff_threads = sfc_globals.get_sff_threads() if sffname in local_sff_threads.keys(): stop_sff(sffname) r_json = flask.request.get_json() with open("jsonputSFF.txt", "w") as outfile: json.dump(r_json, outfile) local_sff_topo = sfc_globals.get_sff_topo() local_sff_topo[sffname] = r_json['service-function-forwarder'][0] sff_port = (local_sff_topo[sffname]['sff-data-plane-locator'][0]['data-plane-locator']['port']) sff_ip = (local_sff_topo[sffname]['sff-data-plane-locator'][0]['data-plane-locator']['ip']) nfq_classifier.set_fwd_socket(sff_ip) start_sff(sffname, sff_ip, sff_port) return flask.jsonify({'sff': sfc_globals.get_sff_topo()}), 201
def create_sff(sffname): """ This function creates a SFF on-the-fly when it receives a PUT request from ODL. The SFF runs on a separate thread. If a SFF thread with same name already exist it is killed before a new one is created. This happens when a SFF is modified or recreated :param sffname: SFF name :type sffname: str """ if not flask.request.json: flask.abort(400) logger.info("Received request from ODL to create SFF ...") local_sff_threads = sfc_globals.get_sff_threads() if sffname in local_sff_threads.keys(): stop_sff(sffname) r_json = flask.request.get_json() with open("jsonputSFF.txt", "w") as outfile: json.dump(r_json, outfile) local_sff_topo = sfc_globals.get_sff_topo() local_sff_topo[sffname] = r_json['service-function-forwarder'][0] sff_port = (local_sff_topo[sffname]['sff-data-plane-locator'][0] ['data-plane-locator']['port']) sff_ip = (local_sff_topo[sffname]['sff-data-plane-locator'][0] ['data-plane-locator']['ip']) nfq_classifier.set_fwd_socket(sff_ip) start_sff(sffname, sff_ip, sff_port) return flask.jsonify({'sff': sfc_globals.get_sff_topo()}), 201
def create_sff(sffname): """ This function creates a SFF on-the-fly when it receives a PUT request from ODL. The SFF runs on a separate thread. If a SFF thread with same name already exist it is killed before a new one is created. This happens when a SFF is modified or recreated :param sffname: SFF name :type sffname: str """ if not flask.request.json: flask.abort(400) local_sff_threads = sfc_globals.get_sff_threads() if sffname in local_sff_threads.keys(): stop_sff(sffname) r_json = flask.request.get_json() local_sff_topo = sfc_globals.get_sff_topo() local_sff_topo[sffname] = r_json['service-function-forwarder'][0] sff_port = (local_sff_topo[sffname]['sff-data-plane-locator'] [0] ['data-plane-locator'] ['port']) start_sff(sffname, "0.0.0.0", sff_port) return flask.jsonify({'sff': sfc_globals.get_sff_topo()}), 201
def start(sffname): start_sff(sffname, '0.0.0.0', 6000)