Merge "New optional_action_timer decorator"
This commit is contained in:
commit
27940131df
@ -49,13 +49,16 @@ class DesignateScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
self.clients("designate").domains.delete(domain_id)
|
||||
|
||||
def _create_record(self, domain, record=None, atomic_action=True):
|
||||
@atomic.optional_action_timer("designate.create_record")
|
||||
def _create_record(self, domain, record=None):
|
||||
"""Create a record in a domain.
|
||||
|
||||
:param domain: domain dict
|
||||
:param record: record dict
|
||||
:param atomic_action: True if the record creation should be tracked
|
||||
as an atomic action
|
||||
:param atomic_action: True if the record creation should be
|
||||
tracked as an atomic action. added and
|
||||
handled by the optional_action_timer()
|
||||
decorator
|
||||
:returns: Designate record dict
|
||||
"""
|
||||
record = record or {}
|
||||
@ -66,10 +69,6 @@ class DesignateScenario(scenario.OpenStackScenario):
|
||||
|
||||
client = self.clients("designate")
|
||||
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "designate.create_record"):
|
||||
return client.records.create(domain["id"], record)
|
||||
|
||||
return client.records.create(domain["id"], record)
|
||||
|
||||
@atomic.action_timer("designate.list_records")
|
||||
@ -81,21 +80,18 @@ class DesignateScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.clients("designate").records.list(domain_id)
|
||||
|
||||
def _delete_record(self, domain_id, record_id, atomic_action=True):
|
||||
@atomic.optional_action_timer("designate.delete_record")
|
||||
def _delete_record(self, domain_id, record_id):
|
||||
"""Delete a domain record.
|
||||
|
||||
:param domain_id: domain ID
|
||||
:param record_id: record ID
|
||||
:param atomic_action: True if the record creation should be tracked
|
||||
as an atomic action
|
||||
:param atomic_action: True if the record creation should be
|
||||
tracked as an atomic action. added and
|
||||
handled by the optional_action_timer()
|
||||
decorator
|
||||
"""
|
||||
client = self.clients("designate")
|
||||
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "designate.delete_record"):
|
||||
client.records.delete(domain_id, record_id)
|
||||
else:
|
||||
client.records.delete(domain_id, record_id)
|
||||
self.clients("designate").records.delete(domain_id, record_id)
|
||||
|
||||
@atomic.action_timer("designate.create_server")
|
||||
def _create_server(self, server=None):
|
||||
|
@ -97,9 +97,9 @@ class MuranoScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.clients("murano").sessions.configure(environment_id)
|
||||
|
||||
@atomic.optional_action_timer("murano.create_service")
|
||||
def _create_service(self, environment, session, full_package_name,
|
||||
image_name=None, flavor_name=None,
|
||||
atomic_action=True):
|
||||
image_name=None, flavor_name=None):
|
||||
"""Create Murano service.
|
||||
|
||||
:param environment: Environment instance
|
||||
@ -107,7 +107,9 @@ class MuranoScenario(scenario.OpenStackScenario):
|
||||
:param full_package_name: full name of the Murano package
|
||||
:param image_name: Image name
|
||||
:param flavor_name: Flavor name
|
||||
:param atomic_action: True if this is atomic action
|
||||
:param atomic_action: True if this is atomic action. added and
|
||||
handled by the optional_action_timer()
|
||||
decorator
|
||||
:returns: Service instance
|
||||
"""
|
||||
app_id = str(uuid.uuid4())
|
||||
@ -115,15 +117,9 @@ class MuranoScenario(scenario.OpenStackScenario):
|
||||
"type": full_package_name},
|
||||
"name": self._generate_random_name("rally_")}
|
||||
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "murano.create_service"):
|
||||
return self.clients("murano").services.post(
|
||||
environment_id=environment.id, path="/", data=data,
|
||||
session_id=session.id)
|
||||
else:
|
||||
return self.clients("murano").services.post(
|
||||
environment_id=environment.id, path="/", data=data,
|
||||
session_id=session.id)
|
||||
return self.clients("murano").services.post(
|
||||
environment_id=environment.id, path="/", data=data,
|
||||
session_id=session.id)
|
||||
|
||||
@atomic.action_timer("murano.deploy_environment")
|
||||
def _deploy_environment(self, environment, session):
|
||||
|
@ -93,16 +93,15 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
return self.clients("neutron").create_network(
|
||||
{"network": network_create_args})
|
||||
|
||||
def _list_networks(self, atomic_action=True, **kwargs):
|
||||
@atomic.optional_action_timer("neutron.list_networks")
|
||||
def _list_networks(self, **kwargs):
|
||||
"""Return user networks list.
|
||||
|
||||
:param atomic_action: True if this is an atomic action
|
||||
:param atomic_action: True if this is an atomic action. added
|
||||
and handled by the
|
||||
optional_action_timer() decorator
|
||||
:param kwargs: network list options
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "neutron.list_networks"):
|
||||
return self.clients("neutron").list_networks(
|
||||
**kwargs)["networks"]
|
||||
return self.clients("neutron").list_networks(**kwargs)["networks"]
|
||||
|
||||
@atomic.action_timer("neutron.update_network")
|
||||
@ -311,13 +310,15 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
self.clients("neutron").remove_interface_router(
|
||||
router["id"], {"subnet_id": subnet["id"]})
|
||||
|
||||
def _create_lb_pool(self, subnet_id, atomic_action=True,
|
||||
**pool_create_args):
|
||||
@atomic.optional_action_timer("neutron.create_pool")
|
||||
def _create_lb_pool(self, subnet_id, **pool_create_args):
|
||||
"""Create LB pool(v1)
|
||||
|
||||
:param subnet_id: str, neutron subnet-id
|
||||
:param pool_create_args: dict, POST /lb/pools request options
|
||||
:param atomic_action: True if this is an atomic action
|
||||
:param atomic_action: True if this is an atomic action. added
|
||||
and handled by the
|
||||
optional_action_timer() decorator
|
||||
:returns: dict, neutron lb pool
|
||||
"""
|
||||
args = {"lb_method": self.LB_METHOD,
|
||||
@ -325,9 +326,6 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
"name": self._generate_random_name("rally_pool_"),
|
||||
"subnet_id": subnet_id}
|
||||
args.update(pool_create_args)
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "neutron.create_pool"):
|
||||
return self.clients("neutron").create_pool({"pool": args})
|
||||
return self.clients("neutron").create_pool({"pool": args})
|
||||
|
||||
def _create_v1_pools(self, networks, **pool_create_args):
|
||||
|
@ -32,14 +32,16 @@ class SwiftScenario(scenario.OpenStackScenario):
|
||||
return self.clients("swift").get_account(full_listing=full_listing,
|
||||
**kwargs)
|
||||
|
||||
def _create_container(self, container_name=None, public=False,
|
||||
atomic_action=True, **kwargs):
|
||||
@atomic.optional_action_timer("swift.create_container")
|
||||
def _create_container(self, container_name=None, public=False, **kwargs):
|
||||
"""Create a new container with given name.
|
||||
|
||||
:param container_name: str, name of the container to create
|
||||
:param public: bool, set container as public
|
||||
:param atomic_action: bool, enable create container to be tracked as an
|
||||
atomic action
|
||||
:param atomic_action: bool, enable create container to be
|
||||
tracked as an atomic action. added and
|
||||
handled by the optional_action_timer()
|
||||
decorator
|
||||
:param kwargs: dict, other optional parameters to put_container
|
||||
|
||||
:returns: container name
|
||||
@ -52,60 +54,51 @@ class SwiftScenario(scenario.OpenStackScenario):
|
||||
container_name = self._generate_random_name(
|
||||
prefix="rally_container_")
|
||||
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "swift.create_container"):
|
||||
self.clients("swift").put_container(container_name, **kwargs)
|
||||
else:
|
||||
self.clients("swift").put_container(container_name, **kwargs)
|
||||
self.clients("swift").put_container(container_name, **kwargs)
|
||||
return container_name
|
||||
|
||||
def _delete_container(self, container_name, atomic_action=True, **kwargs):
|
||||
@atomic.optional_action_timer("swift.delete_container")
|
||||
def _delete_container(self, container_name, **kwargs):
|
||||
"""Delete a container with given name.
|
||||
|
||||
:param container_name: str, name of the container to delete
|
||||
:param atomic_action: bool, enable delete container to be tracked as an
|
||||
atomic action
|
||||
:param atomic_action: bool, enable delete container to be
|
||||
tracked as an atomic action. added and
|
||||
handled by the optional_action_timer()
|
||||
decorator
|
||||
:param kwargs: dict, other optional parameters to delete_container
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "swift.delete_container"):
|
||||
self.clients("swift").delete_container(container_name,
|
||||
**kwargs)
|
||||
else:
|
||||
self.clients("swift").delete_container(container_name, **kwargs)
|
||||
self.clients("swift").delete_container(container_name, **kwargs)
|
||||
|
||||
def _list_objects(self, container_name, full_listing=True,
|
||||
atomic_action=True, **kwargs):
|
||||
@atomic.optional_action_timer("swift.list_objects")
|
||||
def _list_objects(self, container_name, full_listing=True, **kwargs):
|
||||
"""Return objects inside container.
|
||||
|
||||
:param container_name: str, name of the container to make the list
|
||||
objects operation against
|
||||
:param full_listing: bool, enable unlimit number of listing returned
|
||||
:param atomic_action: bool, enable list objects to be tracked as an
|
||||
atomic action
|
||||
:param atomic_action: bool, enable list objects to be tracked
|
||||
as an atomic action. added and handled
|
||||
by the optional_action_timer() decorator
|
||||
:param kwargs: dict, other optional parameters to get_container
|
||||
|
||||
:returns: tuple, (dict of response headers, a list of objects)
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "swift.list_objects"):
|
||||
return self.clients("swift").get_container(
|
||||
container_name, full_listing=full_listing,
|
||||
**kwargs)
|
||||
|
||||
return self.clients("swift").get_container(container_name,
|
||||
full_listing=full_listing,
|
||||
**kwargs)
|
||||
|
||||
@atomic.optional_action_timer("swift.upload_object")
|
||||
def _upload_object(self, container_name, content, object_name=None,
|
||||
atomic_action=True, **kwargs):
|
||||
**kwargs):
|
||||
"""Upload content to a given container.
|
||||
|
||||
:param container_name: str, name of the container to upload object to
|
||||
:param content: file stream, content to upload
|
||||
:param object_name: str, name of the object to upload
|
||||
:param atomic_action: bool, enable upload object to be tracked as an
|
||||
atomic action
|
||||
:param atomic_action: bool, enable upload object to be tracked
|
||||
as an atomic action. added and handled
|
||||
by the optional_action_timer() decorator
|
||||
:param kwargs: dict, other optional parameters to put_object
|
||||
|
||||
:returns: tuple, (etag and object name)
|
||||
@ -113,52 +106,38 @@ class SwiftScenario(scenario.OpenStackScenario):
|
||||
if object_name is None:
|
||||
object_name = self._generate_random_name(prefix="rally_object_")
|
||||
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "swift.upload_object"):
|
||||
return (self.clients("swift").put_object(container_name,
|
||||
object_name, content,
|
||||
**kwargs),
|
||||
object_name)
|
||||
|
||||
return (self.clients("swift").put_object(container_name, object_name,
|
||||
content, **kwargs),
|
||||
object_name)
|
||||
|
||||
def _download_object(self, container_name, object_name, atomic_action=True,
|
||||
**kwargs):
|
||||
@atomic.optional_action_timer("swift.download_object")
|
||||
def _download_object(self, container_name, object_name, **kwargs):
|
||||
"""Download object from container.
|
||||
|
||||
:param container_name: str, name of the container to download object
|
||||
from
|
||||
:param object_name: str, name of the object to download
|
||||
:param atomic_action: bool, enable download object to be tracked as an
|
||||
atomic action
|
||||
:param atomic_action: bool, enable download object to be
|
||||
tracked as an atomic action. added and
|
||||
handled by the optional_action_timer()
|
||||
decorator
|
||||
:param kwargs: dict, other optional parameters to get_object
|
||||
|
||||
:returns: tuple, (dict of response headers, the object's contents)
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "swift.download_object"):
|
||||
return self.clients("swift").get_object(container_name,
|
||||
object_name, **kwargs)
|
||||
|
||||
return self.clients("swift").get_object(container_name, object_name,
|
||||
**kwargs)
|
||||
|
||||
def _delete_object(self, container_name, object_name, atomic_action=True,
|
||||
**kwargs):
|
||||
@atomic.optional_action_timer("swift.delete_object")
|
||||
def _delete_object(self, container_name, object_name, **kwargs):
|
||||
"""Delete object from container.
|
||||
|
||||
:param container_name: str, name of the container to delete object from
|
||||
:param object_name: str, name of the object to delete
|
||||
:param atomic_action: bool, enable delete object to be tracked as an
|
||||
atomic action
|
||||
:param atomic_action: bool, enable delete object to be tracked
|
||||
as an atomic action. added and handled
|
||||
by the optional_action_timer() decorator
|
||||
:param kwargs: dict, other optional parameters to delete_object
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "swift.delete_object"):
|
||||
self.clients("swift").delete_object(container_name,
|
||||
object_name, **kwargs)
|
||||
else:
|
||||
self.clients("swift").delete_object(container_name, object_name,
|
||||
**kwargs)
|
||||
self.clients("swift").delete_object(container_name, object_name,
|
||||
**kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user