Merge "Avoid doing `raise ex` when only logging"
This commit is contained in:
commit
79b615f98c
|
@ -405,9 +405,9 @@ class LBaaSv2Driver(base.LBaaSDriver):
|
|||
fixed_ips = ['subnet_id=%s' % str(loadbalancer.subnet_id),
|
||||
'ip_address=%s' % str(loadbalancer.ip)]
|
||||
ports = neutron.list_ports(fixed_ips=fixed_ips)
|
||||
except n_exc.NeutronClientException as ex:
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.error("Port with fixed ips %s not found!", fixed_ips)
|
||||
raise ex
|
||||
raise
|
||||
|
||||
if ports['ports']:
|
||||
return ports['ports'][0]
|
||||
|
@ -802,10 +802,9 @@ class LBaaSv2Driver(base.LBaaSDriver):
|
|||
l7_rule.id, l7_rule.l7policy_id,
|
||||
{'rule': {'value': new_value}})
|
||||
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Failed to update l7_rule- id=%s ",
|
||||
l7_rule.id)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Failed to update l7_rule- id=%s ", l7_rule.id)
|
||||
raise
|
||||
|
||||
def is_pool_used_by_other_l7policies(self, l7policy, pool):
|
||||
lbaas = clients.get_loadbalancer_client()
|
||||
|
|
|
@ -115,10 +115,10 @@ class NamespacePodSecurityGroupsDriver(base.PodSecurityGroupsDriver):
|
|||
"security_group_id": sg['id']
|
||||
}
|
||||
})
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error creating security group for the namespace "
|
||||
"%s: %s", namespace, ex)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error creating security group for the namespace "
|
||||
"%s", namespace)
|
||||
raise
|
||||
return {'sgId': sg['id']}
|
||||
|
||||
def delete_sg(self, sg_id):
|
||||
|
|
|
@ -138,10 +138,10 @@ class NamespacePodSubnetDriver(default_subnet.DefaultPodSubnetDriver):
|
|||
# connect the subnet to the router
|
||||
neutron.add_interface_router(router_id,
|
||||
{"subnet_id": neutron_subnet['id']})
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error creating neutron resources for the namespace "
|
||||
"%s: %s", namespace, ex)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error creating neutron resources for the namespace "
|
||||
"%s", namespace)
|
||||
raise
|
||||
return {'netId': neutron_net['id'],
|
||||
'routerId': router_id,
|
||||
'subnetId': neutron_subnet['id'],
|
||||
|
|
|
@ -142,7 +142,7 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
port_id,
|
||||
{'port': {'allowed_address_pairs': address_pairs}}
|
||||
)
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error happened during updating Neutron "
|
||||
"port %s: %s", port_id, ex)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error happened during updating Neutron port %s",
|
||||
port_id)
|
||||
raise
|
||||
|
|
|
@ -40,10 +40,10 @@ class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver):
|
|||
fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
|
||||
'ip_address=%s' % str(node_fixed_ip)]
|
||||
ports = neutron.list_ports(fixed_ips=fixed_ips)
|
||||
except n_exc.NeutronClientException as ex:
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.error("Parent vm port with fixed ips %s not found!",
|
||||
fixed_ips)
|
||||
raise ex
|
||||
raise
|
||||
|
||||
if ports['ports']:
|
||||
return ports['ports'][0]
|
||||
|
|
|
@ -81,9 +81,9 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
bulk_port_rq = {'ports': [port_rq for _ in range(len(subports_info))]}
|
||||
try:
|
||||
ports = neutron.create_port(bulk_port_rq).get('ports')
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error creating bulk ports: %s", bulk_port_rq)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error creating bulk ports: %s", bulk_port_rq)
|
||||
raise
|
||||
for index, port in enumerate(ports):
|
||||
subports_info[index]['port_id'] = port['id']
|
||||
|
||||
|
@ -91,14 +91,14 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
try:
|
||||
neutron.trunk_add_subports(trunk_id,
|
||||
{'sub_ports': subports_info})
|
||||
except n_exc.Conflict as ex:
|
||||
except n_exc.Conflict:
|
||||
LOG.error("vlan ids already in use on trunk")
|
||||
for port in ports:
|
||||
neutron.delete_port(port['id'])
|
||||
raise ex
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error happened during subport addition to trunk")
|
||||
raise ex
|
||||
raise
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error happened during subport addition to trunk")
|
||||
raise
|
||||
|
||||
vifs = []
|
||||
for index, port in enumerate(ports):
|
||||
|
@ -185,17 +185,17 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
while True:
|
||||
try:
|
||||
vlan_id = self._get_vlan_id(trunk_id)
|
||||
except n_exc.NeutronClientException as ex:
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.error("Getting VlanID for subport on "
|
||||
"trunk %s failed!!", trunk_id)
|
||||
raise ex
|
||||
raise
|
||||
subport = [{'segmentation_id': vlan_id,
|
||||
'port_id': subport,
|
||||
'segmentation_type': 'vlan'}]
|
||||
try:
|
||||
neutron.trunk_add_subports(trunk_id,
|
||||
{'sub_ports': subport})
|
||||
except n_exc.Conflict as ex:
|
||||
except n_exc.Conflict:
|
||||
if retry_count < DEFAULT_MAX_RETRY_COUNT:
|
||||
LOG.error("vlanid already in use on trunk, "
|
||||
"%s. Retrying...", trunk_id)
|
||||
|
@ -205,12 +205,12 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
else:
|
||||
LOG.error(
|
||||
"MAX retry count reached. Failed to add subport")
|
||||
raise ex
|
||||
raise
|
||||
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error happened during subport "
|
||||
"addition to trunk, %s", trunk_id)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error happened during subport "
|
||||
"addition to trunk %s", trunk_id)
|
||||
raise
|
||||
return vlan_id
|
||||
|
||||
def _remove_subports(self, neutron, trunk_id, subports_id):
|
||||
|
@ -220,11 +220,10 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
|
|||
try:
|
||||
neutron.trunk_remove_subports(trunk_id,
|
||||
{'sub_ports': subports_body})
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error(
|
||||
"Error happened during subport removal from "
|
||||
"trunk, %s", trunk_id)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error happened during subport removal from "
|
||||
"trunk %s", trunk_id)
|
||||
raise
|
||||
|
||||
def _remove_subport(self, neutron, trunk_id, subport_id):
|
||||
self._remove_subports(neutron, trunk_id, [subport_id])
|
||||
|
|
|
@ -51,9 +51,9 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
|
|||
bulk_port_rq = {'ports': [rq for _ in range(num_ports)]}
|
||||
try:
|
||||
ports = neutron.create_port(bulk_port_rq).get('ports')
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error creating bulk ports: %s", bulk_port_rq)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error creating bulk ports: %s", bulk_port_rq)
|
||||
raise
|
||||
|
||||
vif_plugin = self._get_vif_plugin(ports[0])
|
||||
|
||||
|
|
|
@ -133,9 +133,10 @@ class FipPubIpDriver(BasePubIpDriver):
|
|||
|
||||
try:
|
||||
response = neutron.create_floatingip(request)
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Failed to create floating IP - netid=%s ", pub_net_id)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Failed to create floating IP - netid=%s ",
|
||||
pub_net_id)
|
||||
raise
|
||||
return response['floatingip']['id'], response[
|
||||
'floatingip']['floating_ip_address']
|
||||
|
||||
|
|
|
@ -74,10 +74,10 @@ class SriovVIFDriver(neutron_vif.NeutronPodVIFDriver):
|
|||
"""Returns an appropriate physnet for exact subnet_id from mapping"""
|
||||
try:
|
||||
physnet = self._physnet_mapping[subnet_id]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
LOG.error("No mapping for subnet {} in {}".format(
|
||||
subnet_id, self._physnet_mapping))
|
||||
raise ex
|
||||
raise
|
||||
return physnet
|
||||
|
||||
def _get_remaining_sriov_vfs(self, pod):
|
||||
|
|
|
@ -184,10 +184,10 @@ class BaseVIFPool(base.VIFPoolDriver):
|
|||
|
||||
try:
|
||||
return self._get_port_from_pool(pool_key, pod, subnets)
|
||||
except exceptions.ResourceNotReady as ex:
|
||||
except exceptions.ResourceNotReady:
|
||||
LOG.warning("Ports pool does not have available ports!")
|
||||
eventlet.spawn(self._populate_pool, pool_key, pod, subnets)
|
||||
raise ex
|
||||
raise
|
||||
|
||||
def _get_port_from_pool(self, pool_key, pod, subnets):
|
||||
raise NotImplementedError()
|
||||
|
|
|
@ -157,22 +157,22 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||
project_id = drv_project.get_project({})
|
||||
security_groups = drv_sg.get_security_groups({}, project_id)
|
||||
subnets = drv_subnets.get_subnets([], project_id)
|
||||
except TypeError as ex:
|
||||
except TypeError:
|
||||
LOG.error("Invalid driver type")
|
||||
raise ex
|
||||
raise
|
||||
|
||||
for trunk_ip in trunk_ips:
|
||||
try:
|
||||
drv_vif_pool.force_populate_pool(
|
||||
trunk_ip, project_id, subnets, security_groups, num_ports)
|
||||
except n_exc.Conflict as ex:
|
||||
except n_exc.Conflict:
|
||||
LOG.error("VLAN Id conflict (already in use) at trunk %s",
|
||||
trunk_ip)
|
||||
raise ex
|
||||
except n_exc.NeutronClientException as ex:
|
||||
LOG.error("Error happened during subports addition at trunk: "
|
||||
" %s", trunk_ip)
|
||||
raise ex
|
||||
raise
|
||||
except n_exc.NeutronClientException:
|
||||
LOG.exception("Error happened during subports addition at "
|
||||
"trunk: %s", trunk_ip)
|
||||
raise
|
||||
|
||||
def _delete_subports(self, trunk_ips):
|
||||
try:
|
||||
|
@ -181,9 +181,9 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||
drv_vif_pool.set_vif_driver(drv_vif)
|
||||
|
||||
drv_vif_pool.free_pool(trunk_ips)
|
||||
except TypeError as ex:
|
||||
except TypeError:
|
||||
LOG.error("Invalid driver type")
|
||||
raise ex
|
||||
raise
|
||||
|
||||
def _list_pools(self):
|
||||
try:
|
||||
|
@ -192,9 +192,9 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||
drv_vif_pool.set_vif_driver(drv_vif)
|
||||
|
||||
available_pools = drv_vif_pool.list_pools()
|
||||
except TypeError as ex:
|
||||
except TypeError:
|
||||
LOG.error("Invalid driver type")
|
||||
raise ex
|
||||
raise
|
||||
|
||||
pools_info = ""
|
||||
for pool_key, pool_items in available_pools.items():
|
||||
|
@ -211,9 +211,9 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||
drv_vif_pool.set_vif_driver(drv_vif)
|
||||
|
||||
pool = drv_vif_pool.show_pool(pool_key)
|
||||
except TypeError as ex:
|
||||
except TypeError:
|
||||
LOG.error("Invalid driver type")
|
||||
raise ex
|
||||
raise
|
||||
|
||||
if pool:
|
||||
pool_info = ""
|
||||
|
|
Loading…
Reference in New Issue