blob: 81b81105c648fb76a7dc3f1713714e28ceff9c25 [file] [log] [blame]
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +01001# 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
18
19from tempest_lib.common.utils import data_utils as lib_data_utils
20
21CONF = config.CONF
22
Daryl Walleck6b9b2882012-04-08 21:43:39 -050023PING_IPV4_COMMAND = 'ping -c 3 '
24PING_IPV6_COMMAND = 'ping6 -c 3 '
25PING_PACKET_LOSS_REGEX = '(\d{1,3})\.?\d*\% packet loss'
Andrea Frittoli (andreaf)8def7ca2015-05-13 14:24:19 +010026
27
28class 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
45data_utils = DataUtils()