Merge "Add unittests dir"
[functest.git] / testcases / features / sfc / sfc_colorado1.py
index dc13436..ef3a489 100755 (executable)
@@ -26,7 +26,7 @@ HOME = os.environ['HOME'] + "/"
 
 VM_BOOT_TIMEOUT = 180
 INSTANCE_NAME = "client"
-FLAVOR = "m1.small"
+FLAVOR = "custom"
 IMAGE_NAME = "sf_nsh_colorado"
 IMAGE_FILENAME = "sf_nsh_colorado.qcow2"
 IMAGE_FORMAT = "qcow2"
@@ -81,15 +81,6 @@ def main():
                                stderr=subprocess.PIPE)
     ip_server = process.stdout.readline().rstrip()
 
-    contr_cmd2 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
-                  " 'fuel node'|grep compute|awk '{print $10}'")
-    logger.info("Executing script to get ip_compute: '%s'" % contr_cmd2)
-    process = subprocess.Popen(contr_cmd2,
-                               shell=True,
-                               stdout=subprocess.PIPE,
-                               stderr=subprocess.PIPE)
-    ip_compute = process.stdout.readline().rstrip()
-
     iptable_cmd1 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
                     " ssh " + ip_server + " iptables -P INPUT ACCEPT ")
     iptable_cmd2 = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2"
@@ -159,6 +150,20 @@ def main():
                                       'egress', 'tcp',
                                       port_range_min=22,
                                       port_range_max=22)
+        os_utils.create_secgroup_rule(neutron_client, sg['id'],
+                                      'ingress', 'tcp',
+                                      port_range_min=80,
+                                      port_range_max=80)
+        os_utils.create_secgroup_rule(neutron_client, sg['id'],
+                                      'egress', 'tcp',
+                                      port_range_min=80,
+                                      port_range_max=80)
+
+    _, custom_flv_id = os_utils.get_or_create_flavor(
+        'custom', 1500, 10, 1, public=True)
+    if not custom_flv_id:
+        logger.error("Failed to create custom flavor")
+        sys.exit(1)
 
     iterator = 0
     while(iterator < 6):
@@ -167,13 +172,16 @@ def main():
         logger.debug(
             "Configuration:\n name=%s \n flavor=%s \n image=%s \n "
             "network=%s \n" % (INSTANCE_NAME, FLAVOR, image_id, network_id))
-        instance = os_utils.create_instance_and_wait_for_active(FLAVOR,
-                                                                image_id,
-                                                                network_id,
-                                                                INSTANCE_NAME)
+        instance = os_utils.create_instance_and_wait_for_active(
+            FLAVOR,
+            image_id,
+            network_id,
+            INSTANCE_NAME,
+            av_zone='nova')
 
         if instance is None:
             logger.error("Error while booting instance.")
+            iterator += 1
             continue
         # Retrieve IP of INSTANCE
         instance_ip = instance.networks.get(NET_NAME)[0]
@@ -191,6 +199,7 @@ def main():
 
         if floatip_client is None:
             logger.error("Cannot create floating IP.")
+            iterator += 1
             continue
         logger.info("Floating IP created: '%s'" % floatip_client)
 
@@ -200,6 +209,7 @@ def main():
                                         instance.id,
                                         floatip_client):
             logger.error("Cannot associate floating IP to VM.")
+            iterator += 1
             continue
 
     # STARTING SECOND VM (server) ###
@@ -208,15 +218,17 @@ def main():
         logger.info("Creating instance '%s'..." % INSTANCE_NAME)
         logger.debug(
             "Configuration:\n name=%s \n flavor=%s \n image=%s \n "
-            "network=%s \n" % (INSTANCE_NAME, FLAVOR, image_id, network_id))
+            "network=%s \n" % (INSTANCE_NAME_2, FLAVOR, image_id, network_id))
         instance_2 = os_utils.create_instance_and_wait_for_active(
             FLAVOR,
             image_id,
             network_id,
-            INSTANCE_NAME_2)
+            INSTANCE_NAME_2,
+            av_zone='nova')
 
         if instance_2 is None:
             logger.error("Error while booting instance.")
+            iterator += 1
             continue
         # Retrieve IP of INSTANCE
         instance_ip_2 = instance_2.networks.get(NET_NAME)[0]
@@ -234,6 +246,7 @@ def main():
 
         if floatip_server is None:
             logger.error("Cannot create floating IP.")
+            iterator += 1
             continue
         logger.info("Floating IP created: '%s'" % floatip_server)
 
@@ -244,6 +257,7 @@ def main():
                                         instance_2.id,
                                         floatip_server):
             logger.error("Cannot associate floating IP to VM.")
+            iterator += 1
             continue
 
         # CREATION OF THE 2 SF ####
@@ -309,6 +323,7 @@ def main():
 
         if not all(check):
             logger.error("Cannot establish SSH connection to the SFs")
+            iterator += 1
             continue
 
         logger.info("SSH connectivity to the SFs established")
@@ -372,16 +387,6 @@ def main():
         except Exception:
             logger.exception("vxlan_tool not started in SF2")
 
-        # SSH to modify the classification flows in compute
-
-        contr_cmd3 = ("sshpass -p r00tme ssh " + ssh_options + " "
-                      "root@10.20.0.2 'ssh " + ip_compute + " "
-                      "'bash correct_classifier.bash''")
-        logger.info("Executing script to modify the classi: '%s'" % contr_cmd3)
-        process = subprocess.Popen(contr_cmd3,
-                                   shell=True,
-                                   stdout=subprocess.PIPE)
-
         i = 0
 
         # SSH TO EXECUTE cmd_client
@@ -439,17 +444,7 @@ def main():
         subprocess.call(tacker_classi, shell=True)
 
         logger.info("Wait for ODL to update the classification rules in OVS")
-        time.sleep(10)
-
-        # SSH to modify the classification flows in compute
-
-        contr_cmd4 = ("sshpass -p r00tme ssh " + ssh_options + " "
-                      "root@10.20.0.2 'ssh " + ip_compute + " "
-                      "'bash correct_classifier.bash''")
-        logger.info("Executing script to modify the classi: '%s'" % contr_cmd4)
-        process = subprocess.Popen(contr_cmd4,
-                                   shell=True,
-                                   stdout=subprocess.PIPE)
+        time.sleep(100)
 
         # SSH TO EXECUTE cmd_client