Add resource prefix string

When running tempest several resources are created and afterwards
deleted. On systems where the cloud under tests is not destroyed
after the tests, it is useful to be able to associated resources
to specific test jobs and test runs.

The 'rand_name' function in tempest-lib exposes a prefix option,
which tempest does not use at the moment.

Adding a new configuration option to make the prefix configurable.
Creating a local version of the rand_name util, which passes the
prefix from configuration. Eventually all calls of rand_name
shall be redirected from tempest_lib to the local version.
In this patch, only the credentials provider is change to
validate that the mechanism is working. Follow-up patches will
migrate the rest of the code base.

Co-Authored-By: Fei Long Wang (flwang@catalyst.net.nz)

Change-Id: If15993f1ca0fd932e13d73c8ef9875ce13d79c53
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()