Added more logs to track better errors
[functest.git] / testcases / features / sfc / sfc.py
index 3f46026..122ed5d 100755 (executable)
@@ -27,7 +27,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"
@@ -82,15 +82,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"
@@ -149,6 +140,32 @@ def main():
     sg_id = os_utils.create_security_group_full(neutron_client,
                                                 SECGROUP_NAME, SECGROUP_DESCR)
 
+    secgroups = os_utils.get_security_groups(neutron_client)
+
+    for sg in secgroups:
+        os_utils.create_secgroup_rule(neutron_client, sg['id'],
+                                      'ingress', 'tcp',
+                                      port_range_min=22,
+                                      port_range_max=22)
+        os_utils.create_secgroup_rule(neutron_client, sg['id'],
+                                      '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)
+
     # boot INSTANCE
     logger.info("Creating instance '%s'..." % INSTANCE_NAME)
     logger.debug(
@@ -157,7 +174,8 @@ def main():
     instance = os_utils.create_instance_and_wait_for_active(FLAVOR,
                                                             image_id,
                                                             network_id,
-                                                            INSTANCE_NAME)
+                                                            INSTANCE_NAME,
+                                                            av_zone='nova')
 
     if instance is None:
         logger.error("Error while booting instance.")
@@ -190,14 +208,15 @@ def main():
 # STARTING SECOND VM (server) ###
 
     # boot INTANCE
-    logger.info("Creating instance '%s'..." % INSTANCE_NAME)
+    logger.info("Creating instance '%s'..." % INSTANCE_NAME_2)
     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.")
@@ -289,12 +308,12 @@ def main():
         time.sleep(3)
         r += 1
 
-    logger.info("SSH connectivity to the SFs established")
-
     if not all(check):
         logger.error("Cannot establish SSH connection to the SFs")
         sys.exit(1)
 
+    logger.info("SSH connectivity to the SFs established")
+
     # SSH TO START THE VXLAN_TOOL ON SF1
     logger.info("Configuring the SFs")
     try:
@@ -346,15 +365,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
@@ -412,16 +422,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