summaryrefslogtreecommitdiffstats
path: root/yardstick/common
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/common')
-rw-r--r--yardstick/common/constants.py1
-rw-r--r--yardstick/common/exceptions.py19
-rw-r--r--yardstick/common/openstack_utils.py9
-rw-r--r--yardstick/common/utils.py39
-rw-r--r--yardstick/common/yaml_loader.py12
5 files changed, 73 insertions, 7 deletions
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py
index 954e59235..2f14d4bc4 100644
--- a/yardstick/common/constants.py
+++ b/yardstick/common/constants.py
@@ -119,6 +119,7 @@ INFLUXDB_DB_NAME = get_param('influxdb.db_name', 'yardstick')
INFLUXDB_IMAGE = get_param('influxdb.image', 'tutum/influxdb')
INFLUXDB_TAG = get_param('influxdb.tag', '0.13')
INFLUXDB_DASHBOARD_PORT = 8083
+QUEUE_PUT_TIMEOUT = 10
# grafana
GRAFANA_IP = get_param('grafana.ip', SERVER_IP)
diff --git a/yardstick/common/exceptions.py b/yardstick/common/exceptions.py
index 2005bebd2..2d160bef1 100644
--- a/yardstick/common/exceptions.py
+++ b/yardstick/common/exceptions.py
@@ -70,6 +70,10 @@ class ResourceCommandError(YardstickException):
message = 'Command: "%(command)s" Failed, stderr: "%(stderr)s"'
+class ContextUpdateCollectdForNodeError(YardstickException):
+ message = 'Cannot find node %(attr_name)s'
+
+
class FunctionNotImplemented(YardstickException):
message = ('The function "%(function_name)s" is not implemented in '
'"%(class_name)" class.')
@@ -170,7 +174,7 @@ class IncorrectNodeSetup(IncorrectSetup):
class ScenarioConfigContextNameNotFound(YardstickException):
- message = 'Context name "%(context_name)s" not found'
+ message = 'Context for host name "%(host_name)s" not found'
class StackCreationInterrupt(YardstickException):
@@ -338,3 +342,16 @@ class IxNetworkFlowNotPresent(YardstickException):
class IxNetworkFieldNotPresentInStackItem(YardstickException):
message = 'Field "%(field_name)s" not present in stack item %(stack_item)s'
+
+
+class SLAValidationError(YardstickException):
+ message = '%(case_name)s SLA validation failed. Error: %(error_msg)s'
+
+
+class AclMissingActionArguments(YardstickException):
+ message = ('Missing ACL action parameter '
+ '[action=%(action_name)s parameter=%(action_param)s]')
+
+
+class AclUknownActionTemplate(YardstickException):
+ message = 'No ACL CLI template found for "%(action_name)s" action'
diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py
index 6ff6617a9..541061351 100644
--- a/yardstick/common/openstack_utils.py
+++ b/yardstick/common/openstack_utils.py
@@ -172,6 +172,15 @@ def get_shade_client(**os_cloud_config):
params.update(os_cloud_config)
return shade.openstack_cloud(**params)
+def get_shade_operator_client(**os_cloud_config):
+ """Get Shade Operator cloud client
+
+ :return: ``shade.OperatorCloud`` object.
+ """
+ params = copy.deepcopy(constants.OS_CLOUD_DEFAULT_CONFIG)
+ params.update(os_cloud_config)
+ return shade.operator_cloud(**params)
+
# *********************************************
# NOVA
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 108ee17bc..f9fe0e336 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -306,6 +306,19 @@ def get_ip_version(ip_addr):
return address.version
+def make_ip_addr(ip, mask):
+ """
+ :param ip[str]: ip adddress
+ :param mask[str]: /24 prefix of 255.255.255.0 netmask
+ :return: IPv4Interface object
+ """
+ try:
+ return ipaddress.ip_interface(six.text_type('/'.join([ip, mask])))
+ except (TypeError, ValueError):
+ # None so we can skip later
+ return None
+
+
def ip_to_hex(ip_addr, separator=''):
try:
address = ipaddress.ip_address(six.text_type(ip_addr))
@@ -409,13 +422,18 @@ class ErrorClass(object):
class Timer(object):
- def __init__(self, timeout=None):
+ def __init__(self, timeout=None, raise_exception=True):
super(Timer, self).__init__()
self.start = self.delta = None
self._timeout = int(timeout) if timeout else None
+ self._timeout_flag = False
+ self._raise_exception = raise_exception
def _timeout_handler(self, *args):
- raise exceptions.TimerTimeout(timeout=self._timeout)
+ self._timeout_flag = True
+ if self._raise_exception:
+ raise exceptions.TimerTimeout(timeout=self._timeout)
+ self.__exit__()
def __enter__(self):
self.start = datetime.datetime.now()
@@ -432,6 +450,23 @@ class Timer(object):
def __getattr__(self, item):
return getattr(self.delta, item)
+ def __iter__(self):
+ self._raise_exception = False
+ return self.__enter__()
+
+ def next(self): # pragma: no cover
+ # NOTE(ralonsoh): Python 2 support.
+ if not self._timeout_flag:
+ return datetime.datetime.now()
+ raise StopIteration()
+
+ def __next__(self): # pragma: no cover
+ # NOTE(ralonsoh): Python 3 support.
+ return self.next()
+
+ def __del__(self): # pragma: no cover
+ signal.alarm(0)
+
def read_meminfo(ssh_client):
"""Read "/proc/meminfo" file and parse all keys and values"""
diff --git a/yardstick/common/yaml_loader.py b/yardstick/common/yaml_loader.py
index 0572bd582..18673be7c 100644
--- a/yardstick/common/yaml_loader.py
+++ b/yardstick/common/yaml_loader.py
@@ -10,10 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-# yardstick: this file is copied from python-heatclient and slightly modified
-
-from __future__ import absolute_import
-
import yaml
@@ -23,6 +19,7 @@ if hasattr(yaml, 'CSafeLoader'):
else:
yaml_loader = type('CustomLoader', (yaml.SafeLoader,), {})
+
if hasattr(yaml, 'CSafeDumper'):
yaml_dumper = yaml.CSafeDumper
else:
@@ -31,3 +28,10 @@ else:
def yaml_load(tmpl_str):
return yaml.load(tmpl_str, Loader=yaml_loader)
+
+
+def read_yaml_file(path):
+ """Read yaml file"""
+ with open(path) as stream:
+ data = yaml_load(stream)
+ return data