Throw error if SFC ports are not found on servers 55/7155/6
authorschillinge <ablu@mail.uni-paderborn.de>
Thu, 31 Jan 2019 07:53:39 +0000 (08:53 +0100)
committerschillinge <ablu@mail.uni-paderborn.de>
Wed, 6 Feb 2019 09:17:03 +0000 (10:17 +0100)
This breaks the port chain creation and most likely reveals some kind of
implementation error elsewhere.

Change-Id: I907eb5e828f80ae5ab12de851a98f3c19c9c2d5b
Signed-off-by: schillinge <ablu@mail.uni-paderborn.de>
src/emuvim/api/openstack/resources/port_chain.py
src/emuvim/test/unittests/test_openstack.py

index 7c0a2b0..7dcd834 100644 (file)
@@ -76,15 +76,12 @@ class PortChain(object):
                     if port_pair.egress.name in server.port_names or port_pair.egress.id in server.port_names:
                         server_egress = server
 
-                # TODO: Not sure, if this should throw an error
                 if not server_ingress:
-                    logging.warn("Neutron SFC: ingress port %s not connected." % str(
-                        port_pair.ingress.name))
-                    continue
+                    raise RuntimeError("Neutron SFC: ingress port %s not connected to any server." %
+                                       port_pair.ingress.name)
                 if not server_egress:
-                    logging.warn("Neutron SFC: egress port %s not connected." % str(
-                        port_pair.egress.name))
-                    continue
+                    raise RuntimeError("Neutron SFC: egress port %s not connected to any server." %
+                                       port_pair.egress.name)
 
                 compute.dc.net.setChain(
                     server_ingress.name, server_egress.name,
index 7530f15..700def4 100755 (executable)
@@ -904,6 +904,34 @@ class testRestApi(ApiBaseOpenStack):
         p3_id = json.loads(p3_resp.content)["port"]["id"]
         p4_id = json.loads(p4_resp.content)["port"]["id"]
 
+        listflavorsresponse = requests.get("http://0.0.0.0:18774/v2.1/id_bla/flavors", headers=headers)
+        self.assertEqual(listflavorsresponse.status_code, 200)
+        flavors = json.loads(listflavorsresponse.content)["flavors"]
+        m1_tiny_flavor = filter(lambda flavor: flavor["name"] == "m1.tiny", flavors)[0]
+
+        listimagesdetailsresponse = requests.get("http://0.0.0.0:18774/v2.1/id_bla/images/detail", headers=headers)
+        self.assertEqual(listimagesdetailsresponse.status_code, 200)
+        images = json.loads(listimagesdetailsresponse.content)["images"]
+        ubuntu_image = filter(lambda image: image["name"] == "ubuntu:trusty", images)[0]
+
+        server_url = "http://0.0.0.0:18774/v2.1/id_bla/servers"
+        s1 = '{"server": {' \
+             '"name": "s1",' \
+             '"networks": [{"port": "p1"}, {"port": "p2"}],' \
+             '"flavorRef": "%s",' \
+             '"imageRef": "%s"' \
+             '}}' % (m1_tiny_flavor["id"], ubuntu_image["id"])
+        s2 = '{"server": {' \
+             '"name": "s2",' \
+             '"networks": [{"port": "p3"}, {"port": "p4"}],' \
+             '"flavorRef": "%s",' \
+             '"imageRef": "%s"' \
+             '}}' % (m1_tiny_flavor["id"], ubuntu_image["id"])
+        s1_response = requests.post(server_url, data=s1, headers=headers)
+        s2_response = requests.post(server_url, data=s2, headers=headers)
+        self.assertEqual(s1_response.status_code, 200)
+        self.assertEqual(s2_response.status_code, 200)
+
         print('->>>>>>> test Neutron SFC Port Pair Create ->>>>>>>>>>>>>>>')
         print('->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
         url = "http://0.0.0.0:19696/v2.0/sfc/port_pairs"