Skip to content

Commit f2a1cba

Browse files
authored
Merge pull request #1079 from zongzw/lb-dict-stable-pike
Compat with lb dict passed from neutron_lbaas.
2 parents a2ffeb7 + e7cb3a8 commit f2a1cba

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

f5lbaasdriver/v2/bigip/agent_scheduler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from neutron_lbaas import agent_scheduler
2525
from neutron_lbaas.extensions import lbaas_agentschedulerv2
26+
from neutron_lbaas.services.loadbalancer.data_models import LoadBalancer
2627

2728
LOG = logging.getLogger(__name__)
2829

@@ -221,6 +222,8 @@ def schedule(self, plugin, context, loadbalancer_id, env=None):
221222
# already above, so this db call is avoided.
222223
LOG.info('get_loadbalancer start inside schedule')
223224
loadbalancer = plugin.db.get_loadbalancer(context, loadbalancer_id)
225+
loadbalancer = LoadBalancer(**loadbalancer) \
226+
if type(loadbalancer) == dict else loadbalancer
224227
LOG.info('get_loadbalancer end inside schedule')
225228

226229
# There is no existing loadbalancer agent binding.

f5lbaasdriver/v2/bigip/plugin_rpc.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from neutron_lbaas.db.loadbalancer import models
2626
from neutron_lbaas.services.loadbalancer import constants as nlb_constant
27+
from neutron_lbaas.services.loadbalancer.data_models import LoadBalancer
2728

2829
from neutron_lib.api.definitions import portbindings
2930
from neutron_lib import constants as neutron_const
@@ -108,6 +109,7 @@ def get_service_by_loadbalancer_id(
108109
context,
109110
id=loadbalancer_id
110111
)
112+
lb = LoadBalancer(**lb) if type(lb) == dict else lb
111113
agent = self.driver.plugin.db.get_agent_hosting_loadbalancer(
112114
context,
113115
loadbalancer_id
@@ -138,11 +140,12 @@ def get_all_loadbalancers(self, context, env, group=None, host=None):
138140
agent.id
139141
)
140142
for lb in agent_lbs:
143+
lbobj = LoadBalancer(**lb) if type(lb) == dict else lb
141144
loadbalancers.append(
142145
{
143146
'agent_host': agent['host'],
144-
'lb_id': lb.id,
145-
'tenant_id': lb.tenant_id
147+
'lb_id': lbobj.id,
148+
'tenant_id': lbobj.tenant_id
146149
}
147150
)
148151
if host:
@@ -166,12 +169,13 @@ def get_active_loadbalancers(self, context, env, group=None, host=None):
166169
agent.id
167170
)
168171
for lb in agent_lbs:
169-
if lb.provisioning_status == plugin_constants.ACTIVE:
172+
lbobj = LoadBalancer(**lb) if type(lb) == dict else lb
173+
if lbobj.provisioning_status == plugin_constants.ACTIVE:
170174
loadbalancers.append(
171175
{
172176
'agent_host': agent['host'],
173-
'lb_id': lb.id,
174-
'tenant_id': lb.tenant_id
177+
'lb_id': lbobj.id,
178+
'tenant_id': lbobj.tenant_id
175179
}
176180
)
177181
if host:
@@ -195,13 +199,16 @@ def get_pending_loadbalancers(self, context, env, group=None, host=None):
195199
agent.id
196200
)
197201
for lb in agent_lbs:
198-
if (lb.provisioning_status != plugin_constants.ACTIVE and
199-
lb.provisioning_status != plugin_constants.ERROR):
202+
lbobj = LoadBalancer(**lb) if type(lb) == dict else lb
203+
if (lbobj.provisioning_status !=
204+
plugin_constants.ACTIVE and
205+
lbobj.provisioning_status !=
206+
plugin_constants.ERROR):
200207
loadbalancers.append(
201208
{
202209
'agent_host': agent['host'],
203-
'lb_id': lb.id,
204-
'tenant_id': lb.tenant_id
210+
'lb_id': lbobj.id,
211+
'tenant_id': lbobj.tenant_id
205212
}
206213
)
207214
if host:
@@ -225,12 +232,13 @@ def get_errored_loadbalancers(self, context, env, group=None, host=None):
225232
agent.id
226233
)
227234
for lb in agent_lbs:
228-
if (lb.provisioning_status == plugin_constants.ERROR):
235+
lbobj = LoadBalancer(**lb) if type(lb) == dict else lb
236+
if (lbobj.provisioning_status == plugin_constants.ERROR):
229237
loadbalancers.append(
230238
{
231239
'agent_host': agent['host'],
232-
'lb_id': lb.id,
233-
'tenant_id': lb.tenant_id
240+
'lb_id': lbobj.id,
241+
'tenant_id': lbobj.tenant_id
234242
}
235243
)
236244
if host:
@@ -711,6 +719,8 @@ def validate_loadbalancers_state(self, context, loadbalancers, host=None):
711719
try:
712720
lb_db = self.driver.plugin.db.get_loadbalancer(context,
713721
lbid)
722+
lb_db = LoadBalancer(**lb_db) \
723+
if type(lb_db) == dict else lb_db
714724
lb_status[lbid] = lb_db.provisioning_status
715725

716726
except q_exc.NotFound:

0 commit comments

Comments
 (0)