rename ACTIVE_PENDING to ACTIVE_PENDING_STATUSES

Looking at the lbaas code it's not very obvious that constants.ACTIVE_PENDING
is a list of statuses that contain statuses that are ACTIVE or
PENDING. This patch renames ACTIVE_PENDING to ACTIVE_PENDING_STATUSES so
it's obvious that this is a list and not just a string called ACTIVE_PENDING.

Closes-bug: #1295790

Change-Id: I7af96bcc6b145c6ab809c0b032ccb18baad9c98e
This commit is contained in:
Aaron Rosen
2014-03-21 11:23:05 -07:00
parent 21e8c2235b
commit 15e1c4fb56
4 changed files with 16 additions and 13 deletions

View File

@@ -58,7 +58,7 @@ PENDING_DELETE = "PENDING_DELETE"
INACTIVE = "INACTIVE" INACTIVE = "INACTIVE"
ERROR = "ERROR" ERROR = "ERROR"
ACTIVE_PENDING = ( ACTIVE_PENDING_STATUSES = (
ACTIVE, ACTIVE,
PENDING_CREATE, PENDING_CREATE,
PENDING_UPDATE PENDING_UPDATE

View File

@@ -84,7 +84,8 @@ class LoadBalancerCallbacks(object):
qry = context.session.query(loadbalancer_db.Pool.id) qry = context.session.query(loadbalancer_db.Pool.id)
qry = qry.filter(loadbalancer_db.Pool.id.in_(pool_ids)) qry = qry.filter(loadbalancer_db.Pool.id.in_(pool_ids))
qry = qry.filter( qry = qry.filter(
loadbalancer_db.Pool.status.in_(constants.ACTIVE_PENDING)) loadbalancer_db.Pool.status.in_(
constants.ACTIVE_PENDING_STATUSES))
up = True # makes pep8 and sqlalchemy happy up = True # makes pep8 and sqlalchemy happy
qry = qry.filter(loadbalancer_db.Pool.admin_state_up == up) qry = qry.filter(loadbalancer_db.Pool.admin_state_up == up)
return [id for id, in qry] return [id for id, in qry]
@@ -116,13 +117,13 @@ class LoadBalancerCallbacks(object):
retval['members'] = [ retval['members'] = [
self.plugin._make_member_dict(m) self.plugin._make_member_dict(m)
for m in pool.members if ( for m in pool.members if (
m.status in constants.ACTIVE_PENDING or m.status in constants.ACTIVE_PENDING_STATUSES or
m.status == constants.INACTIVE) m.status == constants.INACTIVE)
] ]
retval['healthmonitors'] = [ retval['healthmonitors'] = [
self.plugin._make_health_monitor_dict(hm.healthmonitor) self.plugin._make_health_monitor_dict(hm.healthmonitor)
for hm in pool.monitors for hm in pool.monitors
if hm.status in constants.ACTIVE_PENDING if hm.status in constants.ACTIVE_PENDING_STATUSES
] ]
retval['driver'] = ( retval['driver'] = (
self.plugin.drivers[pool.provider.provider_name].device_driver) self.plugin.drivers[pool.provider.provider_name].device_driver)
@@ -136,18 +137,19 @@ class LoadBalancerCallbacks(object):
pool = qry.one() pool = qry.one()
# set all resources to active # set all resources to active
if pool.status in constants.ACTIVE_PENDING: if pool.status in constants.ACTIVE_PENDING_STATUSES:
pool.status = constants.ACTIVE pool.status = constants.ACTIVE
if pool.vip and pool.vip.status in constants.ACTIVE_PENDING: if (pool.vip and pool.vip.status in
constants.ACTIVE_PENDING_STATUSES):
pool.vip.status = constants.ACTIVE pool.vip.status = constants.ACTIVE
for m in pool.members: for m in pool.members:
if m.status in constants.ACTIVE_PENDING: if m.status in constants.ACTIVE_PENDING_STATUSES:
m.status = constants.ACTIVE m.status = constants.ACTIVE
for hm in pool.monitors: for hm in pool.monitors:
if hm.status in constants.ACTIVE_PENDING: if hm.status in constants.ACTIVE_PENDING_STATUSES:
hm.status = constants.ACTIVE hm.status = constants.ACTIVE
def update_status(self, context, obj_type, obj_id, status): def update_status(self, context, obj_type, obj_id, status):
@@ -366,7 +368,7 @@ class AgentDriverBase(abstract_driver.LoadBalancerAbstractDriver):
def update_vip(self, context, old_vip, vip): def update_vip(self, context, old_vip, vip):
agent = self.get_pool_agent(context, vip['pool_id']) agent = self.get_pool_agent(context, vip['pool_id'])
if vip['status'] in constants.ACTIVE_PENDING: if vip['status'] in constants.ACTIVE_PENDING_STATUSES:
self.agent_rpc.update_vip(context, old_vip, vip, agent['host']) self.agent_rpc.update_vip(context, old_vip, vip, agent['host'])
else: else:
self.agent_rpc.delete_vip(context, vip, agent['host']) self.agent_rpc.delete_vip(context, vip, agent['host'])
@@ -386,7 +388,7 @@ class AgentDriverBase(abstract_driver.LoadBalancerAbstractDriver):
def update_pool(self, context, old_pool, pool): def update_pool(self, context, old_pool, pool):
agent = self.get_pool_agent(context, pool['id']) agent = self.get_pool_agent(context, pool['id'])
if pool['status'] in constants.ACTIVE_PENDING: if pool['status'] in constants.ACTIVE_PENDING_STATUSES:
self.agent_rpc.update_pool(context, old_pool, pool, self.agent_rpc.update_pool(context, old_pool, pool,
agent['host']) agent['host'])
else: else:

View File

@@ -47,7 +47,7 @@ STATS_MAP = {
constants.STATS_RESPONSE_ERRORS: 'eresp' constants.STATS_RESPONSE_ERRORS: 'eresp'
} }
ACTIVE_PENDING = qconstants.ACTIVE_PENDING ACTIVE_PENDING_STATUSES = qconstants.ACTIVE_PENDING_STATUSES
INACTIVE = qconstants.INACTIVE INACTIVE = qconstants.INACTIVE
@@ -138,7 +138,7 @@ def _build_backend(config):
# add the members # add the members
for member in config['members']: for member in config['members']:
if ((member['status'] in ACTIVE_PENDING or if ((member['status'] in ACTIVE_PENDING_STATUSES or
member['status'] == INACTIVE) member['status'] == INACTIVE)
and member['admin_state_up']): and member['admin_state_up']):
server = (('server %(id)s %(address)s:%(protocol_port)s ' server = (('server %(id)s %(address)s:%(protocol_port)s '

View File

@@ -267,7 +267,8 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
def deploy_instance(self, logical_config): def deploy_instance(self, logical_config):
# do actual deploy only if vip is configured and active # do actual deploy only if vip is configured and active
if ('vip' not in logical_config or if ('vip' not in logical_config or
logical_config['vip']['status'] not in constants.ACTIVE_PENDING or (logical_config['vip']['status'] not in
constants.ACTIVE_PENDING_STATUSES) or
not logical_config['vip']['admin_state_up']): not logical_config['vip']['admin_state_up']):
return return