예제 #1
0
def create_path(rsp_name):
    logger.info("gmy=>create_path(rsp_name) \n")
    if not flask.request.json:
        flask.abort(400)
    # logger.info("gmy=tag1\n")
    local_path = sfc_globals.get_path()
    # logger.info(local_path)
    # logger.info("gmy=tag2\n")
    local_sff_os = sfc_globals.get_sff_os()
    # logger.info(local_sff_os)
    # logger.info("gmy=tag3\n")
    if (not sfc_globals.get_my_sff_name()) and auto_sff_name():
        # logger.fatal("gmy=>"+str(sfc_globals.get_my_sff_name())+"\n")
        # logger.fatal("gmy=>"+str(auto_sff_name())+"\n")
        logger.fatal("Could not determine my SFF name \n")
        sys.exit(1)
    local_path[rsp_name] = flask.request.get_json()["rendered-service-path"][0]
    logger.info("Building Service Path for path: %s", rsp_name)

    if not build_data_plane_service_path(local_path[rsp_name]):
        # Testing XE cli processing module
        if local_sff_os == 'XE':
            logger.info("Provisioning %s XE SFF", local_sff_os)
            xe_cli.process_xe_cli(sfc_globals.get_data_plane_path())

        elif local_sff_os == 'XR':
            logger.info("Provisioning %s XR SFF", local_sff_os)
            xr_cli.process_xr_cli(sfc_globals.get_data_plane_path())

        elif local_sff_os == 'OVS':
            logger.info("Provisioning %s SFF", local_sff_os)
            # process_ovs_cli(data_plane_path)
            ovs_cli.process_ovs_sff__cli(sfc_globals.get_data_plane_path())

        elif local_sff_os == "ODL":
            logger.info("Provisioning %s SFF", local_sff_os)

        # should never get here
        else:
            logger.error("Unknown SFF OS: %s", local_sff_os)
            # json_string = json.dumps(data_plane_path)
        logger.info("ODL locator %s ", sfc_globals.get_odl_locator())
        get_sfp_from_odl(sfc_globals.get_odl_locator())
        get_metadata_from_odl(sfc_globals.get_odl_locator())
        find_metadata()
        return flask.jsonify(local_path), 201
    else:
        msg = "Could not build service path: {}".format(rsp_name)
        return msg, 400
예제 #2
0
파일: sfc_agent.py 프로젝트: Kibrom1/sfc
def create_path(rsp_name):
    if not flask.request.json:
        flask.abort(400)

    local_path = sfc_globals.get_path()
    local_sff_os = sfc_globals.get_sff_os()

    if (not sfc_globals.get_my_sff_name()) and auto_sff_name():
        logger.fatal("Could not determine my SFF name \n")
        sys.exit(1)

    # print json.dumps(sfpjson)
    # sfpj_name = sfpjson["service-function-path"][0]['name']

    local_path[rsp_name] = flask.request.get_json()["rendered-service-path"][0]
    logger.info("Building Service Path for path: %s", rsp_name)

    if not build_data_plane_service_path(local_path[rsp_name]):
        # Testing XE cli processing module
        if local_sff_os == 'XE':
            logger.info("Provisioning %s XE SFF", local_sff_os)
            xe_cli.process_xe_cli(sfc_globals.get_data_plane_path())

        elif local_sff_os == 'XR':
            logger.info("Provisioning %s XR SFF", local_sff_os)
            print('local path : ', local_path)  # debug to see if receive metadata - will remove
            xr_cli.process_xr_cli(sfc_globals.get_data_plane_path())

        elif local_sff_os == 'OVS':
            logger.info("Provisioning %s SFF", local_sff_os)
            # process_ovs_cli(data_plane_path)
            ovs_cli.process_ovs_sff__cli(sfc_globals.get_data_plane_path())

        elif local_sff_os == "ODL":
            logger.info("Provisioning %s SFF", local_sff_os)

        # should never get here
        else:
            logger.error("Unknown SFF OS: %s", local_sff_os)
            # json_string = json.dumps(data_plane_path)

        return flask.jsonify(local_path), 201
    else:
        msg = "Could not build service path: {}".format(rsp_name)
        return msg, 400