Merge "Convert scenarios to optional_action_timer"
This commit is contained in:
commit
e13ab7142f
@ -442,14 +442,16 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
"""
|
||||
return self.clients("neutron").delete_floatingip(floating_ip["id"])
|
||||
|
||||
def _create_v1_healthmonitor(self, atomic_action=True,
|
||||
**healthmonitor_create_args):
|
||||
@atomic.optional_action_timer("neutron.create_healthmonitor")
|
||||
def _create_v1_healthmonitor(self, **healthmonitor_create_args):
|
||||
"""Create LB healthmonitor.
|
||||
|
||||
This atomic function creates healthmonitor with the provided
|
||||
healthmonitor_create_args.
|
||||
|
||||
: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 healthmonitor_create_args: dict, POST /lb/healthmonitors
|
||||
:returns: neutron healthmonitor dict
|
||||
"""
|
||||
@ -458,10 +460,6 @@ class NeutronScenario(scenario.OpenStackScenario):
|
||||
"max_retries": self.HM_MAX_RETRIES,
|
||||
"timeout": self.HM_TIMEOUT}
|
||||
args.update(healthmonitor_create_args)
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "neutron.create_healthmonitor"):
|
||||
return self.clients("neutron").create_health_monitor(
|
||||
{"health_monitor": args})
|
||||
return self.clients("neutron").create_health_monitor(
|
||||
{"health_monitor": args})
|
||||
|
||||
|
@ -551,56 +551,41 @@ class NovaScenario(scenario.OpenStackScenario):
|
||||
) for server in servers]
|
||||
return servers
|
||||
|
||||
def _associate_floating_ip(self, server, address, fixed_address=None,
|
||||
atomic_action=True):
|
||||
@atomic.optional_action_timer("nova.associate_floating_ip")
|
||||
def _associate_floating_ip(self, server, address, fixed_address=None):
|
||||
"""Add floating IP to an instance
|
||||
|
||||
:param server: The :class:`Server` to add an IP to.
|
||||
:param address: The ip address or FloatingIP to add to the instance
|
||||
:param fixed_address: The fixedIP address the FloatingIP is to be
|
||||
associated with (optional)
|
||||
:param atomic_action: True if this is an atomic action (optional)
|
||||
:param atomic_action: True if this is an atomic action. added
|
||||
and handled by the
|
||||
optional_action_timer() decorator
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "nova.associate_floating_ip"):
|
||||
server.add_floating_ip(address, fixed_address=fixed_address)
|
||||
utils.wait_for(
|
||||
server,
|
||||
is_ready=self.check_ip_address(address),
|
||||
update_resource=utils.get_from_manager()
|
||||
)
|
||||
else:
|
||||
server.add_floating_ip(address, fixed_address=fixed_address)
|
||||
utils.wait_for(
|
||||
server,
|
||||
is_ready=self.check_ip_address(address),
|
||||
update_resource=utils.get_from_manager()
|
||||
)
|
||||
server.add_floating_ip(address, fixed_address=fixed_address)
|
||||
utils.wait_for(server,
|
||||
is_ready=self.check_ip_address(address),
|
||||
update_resource=utils.get_from_manager())
|
||||
# Update server data
|
||||
server.addresses = server.manager.get(server.id).addresses
|
||||
|
||||
def _dissociate_floating_ip(self, server, address, atomic_action=True):
|
||||
@atomic.optional_action_timer("nova.dissociate_floating_ip")
|
||||
def _dissociate_floating_ip(self, server, address):
|
||||
"""Remove floating IP from an instance
|
||||
|
||||
:param server: The :class:`Server` to add an IP to.
|
||||
:param address: The ip address or FloatingIP to remove
|
||||
:param atomic_action: True if this is an atomic action (optional)
|
||||
:param atomic_action: True if this is an atomic action. added
|
||||
and handled by the
|
||||
optional_action_timer() decorator
|
||||
"""
|
||||
if atomic_action:
|
||||
with atomic.ActionTimer(self, "nova.dissociate_floating_ip"):
|
||||
server.remove_floating_ip(address)
|
||||
utils.wait_for(
|
||||
server,
|
||||
is_ready=self.check_ip_address(address, must_exist=False),
|
||||
update_resource=utils.get_from_manager()
|
||||
)
|
||||
else:
|
||||
server.remove_floating_ip(address)
|
||||
utils.wait_for(
|
||||
server,
|
||||
is_ready=self.check_ip_address(address, must_exist=False),
|
||||
update_resource=utils.get_from_manager()
|
||||
)
|
||||
server.remove_floating_ip(address)
|
||||
utils.wait_for(
|
||||
server,
|
||||
is_ready=self.check_ip_address(address, must_exist=False),
|
||||
update_resource=utils.get_from_manager()
|
||||
)
|
||||
# Update server data
|
||||
server.addresses = server.manager.get(server.id).addresses
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user