예제 #1
0
def onboard_appd(body):
    """
    Function to onboard the APPD, including the downloading from the url specified in the input.
    Parameters
    ----------
    body: dict
        IFA013 request to onboard an appd.
    Returns
    -------
    info: dict
        Dictionary with the IFA013 answer to the appd onboarding process
    """
    log_queue.put(["INFO", "app_package_path: %s" % body.app_package_path])
    filename = wget.download(body.app_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 appd_json:
            appd_json = load(appd_json)
            appd_record = {
                "appdId": appd_json["appDId"],
                "appdVersion": appd_json["appDVersion"],
                "appdName": appd_json["appName"],
                "appdJson": appd_json
            }
        if appd_db.exists_appd(appd_json["appDId"], appd_json["appDVersion"]):
            appd_db.delete_appd_json(appd_json["appDId"])
        # then insert it again (creation or "update")
        appd_db.insert_appd(appd_record)
        # create the answer
        info = {
            "onboardedAppPkgId": appd_record["appdId"],
            "appDId": appd_record["appdId"]
        }
    # remove the tar package and the json file
    os.remove(filename)
    os.remove(fname)
    return info
예제 #2
0
def delete_appd(appdId, version):
    """
    Function to delete from the catalog the MEC app defined by vnfdId and version.
    Parameters
    ----------
    appdId: string
        Identifier of the MEC application descriptor.
    version: string
        Version of the MEC application descriptor.

    Returns
    -------
    boolean
    """
    operation_result = appd_db.delete_appd_json(appdId, version)
    return operation_result