Esempio n. 1
0
def onboard_vnfd(body):
    """
    Function to onboard the VNFD, including the downloading from the url specified in the input.
    Parameters
    ----------
    body: dict
        IFA013 request to onboard a vnfd.
    Returns
    -------
    info: dict
        Dictionary with the IFA013 answer to the vnfd onboarding process
    """
    log_queue.put(["INFO", "vnf_package_path: %s" % body.vnf_package_path])
    filename = wget.download(body.vnf_package_path)
    tf = tarfile.open(filename)
    tf.extractall()
    with tf as _tar:
        for member in _tar:
            if member.isdir():
                continue
            print(member.name)
            if member.name.find("json"):
                fname = member.name
                break
    # upload it in the vnfd_db
    if (fname):
        with open(fname) as vnfd_json:
            vnfd_json = load(vnfd_json)
            vnfd_record = {
                "vnfdId": vnfd_json["vnfdId"],
                "vnfdVersion": vnfd_json["vnfdVersion"],
                "vnfdName": vnfd_json["vnfProductName"],
                "vnfdJson": vnfd_json
            }
        if vnfd_db.exists_vnfd(vnfd_json["vnfdId"], vnfd_json["vnfdVersion"]):
            vnfd_db.delete_vnfd_json(vnfd_json["vnfdId"])
        # then insert it again (creation or "update")
        vnfd_db.insert_vnfd(vnfd_record)
        # upload the descriptor in the MANO platform
        onboard_vnfd_mano(vnfd_json)
        # create the answer
        info = {
            "onboardedVnfPkgInfoId": vnfd_record["vnfdId"],
            "vnfId": vnfd_record["vnfdId"]
        }
    # remove the tar package and the json file
    os.remove(fname)
    return info
Esempio n. 2
0
def delete_vnfd(vnfdId, version):
    """
    Function to delete from the catalog the VNFD defined by vnfdId and version.
    Parameters
    ----------
    vnfdId: string
        Identifier of the virtual network function descriptor.
    version: string
        Version of the virtual network function service descriptor.

    Returns
    -------
    boolean
    """
    operation_result = vnfd_db.delete_vnfd_json(vnfdId, version)
    return operation_result