l3_agent list_networks should be wrapped in try except
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
I was noticing an error in my logs for l3_agent and took a bit to figure out what it was telling me.
2012-10-06 01:10:26 ERROR [quantum.
Traceback (most recent call last):
File "/usr/lib/
self.
File "/usr/lib/
target_
File "/usr/lib/
ex_nets = self.qclient.
File "/usr/lib/
ret = self.function(
File "/usr/lib/
return self.get(
File "/usr/lib/
headers=
File "/usr/lib/
headers=
File "/usr/lib/
self.
File "/usr/lib/
exception_
File "/usr/lib/
message=
QuantumClientEx
This happens when the database has no tables created yet.
It can be seen using the code from quantumclient.
>>> from quantumclient.v2_0 import client
>>> client20 = client.
>>> client20.tenant = 'default'
>>> client20.format = 'json'
>>> nets = client20.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
ret = self.function(
File "/usr/lib/
return self.get(
File "/usr/lib/
headers=
File "/usr/lib/
headers=
File "/usr/lib/
self.
File "/usr/lib/
exception_
File "/usr/lib/
message=
quantumclient.
Just to make it more friendly, wrapping it in a try except seems to make things much nicer:
>>> from quantumclient.v2_0 import client
>>> client20 = client.
>>> client20.tenant = 'default'
>>> client20.format = 'json'
>>> params = {'router:external': True}
>>> try:
... nets = self.client20.
... print nets
... except:
... print "Connection to database failed"
...
Connection to database failed
>>>
To make it so you don't need to wrap a all the returns, it might be a good idea to set ex_net so you don't get an error when doing the len():
def _fetch_
"""Find UUID of single external network for this agent"""
if self.conf.
return self.conf.
ex_nets = {}
params = {'router:external': True}
try:
except:
if len(ex_nets) > 1:
raise Exception("must configure 'gateway_
if len(ex_nets) == 0:
return None
return ex_nets[0]['id']
This also happens for list_routers:
def do_single_
#......
# identify and update new or modified routers
for r in self.qclient.
I tried wrapping it with a new function:
def _fetch_
routers = {}
try:
except:
return routers
def do_single_
#......
# identify and update new or modified routers
#for r in self.qclient.
for r in routers:
But that didn't catch the error for some reason, my python must be lacking some mojo.
this is a reasonable suggestion I think, but this code should be going away once we update the L3 agent to use RPC: https:/ /blueprints. launchpad. net/quantum/ +spec/rpc- for-l3- agent