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 test_post_cs_instances_nsinstanceid_instantiate(
        post_cs_instances_nsinstanceid_instantiate_keys):
    """Tests API call to instantiate an NS"""
    sonata_pishahang = SONATAClient.Pishahang(HOST_URL)
    sonata_auth = SONATAClient.Auth(HOST_URL)

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

    _cosd_list = json.loads(
        sonata_pishahang.get_cosd_descriptors(
            token=_token["token"]["access_token"]))
    _cosd_list = json.loads(_cosd_list["data"])

    _ns = None
    for _n in _cosd_list:
        if "scramble-cosd" == _n['cosd']['name']:
            _ns = _n['uuid']

    print(_ns)
    if _ns:
        response = json.loads(
            sonata_pishahang.post_cs_instances_nsinstanceid_instantiate(
                token=_token["token"]["access_token"], nsInstanceId=_ns))

        print(response)
        assert response['error'] == False
        response = json.loads(response["data"])
        assert isinstance(response, dict)
        assert set(post_cs_instances_nsinstanceid_instantiate_keys).issubset(
            response.keys()), "All keys should be in the response"
    else:
        return False
Пример #3
0
def test_get_csd_descriptors(get_csd_descriptors_keys):
    """Tests API call to fetch multiple NS descriptor resources"""
    sonata_pishahang = SONATAClient.Pishahang(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_pishahang.get_csd_descriptors(
            token=_token["token"]["access_token"], limit=1000))

    response = json.loads(response["data"])
    assert isinstance(response, list)
    if len(response) > 0:
        assert set(get_csd_descriptors_keys).issubset(
            response[0].keys()), "All keys should be in the response"
Пример #4
0
def test_post_cosd_descriptors(post_cosd_descriptors_keys):
    """Tests API call to onboard NS descriptor resources"""
    sonata_pishahang = SONATAClient.Pishahang(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_cosds(_token=_token["token"]["access_token"])

    response = json.loads(
        sonata_pishahang.post_cosd_descriptors(
            token=_token["token"]["access_token"],
            package_path="tests/samples/cosd_example.yml"))

    assert response['error'] == False
    assert response['data'] != ''
Пример #5
0
    def _delete_test_cosds(_token, cosdname="scramble-cosd"):
        time.sleep(1)
        sonata_pishahang = SONATAClient.Pishahang(HOST_URL)

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

        _cosd = None
        for _v in _cosd_list:
            if "scramble-cosd" == _v['cosd']['name']:
                _cosd = _v['uuid']

        response = None
        if _cosd:
            response = json.loads(
                sonata_pishahang.delete_cosd_descriptors_cosdpkgid(
                    token=_token, cosdpkgid=_cosd))
def sonata_cleanup():

    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'])


    sonata_pishahang_2 = SONATAClient.Pishahang(HOST_URL_2)
    sonata_auth_2 = SONATAClient.Auth(HOST_URL_2)

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

    _csd_list = json.loads(sonata_pishahang_2.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_2.delete_csd_descriptors_csdpkgid(
                    token=_token,
                    csdpkgid=_csd['uuid'])

    _cosd_list = json.loads(sonata_pishahang_2.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_2.delete_cosd_descriptors_cosdpkgid(
                    token=_token,
                    cosdpkgid=_cosd['uuid'])



    time.sleep(5)
            for _run in range(1, RUNS+1):
                print("{image}_case{case}_{instances}_Run{run}".format(image=_image, case=_case, instances=_instances, run=_run))
                # NO_INSTANCES = _instances
                NSNAME = "{image}_case{case}-{_id}"
                NSDESCRIPTION = "{image}_case{case}_{instances}_Run{run}".format(image=_image, case=_case, instances=_instances, run=_run)

                NSD_PATH = "/app/SONATA/Container/CASE{case}/{image}_case{case}_cosd_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_pishahang = SONATAClient.Pishahang(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):