Add device name, ssh password to Tempest config

The following options have been added to the compute section of the
Tempest configuration:

- image_ssh_password
- image_alt_ssh_password
- volume_device_name

The "volume_device_name" is being added to rid the test_attach_volume
test of hardcoded data. In the effort to remove a hardcoded password
from the same test, we introduce the option "image_ssh_password" to
store the password instead. Then, the deprecated "ssh_user" in the
test is swapped out in favor of "image_ssh_user". Finally, we add an
"image_alt_ssh_password" so the option remains symmetrical to the
"image_ssh_password" option.

Closes-Bug: #1220514
Change-Id: If7816e534200c54826c1da0d0464f643163b8657
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")
 ]