| Rabi Mishra | 8e87ccb | 2017-07-25 04:30:21 +0000 | [diff] [blame] | 1 | # 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 | |
| 15 | from functools import partial |
| 16 | |
| 17 | from tempest import config |
| 18 | from tempest.lib.common.utils import data_utils as lib_data_utils |
| 19 | |
| 20 | CONF = config.CONF |
| 21 | |
| 22 | |
| 23 | class 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 | |
| 38 | data_utils = DataUtils() |