Merge "fix race condition between addCleanup and lockutils"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index d39ef70..8d96858 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -76,10 +76,18 @@
 flavor_ref = 1
 flavor_ref_alt = 2
 
-# User names used to authenticate to an instance for a given image.
+# User name used to authenticate to an instance
 image_ssh_user = root
+
+# Password used to authenticate to an instance
+image_ssh_password = password
+
+# User name used to authenticate to an instance using the alternate image
 image_alt_ssh_user = root
 
+# Password used to authenticate to an instance using the alternate image
+image_alt_ssh_password = password
+
 # Number of seconds to wait while looping to check the status of an
 # instance that is building.
 build_interval = 10
@@ -93,7 +101,7 @@
 #  executing the tests
 run_ssh = false
 
-# Name of a user used to authenticated to an instance
+# Name of a user used to authenticate to an instance.
 ssh_user = cirros
 
 # Visible fixed network name
@@ -150,6 +158,9 @@
 # When set to false, flavor extra data tests are forced to skip
 flavor_extra_enabled = true
 
+# Expected first device name when a volume is attached to an instance
+volume_device_name = vdb
+
 [whitebox]
 # Whitebox options for compute. Whitebox options enable the
 # whitebox test cases, which look at internal Nova database state,
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index acf0275..09d9bc0 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -73,6 +73,8 @@
         cls.build_interval = cls.config.compute.build_interval
         cls.build_timeout = cls.config.compute.build_timeout
         cls.ssh_user = cls.config.compute.ssh_user
+        cls.image_ssh_user = cls.config.compute.image_ssh_user
+        cls.image_ssh_password = cls.config.compute.image_ssh_password
         cls.image_ref = cls.config.compute.image_ref
         cls.image_ref_alt = cls.config.compute.image_ref_alt
         cls.flavor_ref = cls.config.compute.flavor_ref
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index b67a5e0..5c1ad0d 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -26,6 +26,7 @@
 class AttachVolumeTestJSON(base.BaseComputeTest):
     _interface = 'json'
     run_ssh = tempest.config.TempestConfig().compute.run_ssh
+    device = tempest.config.TempestConfig().compute.volume_device_name
 
     def __init__(self, *args, **kwargs):
         super(AttachVolumeTestJSON, self).__init__(*args, **kwargs)
@@ -36,7 +37,7 @@
     @classmethod
     def setUpClass(cls):
         super(AttachVolumeTestJSON, cls).setUpClass()
-        cls.device = 'vdb'
+
         if not cls.config.service_available.cinder:
             skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
             raise cls.skipException(skip_msg)
@@ -54,7 +55,7 @@
     def _create_and_attach(self):
         # Start a server and wait for it to become ready
         resp, server = self.create_server(wait_until='ACTIVE',
-                                          adminPass='password')
+                                          adminPass=self.image_ssh_password)
         self.server = server
 
         # Record addresses so that we can ssh later
@@ -92,7 +93,7 @@
         self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
 
         linux_client = RemoteClient(server,
-                                    self.ssh_user, server['adminPass'])
+                                    self.image_ssh_user, server['adminPass'])
         partitions = linux_client.get_partitions()
         self.assertIn(self.device, partitions)
 
@@ -106,7 +107,7 @@
         self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
 
         linux_client = RemoteClient(server,
-                                    self.ssh_user, server['adminPass'])
+                                    self.image_ssh_user, server['adminPass'])
         partitions = linux_client.get_partitions()
         self.assertNotIn(self.device, partitions)
 
diff --git a/tempest/config.py b/tempest/config.py
index 3b09b5e..7245b10 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -121,10 +121,17 @@
     cfg.StrOpt('image_ssh_user',
                default="root",
                help="User name used to authenticate to an instance."),
+    cfg.StrOpt('image_ssh_password',
+               default="password",
+               help="Password used to authenticate to an instance."),
     cfg.StrOpt('image_alt_ssh_user',
                default="root",
                help="User name used to authenticate to an instance using "
                     "the alternate image."),
+    cfg.StrOpt('image_alt_ssh_password',
+               default="password",
+               help="Password used to authenticate to an instance using "
+                    "the alternate image."),
     cfg.BoolOpt('resize_available',
                 default=False,
                 help="Does the test environment support resizing?"),
@@ -196,6 +203,10 @@
     cfg.BoolOpt('flavor_extra_enabled',
                 default=True,
                 help="If false, skip flavor extra data test"),
+    cfg.StrOpt('volume_device_name',
+               default='vdb',
+               help="Expected device name when a volume is attached to "
+                    "an instance")
 ]
 
 
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 7681f04..90b3fca 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -361,7 +361,7 @@
             client = self.volume_client
         if name is None:
             name = rand_name('scenario-volume-')
-        LOG.debug("Creating a volume (size :%s, name: %s)", size, name)
+        LOG.debug("Creating a volume (size: %s, name: %s)", size, name)
         volume = client.volumes.create(size=size, display_name=name,
                                        snapshot_id=snapshot_id,
                                        imageRef=imageRef)
diff --git a/tempest/services/compute/json/servers_client.py b/tempest/services/compute/json/servers_client.py
index 6906610..c5827f6 100644
--- a/tempest/services/compute/json/servers_client.py
+++ b/tempest/services/compute/json/servers_client.py
@@ -157,6 +157,8 @@
         start = int(time.time())
 
         while(server_status != status):
+            if status == 'BUILD' and server_status != 'UNKNOWN':
+                return
             time.sleep(self.build_interval)
             resp, body = self.get_server(server_id)
             server_status = body['status']
diff --git a/tempest/services/compute/xml/servers_client.py b/tempest/services/compute/xml/servers_client.py
index 5c7a629..ec9464a 100644
--- a/tempest/services/compute/xml/servers_client.py
+++ b/tempest/services/compute/xml/servers_client.py
@@ -312,6 +312,8 @@
         start = int(time.time())
 
         while(server_status != status):
+            if status == 'BUILD' and server_status != 'UNKNOWN':
+                return
             time.sleep(self.build_interval)
             resp, body = self.get_server(server_id)
             server_status = body['status']