def service_exists(**kwargs):
"""Decorator function to check whether a service exists
Usage:
@unittest.skipUnless(base.service_exists(service_type="metering"),
"Metering service does not exist")
class TestMeter(base.BaseFunctionalTest):
...
:param kwargs: The kwargs needed to filter an endpoint.
:returns: True if the service exists, otherwise False.
"""
try:
conn = connection.from_config(cloud_name=TEST_CLOUD)
conn.session.get_endpoint(**kwargs)
return True
except _exceptions.EndpointNotFound:
return False
评论列表
文章目录