def sonata_cleanup():
    sonata_nsd = SONATAClient.Nsd(HOST_URL)
    sonata_pishahang = SONATAClient.Pishahang(HOST_URL)
    sonata_nslcm = SONATAClient.Nslcm(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)

    print("Sonata NSD/VNFD Cleanup")

    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    _csd_list = json.loads(
        sonata_pishahang.get_csd_descriptors(
            token=_token,
            limit=1000,
        ))
    _csd_list = json.loads(_csd_list["data"])

    print(len(_csd_list))
    for _csd in _csd_list:
        sonata_pishahang.delete_csd_descriptors_csdpkgid(token=_token,
                                                         csdpkgid=_csd['uuid'])

    _cosd_list = json.loads(
        sonata_pishahang.get_cosd_descriptors(token=_token, limit=1000))
    _cosd_list = json.loads(_cosd_list["data"])

    print(len(_cosd_list))
    for _cosd in _cosd_list:
        sonata_pishahang.delete_cosd_descriptors_cosdpkgid(
            token=_token, cosdpkgid=_cosd['uuid'])
예제 #2
0
    def _delete_test_nsd(_token, nsdname="sonata-demo"):
        time.sleep(5)
        sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
        sonata_nsd = Nsd(HOST_URL)

        _nsd_list = json.loads(sonata_nsd.get_ns_descriptors(token=_token))
        _nsd_list = json.loads(_nsd_list["data"])

        _nsd = None
        for _n in _nsd_list:
            if "sonata-demo" == _n['nsd']['name']:
                _nsd = _n['uuid']

        time.sleep(10)
        response = json.loads(
            sonata_nsd.delete_ns_descriptors_nsdinfoid(token=_token,
                                                       nsdinfoid=_nsd))

        time.sleep(5)

        _vnfd_list = json.loads(sonata_vnfpkgm.get_vnf_packages(token=_token))
        _vnfd_list = json.loads(_vnfd_list["data"])

        _vnfd = None
        for _v in _vnfd_list:
            if "vnfd_example" == _v['uuid']:
                _vnfd = _v['uuid']

        response = None
        if _vnfd:
            response = json.loads(
                sonata_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token,
                                                            vnfPkgId=_vnfd))
예제 #3
0
def test_put_vnf_packages_vnfpkgid():
    """Tests API call to update NS descriptor resources"""
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)
    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    _vnfd_list = json.loads(
        sonata_vnfpkgm.get_vnf_packages(token=_token["token"]["access_token"]))
    _vnfd_list = json.loads(_vnfd_list["data"])

    _vnfd = None
    for _v in _vnfd_list:
        if "vnfd_example" == _v['uuid']:
            _vnfd = _v['uuid']

    response = json.loads(
        sonata_vnfpkgm.put_vnf_packages_vnfpkgid(
            token=_token["token"]["access_token"],
            data_path="tests/samples/Sonata/sonata_simple_vnfd.json",
            vnfPkgId=_vnfd))
    print(response)
    Helpers._delete_test_vnf("vnfd_example")
    if response["error"]:
        return True
    else:
        return False
예제 #4
0
    def _upload_test_vnf(_token):
        time.sleep(5)
        sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
        response = json.loads(
            sonata_vnfpkgm.post_vnf_packages(
                token=_token, package_path="tests/samples/vnfd_example.yml"))

        if response["error"]:
            return True
        else:
            return False
예제 #5
0
def test_get_vnf_packages(get_vnf_packages_keys):
    """Tests API call to fetch multiple NS descriptor resources"""
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)
    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    response = json.loads(
        sonata_vnfpkgm.get_vnf_packages(token=_token["token"]["access_token"],
                                        limit=1000))

    response = json.loads(response["data"])
    assert isinstance(response, list)
    if len(response) > 0:
        assert set(get_vnf_packages_keys).issubset(
            response[0].keys()), "All keys should be in the response"
예제 #6
0
def test_post_vnf_packages(post_vnf_packages_keys):
    """Tests API call to onboard VNF descriptor resources"""
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)

    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])
    Helpers._delete_test_vnf(_token=_token["token"]["access_token"])

    response = json.loads(
        sonata_vnfpkgm.post_vnf_packages(
            token=_token["token"]["access_token"],
            package_path="tests/samples/vnfd_example.yml"))

    assert response['error'] == True
    assert response['data'] != ''
예제 #7
0
    def _delete_test_vnf(_token, vnfname="vnfd_example"):
        time.sleep(5)
        sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)

        _vnfd_list = json.loads(sonata_vnfpkgm.get_vnf_packages(token=_token))
        _vnfd_list = json.loads(_vnfd_list["data"])

        _vnfd = None
        for _v in _vnfd_list:
            if "vnfd_example" == _v['uuid']:
                _vnfd = _v['uuid']

        response = None
        if _vnfd:
            response = json.loads(
                sonata_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token,
                                                            vnfPkgId=_vnfd))
예제 #8
0
    def _upload_reference_vnfd_for_nsd(_referencevnfdname="sonata-demo"):
        time.sleep(5)
        sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
        sonata_nsd = Nsd(HOST_URL)

        _nsd_list = json.loads(sonata_nsd.get_ns_descriptors(token=_token))
        _nsd_list = json.loads(_nsd_list["data"])

        if _referencevnfdname:
            response = json.loads(
                sonata_vnfpkgm.post_vnf_packages(
                    token=_token,
                    package_path="tests/samples/vnfd_example.yml"))

        if response["error"]:
            return True
        else:
            return False
