Merge "Removed os_utils and fully switched to snaps"
[functest.git] / functest / opnfv_tests / vnf / ims / orchestra_openims.py
index f4c140e..572eaa9 100644 (file)
@@ -17,6 +17,12 @@ import time
 import pkg_resources
 import yaml
 
 import pkg_resources
 import yaml
 
+import functest.core.vnf as vnf
+import functest.utils.openstack_utils as os_utils
+from functest.utils.constants import CONST
+
+from org.openbaton.cli.errors.errors import NfvoException
+from org.openbaton.cli.agents.agents import MainAgent
 from snaps.config.flavor import FlavorConfig
 from snaps.config.image import ImageConfig
 from snaps.config.network import NetworkConfig, PortConfig, SubnetConfig
 from snaps.config.flavor import FlavorConfig
 from snaps.config.image import ImageConfig
 from snaps.config.network import NetworkConfig, PortConfig, SubnetConfig
@@ -24,7 +30,7 @@ from snaps.config.router import RouterConfig
 from snaps.config.security_group import (
     Direction, Protocol, SecurityGroupConfig, SecurityGroupRuleConfig)
 from snaps.config.vm_inst import VmInstanceConfig
 from snaps.config.security_group import (
     Direction, Protocol, SecurityGroupConfig, SecurityGroupRuleConfig)
 from snaps.config.vm_inst import VmInstanceConfig
-
+from snaps.openstack.utils import keystone_utils
 from snaps.openstack.create_image import OpenStackImage
 from snaps.openstack.create_flavor import OpenStackFlavor
 from snaps.openstack.create_security_group import OpenStackSecurityGroup
 from snaps.openstack.create_image import OpenStackImage
 from snaps.openstack.create_flavor import OpenStackFlavor
 from snaps.openstack.create_security_group import OpenStackSecurityGroup
@@ -34,13 +40,6 @@ from snaps.openstack.create_instance import OpenStackVmInstance
 
 from functest.opnfv_tests.openstack.snaps import snaps_utils
 
 
 from functest.opnfv_tests.openstack.snaps import snaps_utils
 
-import functest.core.vnf as vnf
-import functest.utils.openstack_utils as os_utils
-from functest.utils.constants import CONST
-
-from org.openbaton.cli.errors.errors import NfvoException
-from org.openbaton.cli.agents.agents import MainAgent
-
 
 __author__ = "Pauls, Michael <michael.pauls@fokus.fraunhofer.de>"
 # ----------------------------------------------------------
 
 __author__ = "Pauls, Michael <michael.pauls@fokus.fraunhofer.de>"
 # ----------------------------------------------------------
@@ -202,12 +201,15 @@ class OpenImsVnf(vnf.VnfOnBoarding):
         """Prepare testscase (Additional pre-configuration steps)."""
         super(OpenImsVnf, self).prepare()
 
         """Prepare testscase (Additional pre-configuration steps)."""
         super(OpenImsVnf, self).prepare()
 
+        public_auth_url = keystone_utils.get_endpoint(
+            self.snaps_creds, 'identity')
+
         self.logger.info("Additional pre-configuration steps")
         self.creds = {
         self.logger.info("Additional pre-configuration steps")
         self.creds = {
-                "tenant": self.tenant_name,
-                "username": self.tenant_name,
-                "password": self.tenant_name,
-                "auth_url": os_utils.get_credentials()['auth_url']
+                "tenant": self.snaps_creds.project_name,
+                "username": self.snaps_creds.username,
+                "password": self.snaps_creds.password,
+                "auth_url": public_auth_url
                 }
         self.prepare_images()
         self.prepare_flavor()
                 }
         self.prepare_images()
         self.prepare_flavor()
@@ -461,7 +463,7 @@ class OpenImsVnf(vnf.VnfOnBoarding):
 
         self.logger.info("Waiting for Open Baton NFVO to be up and running...")
         timeout = 0
 
         self.logger.info("Waiting for Open Baton NFVO to be up and running...")
         timeout = 0
-        while timeout < 45:
+        while timeout < 20:
             if servertest(
                     self.mano['details']['fip'].ip,
                     "8080"):
             if servertest(
                     self.mano['details']['fip'].ip,
                     "8080"):
@@ -472,7 +474,7 @@ class OpenImsVnf(vnf.VnfOnBoarding):
                 time.sleep(60)
                 timeout += 1
 
                 time.sleep(60)
                 timeout += 1
 
-        if timeout >= 45:
+        if timeout >= 20:
             duration = time.time() - start_time
             self.details["orchestrator"].update(
                 status='FAIL', duration=duration)
             duration = time.time() - start_time
             self.details["orchestrator"].update(
                 status='FAIL', duration=duration)
@@ -659,8 +661,6 @@ class OpenImsVnf(vnf.VnfOnBoarding):
                 time.sleep(60)
             else:
                 self.logger.info("No need to terminate the VNF...")
                 time.sleep(60)
             else:
                 self.logger.info("No need to terminate the VNF...")
-            # os_utils.delete_instance(nova_client=os_utils.get_nova_client(),
-            #                          instance_id=self.mano_instance_id)
         except (NfvoException, KeyError) as exc:
             self.logger.error('Unexpected error cleaning - %s', exc)
 
         except (NfvoException, KeyError) as exc:
             self.logger.error('Unexpected error cleaning - %s', exc)
 
@@ -672,13 +672,13 @@ class OpenImsVnf(vnf.VnfOnBoarding):
                 port_name='%s_port' % self.case_name)
             snaps_utils.neutron_utils.delete_port(neutron_client, port)
             time.sleep(10)
                 port_name='%s_port' % self.case_name)
             snaps_utils.neutron_utils.delete_port(neutron_client, port)
             time.sleep(10)
-        except Exception as exc:
+        except Exception as exc:  # pylint: disable=broad-except
             self.logger.error('Unexpected error cleaning - %s', exc)
         try:
             self.logger.info("Deleting Open Baton Floating IP...")
             snaps_utils.neutron_utils.delete_floating_ip(
                 neutron_client, self.mano['details']['fip'])
             self.logger.error('Unexpected error cleaning - %s', exc)
         try:
             self.logger.info("Deleting Open Baton Floating IP...")
             snaps_utils.neutron_utils.delete_floating_ip(
                 neutron_client, self.mano['details']['fip'])
-        except Exception as exc:
+        except Exception as exc:  # pylint: disable=broad-except
             self.logger.error('Unexpected error cleaning - %s', exc)
 
         for resource in reversed(self.created_resources):
             self.logger.error('Unexpected error cleaning - %s', exc)
 
         for resource in reversed(self.created_resources):