"""Tests and sets a load balancer and provisioning status.
Puts a lock on the load balancer table to check the status of a
load balancer. If the status is ACTIVE then the status of the load
balancer is updated and the method returns True. If the
status is not ACTIVE, then nothing is done and False is returned.
:param session: A Sql Alchemy database session.
:param id: id of Load Balancer
:param status: Status to set Load Balancer if check passes.
:returns: bool
"""
323
lb = session.query(self.model_class).with_for_update().filter_by(
324
id=id).one()
325
if lb.provisioning_status not in constants.MUTABLE_STATUSES:
return False lb.provisioning_status = status session.add(lb)
return True
By Octavia design unless Load balancer is in ACTIVE state, it is NOT allowing to delete it.
I think, we should be able to DELETE it, if it is in ERROR state too.
octavia/ common/ constants. py
64
PENDING_UPDATE, DELETED, ERROR)
65
MUTABLE_STATUSES = (ACTIVE,)
66
67 AMPHORA_ STATUSES = (AMPHORA_ALLOCATED, AMPHORA_BOOTING,
SUPPORTED_
octavia/ db/repositories .py
"""Tests and sets a load balancer and provisioning status.
Puts a lock on the load balancer table to check the status of a
load balancer. If the status is ACTIVE then the status of the load
balancer is updated and the method returns True. If the
status is not ACTIVE, then nothing is done and False is returned.
:param session: A Sql Alchemy database session.
:param id: id of Load Balancer
:param status: Status to set Load Balancer if check passes.
:returns: bool
"""
323 query(self. model_class) .with_for_ update( ).filter_ by( _status not in constants. MUTABLE_ STATUSES:
lb. provisioning_ status = status
session. add(lb)
lb = session.
324
id=id).one()
325
if lb.provisioning
return False
return True