Exemplo n.º 1
0
def test_put_ns_descriptors_nsd_content():
    """Tests API call to upload the content of a NSD"""
    osm_nsd = OSMClient.Nsd(HOST_URL)
    osm_auth = OSMClient.Auth(HOST_URL)
    _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])
    Helpers._upload_reference_vnfd_for_nsd()
    Helpers._upload_test_nsd()
    _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"]))
    _nsd_list = json.loads(_nsd_list["data"])

    _nsd = None
    for _n in _nsd_list:
        if "test_osm_cirros_2vnf_nsd" == _n['id']:
            _nsd = _n['_id']

    response = json.loads(
        osm_nsd.put_ns_descriptors_nsd_content(
            token=_token["id"],
            nsdinfoid=_nsd,
            data_path="tests/samples/test_osm_cirros_nsd.tar.gz"))
    Helpers._delete_test_nsd("test_osm_cirros_2vnf_nsd")
    if response["error"]:
        return True
    else:
        return False
Exemplo n.º 2
0
def test_post_ns_instances_nsinstanceid_instantiate(
        post_ns_instances_nsinstanceid_instantiate_keys):
    """Tests API call to create a NS instance resource"""
    # Helpers._delete_test_ns_instance()
    Helpers._upload_reference_vnfd_for_nsd()
    Helpers._upload_test_nsd()
    time.sleep(5)  # Wait
    osm_nsd = OSMClient.Nsd(HOST_URL)
    osm_nslcm = OSMClient.Nslcm(HOST_URL)
    osm_auth = OSMClient.Auth(HOST_URL)
    _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])
    _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"]))
    _nsd_list = json.loads(_nsd_list["data"])
    _nsd = None
    for _n in _nsd_list:
        if "test_osm_cirros_2vnf_nsd" == _n['id']:
            _nsd = _n['_id']

    response = json.loads(
        osm_nslcm.post_ns_instances_nsinstanceid_instantiate(
            token=_token["id"],
            nsDescription=NSDESCRIPTION,
            nsName=NSNAME,
            nsdId=_nsd,
            vimAccountId=VIMACCOUNTID))
    response = json.loads(response["data"])

    Helpers._delete_test_nsd("test_osm_cirros_2vnf_nsd")

    assert isinstance(response, dict)
    assert set(post_ns_instances_nsinstanceid_instantiate_keys).issubset(
        response.keys()), "All keys should be in the response"
    time.sleep(5)  # Wait for NS instantiation
Exemplo n.º 3
0
def test_get_ns_descriptors(get_ns_descriptors_keys):
    """Tests API call to fetch multiple NS descriptor resources"""
    osm_nsd = OSMClient.Nsd(HOST_URL)
    osm_auth = OSMClient.Auth(HOST_URL)
    _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    response = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"]))
    response = json.loads(response["data"])

    assert isinstance(response, list)
    if len(response) > 0:
        assert set(get_ns_descriptors_keys).issubset(
            response[0].keys()), "All keys should be in the response"
Exemplo n.º 4
0
def test_delete_ns_descriptors_nsdinfoid(delete_ns_descriptors_nsdinfoid_keys):
    """Tests API call to delete NS descriptor resources"""
    osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL)
    osm_nsd = OSMClient.Nsd(HOST_URL)
    osm_auth = OSMClient.Auth(HOST_URL)
    _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

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

    _nsd = None
    for _n in _nsd_list:
        if "test_osm_cirros_2vnf_nsd" == _n['id']:
            _nsd = _n['_id']

    time.sleep(10)  # Wait for NSD onboarding
    response = json.loads(
        osm_nsd.delete_ns_descriptors_nsdinfoid(token=_token["id"],
                                                nsdinfoid=_nsd))

    time.sleep(2)  # Wait for NSD onboarding

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

    _vnfd = None
    for _v in _vnfd_list:
        if "test_osm_cirros_vnfd" == _v['id']:
            _vnfd = _v['_id']

    response = None
    if _vnfd:
        response = json.loads(
            osm_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token["id"],
                                                     vnfPkgId=_vnfd))
        assert isinstance(response, dict)
        assert response["data"] == ""

    assert isinstance(response, dict)
    assert response["data"] == ""
