blob: 84e31d0d4ada3c361eb178335467e09b80922764 [file] [log] [blame]
Rabi Mishra8e87ccb2017-07-25 04:30:21 +00001# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from functools import partial
16
17from tempest import config
18from tempest.lib.common.utils import data_utils as lib_data_utils
19
20CONF = config.CONF
21
22
23class DataUtils(object):
24 def __getattr__(self, attr):
25
26 if attr == 'rand_name':
27 # NOTE(flwang): This is a proxy to generate a random name that
28 # includes a random number and a prefix if one is configured in
29 # CONF.resources_prefix
30 attr_obj = partial(lib_data_utils.rand_name,
31 prefix=CONF.resources_prefix)
32 else:
33 attr_obj = getattr(lib_data_utils, attr)
34
35 self.__dict__[attr] = attr_obj
36 return attr_obj
37
38data_utils = DataUtils()