예제 #9
0
def test_get_vnf_packages_vnfpkgid(get_vnf_packages_vnfpkgid_keys):
    """Tests API call to onboard VNF descriptor resources"""
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)
    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    _vnfd_list = json.loads(
        sonata_vnfpkgm.get_vnf_packages(token=_token["token"]["access_token"]))
    _vnfd_list = json.loads(_vnfd_list["data"])

    _vnfd = None
    for _v in _vnfd_list:
        if "vnfd_example" == _v['uuid']:
            _vnfd = _v['uuid']

    response = json.loads(
        sonata_vnfpkgm.get_vnf_packages_vnfpkgid(
            token=_token["token"]["access_token"], vnfPkgId=_vnfd))
예제 #10
0
    def _delete_test_csds(_token, csdname="scramble-csd"):
        time.sleep(1)
        sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
        sonata_pishahang = SONATAClient.Pishahang(HOST_URL)

        _csd_list = json.loads(
            sonata_pishahang.get_csd_descriptors(token=_token, limit=1000))
        _csd_list = json.loads(_csd_list["data"])

        _csd = None
        for _v in _csd_list:
            if "scramble-csd" == _v['csd']['name']:
                _csd = _v['uuid']

        response = None
        if _csd:
            response = json.loads(
                sonata_pishahang.delete_csd_descriptors_csdpkgid(
                    token=_token, csdpkgid=_csd))
예제 #11
0
def test_delete_ns_descriptors_nsdinfoid(delete_ns_descriptors_nsdinfoid_keys):
    """Tests API call to delete NS descriptor resources"""
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
    sonata_nsd = SONATAClient.Nsd(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)
    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    _nsd_list = json.loads(
        sonata_nsd.get_ns_descriptors(token=_token["token"]["access_token"]))
    _nsd_list = json.loads(_nsd_list["data"])

    _nsd = None
    for _n in _nsd_list:
        if "sonata-demo" == _n['nsd']['name']:
            _nsd = _n['uuid']

    time.sleep(10)  # Wait for NSD onboarding
    response = json.loads(
        sonata_nsd.delete_ns_descriptors_nsdinfoid(
            token=_token["token"]["access_token"], nsdinfoid=_nsd))
    assert isinstance(response, dict)
    assert response["data"] == "{\"error\":\"The NSD ID None does not exist\"}"

    time.sleep(2)  #Wait for NSD onboarding

    _vnfd_list = json.loads(
        sonata_vnfpkgm.get_vnf_packages(token=_token["token"]["access_token"]))
    _vnfd_list = json.loads(_vnfd_list["data"])

    _vnfd = None
    for _v in _vnfd_list:
        if "vnfd_example" == _v['uuid']:
            _vnfd = _v['uuid']

    response = None
    if _vnfd:
        response = json.loads(
            sonata_vnfpkgm.delete_vnf_packages_vnfpkgid(
                token=_token["token"]["access_token"], vnfPkgId=_vnfd))
        assert isinstance(response, dict)
        assert response["data"] == ""
예제 #12
0
def test_delete_vnf_packages_vnfpkgid(delete_vnf_packages_vnfpkgid_keys):
    """Tests API call to delete NS descriptor resources"""
    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)
    _token = json.loads(sonata_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    _vnfd_list = json.loads(
        sonata_vnfpkgm.get_vnf_packages(token=_token["token"]["access_token"]))
    _vnfd_list = json.loads(_vnfd_list["data"])

    _vnfd = None
    for _v in _vnfd_list:
        if "vnfd_example" == _v['uuid']:
            _vnfd = _v['uuid']

    response = None
    if _vnfd:
        response = json.loads(
            sonata_vnfpkgm.delete_vnf_packages_vnfpkgid(
                token=_token["token"]["access_token"], vnfPkgId=_vnfd))
        assert isinstance(response, dict)
        assert response["data"] == ""
                        rpm=_rpm,
                        run=_run)

                    NSD_PATH = "/app/SONATA/Descriptors/CASE{case}/{image}_case{case}_nsd_sonata.yml".format(
                        image=_image, case=_case)
                    # VNFD_PATHS = ["/app/SONATA/Descriptors/CASE{case}/{image}_vnfd.1.yml".format(image=_image, case=_case), "/app/SONATA/Descriptors/CASE{case}/{image}_vnfd.2.yml".format(image=_image, case=_case), "/app/SONATA/Descriptors/CASE{case}/{image}_vnfd.3.yml".format(image=_image, case=_case), "/app/SONATA/Descriptors/CASE{case}/{image}_vnfd.4.yml".format(image=_image, case=_case), "/app/SONATA/Descriptors/CASE{case}/{image}_vnfd.5.yml".format(image=_image, case=_case)]
                    with open(NSD_PATH, 'r') as file:
                        nsd_data = file.read()

                    # with open(VNFD_PATH, 'r') as file:
                    #     vnfd_data = file.read()

                    sonata_nsd = SONATAClient.Nsd(HOST_URL)
                    sonata_nslcm = SONATAClient.Nslcm(HOST_URL)
                    sonata_auth = SONATAClient.Auth(HOST_URL)
                    sonata_vnfpkgm = SONATAClient.VnfPkgm(HOST_URL)

                    experiment_timestamps = {}

                    sonata_cleanup()

                    _token = json.loads(
                        sonata_auth.auth(username=USERNAME, password=PASSWORD))
                    _token = json.loads(_token["data"])

                    for _c in range(1, 6):
                        # for _vnfd in VNFD_PATHS:
                        VNFD_PATH = "/app/SONATA/Descriptors/CASE{case}/{image}_vnfd_{vnfid}.yml".format(
                            image=_image, case=_case, vnfid=_c)
                        _res = sonata_vnfpkgm.post_vnf_packages(
                            token=_token, package_path=VNFD_PATH)