예제 #1
0
def create_sf(sfname):
    logger.info("Received request for SF creation: %s", sfname)
    # show the json string get from API
    logger.info(flask.request.get_json()['service-function'][0])

    if not flask.request.json:
        flask.abort(400)

    logger.info("Received request from ODL to create SF ...")
    local_sf_topo = sfc_globals.get_sf_topo()
    r_json = flask.request.get_json()
    with open("jsonputSF.txt", "w") as outfile:
        json.dump(r_json, outfile)
    local_sf_topo[sfname] = flask.request.get_json()['service-function'][0]
    data_plane_locator_list = local_sf_topo[sfname]['sf-data-plane-locator']

    for data_plane_locator in data_plane_locator_list:
        if ("ip" in data_plane_locator) and ("port" in data_plane_locator):
            sf_port = data_plane_locator['port']
            # logger.info(local_sf_topo[sfname]['type'])
            _, sf_type = (local_sf_topo[sfname]['type']).split(':')
            sf_ip = data_plane_locator['ip']
            # TODO: We need more checks to make sure IP in locator actually
            # corresponds to one of the existing interfaces in the system
            start_sf(sfname, sf_ip, sf_port, sf_type)
    return flask.jsonify({'sf': local_sf_topo[sfname]}), 201
예제 #2
0
def check_and_start_sf_thread(sf_name):
    """
    Checks whether a SF is local and its thread has been started. If thread is
    not running we start it.

    :param sf_name: Service Function Name
    :type sf_name: str
    :return int

    """
    if sf_local_host(sf_name):
        local_sf_threads = sfc_globals.get_sf_threads()
        if sf_name not in local_sf_threads.keys():
            local_sf_topo = sfc_globals.get_sf_topo()
            _, sf_type = (local_sf_topo[sf_name]['type']).split(':')
            data_plane_locator_list = local_sf_topo[sf_name]['sf-data-plane-locator']
            for data_plane_locator in data_plane_locator_list:
                if ("ip" in data_plane_locator) and ("port" in data_plane_locator):
                    sf_port = data_plane_locator['port']
                    start_sf(sf_name, "0.0.0.0", sf_port, sf_type)
예제 #3
0
def check_and_start_sf_thread(sf_name):
    """
    Checks whether a SF is local and its thread has been started. If thread is
    not running we start it.

    :param sf_name: Service Function Name
    :type sf_name: str
    :return int

    """
    if sf_local_host(sf_name):
        local_sf_threads = sfc_globals.get_sf_threads()
        if sf_name not in local_sf_threads.keys():
            local_sf_topo = sfc_globals.get_sf_topo()
            _, sf_type = (local_sf_topo[sf_name]['type']).split(':')
            data_plane_locator_list = local_sf_topo[sf_name]['sf-data-plane-locator']
            for data_plane_locator in data_plane_locator_list:
                if ("ip" in data_plane_locator) and ("port" in data_plane_locator):
                    sf_port = data_plane_locator['port']
                    start_sf(sf_name, "0.0.0.0", sf_port, sf_type)
예제 #4
0
파일: sfc_agent.py 프로젝트: Kibrom1/sfc
def create_sf(sfname):
    logger.info("Received request for SF creation: %s", sfname)

    if not flask.request.json:
        flask.abort(400)

    local_sf_topo = sfc_globals.get_sf_topo()
    local_sf_topo[sfname] = flask.request.get_json()['service-function'][0]
    data_plane_locator_list = local_sf_topo[sfname]['sf-data-plane-locator']

    for data_plane_locator in data_plane_locator_list:
        if ("ip" in data_plane_locator) and ("port" in data_plane_locator):
            sf_port = data_plane_locator['port']
            _, sf_type = (local_sf_topo[sfname]['type']).split(':')

            # TODO: We need more checks to make sure IP in locator actually
            # corresponds to one of the existing interfaces in the system
            start_sf(sfname, "0.0.0.0", sf_port, sf_type)

    return flask.jsonify({'sf': local_sf_topo[sfname]}), 201
예제 #5
0
파일: sfc_agent.py 프로젝트: 522986491/sfc
def create_sf(sfname):
    logger.info("Received request for SF creation: %s", sfname)

    if not flask.request.json:
        flask.abort(400)

    logger.info("Received request from ODL to create SF ...")
    local_sf_topo = sfc_globals.get_sf_topo()
    r_json = flask.request.get_json()
    with open("jsonputSF.txt", "w") as outfile:
        json.dump(r_json, outfile)
    local_sf_topo[sfname] = flask.request.get_json()['service-function'][0]
    data_plane_locator_list = local_sf_topo[sfname]['sf-data-plane-locator']

    for data_plane_locator in data_plane_locator_list:
        if ("ip" in data_plane_locator) and ("port" in data_plane_locator):
            sf_port = data_plane_locator['port']
            _, sf_type = (local_sf_topo[sfname]['type']).split(':')
            sf_ip = data_plane_locator['ip']
            # TODO: We need more checks to make sure IP in locator actually
            # corresponds to one of the existing interfaces in the system
            start_sf(sfname, sf_ip, sf_port, sf_type)
    return flask.jsonify({'sf': local_sf_topo[sfname]}), 201
예제 #6
0
def start():
    start_sf('firewall', '0.0.0.0', 6001, 'firewall')