Exemplo n.º 5
0
    def _upload_test_nsd():
        time.sleep(3)  # Wait
        osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL)
        osm_nsd = OSMClient.Nsd(HOST_URL)
        osm_auth = OSMClient.Auth(HOST_URL)
        _token = json.loads(osm_auth.auth(username=USERNAME,
                                          password=PASSWORD))
        _token = json.loads(_token["data"])

        osm_vnfpkgm.post_vnf_packages(
            token=_token["id"],
            package_path="tests/samples/test_osm_cirros_vnfd.tar.gz")

        response = json.loads(
            osm_nsd.post_ns_descriptors(
                token=_token["id"],
                package_path="tests/samples/test_osm_cirros_nsd.tar.gz"))
        if response["error"]:
            return True
        else:
            return False
Exemplo n.º 6
0
def test_post_ns_descriptors(post_ns_descriptors_keys):
    """Tests API call to onboard NS descriptor resources"""
    Helpers._delete_test_nsd()
    osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL)
    osm_nsd = OSMClient.Nsd(HOST_URL)
    osm_auth = OSMClient.Auth(HOST_URL)
    _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])

    osm_vnfpkgm.post_vnf_packages(
        token=_token["id"],
        package_path="tests/samples/test_osm_cirros_vnfd.tar.gz")

    response = json.loads(
        osm_nsd.post_ns_descriptors(
            token=_token["id"],
            package_path="tests/samples/test_osm_cirros_nsd.tar.gz"))
    response = json.loads(response["data"])

    assert isinstance(response, dict)
    assert set(post_ns_descriptors_keys).issubset(
        response.keys()), "All keys should be in the response"
Exemplo n.º 7
0
def test_get_ns_descriptors_nsdinfoid():
    """Tests API call to read information about an individual NS descriptor resource"""
    osm_nsd = OSMClient.Nsd(HOST_URL)
    osm_auth = OSMClient.Auth(HOST_URL)
    _token = json.loads(osm_auth.auth(username=USERNAME, password=PASSWORD))
    _token = json.loads(_token["data"])
    Helpers._upload_test_nsd()
    _nsd_list = json.loads(osm_nsd.get_ns_descriptors(token=_token["id"]))
    _nsd_list = json.loads(_nsd_list["data"])

    for _n in _nsd_list:
        if "test_osm_cirros_2vnf_nsd" == _n['id']:
            _nsd = _n['_id']

    response = json.loads(
        osm_nsd.get_ns_descriptors_nsdinfoid(token=_token["id"],
                                             nsdinfoid=_nsd))
    Helpers._delete_test_nsd()
    if response["error"]:
        return True
    else:
        return False
Exemplo n.º 8
0
    def _delete_test_nsd(nsdname="test_osm_cirros_2vnf_nsd"):
        osm_vnfpkgm = OSMClient.VnfPkgm(HOST_URL)
        osm_nsd = OSMClient.Nsd(HOST_URL)
        osm_auth = OSMClient.Auth(HOST_URL)
        _token = json.loads(osm_auth.auth(username=USERNAME,
                                          password=PASSWORD))
        _token = json.loads(_token["data"])

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

        _nsd = None
        for _n in _nsd_list:
            if "test_osm_cirros_2vnf_nsd" == _n['id']:
                _nsd = _n['_id']

        time.sleep(10)  # Wait for NSD onboarding
        response = json.loads(
            osm_nsd.delete_ns_descriptors_nsdinfoid(token=_token["id"],
                                                    nsdinfoid=_nsd))

        time.sleep(2)  # Wait for NSD onboarding

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

        _vnfd = None
        for _v in _vnfd_list:
            if nsdname == _v['id']:
                _vnfd = _v['_id']

        response = None
        if _vnfd:
            response = json.loads(
                osm_vnfpkgm.delete_vnf_packages_vnfpkgid(token=_token["id"],
                                                         vnfPkgId=_vnfd))
Exemplo n.º 9
0
DOCKER_EXCLUDE = ['experiment-runner']

IDLE_SLEEP = 1
NS_TERMINATION_SLEEP = 20
NO_INSTANCES = 100

USERNAME = "******"
PASSWORD = "******"

HOST_URL = "osmmano.cs.upb.de"
NSNAME = "stress_case1"
NSDESCRIPTION = "case1-100_NS"
nsdId = "stress_case1-ns"
VIMACCOUNTID = "6c74d590-aaad-4951-9200-5f1b6d8b0588"

osm_nsd = OSMClient.Nsd(HOST_URL)
osm_nslcm = OSMClient.Nslcm(HOST_URL)
osm_auth = OSMClient.Auth(HOST_URL)

HOST_URL = "osmmano.cs.upb.de"

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

_ns_list = json.loads(osm_nslcm.get_ns_instances(token=_token["id"]))
_ns_list = json.loads(_ns_list["data"])

_ns = None
for _n in _ns_list:
    if nsdId == _n['nsd']['id']:
        _ns = _n['_id']