Andrea Frittoli (andreaf) | 8def7ca | 2015-05-13 14:24:19 +0100 | [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 | |
| 19 | from tempest_lib.common.utils import data_utils as lib_data_utils |
| 20 | |
| 21 | CONF = config.CONF |
| 22 | |
Daryl Walleck | 6b9b288 | 2012-04-08 21:43:39 -0500 | [diff] [blame] | 23 | PING_IPV4_COMMAND = 'ping -c 3 ' |
| 24 | PING_IPV6_COMMAND = 'ping6 -c 3 ' |
| 25 | PING_PACKET_LOSS_REGEX = '(\d{1,3})\.?\d*\% packet loss' |
Andrea Frittoli (andreaf) | 8def7ca | 2015-05-13 14:24:19 +0100 | [diff] [blame] | 26 | |
| 27 | |
| 28 | class DataUtils(object): |
| 29 | def __getattr__(self, attr): |
| 30 | if attr in self.__dict__: |
| 31 | return self.__dict__[attr] |
| 32 | |
| 33 | if attr == 'rand_name': |
| 34 | # NOTE(flwang): This is a proxy to generate a random name that |
| 35 | # includes a random number and a prefix if one is configured in |
| 36 | # CONF.resources_prefix |
| 37 | attr_obj = partial(lib_data_utils.rand_name, |
| 38 | prefix=CONF.resources_prefix) |
| 39 | else: |
| 40 | attr_obj = getattr(lib_data_utils, attr) |
| 41 | |
| 42 | self.__dict__[attr] = attr_obj |
| 43 | return attr_obj |
| 44 | |
| 45 | data_utils = DataUtils() |