Merge "Removing unnecessary comments"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 1f287c8..840983c 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -88,6 +88,15 @@
 # Enables or disables fatal status of deprecations. (boolean value)
 #fatal_deprecations = false
 
+#
+# From tempest.config
+#
+
+# Prefix to be added when generating the name for test resources. It
+# can be used to discover all resources associated with a specific
+# test run when running tempest on a real-life cloud (string value)
+#resources_prefix = tempest
+
 
 [auth]
 
@@ -428,6 +437,12 @@
 # value)
 #preserve_ports = false
 
+# Does the test environment support attaching an encrypted volume to a
+# running server instance? This may depend on the combination of
+# compute_driver in nova and the volume_driver(s) in cinder. (boolean
+# value)
+#attach_encrypted_volume = true
+
 
 [dashboard]
 
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 5ded3ee..f3dd2e6 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -16,11 +16,11 @@
 import netaddr
 from oslo_log import log as logging
 import six
-from tempest_lib.common.utils import data_utils
 from tempest_lib import exceptions as lib_exc
 
 from tempest import clients
 from tempest.common import cred_provider
+from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
 from tempest.services.identity.v2.json import identity_client as v2_identity
diff --git a/tempest/common/utils/__init__.py b/tempest/common/utils/__init__.py
index 04d898d..81b8110 100644
--- a/tempest/common/utils/__init__.py
+++ b/tempest/common/utils/__init__.py
@@ -1,3 +1,45 @@
+# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from functools import partial
+
+from tempest import config
+
+from tempest_lib.common.utils import data_utils as lib_data_utils
+
+CONF = config.CONF
+
 PING_IPV4_COMMAND = 'ping -c 3 '
 PING_IPV6_COMMAND = 'ping6 -c 3 '
 PING_PACKET_LOSS_REGEX = '(\d{1,3})\.?\d*\% packet loss'
+
+
+class DataUtils(object):
+    def __getattr__(self, attr):
+        if attr in self.__dict__:
+            return self.__dict__[attr]
+
+        if attr == 'rand_name':
+            # NOTE(flwang): This is a proxy to generate a random name that
+            # includes a random number and a prefix if one is configured in
+            # CONF.resources_prefix
+            attr_obj = partial(lib_data_utils.rand_name,
+                               prefix=CONF.resources_prefix)
+        else:
+            attr_obj = getattr(lib_data_utils, attr)
+
+        self.__dict__[attr] = attr_obj
+        return attr_obj
+
+data_utils = DataUtils()
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index d370ebc..18f0b1d 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -14,9 +14,10 @@
 from oslo_log import log as logging
 
 from tempest import config
-from tempest_lib.common.utils import data_utils
 from tempest_lib import exceptions as lib_exc
 
+from tempest.common.utils import data_utils
+
 CONF = config.CONF
 LOG = logging.getLogger(__name__)
 
diff --git a/tempest/config.py b/tempest/config.py
index 5628ec9..e3f9f0a 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -31,9 +31,10 @@
 
 
 def register_opt_group(conf, opt_group, options):
-    conf.register_group(opt_group)
+    if opt_group:
+        conf.register_group(opt_group)
     for opt in options:
-        conf.register_opt(opt, group=opt_group.name)
+        conf.register_opt(opt, group=getattr(opt_group, 'name', None))
 
 
 auth_group = cfg.OptGroup(name='auth',
@@ -391,7 +392,13 @@
                 default=False,
                 help='Does Nova preserve preexisting ports from Neutron '
                      'when deleting an instance? This should be set to True '
-                     'if testing Kilo+ Nova.')
+                     'if testing Kilo+ Nova.'),
+    cfg.BoolOpt('attach_encrypted_volume',
+                default=True,
+                help='Does the test environment support attaching an '
+                     'encrypted volume to a running server instance? This may '
+                     'depend on the combination of compute_driver in nova and '
+                     'the volume_driver(s) in cinder.'),
 ]
 
 
@@ -1138,6 +1145,15 @@
                help="Test generator class for all negative tests"),
 ]
 
+DefaultGroup = [
+    cfg.StrOpt('resources_prefix',
+               default='tempest',
+               help="Prefix to be added when generating the name for "
+                    "test resources. It can be used to discover all "
+                    "resources associated with a specific test run when "
+                    "running tempest on a real-life cloud"),
+]
+
 _opts = [
     (auth_group, AuthGroup),
     (compute_group, ComputeGroup),
@@ -1167,7 +1183,8 @@
     (debug_group, DebugGroup),
     (baremetal_group, BaremetalGroup),
     (input_scenario_group, InputScenarioGroup),
-    (negative_group, NegativeGroup)
+    (negative_group, NegativeGroup),
+    (None, DefaultGroup)
 ]
 
 
@@ -1182,7 +1199,7 @@
     The purpose of this is to allow tools like the Oslo sample config file
     generator to discover the options exposed to users.
     """
-    return [(g.name, o) for g, o in _opts]
+    return [(getattr(g, 'name', None), o) for g, o in _opts]
 
 
 # this should never be called outside of this class
diff --git a/tempest/scenario/test_encrypted_cinder_volumes.py b/tempest/scenario/test_encrypted_cinder_volumes.py
index e6912d8..b66eb59 100644
--- a/tempest/scenario/test_encrypted_cinder_volumes.py
+++ b/tempest/scenario/test_encrypted_cinder_volumes.py
@@ -13,9 +13,12 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from tempest import config
 from tempest.scenario import manager
 from tempest import test
 
+CONF = config.CONF
+
 
 class TestEncryptedCinderVolumes(manager.EncryptionScenarioTest):
 
@@ -31,6 +34,12 @@
         * Attaches and detaches the encrypted volume to the instance
     """
 
+    @classmethod
+    def skip_checks(cls):
+        super(TestEncryptedCinderVolumes, cls).skip_checks()
+        if not CONF.compute_feature_enabled.attach_encrypted_volume:
+            raise cls.skipException('Encrypted volume attach is not supported')
+
     def launch_instance(self):
         self.glance_image_create()
         self.nova_boot()
diff --git a/tox.ini b/tox.ini
index b495fd6..cf7013d 100644
--- a/tox.ini
+++ b/tox.ini
@@ -13,13 +13,7 @@
 [testenv]
 setenv = VIRTUAL_ENV={envdir}
          OS_TEST_PATH=./tempest/tests
-passenv = OS_STDOUT_CAPTURE
-          OS_STDERR_CAPTURE
-          OS_TEST_TIMEOUT
-          OS_TEST_LOCK_PATH
-          OS_TEST_PATH
-          TEMPEST_CONFIG
-          TEMPEST_CONFIG_DIR
+passenv = OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_TEST_TIMEOUT OS_TEST_LOCK_PATH OS_TEST_PATH TEMPEST_CONFIG TEMPEST_CONFIG_DIR http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
 usedevelop = True
 install_command = pip install -U {opts} {packages}
 whitelist_externals = *