From 1628fb72f8fbac15110713530728a03e8e4bd0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Antal?= Date: Mon, 12 Sep 2016 14:30:44 +0200 Subject: [PATCH] Improved readibility and fixed indentation In some places, indentation was wrong. In this patchset, they are fixed. Also, I did some readibility improvements which I've found during indentation fixing. Change-Id: I298b9b0c557c07848c69ed23b0faa3a3147d055d --- neutron/agent/l3/router_info.py | 8 ++--- neutron/agent/linux/pd.py | 8 ++--- neutron/api/v2/base.py | 4 +-- neutron/db/db_base_plugin_v2.py | 2 +- neutron/db/segments_db.py | 40 +++++++++++----------- neutron/services/provider_configuration.py | 10 +++--- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py index 8b1e938bc88..69d762c5bb8 100644 --- a/neutron/agent/l3/router_info.py +++ b/neutron/agent/l3/router_info.py @@ -825,10 +825,10 @@ class RouterInfo(object): ex_gw_port) fip_statuses = self.configure_fip_addresses(interface_name) - except (n_exc.FloatingIpSetupException): - # All floating IPs must be put in error state - LOG.exception(_LE("Failed to process floating IPs.")) - fip_statuses = self.put_fips_in_error_state() + except n_exc.FloatingIpSetupException: + # All floating IPs must be put in error state + LOG.exception(_LE("Failed to process floating IPs.")) + fip_statuses = self.put_fips_in_error_state() finally: self.update_fip_statuses(agent, fip_statuses) diff --git a/neutron/agent/linux/pd.py b/neutron/agent/linux/pd.py index 98aadfd33d4..7ab83cafc5b 100644 --- a/neutron/agent/linux/pd.py +++ b/neutron/agent/linux/pd.py @@ -202,10 +202,10 @@ class PrefixDelegation(object): lla_with_mask) def _spawn_lla_thread(self, gw_ifname, ns_name, lla_with_mask): - eventlet.spawn_n(self._ensure_lla_task, - gw_ifname, - ns_name, - lla_with_mask) + eventlet.spawn_n(self._ensure_lla_task, + gw_ifname, + ns_name, + lla_with_mask) def _delete_lla(self, router, lla_with_mask): if lla_with_mask and router['gw_interface']: diff --git a/neutron/api/v2/base.py b/neutron/api/v2/base.py index 5ca5ddefc71..97c8ccaf083 100644 --- a/neutron/api/v2/base.py +++ b/neutron/api/v2/base.py @@ -474,8 +474,8 @@ class Controller(object): self._plugin) reservations.append(reservation) except n_exc.QuotaResourceUnknown as e: - # We don't want to quota this resource - LOG.debug(e) + # We don't want to quota this resource + LOG.debug(e) def notify(create_result): # Ensure usage trackers for all resources affected by this API diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index dfcecfb03f5..a13bb83ff41 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -488,7 +488,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, "incompatible with DHCP service enabled.") if ((ip_ver == 4 and subnet_prefixlen > 30) or (ip_ver == 6 and subnet_prefixlen > 126)): - raise exc.InvalidInput(error_message=error_message) + raise exc.InvalidInput(error_message=error_message) net = netaddr.IPNetwork(s['cidr']) if net.is_multicast(): diff --git a/neutron/db/segments_db.py b/neutron/db/segments_db.py index 9c2299a0949..9a540ddda20 100644 --- a/neutron/db/segments_db.py +++ b/neutron/db/segments_db.py @@ -100,27 +100,27 @@ def get_segment_by_id(session, segment_id): def get_dynamic_segment(session, network_id, physical_network=None, segmentation_id=None): - """Return a dynamic segment for the filters provided if one exists.""" - with session.begin(subtransactions=True): - query = (session.query(segments_model.NetworkSegment). - filter_by(network_id=network_id, is_dynamic=True)) - if physical_network: - query = query.filter_by(physical_network=physical_network) - if segmentation_id: - query = query.filter_by(segmentation_id=segmentation_id) - record = query.first() + """Return a dynamic segment for the filters provided if one exists.""" + with session.begin(subtransactions=True): + query = (session.query(segments_model.NetworkSegment). + filter_by(network_id=network_id, is_dynamic=True)) + if physical_network: + query = query.filter_by(physical_network=physical_network) + if segmentation_id: + query = query.filter_by(segmentation_id=segmentation_id) + record = query.first() - if record: - return _make_segment_dict(record) - else: - LOG.debug("No dynamic segment found for " - "Network:%(network_id)s, " - "Physical network:%(physnet)s, " - "segmentation_id:%(segmentation_id)s", - {'network_id': network_id, - 'physnet': physical_network, - 'segmentation_id': segmentation_id}) - return None + if record: + return _make_segment_dict(record) + else: + LOG.debug("No dynamic segment found for " + "Network:%(network_id)s, " + "Physical network:%(physnet)s, " + "segmentation_id:%(segmentation_id)s", + {'network_id': network_id, + 'physnet': physical_network, + 'segmentation_id': segmentation_id}) + return None def delete_network_segment(session, segment_id): diff --git a/neutron/services/provider_configuration.py b/neutron/services/provider_configuration.py index 4461a2c9564..ed38f825f44 100644 --- a/neutron/services/provider_configuration.py +++ b/neutron/services/provider_configuration.py @@ -48,10 +48,10 @@ class NeutronModule(object): } def _import_or_none(self): - try: - return importlib.import_module(self.module_name) - except ImportError: - return None + try: + return importlib.import_module(self.module_name) + except ImportError: + return None def installed(self): LOG.debug("NeutronModule installed = %s", self.module_name) @@ -124,7 +124,7 @@ class NeutronModule(object): return providers -#global scope function that should be used in service APIs +# global scope function that should be used in service APIs def normalize_provider_name(name): return name.lower()