Merge "Fixed LP bug 991806. Ensures that floating IP created in test is destroyed in a finally: block"
diff --git a/tempest/services/nova/json/servers_client.py b/tempest/services/nova/json/servers_client.py
index 08ac6df..53b2d6f 100644
--- a/tempest/services/nova/json/servers_client.py
+++ b/tempest/services/nova/json/servers_client.py
@@ -21,6 +21,7 @@
         flavor_ref (Required): The flavor used to build the server.
         Following optional keyword arguments are accepted:
         adminPass: Sets the initial root password.
+        key_name: Key name of keypair that was created earlier.
         meta: A dictionary of values to be used as metadata.
         personality: A list of dictionaries for files to be injected into
         the server.
@@ -40,7 +41,7 @@
             'flavorRef': flavor_ref
         }
 
-        for option in ['personality', 'adminPass',
+        for option in ['personality', 'adminPass', 'key_name',
                         'security_groups', 'networks', 'user_data',
                         'availability_zone', 'accessIPv4', 'accessIPv6',
                         'min_count', 'max_count', ('metadata', 'meta'),
diff --git a/tempest/tests/test_floating_ips_actions.py b/tempest/tests/test_floating_ips_actions.py
index 3762b1d..563d0e3 100644
--- a/tempest/tests/test_floating_ips_actions.py
+++ b/tempest/tests/test_floating_ips_actions.py
@@ -11,7 +11,6 @@
 
     @classmethod
     def setUpClass(cls):
-        cls.os = openstack.Manager()
         cls.client = cls.floating_ips_client
         cls.servers_client = cls.servers_client
 
diff --git a/tempest/tests/test_keypairs.py b/tempest/tests/test_keypairs.py
index 14e1317..fde9de1 100644
--- a/tempest/tests/test_keypairs.py
+++ b/tempest/tests/test_keypairs.py
@@ -10,7 +10,6 @@
 
     @classmethod
     def setUpClass(cls):
-        cls.os = openstack.Manager()
         cls.client = cls.keypairs_client
 
     @attr(type='smoke')
diff --git a/tempest/tests/test_list_floating_ips.py b/tempest/tests/test_list_floating_ips.py
index d100c01..03ed089 100644
--- a/tempest/tests/test_list_floating_ips.py
+++ b/tempest/tests/test_list_floating_ips.py
@@ -39,23 +39,25 @@
     def test_get_floating_ip_details(self):
         """Positive test:Should be able to GET the details of floatingIP"""
         #Creating a floating IP for which details are to be checked
-        resp, body = self.client.create_floating_ip()
-        floating_ip_instance_id = body['instance_id']
-        floating_ip_ip = body['ip']
-        floating_ip_fixed_ip = body['fixed_ip']
-        floating_ip_id = body['id']
-        resp, body = \
-            self.client.get_floating_ip_details(floating_ip_id)
-        self.assertEqual(200, resp.status)
-        #Comparing the details of floating IP
-        self.assertEqual(floating_ip_instance_id,
+        try:
+            resp, body = self.client.create_floating_ip()
+            floating_ip_instance_id = body['instance_id']
+            floating_ip_ip = body['ip']
+            floating_ip_fixed_ip = body['fixed_ip']
+            floating_ip_id = body['id']
+            resp, body = \
+                self.client.get_floating_ip_details(floating_ip_id)
+            self.assertEqual(200, resp.status)
+            #Comparing the details of floating IP
+            self.assertEqual(floating_ip_instance_id,
                             body['instance_id'])
-        self.assertEqual(floating_ip_ip, body['ip'])
-        self.assertEqual(floating_ip_fixed_ip,
+            self.assertEqual(floating_ip_ip, body['ip'])
+            self.assertEqual(floating_ip_fixed_ip,
                             body['fixed_ip'])
-        self.assertEqual(floating_ip_id, body['id'])
+            self.assertEqual(floating_ip_id, body['id'])
         #Deleting the floating IP created in this method
-        self.client.delete_floating_ip(floating_ip_id)
+        finally:
+            self.client.delete_floating_ip(floating_ip_id)
 
     @attr(type='negative')
     @unittest.skip('Skipping until Nova Bug 940500 is fixed')