Skip to content

Commit

Permalink
config-errhdl: In list operations, ignore(with log) inconsistent members
Browse files Browse the repository at this point in the history
Implement catchall exception (that logs the exception) in contrail-to-neutron
transformation in list operations so that any inconsistent entry does not
impact entire operation.

Change-Id: I4f126662c1ea740f88776d33197b1430f798525c
Closes-Bug: #1459670
  • Loading branch information
Hampapur Ajay committed May 28, 2015
1 parent af90fc0 commit 6b6d315
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 15 deletions.
104 changes: 89 additions & 15 deletions src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py
Expand Up @@ -712,6 +712,9 @@ def _port_list(self, port_objs):
port_info = self._port_vnc_to_neutron(port_obj, memo_req)
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in _port_list: %s", str(e))
continue
ret_q_ports.append(port_info)

return ret_q_ports
Expand Down Expand Up @@ -2295,7 +2298,10 @@ def _collect_without_prune(net_ids):
net_repr='LIST')
ret_dict[net_id] = net_info
except NoIdError:
pass
continue
except Exception as e:
self.manager.logger.error("Error in network_list: %s", str(e))
continue
#end _collect_without_prune

# collect phase
Expand Down Expand Up @@ -2349,14 +2355,26 @@ def _collect_without_prune(net_ids):
if filters['shared'][0] == True:
nets = self._network_list_shared()
for net in nets:
net_info = self._network_vnc_to_neutron(net,
net_repr='LIST')
try:
net_info = self._network_vnc_to_neutron(net,
net_repr='LIST')
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in network_list: %s", str(e))
continue
ret_dict[net.uuid] = net_info
elif filters and 'router:external' in filters:
nets = self._network_list_router_external()
if filters['router:external'][0] == True:
for net in nets:
net_info = self._network_vnc_to_neutron(net, net_repr='LIST')
try:
net_info = self._network_vnc_to_neutron(net, net_repr='LIST')
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in network_list: %s", str(e))
continue
ret_dict[net.uuid] = net_info
else:
# read all networks in all projects
Expand Down Expand Up @@ -2385,7 +2403,11 @@ def _collect_without_prune(net_ids):
net_repr='LIST')
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in network_list: %s", str(e))
continue
ret_dict[net_obj.uuid] = net_info

ret_list = []
for net in ret_dict.values():
ret_list.append(net)
Expand Down Expand Up @@ -2652,9 +2674,13 @@ def subnets_list(self, context, filters=None):
for ipam_ref in ipam_refs:
subnet_vncs = ipam_ref['attr'].get_ipam_subnets()
for subnet_vnc in subnet_vncs:
sn_info = self._subnet_vnc_to_neutron(subnet_vnc,
net_obj,
ipam_ref['to'])
try:
sn_info = self._subnet_vnc_to_neutron(subnet_vnc,
net_obj,
ipam_ref['to'])
except Exception as e:
self.manager.logger.error("Error in subnets_list: %s", str(e))
continue
sn_id = sn_info['id']
sn_proj_id = sn_info['tenant_id']
sn_net_id = sn_info['network_id']
Expand Down Expand Up @@ -2755,7 +2781,13 @@ def ipam_list(self, context=None, filters=None):
proj_ipam_id = proj_ipam['uuid']
if not self._filters_is_present(filters, 'id', proj_ipam_id):
continue
ipam_info = self.ipam_read(proj_ipam['uuid'])
try:
ipam_info = self.ipam_read(proj_ipam['uuid'])
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in ipam_list: %s", str(e))
continue
ret_list.append(ipam_info)

return ret_list
Expand Down Expand Up @@ -2833,7 +2865,13 @@ def policy_list(self, context=None, filters=None):
proj_policy_id = proj_policy['uuid']
if not self._filters_is_present(filters, 'id', proj_policy_id):
continue
policy_info = self.policy_read(proj_policy['uuid'])
try:
policy_info = self.policy_read(proj_policy['uuid'])
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in policy_list: %s", str(e))
continue
ret_list.append(policy_info)

return ret_list
Expand Down Expand Up @@ -3132,8 +3170,14 @@ def router_list(self, context=None, filters=None):
for rtr_id in filters['id']:
try:
rtr_obj = self._logical_router_read(rtr_id)
rtr_info = self._router_vnc_to_neutron(rtr_obj,
try:
rtr_info = self._router_vnc_to_neutron(rtr_obj,
rtr_repr='LIST')
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in router_list: %s", str(e))
continue
ret_list.append(rtr_info)
except NoIdError:
pass
Expand Down Expand Up @@ -3393,7 +3437,13 @@ def floatingip_list(self, context, filters=None):
if (fip_obj.get_floating_ip_address() not in
filters['floating_ip_address']):
continue
ret_list.append(self._floatingip_vnc_to_neutron(fip_obj))
try:
ret_list.append(self._floatingip_vnc_to_neutron(fip_obj))
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in floatingip_list: %s", str(e))
continue

return ret_list
#end floatingip_list
Expand Down Expand Up @@ -3798,7 +3848,13 @@ def security_group_list(self, context, filters=None):
if not self._filters_is_present(filters, 'name',
sg_obj.get_display_name() or sg_obj.name):
continue
sg_info = self._security_group_vnc_to_neutron(sg_obj)
try:
sg_info = self._security_group_vnc_to_neutron(sg_obj)
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in security_group_list: %s", str(e))
continue
ret_list.append(sg_info)

return ret_list
Expand Down Expand Up @@ -3925,7 +3981,13 @@ def security_group_rule_list(self, context=None, filters=None):
# TODO implement same for name specified in filter
if not self._filters_is_present(filters, 'id', sg_obj.uuid):
continue
sgr_info = self.security_group_rules_read(sg_obj.uuid, sg_obj)
try:
sgr_info = self.security_group_rules_read(sg_obj.uuid, sg_obj)
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in security_group_rule_list: %s", str(e))
continue
if sgr_info:
ret_list.extend(sgr_info)

Expand Down Expand Up @@ -3994,7 +4056,13 @@ def route_table_list(self, context, filters=None):
proj_rt_id = proj_rt['uuid']
if not self._filters_is_present(filters, 'id', proj_rt_id):
continue
rt_info = self.route_table_read(proj_rt_id)
try:
rt_info = self.route_table_read(proj_rt_id)
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in route_table_list: %s", str(e))
continue
if not self._filters_is_present(filters, 'name',
rt_info['name']):
continue
Expand Down Expand Up @@ -4054,7 +4122,13 @@ def svc_instance_list(self, context, filters=None):
proj_si_id = proj_si['uuid']
if not self._filters_is_present(filters, 'id', proj_si_id):
continue
si_info = self.svc_instance_read(proj_si_id)
try:
si_info = self.svc_instance_read(proj_si_id)
except NoIdError:
continue
except Exception as e:
self.manager.logger.error("Error in svc_instance_list: %s", str(e))
continue
if not self._filters_is_present(filters, 'name',
si_info['name']):
continue
Expand Down
Expand Up @@ -76,6 +76,7 @@ def __init__(self, api_server_ip, api_server_port, conf_sections, sandesh):

global LOG
LOG = sandesh.logger()
self.logger = LOG

def _connect_to_db(self):
"""
Expand Down

0 comments on commit 6b6d315

Please sign in to comment.