]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Enable automatic validation of many HACKING rules.
authorMaru Newby <marun@redhat.com>
Fri, 5 Apr 2013 23:08:40 +0000 (23:08 +0000)
committerMaru Newby <marun@redhat.com>
Thu, 11 Apr 2013 19:48:28 +0000 (19:48 +0000)
 * Add hacking to the tox build - a set of flake8 plugins that
   perform automatic validation of many HACKING.rst rules.
 * This patch configures hacking in the tox build and performs
   the mechanical cleanup required to allow the checks to pass.
 * See https://pypi.python.org/pypi/hacking

Change-Id: Ie9b3eb5627a9b6dd181f79225abae422e6cf3777

150 files changed:
quantum/agent/dhcp_agent.py
quantum/agent/firewall.py
quantum/agent/l3_agent.py
quantum/agent/linux/daemon.py
quantum/agent/linux/dhcp.py
quantum/agent/linux/ip_lib.py
quantum/agent/linux/iptables_firewall.py
quantum/agent/ovs_cleanup_util.py
quantum/agent/securitygroups_rpc.py
quantum/api/api_common.py
quantum/api/extensions.py
quantum/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py
quantum/api/rpc/agentnotifiers/l3_rpc_agent_api.py
quantum/api/v2/attributes.py
quantum/api/v2/base.py
quantum/common/rpc.py
quantum/common/test_lib.py
quantum/common/utils.py
quantum/db/agents_db.py
quantum/db/agentschedulers_db.py
quantum/db/api.py
quantum/db/db_base_plugin_v2.py
quantum/db/extraroute_db.py
quantum/db/l3_db.py
quantum/db/loadbalancer/loadbalancer_db.py
quantum/db/model_base.py
quantum/db/securitygroups_db.py
quantum/db/securitygroups_rpc_base.py
quantum/db/servicetype_db.py
quantum/debug/commands.py
quantum/debug/debug_agent.py
quantum/extensions/agent.py
quantum/extensions/agentscheduler.py
quantum/extensions/l3.py
quantum/extensions/quotasv2.py
quantum/extensions/securitygroup.py
quantum/extensions/servicetype.py
quantum/manager.py
quantum/plugins/bigswitch/plugin.py
quantum/plugins/bigswitch/tests/test_server.py
quantum/plugins/brocade/QuantumPlugin.py
quantum/plugins/brocade/nos/nosdriver.py
quantum/plugins/cisco/common/cisco_credentials_v2.py
quantum/plugins/cisco/common/cisco_exceptions.py
quantum/plugins/cisco/common/cisco_faults.py
quantum/plugins/cisco/common/cisco_utils.py
quantum/plugins/cisco/common/config.py
quantum/plugins/cisco/db/api.py
quantum/plugins/cisco/db/l2network_db.py
quantum/plugins/cisco/db/l2network_models.py
quantum/plugins/cisco/db/models.py
quantum/plugins/cisco/db/network_db_v2.py
quantum/plugins/cisco/db/network_models_v2.py
quantum/plugins/cisco/db/nexus_db_v2.py
quantum/plugins/cisco/db/nexus_models_v2.py
quantum/plugins/cisco/extensions/_credential_view.py
quantum/plugins/cisco/extensions/_qos_view.py
quantum/plugins/cisco/extensions/credential.py
quantum/plugins/cisco/extensions/qos.py
quantum/plugins/cisco/models/virt_phy_sw_v2.py
quantum/plugins/cisco/network_plugin.py
quantum/plugins/cisco/tests/unit/test_cisco_extension.py
quantum/plugins/cisco/tests/unit/test_database.py
quantum/plugins/hyperv/agent/hyperv_quantum_agent.py
quantum/plugins/hyperv/agent/utils.py
quantum/plugins/hyperv/db.py
quantum/plugins/hyperv/model.py
quantum/plugins/hyperv/rpc_callbacks.py
quantum/plugins/linuxbridge/db/l2network_db_v2.py
quantum/plugins/linuxbridge/db/l2network_models_v2.py
quantum/plugins/linuxbridge/lb_quantum_plugin.py
quantum/plugins/metaplugin/meta_quantum_plugin.py
quantum/plugins/metaplugin/proxy_quantum_plugin.py
quantum/plugins/midonet/plugin.py
quantum/plugins/nec/agent/nec_quantum_agent.py
quantum/plugins/nec/common/ofc_client.py
quantum/plugins/nec/db/api.py
quantum/plugins/nec/db/models.py
quantum/plugins/nec/db/nec_plugin_base.py
quantum/plugins/nec/drivers/pfc.py
quantum/plugins/nec/drivers/trema.py
quantum/plugins/nec/nec_plugin.py
quantum/plugins/nicira/QuantumPlugin.py
quantum/plugins/nicira/api_client/client.py
quantum/plugins/nicira/api_client/client_eventlet.py
quantum/plugins/nicira/common/exceptions.py
quantum/plugins/nicira/common/securitygroups.py
quantum/plugins/nicira/extensions/nvp_networkgw.py
quantum/plugins/nicira/extensions/nvp_qos.py
quantum/plugins/nicira/nicira_networkgw_db.py
quantum/plugins/nicira/nvplib.py
quantum/plugins/openvswitch/agent/ovs_quantum_agent.py
quantum/plugins/openvswitch/ovs_db_v2.py
quantum/plugins/openvswitch/ovs_models_v2.py
quantum/plugins/openvswitch/ovs_quantum_plugin.py
quantum/plugins/plumgrid/common/exceptions.py
quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py
quantum/plugins/plumgrid/plumgrid_nos_plugin/rest_connection.py
quantum/plugins/ryu/agent/ryu_quantum_agent.py
quantum/plugins/ryu/ryu_quantum_plugin.py
quantum/plugins/services/agent_loadbalancer/agent/manager.py
quantum/plugins/services/agent_loadbalancer/drivers/haproxy/cfg.py
quantum/plugins/services/agent_loadbalancer/plugin.py
quantum/plugins/services/service_base.py
quantum/policy.py
quantum/rootwrap/filters.py
quantum/rootwrap/wrapper.py
quantum/scheduler/dhcp_agent_scheduler.py
quantum/scheduler/l3_agent_scheduler.py
quantum/service.py
quantum/tests/unit/brocade/test_brocade_db.py
quantum/tests/unit/database_stubs.py
quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py
quantum/tests/unit/dummy_plugin.py
quantum/tests/unit/extensions/extensionattribute.py
quantum/tests/unit/linuxbridge/test_agent_scheduler.py
quantum/tests/unit/metaplugin/test_metaplugin.py
quantum/tests/unit/nec/test_agent_scheduler.py
quantum/tests/unit/nec/test_db.py
quantum/tests/unit/nec/test_nec_plugin.py
quantum/tests/unit/nec/test_ofc_manager.py
quantum/tests/unit/nec/test_pfc_driver.py
quantum/tests/unit/nec/test_trema_driver.py
quantum/tests/unit/nicira/fake_nvpapiclient.py
quantum/tests/unit/nicira/test_networkgw.py
quantum/tests/unit/nicira/test_nicira_plugin.py
quantum/tests/unit/openvswitch/test_agent_scheduler.py
quantum/tests/unit/openvswitch/test_ovs_lib.py
quantum/tests/unit/openvswitch/test_ovs_tunnel.py
quantum/tests/unit/ryu/test_defaults.py
quantum/tests/unit/services/agent_loadbalancer/test_plugin.py
quantum/tests/unit/test_api_v2.py
quantum/tests/unit/test_attributes.py
quantum/tests/unit/test_db_plugin.py
quantum/tests/unit/test_extension_portsecurity.py
quantum/tests/unit/test_extension_security_group.py
quantum/tests/unit/test_iptables_firewall.py
quantum/tests/unit/test_l3_plugin.py
quantum/tests/unit/test_loadbalancer_plugin.py
quantum/tests/unit/test_metadata_agent.py
quantum/tests/unit/test_metadata_namespace_proxy.py
quantum/tests/unit/test_rootwrap.py
quantum/tests/unit/test_servicetype.py
quantum/tests/unit/test_wsgi.py
quantum/wsgi.py
run_tests.py
tools/check_i18n.py
tools/i18n_cfg.py
tools/test-requires
tox.ini

index 42c9f0a04117db8bc9ccdcc15c4bf72d12064018..797f1ec4e9385e8d1c1b6b50e81609340e1d6169 100644 (file)
@@ -36,8 +36,8 @@ from quantum import context
 from quantum import manager
 from quantum.openstack.common import importutils
 from quantum.openstack.common import jsonutils
-from quantum.openstack.common import log as logging
 from quantum.openstack.common import lockutils
+from quantum.openstack.common import log as logging
 from quantum.openstack.common import loopingcall
 from quantum.openstack.common.rpc import proxy
 from quantum.openstack.common import service
@@ -83,7 +83,7 @@ class DhcpAgent(manager.Manager):
         self._populate_networks_cache()
 
     def _populate_networks_cache(self):
-        """Populate the networks cache when the DHCP-agent starts"""
+        """Populate the networks cache when the DHCP-agent starts."""
 
         try:
             existing_networks = self.dhcp_driver_cls.existing_dhcp_networks(
@@ -137,7 +137,7 @@ class DhcpAgent(manager.Manager):
         try:
             self.plugin_rpc.update_lease_expiration(network_id, ip_address,
                                                     time_remaining)
-        except:
+        except Exception:
             self.needs_resync = True
             LOG.exception(_('Unable to update lease'))
 
@@ -153,7 +153,7 @@ class DhcpAgent(manager.Manager):
 
             for network_id in active_networks:
                 self.refresh_dhcp_helper(network_id)
-        except:
+        except Exception:
             self.needs_resync = True
             LOG.exception(_('Unable to sync network state.'))
 
@@ -173,7 +173,7 @@ class DhcpAgent(manager.Manager):
         """Enable DHCP for a network that meets enabling criteria."""
         try:
             network = self.plugin_rpc.get_network_info(network_id)
-        except:
+        except Exception:
             self.needs_resync = True
             LOG.exception(_('Network %s RPC info call failed.'), network_id)
             return
@@ -210,7 +210,7 @@ class DhcpAgent(manager.Manager):
 
         try:
             network = self.plugin_rpc.get_network_info(network_id)
-        except:
+        except Exception:
             self.needs_resync = True
             LOG.exception(_('Network %s RPC info call failed.'), network_id)
             return
@@ -502,7 +502,7 @@ class DeviceManager(object):
         try:
             self.driver = importutils.import_object(conf.interface_driver,
                                                     conf)
-        except:
+        except Exception:
             msg = _("Error importing interface driver "
                     "'%s'") % conf.interface_driver
             raise SystemExit(msg)
index 029dd35b3d5505dc80ead43b1bfcc2b927af8859..8ca6715027373519e7c7b713456d16b294141337 100644 (file)
@@ -20,7 +20,7 @@ import contextlib
 
 
 class FirewallDriver(object):
-    """ Firewall Driver base class.
+    """Firewall Driver base class.
 
     Defines methods that any driver providing security groups
     and provider firewall functionality should implement.
@@ -81,25 +81,25 @@ class FirewallDriver(object):
         raise NotImplementedError()
 
     def remove_port_filter(self, port):
-        """Stop filtering port"""
+        """Stop filtering port."""
         raise NotImplementedError()
 
     def filter_defer_apply_on(self):
-        """Defer application of filtering rule"""
+        """Defer application of filtering rule."""
         pass
 
     def filter_defer_apply_off(self):
-        """Turn off deferral of rules and apply the rules now"""
+        """Turn off deferral of rules and apply the rules now."""
         pass
 
     @property
     def ports(self):
-        """ returns filterd ports"""
+        """Returns filtered ports."""
         pass
 
     @contextlib.contextmanager
     def defer_apply(self):
-        """defer apply context"""
+        """Defer apply context."""
         self.filter_defer_apply_on()
         try:
             yield
@@ -108,7 +108,7 @@ class FirewallDriver(object):
 
 
 class NoopFirewallDriver(FirewallDriver):
-    """ Noop Firewall Driver.
+    """Noop Firewall Driver.
 
     Firewall driver which does nothing.
     This driver is for disabling the firewall functionality.
index 39ea511fc19d2bf589d593656ca79a58c9651abe..090a22ce46832865af68640b2b2eea8aa7db483a 100644 (file)
@@ -156,7 +156,7 @@ class L3NATAgent(manager.Manager):
         try:
             self.driver = importutils.import_object(self.conf.interface_driver,
                                                     self.conf)
-        except:
+        except Exception:
             msg = _("Error importing interface driver "
                     "'%s'") % self.conf.interface_driver
             raise SystemExit(msg)
@@ -185,7 +185,7 @@ class L3NATAgent(manager.Manager):
 
                 try:
                     self._destroy_router_namespace(ns)
-                except:
+                except Exception:
                     LOG.exception(_("Failed deleting namespace '%s'"), ns)
 
     def _destroy_router_namespace(self, namespace):
@@ -200,7 +200,7 @@ class L3NATAgent(manager.Manager):
                                    bridge=self.conf.external_network_bridge,
                                    namespace=namespace,
                                    prefix=EXTERNAL_DEV_PREFIX)
-        #(TODO) Address the failure for the deletion of the namespace
+        #TODO(garyk) Address the failure for the deletion of the namespace
 
     def _create_router_namespace(self, ri):
             ip_wrapper_root = ip_lib.IPWrapper(self.root_helper)
@@ -208,7 +208,7 @@ class L3NATAgent(manager.Manager):
             ip_wrapper.netns.execute(['sysctl', '-w', 'net.ipv4.ip_forward=1'])
 
     def _fetch_external_net_id(self):
-        """Find UUID of single external network for this agent"""
+        """Find UUID of single external network for this agent."""
         if self.conf.gateway_external_network_id:
             return self.conf.gateway_external_network_id
         try:
index cdd6dc2922d7b89a35d05fe5d6be3c48cab59f51..7902868dbdc37aa81195c7664a8de52ee2aeafd7 100644 (file)
@@ -126,7 +126,7 @@ class Daemon(object):
         os.remove(str(self.pidfile))
 
     def start(self):
-        """ Start the daemon """
+        """Start the daemon."""
 
         if self.pidfile.is_running():
             self.pidfile.unlock()
index b91de9fcaec00fe9f6560b1e1d3019e006e1af0b..b154fd2586adbab20b5188adc5276be30c58c514 100644 (file)
@@ -96,7 +96,7 @@ class DhcpBase(object):
 
     @classmethod
     def existing_dhcp_networks(cls, conf, root_helper):
-        """Return a list of existing networks ids (ones we have configs for)"""
+        """Return a list of existing networks ids that we have configs for."""
 
         raise NotImplementedError
 
@@ -218,7 +218,7 @@ class Dnsmasq(DhcpLocalProcess):
 
     @classmethod
     def existing_dhcp_networks(cls, conf, root_helper):
-        """Return a list of existing networks ids (ones we have configs for)"""
+        """Return a list of existing networks ids that we have configs for."""
 
         confs_dir = os.path.abspath(os.path.normpath(conf.dhcp_confs))
 
@@ -265,7 +265,7 @@ class Dnsmasq(DhcpLocalProcess):
             if subnet.ip_version == 4:
                 mode = 'static'
             else:
-                # TODO (mark): how do we indicate other options
+                # TODO(mark): how do we indicate other options
                 # ra-only, slaac, ra-nameservers, and ra-stateless.
                 mode = 'static'
             cmd.append('--dhcp-range=set:%s,%s,%s,%ss' %
index 5207c230e7f797d55d54b320156178235a6556a8..88294d1be30787d2324b2b235bef640332527c17 100644 (file)
@@ -354,7 +354,7 @@ class IpRouteCommand(IpDeviceCommandBase):
         for device_route_line in device_route_list_lines:
             try:
                 subnet = device_route_line.split()[0]
-            except:
+            except Exception:
                 continue
             subnet_route_list_lines = self._run('list', 'proto', 'kernel',
                                                 'match', subnet).split('\n')
@@ -367,7 +367,7 @@ class IpRouteCommand(IpDeviceCommandBase):
                     while(i.next() != 'src'):
                         pass
                     src = i.next()
-                except:
+                except Exception:
                     src = ''
                 if device != interface_name:
                     device_list.append((device, src))
index 83c65f08b94475ac5f3811885af0a6651604ed48..8205b52ba2737f141c60a9ac0e0d210342c59721 100644 (file)
@@ -81,7 +81,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
         self.iptables.apply()
 
     def _setup_chains(self):
-        """Setup ingress and egress chain for a port. """
+        """Setup ingress and egress chain for a port."""
         self._add_chain_by_name_v4v6(SG_CHAIN)
         for port in self.filtered_ports.values():
             self._setup_chain(port, INGRESS_DIRECTION)
@@ -90,7 +90,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
             self.iptables.ipv6['filter'].add_rule(SG_CHAIN, '-j ACCEPT')
 
     def _remove_chains(self):
-        """Remove ingress and egress chain for a port"""
+        """Remove ingress and egress chain for a port."""
         for port in self.filtered_ports.values():
             self._remove_chain(port, INGRESS_DIRECTION)
             self._remove_chain(port, EGRESS_DIRECTION)
index 3f96018270d11259f18feaf24ded8a30520012f4..74544430cc47e3df25c637f2107f8afb9f4c803e 100644 (file)
@@ -53,7 +53,7 @@ def setup_conf():
 
 
 def collect_quantum_ports(bridges, root_helper):
-    """Collect ports created by Quantum from OVS"""
+    """Collect ports created by Quantum from OVS."""
     ports = []
     for bridge in bridges:
         ovs = ovs_lib.OVSBridge(bridge, root_helper)
index 51cc0fecda7bf45364460b1cc9bee34a703ba9ba..2ca2c41979d01c28a5d67566df1b630190debfc4 100644 (file)
@@ -66,7 +66,7 @@ class SecurityGroupAgentRpcCallbackMixin(object):
     sg_agent = None
 
     def security_groups_rule_updated(self, context, **kwargs):
-        """ callback for security group rule update
+        """Callback for security group rule update.
 
         :param security_groups: list of updated security_groups
         """
@@ -76,7 +76,7 @@ class SecurityGroupAgentRpcCallbackMixin(object):
         self.sg_agent.security_groups_rule_updated(security_groups)
 
     def security_groups_member_updated(self, context, **kwargs):
-        """ callback for security group member update
+        """Callback for security group member update.
 
         :param security_groups: list of updated security_groups
         """
@@ -86,9 +86,7 @@ class SecurityGroupAgentRpcCallbackMixin(object):
         self.sg_agent.security_groups_member_updated(security_groups)
 
     def security_groups_provider_updated(self, context, **kwargs):
-        """ callback for security group provider update
-
-        """
+        """Callback for security group provider update."""
         LOG.debug(_("Provider rule updated"))
         self.sg_agent.security_groups_provider_updated()
 
@@ -172,7 +170,7 @@ class SecurityGroupAgentRpcApiMixin(object):
                                      topics.UPDATE)
 
     def security_groups_rule_updated(self, context, security_groups):
-        """ notify rule updated security groups """
+        """Notify rule updated security groups."""
         if not security_groups:
             return
         self.fanout_cast(context,
@@ -182,7 +180,7 @@ class SecurityGroupAgentRpcApiMixin(object):
                          topic=self._get_security_group_topic())
 
     def security_groups_member_updated(self, context, security_groups):
-        """ notify member updated security groups """
+        """Notify member updated security groups."""
         if not security_groups:
             return
         self.fanout_cast(context,
@@ -192,7 +190,7 @@ class SecurityGroupAgentRpcApiMixin(object):
                          topic=self._get_security_group_topic())
 
     def security_groups_provider_updated(self, context):
-        """ notify provider updated security groups """
+        """Notify provider updated security groups."""
         self.fanout_cast(context,
                          self.make_msg('security_groups_provider_updated'),
                          version=SG_RPC_VERSION,
index dfabb3c687d160b707ef07c1ec17a3a8df39fae2..d408182b47b4a4b73268b5b7be319cbc4c99c9ed 100644 (file)
@@ -119,7 +119,7 @@ def _get_limit_param(request, max_limit):
 
 
 def list_args(request, arg):
-    """Extracts the list of arg from request"""
+    """Extracts the list of arg from request."""
     return [v for v in request.GET.getall(arg) if v]
 
 
@@ -292,7 +292,7 @@ class NoSortingHelper(SortingHelper):
 
 
 class QuantumController(object):
-    """ Base controller class for Quantum API """
+    """Base controller class for Quantum API."""
     # _resource_name will be redefined in sub concrete controller
     _resource_name = None
 
@@ -301,7 +301,7 @@ class QuantumController(object):
         super(QuantumController, self).__init__()
 
     def _prepare_request_body(self, body, params):
-        """ verifies required parameters are in request body.
+        """Verifies required parameters are in request body.
             sets default value for missing optional parameters.
 
             body argument must be the deserialized body
index e6c730cd757e4d59f251e7012e129d676269a244..ce562ca8d0ad864934e17655b73724f10ef59ea5 100644 (file)
@@ -552,7 +552,8 @@ class PluginAwareExtensionManager(ExtensionManager):
 
     def _check_extension(self, extension):
         """Checks if any of plugins supports extension and implements the
-        extension contract."""
+        extension contract.
+        """
         extension_is_valid = super(PluginAwareExtensionManager,
                                    self)._check_extension(extension)
         return (extension_is_valid and
index 21115576aa2a23f3abc9ace062ae6fe8a0d1013a..fbb1bbb2f5e3140bf675b869c7777be3d0911b8a 100644 (file)
@@ -51,14 +51,14 @@ class DhcpAgentNotifyAPI(proxy.RpcProxy):
                 dhcp_agent in dhcp_agents]
 
     def _notification_host(self, context, method, payload, host):
-        """Notify the agent on host"""
+        """Notify the agent on host."""
         self.cast(
             context, self.make_msg(method,
                                    payload=payload),
             topic='%s.%s' % (topics.DHCP_AGENT, host))
 
     def _notification(self, context, method, payload, network_id):
-        """Notify all the agents that are hosting the network"""
+        """Notify all the agents that are hosting the network."""
         plugin = manager.QuantumManager.get_plugin()
         if (method != 'network_delete_end' and utils.is_extension_supported(
                 plugin, constants.AGENT_SCHEDULER_EXT_ALIAS)):
@@ -87,7 +87,7 @@ class DhcpAgentNotifyAPI(proxy.RpcProxy):
             self._notification_fanout(context, method, payload)
 
     def _notification_fanout(self, context, method, payload):
-        """Fanout the payload to all dhcp agents"""
+        """Fanout the payload to all dhcp agents."""
         self.fanout_cast(
             context, self.make_msg(method,
                                    payload=payload),
index 9f716d65f9d3818daabfe223fe1e391a20492b04..4dc56f94083ad041c38821dccd23f5b544db2022 100644 (file)
@@ -33,7 +33,7 @@ class L3AgentNotifyAPI(proxy.RpcProxy):
             topic=topic, default_version=self.BASE_RPC_API_VERSION)
 
     def _notification_host(self, context, method, payload, host):
-        """Notify the agent that is hosting the router"""
+        """Notify the agent that is hosting the router."""
         LOG.debug(_('Nofity agent at %(host)s the message '
                     '%(method)s'), {'host': host,
                                     'method': method})
@@ -69,7 +69,7 @@ class L3AgentNotifyAPI(proxy.RpcProxy):
                     topic='%s.%s' % (l3_agent.topic, l3_agent.host))
 
     def _notification(self, context, method, routers, operation, data):
-        """Notify all the agents that are hosting the routers"""
+        """Notify all the agents that are hosting the routers."""
         plugin = manager.QuantumManager.get_plugin()
         if utils.is_extension_supported(
             plugin, constants.AGENT_SCHEDULER_EXT_ALIAS):
@@ -85,7 +85,7 @@ class L3AgentNotifyAPI(proxy.RpcProxy):
                 topic=topics.L3_AGENT)
 
     def _notification_fanout(self, context, method, router_id):
-        """Fanout the deleted router to all L3 agents"""
+        """Fanout the deleted router to all L3 agents."""
         LOG.debug(_('Fanout notify agent at %(topic)s the message '
                     '%(method)s on router %(router_id)s'),
                   {'topic': topics.DHCP_AGENT,
index 14496037d8547e20519de184d78cb083e8046603..fa3e81cfbb276b2189bc05cab8a3ec837bc63ff6 100644 (file)
@@ -32,7 +32,7 @@ SHARED = 'shared'
 
 
 def _verify_dict_keys(expected_keys, target_dict, strict=True):
-    """ Allows to verify keys in a dictionary.
+    """Allows to verify keys in a dictionary.
     :param expected_keys: A list of keys expected to be present.
     :param target_dict: The dictionary which should be verified.
     :param strict: Specifies whether additional keys are allowed to be present.
index 8ddb1911890222e55797a9acdfb7e07a81bb8339..33b16973b458078c88a29404592c7f9232597cb5 100644 (file)
@@ -181,7 +181,7 @@ class Controller(object):
         return api_common.NoSortingHelper(request, self._attr_info)
 
     def _items(self, request, do_authz=False, parent_id=None):
-        """Retrieves and formats a list of elements of the requested entity"""
+        """Retrieves and formats a list of elements of the requested entity."""
         # NOTE(salvatore-orlando): The following ensures that fields which
         # are needed for authZ policy validation are not stripped away by the
         # plugin before returning.
@@ -227,7 +227,7 @@ class Controller(object):
 
     def _item(self, request, id, do_authz=False, field_list=None,
               parent_id=None):
-        """Retrieves and formats a single element of the requested entity"""
+        """Retrieves and formats a single element of the requested entity."""
         kwargs = {'fields': field_list}
         action = self._plugin_handlers[self.SHOW]
         if parent_id:
@@ -246,12 +246,12 @@ class Controller(object):
             self._dhcp_agent_notifier.notify(context, data, methodname)
 
     def index(self, request, **kwargs):
-        """Returns a list of the requested entity"""
+        """Returns a list of the requested entity."""
         parent_id = kwargs.get(self._parent_id_name)
         return self._items(request, True, parent_id)
 
     def show(self, request, id, **kwargs):
-        """Returns detailed information about the requested entity"""
+        """Returns detailed information about the requested entity."""
         try:
             # NOTE(salvatore-orlando): The following ensures that fields
             # which are needed for authZ policy validation are not stripped
@@ -304,7 +304,7 @@ class Controller(object):
             raise ex
 
     def create(self, request, body=None, **kwargs):
-        """Creates a new instance of the requested entity"""
+        """Creates a new instance of the requested entity."""
         parent_id = kwargs.get(self._parent_id_name)
         notifier_api.notify(request.context,
                             self._publisher_id,
@@ -382,7 +382,7 @@ class Controller(object):
                 return notify({self._resource: self._view(obj)})
 
     def delete(self, request, id, **kwargs):
-        """Deletes the specified entity"""
+        """Deletes the specified entity."""
         notifier_api.notify(request.context,
                             self._publisher_id,
                             self._resource + '.delete.start',
@@ -417,7 +417,7 @@ class Controller(object):
                                      notifier_method)
 
     def update(self, request, id, body=None, **kwargs):
-        """Updates the specified entity's attributes"""
+        """Updates the specified entity's attributes."""
         parent_id = kwargs.get(self._parent_id_name)
         try:
             payload = body.copy()
@@ -492,7 +492,7 @@ class Controller(object):
     @staticmethod
     def prepare_request_body(context, body, is_create, resource, attr_info,
                              allow_bulk=False):
-        """ verifies required attributes are in request body, and that
+        """Verifies required attributes are in request body, and that
             an attribute is only specified if it is allowed for the given
             operation (create/update).
             Attribute with default values are considered to be
index a381db9a2a6a837d7ae8b5a1e84f28d9d656fe12..06803873c92806461bf910e55a92ba873ba69b0d 100644 (file)
@@ -25,7 +25,8 @@ LOG = logging.getLogger(__name__)
 
 class PluginRpcDispatcher(dispatcher.RpcDispatcher):
     """This class is used to convert RPC common context into
-    Quantum Context."""
+    Quantum Context.
+    """
 
     def __init__(self, callbacks):
         super(PluginRpcDispatcher, self).__init__(callbacks)
index e6c440c4c56f727e87742d990f1c3d48917ba820..21e82272a6113b50cee969ff1b39ccaee35c4268 100644 (file)
@@ -77,7 +77,7 @@ class _AnsiColorizer(object):
                 except curses.error:
                     curses.setupterm()
                     return curses.tigetnum("colors") > 2
-            except:
+            except Exception:
                 raise
                 # guess false in case of error
                 return False
index 6df3cce898dbabf1eba22949888c3a083139d564..8c3467a844c516e4faec27105bba248071f04f11 100644 (file)
@@ -154,7 +154,7 @@ def get_hostname():
 
 
 def compare_elements(a, b):
-    """ compare elements if a and b have same elements
+    """Compare elements if a and b have same elements.
 
     This method doesn't consider ordering
     """
index 90f8cf504f51b8324b7c6092710272c9595d9b91..055380bcf49bb058410d82739ddf1d4a89eaa8e0 100644 (file)
@@ -34,7 +34,7 @@ cfg.CONF.register_opt(
 
 
 class Agent(model_base.BASEV2, models_v2.HasId):
-    """Represents agents running in quantum deployments"""
+    """Represents agents running in quantum deployments."""
 
     # L3 agent, DHCP agent, OVS agent, LinuxBridge
     agent_type = sa.Column(sa.String(255), nullable=False)
@@ -162,7 +162,7 @@ class AgentExtRpcCallback(object):
     START_TIME = timeutils.utcnow()
 
     def report_state(self, context, **kwargs):
-        """Report state from agent to server. """
+        """Report state from agent to server."""
         time = kwargs['time']
         time = timeutils.parse_strtime(time)
         if self.START_TIME > time:
index c84d7fa95d25a83a4c6065017f5eecb7c803920b..2fcaa0c43aa7f4655a5f79d11428325ad56ff984 100644 (file)
@@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
 
 
 class NetworkDhcpAgentBinding(model_base.BASEV2):
-    """Represents binding between quantum networks and DHCP agents"""
+    """Represents binding between quantum networks and DHCP agents."""
     network_id = sa.Column(sa.String(36),
                            sa.ForeignKey("networks.id", ondelete='CASCADE'),
                            primary_key=True)
@@ -44,7 +44,7 @@ class NetworkDhcpAgentBinding(model_base.BASEV2):
 
 
 class RouterL3AgentBinding(model_base.BASEV2, models_v2.HasId):
-    """Represents binding between quantum routers and L3 agents"""
+    """Represents binding between quantum routers and L3 agents."""
     router_id = sa.Column(sa.String(36),
                           sa.ForeignKey("routers.id", ondelete='CASCADE'))
     l3_agent = orm.relation(agents_db.Agent)
@@ -194,7 +194,8 @@ class AgentSchedulerDbMixin(agentscheduler.AgentSchedulerPluginBase,
     def remove_router_from_l3_agent(self, context, id, router_id):
         """Remove the router from l3 agent. After it, the router
         will be non-hosted until there is update which
-        lead to re schedule or be added to another agent manually."""
+        lead to re schedule or be added to another agent manually.
+        """
         agent = self._get_agent(context, id)
         with context.session.begin(subtransactions=True):
             query = context.session.query(RouterL3AgentBinding)
@@ -321,7 +322,7 @@ class AgentSchedulerDbMixin(agentscheduler.AgentSchedulerPluginBase,
         return l3_agents
 
     def get_l3_agent_candidates(self, sync_router, l3_agents):
-        """Get the valid l3 agents for the router from a list of l3_agents"""
+        """Get the valid l3 agents for the router from a list of l3_agents."""
         candidates = []
         for l3_agent in l3_agents:
             if not l3_agent.admin_state_up:
index 2629b29379250aca5487ed97584ee3096eb709b4..826b93efe84bb94784dd72f4039531de28759439 100644 (file)
@@ -120,7 +120,7 @@ def configure_db():
         if not sql_connection:
             LOG.warn(_("Option 'sql_connection' not specified "
                        "in any config file - using default "
-                       "value '%s'" % SQL_CONNECTION_DEFAULT))
+                       "value '%s'") % SQL_CONNECTION_DEFAULT)
             sql_connection = SQL_CONNECTION_DEFAULT
         connection_dict = sql.engine.url.make_url(sql_connection)
         engine_args = {
@@ -185,7 +185,7 @@ def clear_db(base=BASE):
 
 
 def get_session(autocommit=True, expire_on_commit=False):
-    """Helper method to grab session"""
+    """Helper method to grab session."""
     global _MAKER, _ENGINE
     if not _MAKER:
         assert _ENGINE
@@ -213,7 +213,7 @@ def retry_registration(remaining, reconnect_interval, base=BASE):
 
 
 def register_models(base=BASE):
-    """Register Models and create properties"""
+    """Register Models and create properties."""
     global _ENGINE
     assert _ENGINE
     try:
@@ -225,7 +225,7 @@ def register_models(base=BASE):
 
 
 def unregister_models(base=BASE):
-    """Unregister Models, useful clearing out data before testing"""
+    """Unregister Models, useful clearing out data before testing."""
     global _ENGINE
     assert _ENGINE
     base.metadata.drop_all(_ENGINE)
index 6182c45e2451089bd708c1fb53c2069b18265707..54307b68c106f5aae4e9de2b3ae1def54ae7238a 100644 (file)
@@ -50,7 +50,7 @@ AUTO_DELETE_PORT_OWNERS = ['network:dhcp']
 
 
 class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
-    """ A class that implements the v2 Quantum plugin interface
+    """A class that implements the v2 Quantum plugin interface
         using SQLAlchemy models.  Whenever a non-read call happens
         the plugin will call an event handler class method (e.g.,
         network_created()).  The result is that this class can be
@@ -120,7 +120,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
     @classmethod
     def register_model_query_hook(cls, model, name, query_hook, filter_hook,
                                   result_filters=None):
-        """ register an hook to be invoked when a query is executed.
+        """Register a hook to be invoked when a query is executed.
 
         Add the hooks to the _model_query_hooks dict. Models are the keys
         of this dict, whereas the value is another dict mapping hook names to
@@ -948,7 +948,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         return self._create_bulk('network', context, networks)
 
     def create_network(self, context, network):
-        """ handle creation of a single network """
+        """Handle creation of a single network."""
         # single request processing
         n = network['network']
         # NOTE(jkoelker) Get the tenant_id outside of the session to avoid
@@ -1026,7 +1026,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         return self._create_bulk('subnet', context, subnets)
 
     def _validate_ip_version(self, ip_version, addr, name):
-        """Check IP field of a subnet match specified ip version"""
+        """Check IP field of a subnet match specified ip version."""
         ip = netaddr.IPNetwork(addr)
         if ip.version != ip_version:
             msg = _("%(name)s '%(addr)s' does not match "
@@ -1034,7 +1034,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             raise q_exc.InvalidInput(error_message=msg)
 
     def _validate_subnet(self, s):
-        """Validate a subnet spec"""
+        """Validate a subnet spec."""
 
         # This method will validate attributes which may change during
         # create_subnet() and update_subnet().
@@ -1155,7 +1155,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
     def update_subnet(self, context, id, subnet):
         """Update the subnet with new info. The change however will not be
            realized until the client renew the dns lease or we support
-           gratuitous DHCP offers"""
+           gratuitous DHCP offers
+        """
 
         s = subnet['subnet']
         db_subnet = self._get_subnet(context, id)
index 82425278d82a8ae8ae562c5110a2c0366158ab1a..57f80435af1728ccbe16576f60f96f3b85b40378 100644 (file)
@@ -46,7 +46,7 @@ class RouterRoute(model_base.BASEV2, models_v2.Route):
 
 
 class ExtraRoute_db_mixin(l3_db.L3_NAT_db_mixin):
-    """ Mixin class to support extra route configuration on router"""
+    """Mixin class to support extra route configuration on router."""
     def update_router(self, context, id, router):
         r = router['router']
         with context.session.begin(subtransactions=True):
index 48e202f57ca4a3abafe2191320dad74566c6fede..bb36882e6f2474cce949ed8240bd73a7460d563b 100644 (file)
@@ -75,7 +75,7 @@ class FloatingIP(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
 
 
 class L3_NAT_db_mixin(l3.RouterPluginBase):
-    """Mixin class to add L3/NAT router methods to db_plugin_base_v2"""
+    """Mixin class to add L3/NAT router methods to db_plugin_base_v2."""
 
     def _network_model_hook(self, context, original_model, query):
         query = query.outerjoin(ExternalNetwork,
@@ -716,7 +716,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
                                           filters=filters)
 
     def prevent_l3_port_deletion(self, context, port_id):
-        """ Checks to make sure a port is allowed to be deleted, raising
+        """Checks to make sure a port is allowed to be deleted, raising
         an exception if this is not the case.  This should be called by
         any plugin when the API requests the deletion of a port, since
         some ports for L3 are not intended to be deleted directly via a
index 031a5a09af984e34bd19acb980cefaee7507abed..ee504059aa915b22341b6dbc5c0b614bcc2d913b 100644 (file)
@@ -48,7 +48,7 @@ class SessionPersistence(model_base.BASEV2):
 
 
 class PoolStatistics(model_base.BASEV2):
-    """Represents pool statistics """
+    """Represents pool statistics."""
     pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
                         primary_key=True)
     bytes_in = sa.Column(sa.Integer, nullable=False)
@@ -274,7 +274,7 @@ class LoadBalancerPluginDb(LoadBalancerPluginBase):
         return self._fields(res, fields)
 
     def _check_session_persistence_info(self, info):
-        """ Performs sanity check on session persistence info.
+        """Performs sanity check on session persistence info.
         :param info: Session persistence info
         """
         if info['type'] == 'APP_COOKIE':
index 194fdb96d2e2e1e890dd9d3d2a887ecb3c059bc1..51b762b5052c2be9d8fcddf809181f7ccb93a271 100644 (file)
@@ -39,13 +39,14 @@ class QuantumBase(object):
         return n, getattr(self, n)
 
     def update(self, values):
-        """Make the model object behave like a dict"""
+        """Make the model object behave like a dict."""
         for k, v in values.iteritems():
             setattr(self, k, v)
 
     def iteritems(self):
         """Make the model object behave like a dict.
-        Includes attributes from joins."""
+        Includes attributes from joins.
+        """
         local = dict(self)
         joined = dict([(k, v) for k, v in self.__dict__.iteritems()
                        if not k[0] == '_'])
@@ -53,7 +54,7 @@ class QuantumBase(object):
         return local.iteritems()
 
     def __repr__(self):
-        """sqlalchemy based automatic __repr__ method"""
+        """sqlalchemy based automatic __repr__ method."""
         items = ['%s=%r' % (col.name, getattr(self, col.name))
                  for col in self.__table__.columns]
         return "<%s.%s[object at %x] {%s}>" % (self.__class__.__module__,
index c2b42b50fd5ceb7f174af6220af86999b6c37bf1..285f80d726d648b131659bedf0fb60653c6dbd26 100644 (file)
@@ -35,7 +35,7 @@ class SecurityGroup(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
 
 
 class SecurityGroupPortBinding(model_base.BASEV2):
-    """Represents binding between quantum ports and security profiles"""
+    """Represents binding between quantum ports and security profiles."""
     port_id = sa.Column(sa.String(36),
                         sa.ForeignKey("ports.id",
                                       ondelete='CASCADE'),
@@ -450,7 +450,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
 
     def _check_update_deletes_security_groups(self, port):
         """Return True if port has as a security group and it's value
-        is either [] or not is_attr_set, otherwise return False"""
+        is either [] or not is_attr_set, otherwise return False
+        """
         if (ext_sg.SECURITYGROUPS in port['port'] and
             not (attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS])
                  and port['port'][ext_sg.SECURITYGROUPS] != [])):
@@ -459,7 +460,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
 
     def _check_update_has_security_groups(self, port):
         """Return True if port has as a security group and False if the
-        security_group field is is_attr_set or []."""
+        security_group field is is_attr_set or [].
+        """
         if (ext_sg.SECURITYGROUPS in port['port'] and
             (attr.is_attr_set(port['port'][ext_sg.SECURITYGROUPS]) and
              port['port'][ext_sg.SECURITYGROUPS] != [])):
index 78a4c7e7b72e0ec534046a9feafc83713c485980..7c15ea5015bae63f68de79c8eb0d5cc7b8ede2b6 100644 (file)
@@ -63,7 +63,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
 
     def update_security_group_on_port(self, context, id, port,
                                       original_port, updated_port):
-        """ update security groups on port
+        """Update security groups on port.
 
         This method returns a flag which indicates request notification
         is required and does not perform notification itself.
@@ -85,7 +85,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
 
     def is_security_group_member_updated(self, context,
                                          original_port, updated_port):
-        """ check security group member updated or not
+        """Check security group member updated or not.
 
         This method returns a flag which indicates request notification
         is required and does not perform notification itself.
@@ -102,7 +102,7 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
         return need_notify
 
     def notify_security_groups_member_updated(self, context, port):
-        """ notify update event of security group members
+        """Notify update event of security group members.
 
         The agent setups the iptables rule to allow
         ingress packet from the dhcp server (as a part of provider rules),
@@ -126,7 +126,7 @@ class SecurityGroupServerRpcCallbackMixin(object):
     """
 
     def security_group_rules_for_devices(self, context, **kwargs):
-        """ return security group rules for each port
+        """Return security group rules for each port.
 
         also convert remote_group_id rule
         to source_ip_prefix and dest_ip_prefix rule
index fff5f6356546aafa56eef3f6dd0568bfc67218a0..bfd95d492c0a7fe0cc9344ea1d52ae6da4ee66bc 100644 (file)
@@ -48,7 +48,7 @@ cfg.CONF.register_opts(default_servicetype_opts, 'DEFAULT_SERVICETYPE')
 
 
 def parse_service_definition_opt():
-    """ parse service definition opts and returns result """
+    """Parse service definition opts and returns result."""
     results = []
     svc_def_opt = cfg.CONF.DEFAULT_SERVICETYPE.service_definition
     try:
@@ -96,7 +96,7 @@ class ServiceDefinition(model_base.BASEV2, models_v2.HasId):
 
 
 class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
-    """ Service Type Object Model """
+    """Service Type Object Model."""
     name = sa.Column(sa.String(255))
     description = sa.Column(sa.String(255))
     default = sa.Column(sa.Boolean(), nullable=False, default=False)
@@ -108,7 +108,7 @@ class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
     num_instances = sa.Column(sa.Integer(), default=0)
 
     def as_dict(self):
-        """ Convert a row into a dict """
+        """Convert a row into a dict."""
         ret_dict = {}
         for c in self.__table__.columns:
             ret_dict[c.name] = getattr(self, c.name)
@@ -116,7 +116,7 @@ class ServiceType(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
 
 
 class ServiceTypeManager(object):
-    """ Manage service type objects in Quantum database """
+    """Manage service type objects in Quantum database."""
 
     _instance = None
 
@@ -254,13 +254,13 @@ class ServiceTypeManager(object):
         return res
 
     def get_service_type(self, context, id, fields=None):
-        """ Retrieve a service type record """
+        """Retrieve a service type record."""
         return self._make_svc_type_dict(context,
                                         self._get_service_type(context, id),
                                         fields)
 
     def get_service_types(self, context, fields=None, filters=None):
-        """ Retrieve a possibly filtered list of service types """
+        """Retrieve a possibly filtered list of service types."""
         query = context.session.query(ServiceType)
         if filters:
             for key, value in filters.iteritems():
@@ -271,21 +271,21 @@ class ServiceTypeManager(object):
                 for svc_type in query.all()]
 
     def create_service_type(self, context, service_type):
-        """ Create a new service type """
+        """Create a new service type."""
         svc_type_data = service_type['service_type']
         svc_type_db = self._create_service_type(context, svc_type_data)
         LOG.debug(_("Created service type object:%s"), svc_type_db['id'])
         return self._make_svc_type_dict(context, svc_type_db)
 
     def update_service_type(self, context, id, service_type):
-        """ Update a service type """
+        """Update a service type."""
         svc_type_data = service_type['service_type']
         svc_type_db = self._update_service_type(context, id,
                                                 svc_type_data)
         return self._make_svc_type_dict(context, svc_type_db)
 
     def delete_service_type(self, context, id):
-        """ Delete a service type """
+        """Delete a service type."""
         # Verify that the service type is not in use.
         svc_type_db = self._get_service_type(context, id)
         if svc_type_db['num_instances'] > 0:
@@ -294,7 +294,7 @@ class ServiceTypeManager(object):
             context.session.delete(svc_type_db)
 
     def increase_service_type_refcount(self, context, id):
-        """ Increase references count for a service type object
+        """Increase references count for a service type object
 
         This method should be invoked by plugins using the service
         type concept everytime an instance of an object associated
@@ -309,7 +309,7 @@ class ServiceTypeManager(object):
         return svc_type_db['num_instances']
 
     def decrease_service_type_refcount(self, context, id):
-        """ Decrease references count for a service type object
+        """Decrease references count for a service type object
 
         This method should be invoked by plugins using the service
         type concept everytime an instance of an object associated
index e6f2f0a8494cf16067d880328042751f1782c506..079eef28aa08a3005f6c22050a24f1768155bd41 100644 (file)
@@ -59,7 +59,7 @@ class CreateProbe(ProbeCommand):
 
 
 class DeleteProbe(ProbeCommand):
-    """Delete probe - delete port then uplug """
+    """Delete probe - delete port then uplug."""
 
     log = logging.getLogger(__name__ + '.DeleteProbe')
 
@@ -78,7 +78,7 @@ class DeleteProbe(ProbeCommand):
 
 
 class ListProbe(QuantumCommand, lister.Lister):
-    """ List probes """
+    """List probes."""
 
     log = logging.getLogger(__name__ + '.ListProbe')
     _formatters = {'fixed_ips': _format_fixed_ips, }
@@ -97,7 +97,7 @@ class ListProbe(QuantumCommand, lister.Lister):
 
 
 class ClearProbe(ProbeCommand):
-    """Clear All probes """
+    """Clear All probes."""
 
     log = logging.getLogger(__name__ + '.ClearProbe')
 
index 8701c73f3b94a16326b9a6dec7e611b0873b45ed..ba32f71944c550d1d2be966b1d300ac6f978f31d 100644 (file)
@@ -124,7 +124,7 @@ class QuantumDebugAgent():
                                namespace=namespace)
             try:
                 ip.netns.delete(namespace)
-            except:
+            except Exception:
                 LOG.warn(_('Failed to delete namespace %s'), namespace)
         else:
             self.driver.unplug(self.driver.get_device_name(port),
index 4300682552972df80e3b862ea0686bce5030ba19..f466f4789d94f396d6ffcace9957c05f0db4de3a 100644 (file)
@@ -72,7 +72,7 @@ class MultipleAgentFoundByTypeHost(exceptions.Conflict):
 
 
 class Agent(object):
-    """Agent management extension"""
+    """Agent management extension."""
 
     @classmethod
     def get_name(cls):
@@ -96,7 +96,7 @@ class Agent(object):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
         attr.PLURALS.update(dict(my_plurals))
         plugin = manager.QuantumManager.get_plugin()
@@ -116,13 +116,13 @@ class Agent(object):
 
 
 class AgentPluginBase(object):
-    """ REST API to operate the Agent.
+    """REST API to operate the Agent.
 
     All of method must be in an admin context.
     """
 
     def create_agent(self, context, agent):
-        """ Create agent.
+        """Create agent.
 
         This operation is not allow in REST API.
         @raise exceptions.BadRequest:
index adf430c23fa60f4a1d8f57b8aea561b7c0e76fa1..f5b072f8b992708def8ccb72d38b1a6865e10e24 100644 (file)
@@ -145,7 +145,7 @@ class Agentscheduler(extensions.ExtensionDescriptor):
 
     @classmethod
     def get_resources(cls):
-        """Returns Ext Resources """
+        """Returns Ext Resources."""
         exts = []
         parent = dict(member_name="agent",
                       collection_name="agents")
@@ -214,7 +214,7 @@ class RouterNotHostedByL3Agent(exceptions.Conflict):
 
 
 class AgentSchedulerPluginBase(object):
-    """ REST API to operate the agent scheduler.
+    """REST API to operate the agent scheduler.
 
     All of method must be in an admin context.
     """
index e430e9310f652dbc7acf26330205256ddea664eb..d91cde1036ade401b495599ba6816befc7b6a21a 100644 (file)
@@ -187,7 +187,7 @@ class L3(extensions.ExtensionDescriptor):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
         attr.PLURALS.update(dict(my_plurals))
         exts = []
index eb981ceb35f4a0951b6bacc81ad2e387bc93ace9..d49ffd3c4b148e4b053121ef3bbd72e9da3cb95a 100644 (file)
@@ -104,7 +104,7 @@ class QuotaSetsController(wsgi.Controller):
 
 
 class Quotasv2(extensions.ExtensionDescriptor):
-    """Quotas management support"""
+    """Quotas management support."""
 
     @classmethod
     def get_name(cls):
@@ -131,7 +131,7 @@ class Quotasv2(extensions.ExtensionDescriptor):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         controller = resource.Resource(
             QuotaSetsController(QuantumManager.get_plugin()),
             faults=base.FAULT_MAP)
index 8162218a6fa82ab34d397cd164096225ecb2e899..de4f0664a30d443d714808bc8b4839d3efd58368 100644 (file)
@@ -216,7 +216,7 @@ cfg.CONF.register_opts(security_group_quota_opts, 'QUOTAS')
 
 
 class Securitygroup(extensions.ExtensionDescriptor):
-    """ Security group extension"""
+    """Security group extension."""
 
     @classmethod
     def get_name(cls):
@@ -241,7 +241,7 @@ class Securitygroup(extensions.ExtensionDescriptor):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
         attr.PLURALS.update(dict(my_plurals))
         exts = []
index 0468d1f885b49db8ca8b9e74d0da714d62af7229..270bbb5dbfb5fb14519cc2fefde18125314c36a6 100644 (file)
@@ -72,7 +72,7 @@ def set_default_svctype_id(original_id):
 
 
 def _validate_servicetype_ref(data, valid_values=None):
-    """ Verify the service type id exists """
+    """Verify the service type id exists."""
     svc_type_id = data
     svctype_mgr = servicetype_db.ServiceTypeManager.get_instance()
     try:
@@ -83,7 +83,7 @@ def _validate_servicetype_ref(data, valid_values=None):
 
 
 def _validate_service_defs(data, valid_values=None):
-    """ Validate the list of service definitions. """
+    """Validate the list of service definitions."""
     try:
         if not data:
             return _("No service type definition was provided. At least a "
@@ -182,7 +182,7 @@ class Servicetype(extensions.ExtensionDescriptor):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Extended Resource for service type management """
+        """Returns Extended Resource for service type management."""
         my_plurals = [(key.replace('-', '_'),
                        key[:-1].replace('-', '_')) for
                       key in RESOURCE_ATTRIBUTE_MAP.keys()]
index c7cc8a13e8a9f317c02e64599a25c77131ec1595..f9430cbd54b4e1fe2eda697b9857f24d5b086749 100644 (file)
@@ -97,7 +97,7 @@ class QuantumManager(object):
 
         # core plugin as a part of plugin collection simplifies
         # checking extensions
-        # TODO (enikanorov): make core plugin the same as
+        # TODO(enikanorov): make core plugin the same as
         # the rest of service plugins
         self.service_plugins = {constants.CORE: self.plugin}
         self._load_service_plugins()
index 9239c25adf1608c636f9b52d68ae7f83afc4ef2e..849c38e26f2a5f8b046045d8b178168d116ca6b5 100644 (file)
@@ -789,7 +789,7 @@ class QuantumRestProxyV2(db_base_plugin_v2.QuantumDbPluginV2,
         try:
             self._send_update_network(orig_net)
         except RemoteRestError:
-            # TODO (Sumit): rollback deletion of subnet
+            # TODO(Sumit): rollback deletion of subnet
             raise
 
     def create_router(self, context, router):
index 26afa6a170eeeb582246034597ad5a114945a053..5b38dcb2a4830962916d1019d7062067ddaad7bc 100755 (executable)
@@ -120,7 +120,7 @@ class TestNetworkCtrl(object):
                 if request_data:
                     try:
                         request_data = json.loads(request_data)
-                    except:
+                    except Exception:
                         # OK for it not to be json! Ignore it
                         pass
 
@@ -141,7 +141,7 @@ class TestNetworkCtrl(object):
             if body:
                 try:
                     body_data = json.loads(body)
-                except:
+                except Exception:
                     # OK for it not to be json! Ignore it
                     pass
 
index 895a967ef60fc41e95244abddd0e531d2f2746bb..5639dc40ed582bf9c4ae716f07c30a8b1a9f8187 100644 (file)
@@ -20,7 +20,7 @@
 # Varma Bhupatiraju (vbhupati@#brocade.com)
 #
 # (Some parts adapted from LinuxBridge Plugin)
-# TODO (shiv) need support for security groups
+# TODO(shiv) need support for security groups
 
 
 """
index be0c7880fadcf3195432e6fc05b6e00183e17ce5..c8362a13b76f3a2e797db085e6aef432ffd333d3 100644 (file)
@@ -66,7 +66,8 @@ class NOSdriver():
             LOG.debug(_("Connect failed to switch: %s"), e)
             raise
 
-        LOG.debug(_("Connect success to host %s:%d"), host, SSH_PORT)
+        LOG.debug(_("Connect success to host %(host)s:%(ssh_port)d"),
+                  dict(host=host, ssh_port=SSH_PORT))
         return mgr
 
     def create_network(self, host, username, password, net_id):
index 203c2498e2a4484867017ffc5b84b5ae48fe3820..bfc8a76c5588b7c10215a70badb6b10e402517da 100644 (file)
@@ -18,9 +18,9 @@
 
 import logging as LOG
 
-from quantum.plugins.cisco.common import config
 from quantum.plugins.cisco.common import cisco_constants as const
 from quantum.plugins.cisco.common import cisco_exceptions as cexc
+from quantum.plugins.cisco.common import config
 from quantum.plugins.cisco.db import network_db_v2 as cdb
 
 
@@ -33,7 +33,7 @@ _nexus_dict = config.get_nexus_dictionary()
 
 
 class Store(object):
-    """Credential Store"""
+    """Credential Store."""
 
     @staticmethod
     def initialize():
@@ -51,29 +51,29 @@ class Store(object):
 
     @staticmethod
     def put_credential(cred_name, username, password):
-        """Set the username and password"""
+        """Set the username and password."""
         cdb.add_credential(TENANT, cred_name, username, password)
 
     @staticmethod
     def get_username(cred_name):
-        """Get the username"""
+        """Get the username."""
         credential = cdb.get_credential_name(TENANT, cred_name)
         return credential[const.CREDENTIAL_USERNAME]
 
     @staticmethod
     def get_password(cred_name):
-        """Get the password"""
+        """Get the password."""
         credential = cdb.get_credential_name(TENANT, cred_name)
         return credential[const.CREDENTIAL_PASSWORD]
 
     @staticmethod
     def get_credential(cred_name):
-        """Get the username and password"""
+        """Get the username and password."""
         cdb.get_credential_name(TENANT, cred_name)
         return {const.USERNAME: const.CREDENTIAL_USERNAME,
                 const.PASSWORD: const.CREDENTIAL_PASSWORD}
 
     @staticmethod
     def delete_credential(cred_name):
-        """Delete a credential"""
+        """Delete a credential."""
         cdb.remove_credential(TENANT, cred_name)
index cf1d2020635ba99fc0b390078813b9779651f452..de400582f78e302e9e75156baf39c801cdad12ca 100644 (file)
@@ -25,116 +25,116 @@ from quantum.common import exceptions
 
 
 class NoMoreNics(exceptions.QuantumException):
-    """No more dynamic nics are available in the system"""
+    """No more dynamic nics are available in the system."""
     message = _("Unable to complete operation. No more dynamic nics are "
                 "available in the system.")
 
 
 class NetworksLimit(exceptions.QuantumException):
-    """Total number of network objects limit has been hit"""
+    """Total number of network objects limit has been hit."""
     message = _("Unable to create new network. Number of networks"
                 "for the system has exceeded the limit")
 
 
 class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
-    """Binding cannot be created, since it already exists"""
+    """Binding cannot be created, since it already exists."""
     message = _("NetworkVlanBinding for %(vlan_id)s and network "
                 "%(network_id)s already exists")
 
 
 class VlanIDNotFound(exceptions.QuantumException):
-    """VLAN ID cannot be found"""
+    """VLAN ID cannot be found."""
     message = _("Vlan ID %(vlan_id)s not found")
 
 
 class VlanIDNotAvailable(exceptions.QuantumException):
-    """No VLAN ID available"""
+    """No VLAN ID available."""
     message = _("No Vlan ID available")
 
 
 class QosNotFound(exceptions.QuantumException):
-    """QoS level with this ID cannot be found"""
+    """QoS level with this ID cannot be found."""
     message = _("QoS level %(qos_id)s could not be found "
                 "for tenant %(tenant_id)s")
 
 
 class QoSLevelInvalidDelete(exceptions.QuantumException):
-    """QoS is associated with a port profile, hence cannot be deleted"""
+    """QoS is associated with a port profile, hence cannot be deleted."""
     message = _("QoS level %(qos_id)s could not be deleted "
                 "for tenant %(tenant_id)s since association exists")
 
 
 class QosNameAlreadyExists(exceptions.QuantumException):
-    """QoS Name already exists"""
+    """QoS Name already exists."""
     message = _("QoS level with name %(qos_name)s already exists "
                 "for tenant %(tenant_id)s")
 
 
 class CredentialNotFound(exceptions.QuantumException):
-    """Credential with this ID cannot be found"""
+    """Credential with this ID cannot be found."""
     message = _("Credential %(credential_id)s could not be found "
                 "for tenant %(tenant_id)s")
 
 
 class CredentialNameNotFound(exceptions.QuantumException):
-    """Credential Name could not be found"""
+    """Credential Name could not be found."""
     message = _("Credential %(credential_name)s could not be found "
                 "for tenant %(tenant_id)s")
 
 
 class CredentialAlreadyExists(exceptions.QuantumException):
-    """Credential ID already exists"""
+    """Credential ID already exists."""
     message = _("Credential %(credential_id)s already exists "
                 "for tenant %(tenant_id)s")
 
 
 class NexusPortBindingNotFound(exceptions.QuantumException):
-    """NexusPort Binding is not present"""
+    """NexusPort Binding is not present."""
     message = _("Nexus Port Binding %(port_id)s is not present")
 
 
 class NexusPortBindingAlreadyExists(exceptions.QuantumException):
-    """NexusPort Binding alredy exists"""
+    """NexusPort Binding alredy exists."""
     message = _("Nexus Port Binding %(port_id)s already exists")
 
 
 class UcsmBindingNotFound(exceptions.QuantumException):
-    """Ucsm Binding is not present"""
+    """Ucsm Binding is not present."""
     message = _("Ucsm Binding with ip %(ucsm_ip)s is not present")
 
 
 class UcsmBindingAlreadyExists(exceptions.QuantumException):
-    """Ucsm Binding already exists"""
+    """Ucsm Binding already exists."""
     message = _("Ucsm Binding with ip %(ucsm_ip)s already exists")
 
 
 class DynamicVnicNotFound(exceptions.QuantumException):
-    """Ucsm Binding is not present"""
+    """Ucsm Binding is not present."""
     message = _("Dyanmic Vnic %(vnic_id)s is not present")
 
 
 class DynamicVnicAlreadyExists(exceptions.QuantumException):
-    """Ucsm Binding already exists"""
+    """Ucsm Binding already exists."""
     message = _("Dynamic Vnic with name %(device_name)s already exists")
 
 
 class BladeNotFound(exceptions.QuantumException):
-    """Blade is not present"""
+    """Blade is not present."""
     message = _("Blade %(blade_id)s is not present")
 
 
 class BladeAlreadyExists(exceptions.QuantumException):
-    """Blade already exists"""
+    """Blade already exists."""
     message = _("Blade with mgmt_ip %(mgmt_ip)s already exists")
 
 
 class PortVnicBindingAlreadyExists(exceptions.QuantumException):
-    """PortVnic Binding already exists"""
+    """PortVnic Binding already exists."""
     message = _("PortVnic Binding %(port_id)s already exists")
 
 
 class PortVnicNotFound(exceptions.QuantumException):
-    """PortVnic Binding is not present"""
+    """PortVnic Binding is not present."""
     message = _("PortVnic Binding %(port_id)s is not present")
 
 
index 48d9001ae90c2300c6f1f992d229ede28b880602..2ffc984a054ab99e9a40143b901e352dde27f2b7 100644 (file)
@@ -22,7 +22,7 @@ from quantum import wsgi
 
 
 class Fault(webob.exc.HTTPException):
-    """Error codes for API faults"""
+    """Error codes for API faults."""
 
     _fault_names = {
         400: "malformedRequest",
@@ -42,7 +42,8 @@ class Fault(webob.exc.HTTPException):
     @webob.dec.wsgify(RequestClass=wsgi.Request)
     def __call__(self, req):
         """Generate a WSGI response based on the
-         exception passed to constructor."""
+         exception passed to constructor.
+        """
         # Replace the body with fault details.
         code = self.wrapped_exc.status_int
         fault_name = self._fault_names.get(code, "quantumServiceFault")
index 080493250d57271c877ea55aef3b5071a4567828..7baa1d687ae7e4cbf391bc7d7eeb5ec9ae0b6d43 100644 (file)
@@ -34,14 +34,14 @@ def get16ByteUUID(uuid):
 
 
 def make_net_dict(net_id, net_name, ports):
-    """Helper funciton"""
+    """Helper funciton."""
     res = {const.NET_ID: net_id, const.NET_NAME: net_name}
     res[const.NET_PORTS] = ports
     return res
 
 
 def make_port_dict(port_id, port_state, net_id, attachment):
-    """Helper funciton"""
+    """Helper funciton."""
     res = {const.PORT_ID: port_id, const.PORT_STATE: port_state}
     res[const.NET_ID] = net_id
     res[const.ATTACHMENT] = attachment
index ba6bbc554a372ffceb0698a2b7dbec31afa341ef..d9ad2a60ff589a18b81846607287b42ddb5842ef 100644 (file)
@@ -87,7 +87,7 @@ nexus_dictionary = {}
 
 
 class CiscoConfigOptions():
-    """ Cisco Configuration Options Class """
+    """Cisco Configuration Options Class."""
     def __init__(self):
         self._create_nexus_dictionary()
 
index 708b01661e77b1a67de22672cdc9e2e411eebd4b..7b3018971f5ee9ce444f19635202a9aa420f97e8 100644 (file)
@@ -53,7 +53,7 @@ def clear_db():
 
 
 def get_session(autocommit=True, expire_on_commit=False):
-    """Helper method to grab session"""
+    """Helper method to grab session."""
     global _MAKER, _ENGINE
     if not _MAKER:
         assert _ENGINE
@@ -64,14 +64,14 @@ def get_session(autocommit=True, expire_on_commit=False):
 
 
 def register_models():
-    """Register Models and create properties"""
+    """Register Models and create properties."""
     global _ENGINE
     assert _ENGINE
     BASE.metadata.create_all(_ENGINE)
 
 
 def unregister_models():
-    """Unregister Models, useful clearing out data before testing"""
+    """Unregister Models, useful clearing out data before testing."""
     global _ENGINE
     assert _ENGINE
     BASE.metadata.drop_all(_ENGINE)
index 74b8350c927f8b91823bf9c09b5c08ad40940d06..8c2e87c25511f05eb7b963191cd276ed39faf859 100644 (file)
@@ -30,12 +30,12 @@ LOG = logging.getLogger(__name__)
 
 
 def initialize():
-    """Establish database connection and load models"""
+    """Establish database connection and load models."""
     db.configure_db()
 
 
 def create_vlanids():
-    """Prepopulates the vlan_bindings table"""
+    """Prepopulates the vlan_bindings table."""
     LOG.debug(_("create_vlanids() called"))
     session = db.get_session()
     try:
@@ -54,7 +54,7 @@ def create_vlanids():
 
 
 def get_all_vlanids():
-    """Gets all the vlanids"""
+    """Gets all the vlanids."""
     LOG.debug(_("get_all_vlanids() called"))
     session = db.get_session()
     try:
@@ -65,7 +65,7 @@ def get_all_vlanids():
 
 
 def is_vlanid_used(vlan_id):
-    """Checks if a vlanid is in use"""
+    """Checks if a vlanid is in use."""
     LOG.debug(_("is_vlanid_used() called"))
     session = db.get_session()
     try:
@@ -77,7 +77,7 @@ def is_vlanid_used(vlan_id):
 
 
 def release_vlanid(vlan_id):
-    """Sets the vlanid state to be unused"""
+    """Sets the vlanid state to be unused."""
     LOG.debug(_("release_vlanid() called"))
     session = db.get_session()
     try:
@@ -93,7 +93,7 @@ def release_vlanid(vlan_id):
 
 
 def delete_vlanid(vlan_id):
-    """Deletes a vlanid entry from db"""
+    """Deletes a vlanid entry from db."""
     LOG.debug(_("delete_vlanid() called"))
     session = db.get_session()
     try:
@@ -107,7 +107,7 @@ def delete_vlanid(vlan_id):
 
 
 def reserve_vlanid():
-    """Reserves the first unused vlanid"""
+    """Reserves the first unused vlanid."""
     LOG.debug(_("reserve_vlanid() called"))
     session = db.get_session()
     try:
@@ -126,7 +126,7 @@ def reserve_vlanid():
 
 
 def get_all_vlanids_used():
-    """Gets all the vlanids used"""
+    """Gets all the vlanids used."""
     LOG.debug(_("get_all_vlanids() called"))
     session = db.get_session()
     try:
@@ -138,7 +138,7 @@ def get_all_vlanids_used():
 
 
 def get_all_vlan_bindings():
-    """Lists all the vlan to network associations"""
+    """Lists all the vlan to network associations."""
     LOG.debug(_("get_all_vlan_bindings() called"))
     session = db.get_session()
     try:
@@ -149,7 +149,7 @@ def get_all_vlan_bindings():
 
 
 def get_vlan_binding(netid):
-    """Lists the vlan given a network_id"""
+    """Lists the vlan given a network_id."""
     LOG.debug(_("get_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -161,7 +161,7 @@ def get_vlan_binding(netid):
 
 
 def add_vlan_binding(vlanid, vlanname, netid):
-    """Adds a vlan to network association"""
+    """Adds a vlan to network association."""
     LOG.debug(_("add_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -177,7 +177,7 @@ def add_vlan_binding(vlanid, vlanname, netid):
 
 
 def remove_vlan_binding(netid):
-    """Removes a vlan to network association"""
+    """Removes a vlan to network association."""
     LOG.debug(_("remove_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -191,7 +191,7 @@ def remove_vlan_binding(netid):
 
 
 def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
-    """Updates a vlan to network association"""
+    """Updates a vlan to network association."""
     LOG.debug(_("update_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -209,7 +209,7 @@ def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
 
 
 def get_all_qoss(tenant_id):
-    """Lists all the qos to tenant associations"""
+    """Lists all the qos to tenant associations."""
     LOG.debug(_("get_all_qoss() called"))
     session = db.get_session()
     try:
@@ -221,7 +221,7 @@ def get_all_qoss(tenant_id):
 
 
 def get_qos(tenant_id, qos_id):
-    """Lists the qos given a tenant_id and qos_id"""
+    """Lists the qos given a tenant_id and qos_id."""
     LOG.debug(_("get_qos() called"))
     session = db.get_session()
     try:
@@ -235,7 +235,7 @@ def get_qos(tenant_id, qos_id):
 
 
 def add_qos(tenant_id, qos_name, qos_desc):
-    """Adds a qos to tenant association"""
+    """Adds a qos to tenant association."""
     LOG.debug(_("add_qos() called"))
     session = db.get_session()
     try:
@@ -252,7 +252,7 @@ def add_qos(tenant_id, qos_name, qos_desc):
 
 
 def remove_qos(tenant_id, qos_id):
-    """Removes a qos to tenant association"""
+    """Removes a qos to tenant association."""
     session = db.get_session()
     try:
         qos = (session.query(l2network_models.QoS).
@@ -266,7 +266,7 @@ def remove_qos(tenant_id, qos_id):
 
 
 def update_qos(tenant_id, qos_id, new_qos_name=None):
-    """Updates a qos to tenant association"""
+    """Updates a qos to tenant association."""
     session = db.get_session()
     try:
         qos = (session.query(l2network_models.QoS).
@@ -283,7 +283,7 @@ def update_qos(tenant_id, qos_id, new_qos_name=None):
 
 
 def get_all_credentials(tenant_id):
-    """Lists all the creds for a tenant"""
+    """Lists all the creds for a tenant."""
     session = db.get_session()
     try:
         creds = (session.query(l2network_models.Credential).
@@ -294,7 +294,7 @@ def get_all_credentials(tenant_id):
 
 
 def get_credential(tenant_id, credential_id):
-    """Lists the creds for given a cred_id and tenant_id"""
+    """Lists the creds for given a cred_id and tenant_id."""
     session = db.get_session()
     try:
         cred = (session.query(l2network_models.Credential).
@@ -307,7 +307,7 @@ def get_credential(tenant_id, credential_id):
 
 
 def get_credential_name(tenant_id, credential_name):
-    """Lists the creds for given a cred_name and tenant_id"""
+    """Lists the creds for given a cred_name and tenant_id."""
     session = db.get_session()
     try:
         cred = (session.query(l2network_models.Credential).
@@ -320,7 +320,7 @@ def get_credential_name(tenant_id, credential_name):
 
 
 def add_credential(tenant_id, credential_name, user_name, password):
-    """Adds a qos to tenant association"""
+    """Adds a qos to tenant association."""
     session = db.get_session()
     try:
         cred = (session.query(l2network_models.Credential).
@@ -337,7 +337,7 @@ def add_credential(tenant_id, credential_name, user_name, password):
 
 
 def remove_credential(tenant_id, credential_id):
-    """Removes a credential from a  tenant"""
+    """Removes a credential from a  tenant."""
     session = db.get_session()
     try:
         cred = (session.query(l2network_models.Credential).
@@ -352,7 +352,7 @@ def remove_credential(tenant_id, credential_id):
 
 def update_credential(tenant_id, credential_id,
                       new_user_name=None, new_password=None):
-    """Updates a credential for a tenant"""
+    """Updates a credential for a tenant."""
     session = db.get_session()
     try:
         cred = (session.query(l2network_models.Credential).
index 45ccc9f1d0f67a792b70e995b648b32bab98f86c..e39ef1e686de747a1d613c4f0021ac2a9c02862a 100644 (file)
@@ -27,35 +27,36 @@ class L2NetworkBase(object):
     __table_args__ = {'mysql_engine': 'InnoDB'}
 
     def __setitem__(self, key, value):
-        """Internal Dict set method"""
+        """Internal Dict set method."""
         setattr(self, key, value)
 
     def __getitem__(self, key):
-        """Internal Dict get method"""
+        """Internal Dict get method."""
         return getattr(self, key)
 
     def get(self, key, default=None):
-        """Dict get method"""
+        """Dict get method."""
         return getattr(self, key, default)
 
     def __iter__(self):
-        """Iterate over table columns"""
+        """Iterate over table columns."""
         self._i = iter(object_mapper(self).columns)
         return self
 
     def next(self):
-        """Next method for the iterator"""
+        """Next method for the iterator."""
         n = self._i.next().name
         return n, getattr(self, n)
 
     def update(self, values):
-        """Make the model object behave like a dict"""
+        """Make the model object behave like a dict."""
         for k, v in values.iteritems():
             setattr(self, k, v)
 
     def iteritems(self):
         """Make the model object behave like a dict"
-        Includes attributes from joins."""
+        Includes attributes from joins.
+        """
         local = dict(self)
         joined = dict([(k, v) for k, v in self.__dict__.iteritems()
                        if not k[0] == '_'])
@@ -64,7 +65,7 @@ class L2NetworkBase(object):
 
 
 class VlanID(BASE, L2NetworkBase):
-    """Represents a vlan_id usage"""
+    """Represents a vlan_id usage."""
     __tablename__ = 'vlan_ids'
 
     vlan_id = Column(Integer, primary_key=True)
@@ -79,7 +80,7 @@ class VlanID(BASE, L2NetworkBase):
 
 
 class VlanBinding(BASE, L2NetworkBase):
-    """Represents a binding of vlan_id to network_id"""
+    """Represents a binding of vlan_id to network_id."""
     __tablename__ = 'vlan_bindings'
 
     vlan_id = Column(Integer, primary_key=True)
@@ -99,7 +100,7 @@ class VlanBinding(BASE, L2NetworkBase):
 
 
 class QoS(BASE, L2NetworkBase):
-    """Represents QoS for a tenant"""
+    """Represents QoS for a tenant."""
     __tablename__ = 'qoss'
 
     qos_id = Column(String(255))
@@ -119,7 +120,7 @@ class QoS(BASE, L2NetworkBase):
 
 
 class Credential(BASE, L2NetworkBase):
-    """Represents credentials for a tenant"""
+    """Represents credentials for a tenant."""
     __tablename__ = 'credentials'
 
     credential_id = Column(String(255))
index 99ae98c5c63a3aa996b3c6ea4bafa44acd5cce3f..82062a659ada60e4317079238e61530157103a30 100644 (file)
@@ -50,13 +50,14 @@ class QuantumBase(object):
         return n, getattr(self, n)
 
     def update(self, values):
-        """Make the model object behave like a dict"""
+        """Make the model object behave like a dict."""
         for k, v in values.iteritems():
             setattr(self, k, v)
 
     def iteritems(self):
         """Make the model object behave like a dict.
-        Includes attributes from joins."""
+        Includes attributes from joins.
+        """
         local = dict(self)
         joined = dict([(k, v) for k, v in self.__dict__.iteritems()
                        if not k[0] == '_'])
@@ -65,7 +66,7 @@ class QuantumBase(object):
 
 
 class Port(BASE, QuantumBase):
-    """Represents a port on a quantum network"""
+    """Represents a port on a quantum network."""
     __tablename__ = 'ports'
 
     uuid = Column(String(255), primary_key=True)
@@ -86,7 +87,7 @@ class Port(BASE, QuantumBase):
 
 
 class Network(BASE, QuantumBase):
-    """Represents a quantum network"""
+    """Represents a quantum network."""
     __tablename__ = 'networks'
 
     uuid = Column(String(255), primary_key=True)
index e5339d4a441ebf96ecc34b6ad37d56129c64972b..f2a089cd1ddd4d172807bfe5f86c5063e5e1ee18 100644 (file)
@@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__)
 
 
 def create_vlanids():
-    """Prepopulates the vlan_bindings table"""
+    """Prepopulates the vlan_bindings table."""
     LOG.debug(_("create_vlanids() called"))
     session = db.get_session()
     try:
@@ -51,7 +51,7 @@ def create_vlanids():
 
 
 def get_all_vlanids():
-    """Gets all the vlanids"""
+    """Gets all the vlanids."""
     LOG.debug(_("get_all_vlanids() called"))
     session = db.get_session()
     try:
@@ -62,7 +62,7 @@ def get_all_vlanids():
 
 
 def is_vlanid_used(vlan_id):
-    """Checks if a vlanid is in use"""
+    """Checks if a vlanid is in use."""
     LOG.debug(_("is_vlanid_used() called"))
     session = db.get_session()
     try:
@@ -74,7 +74,7 @@ def is_vlanid_used(vlan_id):
 
 
 def release_vlanid(vlan_id):
-    """Sets the vlanid state to be unused"""
+    """Sets the vlanid state to be unused."""
     LOG.debug(_("release_vlanid() called"))
     session = db.get_session()
     try:
@@ -90,7 +90,7 @@ def release_vlanid(vlan_id):
 
 
 def delete_vlanid(vlan_id):
-    """Deletes a vlanid entry from db"""
+    """Deletes a vlanid entry from db."""
     LOG.debug(_("delete_vlanid() called"))
     session = db.get_session()
     try:
@@ -104,7 +104,7 @@ def delete_vlanid(vlan_id):
 
 
 def reserve_vlanid():
-    """Reserves the first unused vlanid"""
+    """Reserves the first unused vlanid."""
     LOG.debug(_("reserve_vlanid() called"))
     session = db.get_session()
     try:
@@ -123,7 +123,7 @@ def reserve_vlanid():
 
 
 def get_all_vlanids_used():
-    """Gets all the vlanids used"""
+    """Gets all the vlanids used."""
     LOG.debug(_("get_all_vlanids() called"))
     session = db.get_session()
     try:
@@ -135,7 +135,7 @@ def get_all_vlanids_used():
 
 
 def get_all_vlan_bindings():
-    """Lists all the vlan to network associations"""
+    """Lists all the vlan to network associations."""
     LOG.debug(_("get_all_vlan_bindings() called"))
     session = db.get_session()
     try:
@@ -146,7 +146,7 @@ def get_all_vlan_bindings():
 
 
 def get_vlan_binding(netid):
-    """Lists the vlan given a network_id"""
+    """Lists the vlan given a network_id."""
     LOG.debug(_("get_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -158,7 +158,7 @@ def get_vlan_binding(netid):
 
 
 def add_vlan_binding(vlanid, vlanname, netid):
-    """Adds a vlan to network association"""
+    """Adds a vlan to network association."""
     LOG.debug(_("add_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -174,7 +174,7 @@ def add_vlan_binding(vlanid, vlanname, netid):
 
 
 def remove_vlan_binding(netid):
-    """Removes a vlan to network association"""
+    """Removes a vlan to network association."""
     LOG.debug(_("remove_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -188,7 +188,7 @@ def remove_vlan_binding(netid):
 
 
 def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
-    """Updates a vlan to network association"""
+    """Updates a vlan to network association."""
     LOG.debug(_("update_vlan_binding() called"))
     session = db.get_session()
     try:
@@ -206,7 +206,7 @@ def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
 
 
 def get_all_qoss(tenant_id):
-    """Lists all the qos to tenant associations"""
+    """Lists all the qos to tenant associations."""
     LOG.debug(_("get_all_qoss() called"))
     session = db.get_session()
     try:
@@ -218,7 +218,7 @@ def get_all_qoss(tenant_id):
 
 
 def get_qos(tenant_id, qos_id):
-    """Lists the qos given a tenant_id and qos_id"""
+    """Lists the qos given a tenant_id and qos_id."""
     LOG.debug(_("get_qos() called"))
     session = db.get_session()
     try:
@@ -232,7 +232,7 @@ def get_qos(tenant_id, qos_id):
 
 
 def add_qos(tenant_id, qos_name, qos_desc):
-    """Adds a qos to tenant association"""
+    """Adds a qos to tenant association."""
     LOG.debug(_("add_qos() called"))
     session = db.get_session()
     try:
@@ -249,7 +249,7 @@ def add_qos(tenant_id, qos_name, qos_desc):
 
 
 def remove_qos(tenant_id, qos_id):
-    """Removes a qos to tenant association"""
+    """Removes a qos to tenant association."""
     session = db.get_session()
     try:
         qos = (session.query(network_models_v2.QoS).
@@ -263,7 +263,7 @@ def remove_qos(tenant_id, qos_id):
 
 
 def update_qos(tenant_id, qos_id, new_qos_name=None):
-    """Updates a qos to tenant association"""
+    """Updates a qos to tenant association."""
     session = db.get_session()
     try:
         qos = (session.query(network_models_v2.QoS).
@@ -280,7 +280,7 @@ def update_qos(tenant_id, qos_id, new_qos_name=None):
 
 
 def get_all_credentials(tenant_id):
-    """Lists all the creds for a tenant"""
+    """Lists all the creds for a tenant."""
     session = db.get_session()
     try:
         creds = (session.query(network_models_v2.Credential).
@@ -291,7 +291,7 @@ def get_all_credentials(tenant_id):
 
 
 def get_credential(tenant_id, credential_id):
-    """Lists the creds for given a cred_id and tenant_id"""
+    """Lists the creds for given a cred_id and tenant_id."""
     session = db.get_session()
     try:
         cred = (session.query(network_models_v2.Credential).
@@ -304,7 +304,7 @@ def get_credential(tenant_id, credential_id):
 
 
 def get_credential_name(tenant_id, credential_name):
-    """Lists the creds for given a cred_name and tenant_id"""
+    """Lists the creds for given a cred_name and tenant_id."""
     session = db.get_session()
     try:
         cred = (session.query(network_models_v2.Credential).
@@ -317,7 +317,7 @@ def get_credential_name(tenant_id, credential_name):
 
 
 def add_credential(tenant_id, credential_name, user_name, password):
-    """Adds a qos to tenant association"""
+    """Adds a qos to tenant association."""
     session = db.get_session()
     try:
         cred = (session.query(network_models_v2.Credential).
@@ -334,7 +334,7 @@ def add_credential(tenant_id, credential_name, user_name, password):
 
 
 def remove_credential(tenant_id, credential_id):
-    """Removes a credential from a  tenant"""
+    """Removes a credential from a  tenant."""
     session = db.get_session()
     try:
         cred = (session.query(network_models_v2.Credential).
@@ -349,7 +349,7 @@ def remove_credential(tenant_id, credential_id):
 
 def update_credential(tenant_id, credential_id,
                       new_user_name=None, new_password=None):
-    """Updates a credential for a tenant"""
+    """Updates a credential for a tenant."""
     session = db.get_session()
     try:
         cred = (session.query(network_models_v2.Credential).
index f9c0189875fb0914a510325196db2ef32a58ced3..fadbbfef8a08c101e4058c43d821259c1c5ce10f 100644 (file)
@@ -29,35 +29,36 @@ class L2NetworkBase(object):
     #__table_args__ = {'mysql_engine': 'InnoDB'}
 
     def __setitem__(self, key, value):
-        """Internal Dict set method"""
+        """Internal Dict set method."""
         setattr(self, key, value)
 
     def __getitem__(self, key):
-        """Internal Dict get method"""
+        """Internal Dict get method."""
         return getattr(self, key)
 
     def get(self, key, default=None):
-        """Dict get method"""
+        """Dict get method."""
         return getattr(self, key, default)
 
     def __iter__(self):
-        """Iterate over table columns"""
+        """Iterate over table columns."""
         self._i = iter(object_mapper(self).columns)
         return self
 
     def next(self):
-        """Next method for the iterator"""
+        """Next method for the iterator."""
         n = self._i.next().name
         return n, getattr(self, n)
 
     def update(self, values):
-        """Make the model object behave like a dict"""
+        """Make the model object behave like a dict."""
         for k, v in values.iteritems():
             setattr(self, k, v)
 
     def iteritems(self):
         """Make the model object behave like a dict"
-        Includes attributes from joins."""
+        Includes attributes from joins.
+        """
         local = dict(self)
         joined = dict([(k, v) for k, v in self.__dict__.iteritems()
                        if not k[0] == '_'])
@@ -66,7 +67,7 @@ class L2NetworkBase(object):
 
 
 class VlanID(model_base.BASEV2, L2NetworkBase):
-    """Represents a vlan_id usage"""
+    """Represents a vlan_id usage."""
     __tablename__ = 'cisco_vlan_ids'
 
     vlan_id = Column(Integer, primary_key=True)
@@ -81,7 +82,7 @@ class VlanID(model_base.BASEV2, L2NetworkBase):
 
 
 class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
-    """Represents a binding of vlan_id to network_id"""
+    """Represents a binding of vlan_id to network_id."""
     __tablename__ = 'cisco_vlan_bindings'
 
     vlan_id = Column(Integer, primary_key=True)
@@ -101,7 +102,7 @@ class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
 
 
 class QoS(model_base.BASEV2, L2NetworkBase):
-    """Represents QoS for a tenant"""
+    """Represents QoS for a tenant."""
     __tablename__ = 'qoss'
 
     qos_id = Column(String(255))
@@ -121,7 +122,7 @@ class QoS(model_base.BASEV2, L2NetworkBase):
 
 
 class Credential(model_base.BASEV2, L2NetworkBase):
-    """Represents credentials for a tenant"""
+    """Represents credentials for a tenant."""
     __tablename__ = 'credentials'
 
     credential_id = Column(String(255))
index 0f951204846824101771704299b31cc18c7f4178..bdae9f7b701c23d99c7851cdb0d3532033d2e171 100644 (file)
@@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__)
 
 
 def get_all_nexusport_bindings():
-    """Lists all the nexusport bindings"""
+    """Lists all the nexusport bindings."""
     LOG.debug(_("get_all_nexusport_bindings() called"))
     session = db.get_session()
     try:
@@ -41,7 +41,7 @@ def get_all_nexusport_bindings():
 
 
 def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
-    """Lists a nexusport binding"""
+    """Lists a nexusport binding."""
     LOG.debug(_("get_nexusport_binding() called"))
     session = db.get_session()
     try:
@@ -55,7 +55,7 @@ def get_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
 
 
 def get_nexusvlan_binding(vlan_id, switch_ip):
-    """Lists a vlan and switch binding"""
+    """Lists a vlan and switch binding."""
     LOG.debug(_("get_nexusvlan_binding() called"))
     session = db.get_session()
     try:
@@ -68,7 +68,7 @@ def get_nexusvlan_binding(vlan_id, switch_ip):
 
 
 def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
-    """Adds a nexusport binding"""
+    """Adds a nexusport binding."""
     LOG.debug(_("add_nexusport_binding() called"))
     session = db.get_session()
     binding = nexus_models_v2.NexusPortBinding(
@@ -79,7 +79,7 @@ def add_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
 
 
 def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
-    """Removes a nexusport binding"""
+    """Removes a nexusport binding."""
     LOG.debug(_("remove_nexusport_binding() called"))
     session = db.get_session()
     try:
@@ -97,7 +97,7 @@ def remove_nexusport_binding(port_id, vlan_id, switch_ip, instance_id):
 
 
 def update_nexusport_binding(port_id, new_vlan_id):
-    """Updates nexusport binding"""
+    """Updates nexusport binding."""
     LOG.debug(_("update_nexusport_binding called"))
     session = db.get_session()
     try:
@@ -113,7 +113,7 @@ def update_nexusport_binding(port_id, new_vlan_id):
 
 
 def get_nexusvm_binding(vlan_id, instance_id):
-    """Lists nexusvm bindings"""
+    """Lists nexusvm bindings."""
     LOG.debug(_("get_nexusvm_binding() called"))
     session = db.get_session()
     try:
@@ -126,7 +126,7 @@ def get_nexusvm_binding(vlan_id, instance_id):
 
 
 def get_port_vlan_switch_binding(port_id, vlan_id, switch_ip):
-    """Lists nexusvm bindings"""
+    """Lists nexusvm bindings."""
     LOG.debug(_("get_port_vlan_switch_binding() called"))
     session = db.get_session()
     try:
index e1cfd4b3c98770487e142e2108e61931b2305756..e787c4c863c98189659b65389db02bd4e1e63974 100644 (file)
@@ -22,7 +22,7 @@ from quantum.plugins.cisco.db.l2network_models import L2NetworkBase
 
 
 class NexusPortBinding(model_base.BASEV2, L2NetworkBase):
-    """Represents a binding of VM's to nexus ports"""
+    """Represents a binding of VM's to nexus ports."""
     __tablename__ = "nexusport_bindings"
 
     id = Column(Integer, primary_key=True, autoincrement=True)
index 3a5e7f222211ea1f0fcb25266bc4ab8c8fd2f0f8..4456a7378fa6b5715928ba53ca6d0a253b7a71ff 100644 (file)
@@ -19,7 +19,7 @@
 
 
 def get_view_builder(req):
-    """get view builder """
+    """get view builder."""
     base_url = req.application_url
     return ViewBuilder(base_url)
 
index 354fa413d9865578510e8e11be451096d578fba7..06d8e3178bfe484bb7c8a91ebf20439c3f687541 100644 (file)
@@ -19,7 +19,7 @@
 
 
 def get_view_builder(req):
-    """get view builder"""
+    """get view builder."""
     base_url = req.application_url
     return ViewBuilder(base_url)
 
index 2bf56a2d5df47076f7ab27a55c4b473c8b300ffe..b9d53fc65b2097f9886265863be72426e4ca3953 100644 (file)
@@ -31,36 +31,36 @@ from quantum import wsgi
 
 
 class Credential(extensions.ExtensionDescriptor):
-    """extension class Credential"""
+    """extension class Credential."""
 
     @classmethod
     def get_name(cls):
-        """ Returns Ext Resource Name """
+        """Returns Ext Resource Name."""
         return "Cisco Credential"
 
     @classmethod
     def get_alias(cls):
-        """ Returns Ext Resource Alias """
+        """Returns Ext Resource Alias."""
         return "Cisco Credential"
 
     @classmethod
     def get_description(cls):
-        """ Returns Ext Resource Description """
+        """Returns Ext Resource Description."""
         return "Credential include username and password"
 
     @classmethod
     def get_namespace(cls):
-        """ Returns Ext Resource Namespace """
+        """Returns Ext Resource Namespace."""
         return "http://docs.ciscocloud.com/api/ext/credential/v1.0"
 
     @classmethod
     def get_updated(cls):
-        """ Returns Ext Resource Update Time """
+        """Returns Ext Resource Update Time."""
         return "2011-07-25T13:25:27-06:00"
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         parent_resource = dict(member_name="tenant",
                                collection_name="extensions/csco/tenants")
         controller = CredentialController(QuantumManager.get_plugin())
@@ -69,8 +69,7 @@ class Credential(extensions.ExtensionDescriptor):
 
 
 class CredentialController(common.QuantumController, wsgi.Controller):
-    """ credential API controller
-        based on QuantumController """
+    """Credential API controller based on QuantumController."""
 
     _credential_ops_param_list = [
         {'param-name': 'credential_name', 'required': True},
@@ -91,11 +90,11 @@ class CredentialController(common.QuantumController, wsgi.Controller):
         self._plugin = plugin
 
     def index(self, request, tenant_id):
-        """ Returns a list of credential ids """
+        """Returns a list of credential ids."""
         return self._items(request, tenant_id, is_detail=False)
 
     def _items(self, request, tenant_id, is_detail):
-        """ Returns a list of credentials. """
+        """Returns a list of credentials."""
         credentials = self._plugin.get_all_credentials(tenant_id)
         builder = credential_view.get_view_builder(request)
         result = [builder.build(credential, is_detail)['credential']
@@ -104,7 +103,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
 
     # pylint: disable-msg=E1101,W0613
     def show(self, request, tenant_id, id):
-        """ Returns credential details for the given credential id """
+        """Returns credential details for the given credential id."""
         try:
             credential = self._plugin.get_credential_details(tenant_id, id)
             builder = credential_view.get_view_builder(request)
@@ -115,7 +114,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
             return faults.Fault(faults.CredentialNotFound(exp))
 
     def create(self, request, tenant_id):
-        """ Creates a new credential for a given tenant """
+        """Creates a new credential for a given tenant."""
         try:
             body = self._deserialize(request.body, request.get_content_type())
             req_body = self._prepare_request_body(
@@ -134,7 +133,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
         return dict(credentials=result)
 
     def update(self, request, tenant_id, id):
-        """ Updates the name for the credential with the given id """
+        """Updates the name for the credential with the given id."""
         try:
             body = self._deserialize(request.body, request.get_content_type())
             req_body = self._prepare_request_body(
@@ -153,7 +152,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
             return faults.Fault(faults.CredentialNotFound(exp))
 
     def delete(self, request, tenant_id, id):
-        """ Destroys the credential with the given id """
+        """Destroys the credential with the given id."""
         try:
             self._plugin.delete_credential(tenant_id, id)
             return exc.HTTPOk()
index 2729bb6735855419fabc67448e15ac4073355407..1c53b378c8409ef0bb77b8c1d71d0982dd24ad95 100644 (file)
@@ -30,36 +30,36 @@ from quantum import wsgi
 
 
 class Qos(extensions.ExtensionDescriptor):
-    """Qos extension file"""
+    """Qos extension file."""
 
     @classmethod
     def get_name(cls):
-        """ Returns Ext Resource Name """
+        """Returns Ext Resource Name."""
         return "Cisco qos"
 
     @classmethod
     def get_alias(cls):
-        """ Returns Ext Resource Alias """
+        """Returns Ext Resource Alias."""
         return "Cisco qos"
 
     @classmethod
     def get_description(cls):
-        """ Returns Ext Resource Description """
+        """Returns Ext Resource Description."""
         return "qos includes qos_name and qos_desc"
 
     @classmethod
     def get_namespace(cls):
-        """ Returns Ext Resource Namespace """
+        """Returns Ext Resource Namespace."""
         return "http://docs.ciscocloud.com/api/ext/qos/v1.0"
 
     @classmethod
     def get_updated(cls):
-        """ Returns Ext Resource update """
+        """Returns Ext Resource update."""
         return "2011-07-25T13:25:27-06:00"
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         parent_resource = dict(member_name="tenant",
                                collection_name="extensions/csco/tenants")
 
@@ -69,8 +69,7 @@ class Qos(extensions.ExtensionDescriptor):
 
 
 class QosController(common.QuantumController, wsgi.Controller):
-    """ qos API controller
-        based on QuantumController """
+    """qos API controller based on QuantumController."""
 
     _qos_ops_param_list = [
         {'param-name': 'qos_name', 'required': True},
@@ -90,11 +89,11 @@ class QosController(common.QuantumController, wsgi.Controller):
         self._plugin = plugin
 
     def index(self, request, tenant_id):
-        """ Returns a list of qos ids """
+        """Returns a list of qos ids."""
         return self._items(request, tenant_id, is_detail=False)
 
     def _items(self, request, tenant_id, is_detail):
-        """ Returns a list of qoss. """
+        """Returns a list of qoss."""
         qoss = self._plugin.get_all_qoss(tenant_id)
         builder = qos_view.get_view_builder(request)
         result = [builder.build(qos, is_detail)['qos'] for qos in qoss]
@@ -102,7 +101,7 @@ class QosController(common.QuantumController, wsgi.Controller):
 
     # pylint: disable-msg=E1101
     def show(self, request, tenant_id, id):
-        """ Returns qos details for the given qos id """
+        """Returns qos details for the given qos id."""
         try:
             qos = self._plugin.get_qos_details(tenant_id, id)
             builder = qos_view.get_view_builder(request)
@@ -113,7 +112,7 @@ class QosController(common.QuantumController, wsgi.Controller):
             return faults.Fault(faults.QosNotFound(exp))
 
     def create(self, request, tenant_id):
-        """ Creates a new qos for a given tenant """
+        """Creates a new qos for a given tenant."""
         #look for qos name in request
         try:
             body = self._deserialize(request.body, request.get_content_type())
@@ -130,7 +129,7 @@ class QosController(common.QuantumController, wsgi.Controller):
         return dict(qoss=result)
 
     def update(self, request, tenant_id, id):
-        """ Updates the name for the qos with the given id """
+        """Updates the name for the qos with the given id."""
         try:
             body = self._deserialize(request.body, request.get_content_type())
             req_body = self._prepare_request_body(body,
@@ -149,7 +148,7 @@ class QosController(common.QuantumController, wsgi.Controller):
             return faults.Fault(faults.QosNotFound(exp))
 
     def delete(self, request, tenant_id, id):
-        """ Destroys the qos with the given id """
+        """Destroys the qos with the given id."""
         try:
             self._plugin.delete_qos(tenant_id, id)
             return exc.HTTPOk()
index 5ac8bdd2d51ba66b95d712cb69748fb6ac933e75..1623153f166c5b95304cf1b301b1fccdabb5b4e1 100644 (file)
@@ -25,15 +25,15 @@ import logging
 from novaclient.v1_1 import client as nova_client
 from oslo.config import cfg
 
+from quantum.db import api as db_api
 from quantum.manager import QuantumManager
 from quantum.openstack.common import importutils
 from quantum.plugins.cisco.common import cisco_constants as const
 from quantum.plugins.cisco.common import cisco_credentials_v2 as cred
-from quantum.plugins.cisco.db import network_db_v2 as cdb
 from quantum.plugins.cisco.common import config as conf
+from quantum.plugins.cisco.db import network_db_v2 as cdb
 from quantum.plugins.openvswitch import ovs_db_v2 as odb
 from quantum import quantum_plugin_base_v2
-from quantum.db import api as db_api
 
 
 LOG = logging.getLogger(__name__)
@@ -112,7 +112,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             return getattr(plugin, name)
 
     def _func_name(self, offset=0):
-        """Get the name of the calling function"""
+        """Get the name of the calling function."""
         frame_record = inspect.stack()[1 + offset]
         func_name = frame_record[3]
         return func_name
@@ -206,8 +206,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                     ovs_output[0]['id'], vlan_name, vlan_id,
                     {'vlan_ids': vlanids}]
             return ovs_output[0]
-        except:
-            # TODO (Sumit): Check if we need to perform any rollback here
+        except Exception:
+            # TODO(Sumit): Check if we need to perform any rollback here
             raise
 
     def update_network(self, context, id, network):
@@ -253,15 +253,15 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                 self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
                                                self._func_name(), args)
             return ovs_output[0]
-        except:
+        except Exception:
             raise
 
     def get_network(self, context, id, fields=None):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def get_networks(self, context, filters=None, fields=None):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def _invoke_nexus_for_net_create(self, context, tenant_id, net_id,
@@ -308,16 +308,16 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                     context, tenant_id, net_id, instance_id)
 
             return ovs_output[0]
-        except:
-            # TODO (asomya): Check if we need to perform any rollback here
+        except Exception:
+            # TODO(asomya): Check if we need to perform any rollback here
             raise
 
     def get_port(self, context, id, fields=None):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def get_ports(self, context, filters=None, fields=None):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def update_port(self, context, id, port):
@@ -348,7 +348,7 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                     context, tenant_id, net_id, instance_id)
 
             return ovs_output[0]
-        except:
+        except Exception:
             raise
 
     def delete_port(self, context, id):
@@ -369,26 +369,26 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                                            self._func_name(),
                                            n_args)
             return ovs_output[0]
-        except:
-            # TODO (asomya): Check if we need to perform any rollback here
+        except Exception:
+            # TODO(asomya): Check if we need to perform any rollback here
             raise
 
     def create_subnet(self, context, subnet):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def update_subnet(self, context, id, subnet):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def get_subnet(self, context, id, fields=None):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def delete_subnet(self, context, id, kwargs):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
 
     def get_subnets(self, context, filters=None, fields=None):
-        """For this model this method will be delegated to vswitch plugin"""
+        """For this model this method will be delegated to vswitch plugin."""
         pass
index a54d5951e8a07e182a8c099ec34110de6ecca28f..9c599d4045a8d5f32bb36ce645cb798cafa51f1e 100644 (file)
@@ -110,7 +110,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             self._invoke_device_plugins(self._func_name(), [context,
                                                             new_network])
             return new_network
-        except:
+        except Exception:
             super(PluginV2, self).delete_network(context,
                                                  new_network['id'])
             raise
@@ -153,7 +153,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             self._invoke_device_plugins(self._func_name(), [context, id,
                                                             kwargs])
             return super(PluginV2, self).delete_network(context, id)
-        except:
+        except Exception:
             raise
 
     def get_network(self, context, id, fields=None):
@@ -179,7 +179,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         try:
             self._invoke_device_plugins(self._func_name(), [context, new_port])
             return new_port
-        except:
+        except Exception:
             super(PluginV2, self).delete_port(context, new_port['id'])
             raise
 
@@ -199,11 +199,11 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         """
         try:
             kwargs = {const.PORT: port}
-            # TODO (Sumit): Might first need to check here if port is active
+            # TODO(Sumit): Might first need to check here if port is active
             self._invoke_device_plugins(self._func_name(), [context, id,
                                                             kwargs])
             return super(PluginV2, self).delete_port(context, id)
-        except:
+        except Exception:
             raise
 
     def update_port(self, context, id, port):
@@ -215,7 +215,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             self._invoke_device_plugins(self._func_name(), [context, id,
                                                             port])
             return super(PluginV2, self).update_port(context, id, port)
-        except:
+        except Exception:
             raise
 
     def create_subnet(self, context, subnet):
@@ -229,7 +229,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             self._invoke_device_plugins(self._func_name(), [context,
                                                             new_subnet])
             return new_subnet
-        except:
+        except Exception:
             super(PluginV2, self).delete_subnet(context, new_subnet['id'])
             raise
 
@@ -242,7 +242,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             self._invoke_device_plugins(self._func_name(), [context, id,
                                                             subnet])
             return super(PluginV2, self).update_subnet(context, id, subnet)
-        except:
+        except Exception:
             raise
 
     def delete_subnet(self, context, id):
@@ -267,20 +267,20 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             self._invoke_device_plugins(self._func_name(), [context, id,
                                                             kwargs])
             return super(PluginV2, self).delete_subnet(context, id)
-        except:
+        except Exception:
             raise
 
     """
     Extension API implementation
     """
     def get_all_qoss(self, tenant_id):
-        """Get all QoS levels"""
+        """Get all QoS levels."""
         LOG.debug(_("get_all_qoss() called"))
         qoslist = cdb.get_all_qoss(tenant_id)
         return qoslist
 
     def get_qos_details(self, tenant_id, qos_id):
-        """Get QoS Details"""
+        """Get QoS Details."""
         LOG.debug(_("get_qos_details() called"))
         try:
             qos_level = cdb.get_qos(tenant_id, qos_id)
@@ -290,13 +290,13 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         return qos_level
 
     def create_qos(self, tenant_id, qos_name, qos_desc):
-        """Create a QoS level"""
+        """Create a QoS level."""
         LOG.debug(_("create_qos() called"))
         qos = cdb.add_qos(tenant_id, qos_name, str(qos_desc))
         return qos
 
     def delete_qos(self, tenant_id, qos_id):
-        """Delete a QoS level"""
+        """Delete a QoS level."""
         LOG.debug(_("delete_qos() called"))
         try:
             cdb.get_qos(tenant_id, qos_id)
@@ -306,7 +306,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         return cdb.remove_qos(tenant_id, qos_id)
 
     def rename_qos(self, tenant_id, qos_id, new_name):
-        """Rename QoS level"""
+        """Rename QoS level."""
         LOG.debug(_("rename_qos() called"))
         try:
             cdb.get_qos(tenant_id, qos_id)
@@ -317,13 +317,13 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         return qos
 
     def get_all_credentials(self, tenant_id):
-        """Get all credentials"""
+        """Get all credentials."""
         LOG.debug(_("get_all_credentials() called"))
         credential_list = cdb.get_all_credentials(tenant_id)
         return credential_list
 
     def get_credential_details(self, tenant_id, credential_id):
-        """Get a particular credential"""
+        """Get a particular credential."""
         LOG.debug(_("get_credential_details() called"))
         try:
             credential = cdb.get_credential(tenant_id, credential_id)
@@ -334,14 +334,14 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
 
     def create_credential(self, tenant_id, credential_name, user_name,
                           password):
-        """Create a new credential"""
+        """Create a new credential."""
         LOG.debug(_("create_credential() called"))
         credential = cdb.add_credential(tenant_id, credential_name,
                                         user_name, password)
         return credential
 
     def delete_credential(self, tenant_id, credential_id):
-        """Delete a credential"""
+        """Delete a credential."""
         LOG.debug(_("delete_credential() called"))
         try:
             credential = cdb.get_credential(tenant_id, credential_id)
@@ -352,7 +352,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         return credential
 
     def rename_credential(self, tenant_id, credential_id, new_name):
-        """Rename the particular credential resource"""
+        """Rename the particular credential resource."""
         LOG.debug(_("rename_credential() called"))
         try:
             credential = cdb.get_credential(tenant_id, credential_id)
@@ -363,7 +363,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
         return credential
 
     def schedule_host(self, tenant_id, instance_id, instance_desc):
-        """Provides the hostname on which a dynamic vnic is reserved"""
+        """Provides the hostname on which a dynamic vnic is reserved."""
         LOG.debug(_("schedule_host() called"))
         host_list = self._invoke_device_plugins(self._func_name(),
                                                 [tenant_id,
@@ -401,5 +401,5 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
             return getattr(self._model, function_name)(*args)
 
     def _func_name(self, offset=0):
-        """Getting the name of the calling funciton"""
+        """Getting the name of the calling funciton."""
         return inspect.stack()[1 + offset][3]
index 5776249ec410e1b03ddc7314726434d6423bac9b..7eb0af95473b0a4b2a24c52466156732b6d142cb 100644 (file)
@@ -75,7 +75,7 @@ class ExtensionsTestApp(wsgi.Router):
 
     def create_request(self, path, body, content_type, method='GET'):
 
-        """ Test create request"""
+        """Test create request."""
 
         LOG.debug("test_create_request - START")
         req = webob.Request.blank(path)
@@ -88,7 +88,7 @@ class ExtensionsTestApp(wsgi.Router):
 
     def _create_network(self, name=None):
 
-        """ Test create network"""
+        """Test create network."""
 
         LOG.debug("Creating network - START")
         if name:
@@ -108,7 +108,7 @@ class ExtensionsTestApp(wsgi.Router):
 
     def _create_port(self, network_id, port_state):
 
-        """ Test create port"""
+        """Test create port."""
 
         LOG.debug("Creating port for network %s - START", network_id)
         port_path = "/tenants/tt/networks/%s/ports" % network_id
@@ -124,7 +124,7 @@ class ExtensionsTestApp(wsgi.Router):
         return port_data['port']['id']
 
     def _delete_port(self, network_id, port_id):
-        """ Delete port """
+        """Delete port."""
         LOG.debug("Deleting port for network %s - START", network_id)
         port_path = ("/tenants/tt/networks/%(network_id)s/ports/%(port_id)s" %
                      locals())
@@ -134,7 +134,7 @@ class ExtensionsTestApp(wsgi.Router):
         LOG.debug("Deleting port for network - END")
 
     def _delete_network(self, network_id):
-        """ Delete network """
+        """Delete network."""
         LOG.debug("Deleting network %s - START", network_id)
         network_path = "/tenants/tt/networks/%s" % network_id
         network_req = self.create_request(network_path, None,
@@ -143,7 +143,7 @@ class ExtensionsTestApp(wsgi.Router):
         LOG.debug("Deleting network - END")
 
     def tear_down_port_network(self, net_id, port_id):
-        """ Tear down port and network """
+        """Tear down port and network."""
 
         self._delete_port(net_id, port_id)
         self._delete_network(net_id)
@@ -153,7 +153,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def setUp(self):
 
-        """ Set up function """
+        """Set up function."""
 
         super(QosExtensionTest, self).setUp()
         parent_resource = dict(member_name="tenant",
@@ -180,7 +180,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_create_qos(self):
 
-        """ Test create qos """
+        """Test create qos."""
 
         LOG.debug("test_create_qos - START")
         req_body = jsonutils.dumps(self.test_qos_data)
@@ -199,7 +199,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_create_qosBADRequest(self):
 
-        """ Test create qos bad request """
+        """Test create qos bad request."""
 
         LOG.debug("test_create_qosBADRequest - START")
         index_response = self.test_app.post(self.qos_path,
@@ -211,7 +211,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_list_qoss(self):
 
-        """ Test list qoss """
+        """Test list qoss."""
 
         LOG.debug("test_list_qoss - START")
         req_body1 = jsonutils.dumps(self.test_qos_data)
@@ -251,7 +251,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_show_qos(self):
 
-        """ Test show qos """
+        """Test show qos."""
 
         LOG.debug("test_show_qos - START")
         req_body = jsonutils.dumps(self.test_qos_data)
@@ -275,7 +275,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_show_qosDNE(self, qos_id='100'):
 
-        """ Test show qos does not exist"""
+        """Test show qos does not exist."""
 
         LOG.debug("test_show_qosDNE - START")
         show_path_temp = self.qos_second_path + qos_id
@@ -286,7 +286,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_update_qos(self):
 
-        """ Test update qos """
+        """Test update qos."""
 
         LOG.debug("test_update_qos - START")
         req_body = jsonutils.dumps(self.test_qos_data)
@@ -318,7 +318,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_update_qosDNE(self, qos_id='100'):
 
-        """ Test update qos does not exist """
+        """Test update qos does not exist."""
 
         LOG.debug("test_update_qosDNE - START")
         rename_req_body = jsonutils.dumps({
@@ -340,7 +340,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_update_qosBADRequest(self):
 
-        """ Test update qos bad request """
+        """Test update qos bad request."""
 
         LOG.debug("test_update_qosBADRequest - START")
         req_body = jsonutils.dumps(self.test_qos_data)
@@ -361,7 +361,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_delete_qos(self):
 
-        """ Test delte qos """
+        """Test delte qos."""
 
         LOG.debug("test_delete_qos - START")
         req_body = jsonutils.dumps({
@@ -386,7 +386,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def test_delete_qosDNE(self, qos_id='100'):
 
-        """ Test delte qos does not exist"""
+        """Test delte qos does not exist."""
 
         LOG.debug("test_delete_qosDNE - START")
         delete_path_temp = self.qos_second_path + qos_id
@@ -397,7 +397,7 @@ class QosExtensionTest(base.BaseTestCase):
 
     def tearDownQos(self, delete_profile_path):
 
-        """ Tear Down Qos """
+        """Tear Down Qos."""
 
         self.test_app.delete(delete_profile_path)
 
@@ -409,7 +409,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def setUp(self):
 
-        """ Set up function """
+        """Set up function."""
 
         super(CredentialExtensionTest, self).setUp()
         parent_resource = dict(member_name="tenant",
@@ -434,7 +434,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_list_credentials(self):
 
-        """ Test list credentials """
+        """Test list credentials."""
 
         #Create Credential before listing
         LOG.debug("test_list_credentials - START")
@@ -479,7 +479,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_create_credential(self):
 
-        """ Test create credential """
+        """Test create credential."""
 
         LOG.debug("test_create_credential - START")
         req_body = jsonutils.dumps(self.test_credential_data)
@@ -498,7 +498,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_create_credentialBADRequest(self):
 
-        """ Test create credential bad request """
+        """Test create credential bad request."""
 
         LOG.debug("test_create_credentialBADRequest - START")
         index_response = self.test_app.post(
@@ -509,7 +509,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_show_credential(self):
 
-        """ Test show credential """
+        """Test show credential."""
 
         LOG.debug("test_show_credential - START")
         req_body = jsonutils.dumps(self.test_credential_data)
@@ -534,7 +534,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_show_credentialDNE(self, credential_id='100'):
 
-        """ Test show credential does not exist """
+        """Test show credential does not exist."""
 
         LOG.debug("test_show_credentialDNE - START")
         show_path_temp = self.cred_second_path + credential_id
@@ -545,7 +545,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_update_credential(self):
 
-        """ Test update credential """
+        """Test update credential."""
 
         LOG.debug("test_update_credential - START")
         req_body = jsonutils.dumps(self.test_credential_data)
@@ -581,7 +581,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_update_credBADReq(self):
 
-        """ Test update credential bad request """
+        """Test update credential bad request."""
 
         LOG.debug("test_update_credBADReq - START")
         req_body = jsonutils.dumps(self.test_credential_data)
@@ -600,7 +600,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_update_credentialDNE(self, credential_id='100'):
 
-        """ Test update credential does not exist"""
+        """Test update credential does not exist."""
 
         LOG.debug("test_update_credentialDNE - START")
         rename_req_body = jsonutils.dumps({
@@ -620,7 +620,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_delete_credential(self):
 
-        """ Test delete credential """
+        """Test delete credential."""
 
         LOG.debug("test_delete_credential - START")
         req_body = jsonutils.dumps(self.test_credential_data)
@@ -638,7 +638,7 @@ class CredentialExtensionTest(base.BaseTestCase):
 
     def test_delete_credentialDNE(self, credential_id='100'):
 
-        """ Test delete credential does not exist """
+        """Test delete credential does not exist."""
 
         LOG.debug("test_delete_credentialDNE - START")
         delete_path_temp = self.cred_second_path + credential_id
index ac5b4e7a2cf40925567a893cb8b0d3c474cbb01a..798ad045b1026f5363a790c5d9b8174b7e9d8f49 100644 (file)
@@ -31,9 +31,9 @@ LOG = logging.getLogger(__name__)
 
 
 class NexusDB(object):
-    """Class consisting of methods to call nexus db methods"""
+    """Class consisting of methods to call nexus db methods."""
     def get_all_nexusportbindings(self):
-        """get all nexus port bindings"""
+        """get all nexus port bindings."""
         bindings = []
         try:
             for bind in nexus_db.get_all_nexusport_bindings():
@@ -47,7 +47,7 @@ class NexusDB(object):
         return bindings
 
     def get_nexusportbinding(self, vlan_id):
-        """get nexus port binding"""
+        """get nexus port binding."""
         binding = []
         try:
             for bind in nexus_db.get_nexusport_binding(vlan_id):
@@ -61,7 +61,7 @@ class NexusDB(object):
         return binding
 
     def create_nexusportbinding(self, port_id, vlan_id):
-        """create nexus port binding"""
+        """create nexus port binding."""
         bind_dict = {}
         try:
             res = nexus_db.add_nexusport_binding(port_id, vlan_id)
@@ -73,7 +73,7 @@ class NexusDB(object):
             LOG.error("Failed to create nexus binding: %s" % str(exc))
 
     def delete_nexusportbinding(self, vlan_id):
-        """delete nexus port binding"""
+        """delete nexus port binding."""
         bindings = []
         try:
             bind = nexus_db.remove_nexusport_binding(vlan_id)
@@ -88,7 +88,7 @@ class NexusDB(object):
                             % str(exc))
 
     def update_nexusport_binding(self, port_id, new_vlan_id):
-        """update nexus port binding"""
+        """update nexus port binding."""
         try:
             res = nexus_db.update_nexusport_binding(port_id, new_vlan_id)
             LOG.debug("Updating nexus port binding : %s" % res.port_id)
@@ -102,9 +102,9 @@ class NexusDB(object):
 
 
 class L2networkDB(object):
-    """Class conisting of methods to call L2network db methods"""
+    """Class conisting of methods to call L2network db methods."""
     def get_all_vlan_bindings(self):
-        """Get all vlan binding into a list of dict"""
+        """Get all vlan binding into a list of dict."""
         vlans = []
         try:
             for vlan_bind in l2network_db.get_all_vlan_bindings():
@@ -120,7 +120,7 @@ class L2networkDB(object):
         return vlans
 
     def get_vlan_binding(self, network_id):
-        """Get a vlan binding"""
+        """Get a vlan binding."""
         vlan = []
         try:
             for vlan_bind in l2network_db.get_vlan_binding(network_id):
@@ -136,7 +136,7 @@ class L2networkDB(object):
         return vlan
 
     def create_vlan_binding(self, vlan_id, vlan_name, network_id):
-        """Create a vlan binding"""
+        """Create a vlan binding."""
         vlan_dict = {}
         try:
             res = l2network_db.add_vlan_binding(vlan_id, vlan_name, network_id)
@@ -149,7 +149,7 @@ class L2networkDB(object):
             LOG.error("Failed to create vlan binding: %s" % str(exc))
 
     def delete_vlan_binding(self, network_id):
-        """Delete a vlan binding"""
+        """Delete a vlan binding."""
         try:
             res = l2network_db.remove_vlan_binding(network_id)
             LOG.debug("Deleted vlan binding for vlan: %s" % res.vlan_id)
@@ -160,7 +160,7 @@ class L2networkDB(object):
             raise Exception("Failed to delete vlan binding: %s" % str(exc))
 
     def update_vlan_binding(self, network_id, vlan_id, vlan_name):
-        """Update a vlan binding"""
+        """Update a vlan binding."""
         try:
             res = l2network_db.update_vlan_binding(network_id, vlan_id,
                                                    vlan_name)
@@ -175,9 +175,9 @@ class L2networkDB(object):
 
 
 class QuantumDB(object):
-    """Class conisting of methods to call Quantum db methods"""
+    """Class conisting of methods to call Quantum db methods."""
     def get_all_networks(self, tenant_id):
-        """Get all networks"""
+        """Get all networks."""
         nets = []
         try:
             for net in db.network_list(tenant_id):
@@ -192,7 +192,7 @@ class QuantumDB(object):
         return nets
 
     def get_network(self, network_id):
-        """Get a network"""
+        """Get a network."""
         net = []
         try:
             for net in db.network_get(network_id):
@@ -207,7 +207,7 @@ class QuantumDB(object):
         return net
 
     def create_network(self, tenant_id, net_name):
-        """Create a network"""
+        """Create a network."""
         net_dict = {}
         try:
             res = db.network_create(tenant_id, net_name)
@@ -220,7 +220,7 @@ class QuantumDB(object):
             LOG.error("Failed to create network: %s" % str(exc))
 
     def delete_network(self, net_id):
-        """Delete a network"""
+        """Delete a network."""
         try:
             net = db.network_destroy(net_id)
             LOG.debug("Deleted network: %s" % net.uuid)
@@ -231,7 +231,7 @@ class QuantumDB(object):
             raise Exception("Failed to delete port: %s" % str(exc))
 
     def update_network(self, tenant_id, net_id, **kwargs):
-        """Update a network"""
+        """Update a network."""
         try:
             net = db.network_update(net_id, tenant_id, **kwargs)
             LOG.debug("Updated network: %s" % net.uuid)
@@ -243,7 +243,7 @@ class QuantumDB(object):
             raise Exception("Failed to update network: %s" % str(exc))
 
     def get_all_ports(self, net_id):
-        """Get all ports"""
+        """Get all ports."""
         ports = []
         try:
             for port in db.port_list(net_id):
@@ -260,7 +260,7 @@ class QuantumDB(object):
             LOG.error("Failed to get all ports: %s" % str(exc))
 
     def get_port(self, net_id, port_id):
-        """Get a port"""
+        """Get a port."""
         port_list = []
         port = db.port_get(net_id, port_id)
         try:
@@ -276,7 +276,7 @@ class QuantumDB(object):
             LOG.error("Failed to get port: %s" % str(exc))
 
     def create_port(self, net_id):
-        """Add a port"""
+        """Add a port."""
         port_dict = {}
         try:
             port = db.port_create(net_id)
@@ -290,7 +290,7 @@ class QuantumDB(object):
             LOG.error("Failed to create port: %s" % str(exc))
 
     def delete_port(self, net_id, port_id):
-        """Delete a port"""
+        """Delete a port."""
         try:
             port = db.port_destroy(net_id, port_id)
             LOG.debug("Deleted port %s" % port.uuid)
@@ -301,7 +301,7 @@ class QuantumDB(object):
             raise Exception("Failed to delete port: %s" % str(exc))
 
     def update_port(self, net_id, port_id, port_state):
-        """Update a port"""
+        """Update a port."""
         try:
             port = db.port_set_state(net_id, port_id, port_state)
             LOG.debug("Updated port %s" % port.uuid)
@@ -315,7 +315,7 @@ class QuantumDB(object):
             raise Exception("Failed to update port state: %s" % str(exc))
 
     def plug_interface(self, net_id, port_id, int_id):
-        """Plug interface to a port"""
+        """Plug interface to a port."""
         try:
             port = db.port_set_attachment(net_id, port_id, int_id)
             LOG.debug("Attached interface to port %s" % port.uuid)
@@ -329,7 +329,7 @@ class QuantumDB(object):
             raise Exception("Failed to plug interface: %s" % str(exc))
 
     def unplug_interface(self, net_id, port_id):
-        """Unplug interface to a port"""
+        """Unplug interface to a port."""
         try:
             port = db.port_unset_attachment(net_id, port_id)
             LOG.debug("Detached interface from port %s" % port.uuid)
@@ -344,23 +344,23 @@ class QuantumDB(object):
 
 
 class NexusDBTest(base.BaseTestCase):
-    """Class conisting of nexus DB unit tests"""
+    """Class conisting of nexus DB unit tests."""
     def setUp(self):
         super(NexusDBTest, self).setUp()
-        """Setup for nexus db tests"""
+        """Setup for nexus db tests."""
         l2network_db.initialize()
         self.addCleanup(db.clear_db)
         self.dbtest = NexusDB()
         LOG.debug("Setup")
 
     def testa_create_nexusportbinding(self):
-        """create nexus port binding"""
+        """create nexus port binding."""
         binding1 = self.dbtest.create_nexusportbinding("port1", 10)
         self.assertTrue(binding1["port-id"] == "port1")
         self.tearDown_nexusportbinding()
 
     def testb_getall_nexusportbindings(self):
-        """get all nexus port binding"""
+        """get all nexus port binding."""
         self.dbtest.create_nexusportbinding("port1", 10)
         self.dbtest.create_nexusportbinding("port2", 10)
         bindings = self.dbtest.get_all_nexusportbindings()
@@ -372,7 +372,7 @@ class NexusDBTest(base.BaseTestCase):
         self.tearDown_nexusportbinding()
 
     def testc_delete_nexusportbinding(self):
-        """delete nexus port binding"""
+        """delete nexus port binding."""
         self.dbtest.create_nexusportbinding("port1", 10)
         self.dbtest.delete_nexusportbinding(10)
         bindings = self.dbtest.get_all_nexusportbindings()
@@ -384,7 +384,7 @@ class NexusDBTest(base.BaseTestCase):
         self.tearDown_nexusportbinding()
 
     def testd_update_nexusportbinding(self):
-        """update nexus port binding"""
+        """update nexus port binding."""
         binding1 = self.dbtest.create_nexusportbinding("port1", 10)
         binding1 = self.dbtest.update_nexusport_binding(binding1["port-id"],
                                                         20)
@@ -397,7 +397,7 @@ class NexusDBTest(base.BaseTestCase):
         self.tearDown_nexusportbinding()
 
     def tearDown_nexusportbinding(self):
-        """tear down nexusport binding table"""
+        """tear down nexusport binding table."""
         LOG.debug("Tearing Down Nexus port Bindings")
         binds = self.dbtest.get_all_nexusportbindings()
         for bind in binds:
@@ -406,9 +406,9 @@ class NexusDBTest(base.BaseTestCase):
 
 
 class L2networkDBTest(base.BaseTestCase):
-    """Class conisting of L2network DB unit tests"""
+    """Class conisting of L2network DB unit tests."""
     def setUp(self):
-        """Setup for tests"""
+        """Setup for tests."""
         super(L2networkDBTest, self).setUp()
         l2network_db.initialize()
         self.dbtest = L2networkDB()
@@ -417,7 +417,7 @@ class L2networkDBTest(base.BaseTestCase):
         LOG.debug("Setup")
 
     def testa_create_vlanbinding(self):
-        """test add vlan binding"""
+        """test add vlan binding."""
         net1 = self.quantum.create_network("t1", "netid1")
         vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
         self.assertTrue(vlan1["vlan-id"] == "10")
@@ -425,7 +425,7 @@ class L2networkDBTest(base.BaseTestCase):
         self.teardown_network()
 
     def testb_getall_vlanbindings(self):
-        """test get all vlan binding"""
+        """test get all vlan binding."""
         net1 = self.quantum.create_network("t1", "netid1")
         net2 = self.quantum.create_network("t1", "netid2")
         vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
@@ -442,7 +442,7 @@ class L2networkDBTest(base.BaseTestCase):
         self.teardown_network()
 
     def testc_delete_vlanbinding(self):
-        """test delete vlan binding"""
+        """test delete vlan binding."""
         net1 = self.quantum.create_network("t1", "netid1")
         vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
         self.assertTrue(vlan1["vlan-id"] == "10")
@@ -457,7 +457,7 @@ class L2networkDBTest(base.BaseTestCase):
         self.teardown_network()
 
     def testd_update_vlanbinding(self):
-        """test update vlan binding"""
+        """test update vlan binding."""
         net1 = self.quantum.create_network("t1", "netid1")
         vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
         self.assertTrue(vlan1["vlan-id"] == "10")
@@ -472,7 +472,7 @@ class L2networkDBTest(base.BaseTestCase):
         self.teardown_network()
 
     def testm_test_vlanids(self):
-        """test vlanid methods"""
+        """test vlanid methods."""
         l2network_db.create_vlanids()
         vlanids = l2network_db.get_all_vlanids()
         self.assertTrue(len(vlanids) > 0)
@@ -484,7 +484,7 @@ class L2networkDBTest(base.BaseTestCase):
         #counting on default teardown here to clear db
 
     def teardown_network(self):
-        """tearDown Network table"""
+        """tearDown Network table."""
         LOG.debug("Tearing Down Network")
         nets = self.quantum.get_all_networks("t1")
         for net in nets:
@@ -492,7 +492,7 @@ class L2networkDBTest(base.BaseTestCase):
             self.quantum.delete_network(netid)
 
     def teardown_port(self):
-        """tearDown Port table"""
+        """tearDown Port table."""
         LOG.debug("Tearing Down Port")
         nets = self.quantum.get_all_networks("t1")
         for net in nets:
@@ -503,7 +503,7 @@ class L2networkDBTest(base.BaseTestCase):
                 self.quantum.delete_port(netid, portid)
 
     def teardown_vlanbinding(self):
-        """tearDown VlanBinding table"""
+        """tearDown VlanBinding table."""
         LOG.debug("Tearing Down Vlan Binding")
         vlans = self.dbtest.get_all_vlan_bindings()
         for vlan in vlans:
@@ -512,9 +512,9 @@ class L2networkDBTest(base.BaseTestCase):
 
 
 class QuantumDBTest(base.BaseTestCase):
-    """Class conisting of Quantum DB unit tests"""
+    """Class conisting of Quantum DB unit tests."""
     def setUp(self):
-        """Setup for tests"""
+        """Setup for tests."""
         super(QuantumDBTest, self).setUp()
         l2network_db.initialize()
         self.addCleanup(db.clear_db)
@@ -523,13 +523,13 @@ class QuantumDBTest(base.BaseTestCase):
         LOG.debug("Setup")
 
     def testa_create_network(self):
-        """test to create network"""
+        """test to create network."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         self.assertTrue(net1["net-name"] == "plugin_test1")
         self.teardown_network_port()
 
     def testb_get_networks(self):
-        """test to get all networks"""
+        """test to get all networks."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         self.assertTrue(net1["net-name"] == "plugin_test1")
         net2 = self.dbtest.create_network(self.tenant_id, "plugin_test2")
@@ -543,7 +543,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_network_port()
 
     def testc_delete_network(self):
-        """test to delete network"""
+        """test to delete network."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         self.assertTrue(net1["net-name"] == "plugin_test1")
         self.dbtest.delete_network(net1["net-id"])
@@ -556,7 +556,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_network_port()
 
     def testd_update_network(self):
-        """test to update (rename) network"""
+        """test to update (rename) network."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         self.assertTrue(net1["net-name"] == "plugin_test1")
         net = self.dbtest.update_network(self.tenant_id, net1["net-id"],
@@ -565,7 +565,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_network_port()
 
     def teste_create_port(self):
-        """test to create port"""
+        """test to create port."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         port = self.dbtest.create_port(net1["net-id"])
         self.assertTrue(port["net-id"] == net1["net-id"])
@@ -577,7 +577,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_network_port()
 
     def testf_delete_port(self):
-        """test to delete port"""
+        """test to delete port."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         port = self.dbtest.create_port(net1["net-id"])
         self.assertTrue(port["net-id"] == net1["net-id"])
@@ -596,7 +596,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_network_port()
 
     def testg_plug_unplug_interface(self):
-        """test to plug/unplug interface"""
+        """test to plug/unplug interface."""
         net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
         port1 = self.dbtest.create_port(net1["net-id"])
         self.dbtest.plug_interface(net1["net-id"], port1["port-id"], "vif1.1")
@@ -608,7 +608,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_network_port()
 
     def testh_joined_test(self):
-        """test to get network and port"""
+        """test to get network and port."""
         net1 = self.dbtest.create_network("t1", "net1")
         port1 = self.dbtest.create_port(net1["net-id"])
         self.assertTrue(port1["net-id"] == net1["net-id"])
@@ -621,7 +621,7 @@ class QuantumDBTest(base.BaseTestCase):
         self.teardown_joined_test()
 
     def teardown_network_port(self):
-        """tearDown for Network and Port table"""
+        """tearDown for Network and Port table."""
         networks = self.dbtest.get_all_networks(self.tenant_id)
         for net in networks:
             netid = net["net-id"]
@@ -633,7 +633,7 @@ class QuantumDBTest(base.BaseTestCase):
                 self.dbtest.delete_network(netid)
 
     def teardown_joined_test(self):
-        """tearDown for joined Network and Port test"""
+        """tearDown for joined Network and Port test."""
         LOG.debug("Tearing Down Network and Ports")
         nets = self.dbtest.get_all_networks("t1")
         for net in nets:
index 1ffdc91230155930708e5d06fda8f77ab450849b..b340d2421918670bff0badac8980c65bfc310655 100644 (file)
@@ -156,13 +156,14 @@ class HyperVQuantumAgent(object):
             #Nothing to do
             pass
         elif network_type == constants.TYPE_LOCAL:
-            #TODO (alexpilotti): Check that the switch type is private
+            #TODO(alexpilotti): Check that the switch type is private
             #or create it if not existing
             pass
         else:
-            raise utils.HyperVException(_("Cannot provision unknown network "
-                                          "type %s for network %s"),
-                                        network_type, net_uuid)
+            raise utils.HyperVException(
+                _("Cannot provision unknown network type %(network_type)s "
+                  "for network %(net_uuid)s"),
+                dict(network_type=network_type, net_uuid=net_uuid))
 
         map = {
             'network_type': network_type,
@@ -193,8 +194,9 @@ class HyperVQuantumAgent(object):
         self._utils.connect_vnic_to_vswitch(map['vswitch_name'], port_id)
 
         if network_type == constants.TYPE_VLAN:
-            LOG.info(_('Binding VLAN ID %s to switch port %s'),
-                     segmentation_id, port_id)
+            LOG.info(_('Binding VLAN ID %(segmentation_id)s '
+                       'to switch port %(port_id)s'),
+                     dict(segmentation_id=segmentation_id, port_id=port_id))
             self._utils.set_vswitch_port_vlan_id(
                 segmentation_id,
                 port_id)
@@ -253,14 +255,14 @@ class HyperVQuantumAgent(object):
                     self.agent_id)
             except Exception as e:
                 LOG.debug(_(
-                    "Unable to get port details for device %s: %s"),
-                    device, e)
+                    "Unable to get port details for device %(device)s: %(e)s"),
+                    dict(device=device, e=e))
                 resync = True
                 continue
             if 'port_id' in device_details:
                 LOG.info(_(
                     "Port %(device)s updated. Details: %(device_details)s") %
-                    locals())
+                    dict(device=device, device_details=device_details))
                 self._treat_vif_port(
                     device_details['port_id'],
                     device_details['network_id'],
@@ -279,8 +281,9 @@ class HyperVQuantumAgent(object):
                                                    device,
                                                    self.agent_id)
             except Exception as e:
-                LOG.debug(_("Removing port failed for device %s: %s"),
-                          device, e)
+                LOG.debug(
+                    _("Removing port failed for device %(device)s: %(e)s"),
+                    dict(device=device, e=e))
                 resync = True
                 continue
             self._port_unbound(device)
index 703b617656277baadcbf31b994f0b1d562f286cd..1c0468b6386e7ef53e596c499619507f98fce6b7 100644 (file)
@@ -105,11 +105,11 @@ class HyperVUtils(object):
         self._check_job_status(ret_val, job_path)
 
     def _check_job_status(self, ret_val, jobpath):
-        """Poll WMI job state for completion"""
+        """Poll WMI job state for completion."""
         if not ret_val:
             return
         elif ret_val != WMI_JOB_STATE_RUNNING:
-            raise HyperVException(msg=_('Job failed with error %d' % ret_val))
+            raise HyperVException(msg=_('Job failed with error %d') % ret_val)
 
         job_wmi_path = jobpath.replace('\\', '/')
         job = wmi.WMI(moniker=job_wmi_path)
@@ -144,7 +144,7 @@ class HyperVUtils(object):
                   locals())
 
     def _create_switch_port(self, vswitch_name, switch_port_name):
-        """ Creates a switch port """
+        """Creates a switch port."""
         switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0]
         vswitch_path = self._get_vswitch(vswitch_name).path_()
         (new_port, ret_val) = switch_svc.CreateSwitchPort(
@@ -159,7 +159,7 @@ class HyperVUtils(object):
 
     def disconnect_switch_port(
             self, vswitch_name, switch_port_name, delete_port):
-        """ Disconnects the switch port """
+        """Disconnects the switch port."""
         switch_svc = self._conn.Msvm_VirtualSwitchManagementService()[0]
         switch_port_path = self._get_switch_port_path_by_name(
             switch_port_name)
index 361315b2f73078adf338d87d65f43150c8c448a5..b88d286a1efa7a4ee1734f6ebbe2d5bfa2b5e705 100644 (file)
@@ -180,7 +180,7 @@ class HyperVPluginDB(object):
                     session.delete(alloc)
 
     def sync_vlan_allocations(self, network_vlan_ranges):
-        """Synchronize vlan_allocations table with configured VLAN ranges"""
+        """Synchronize vlan_allocations table with configured VLAN ranges."""
 
         session = db_api.get_session()
         with session.begin():
index 57b4ff9391e50dcf5ec20c8f97035379baef94cb..fac657a4ce29363c4d962a17b8cb7471ac6944fa 100644 (file)
@@ -22,7 +22,7 @@ from quantum.db.models_v2 import model_base
 
 
 class VlanAllocation(model_base.BASEV2):
-    """Represents allocation state of vlan_id on physical network"""
+    """Represents allocation state of vlan_id on physical network."""
     __tablename__ = 'hyperv_vlan_allocations'
 
     physical_network = Column(String(64), nullable=False, primary_key=True)
@@ -37,7 +37,7 @@ class VlanAllocation(model_base.BASEV2):
 
 
 class NetworkBinding(model_base.BASEV2):
-    """Represents binding of virtual network to physical realization"""
+    """Represents binding of virtual network to physical realization."""
     __tablename__ = 'hyperv_network_bindings'
 
     network_id = Column(String(36),
index 02df0c2adb9e594e65781d092a19e43b3d43a6f0..f2e17f16ab28c4375f3601ad52b941f1a2691d0b 100644 (file)
@@ -47,7 +47,7 @@ class HyperVRpcCallbacks(
         return q_rpc.PluginRpcDispatcher([self])
 
     def get_device_details(self, rpc_context, **kwargs):
-        """Agent requests device details"""
+        """Agent requests device details."""
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
@@ -70,8 +70,8 @@ class HyperVRpcCallbacks(
         return entry
 
     def update_device_down(self, rpc_context, **kwargs):
-        """Device no longer exists on agent"""
-        # (TODO) garyk - live migration and port status
+        """Device no longer exists on agent."""
+        # TODO(garyk) - live migration and port status
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
@@ -90,7 +90,8 @@ class HyperVRpcCallbacks(
 
     def tunnel_sync(self, rpc_context, **kwargs):
         """Dummy function for ovs agent running on Linux to
-        work with Hyper-V plugin and agent."""
+        work with Hyper-V plugin and agent.
+        """
         entry = dict()
         entry['tunnels'] = {}
         # Return the list of tunnels IP's to the agent
index 3e48b855dfe8c1f66a21a6ce610fecae7e698253..8a5631e537d636c5a03da87ec8ca9c86b9381473 100644 (file)
@@ -93,7 +93,7 @@ def sync_network_states(network_vlan_ranges):
 
 
 def get_network_state(physical_network, vlan_id):
-    """Get state of specified network"""
+    """Get state of specified network."""
 
     session = db.get_session()
     try:
@@ -193,7 +193,7 @@ def get_network_binding(session, network_id):
 
 
 def get_port_from_device(device):
-    """Get port from database"""
+    """Get port from database."""
     LOG.debug(_("get_port_from_device() called"))
     session = db.get_session()
     sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
@@ -221,7 +221,7 @@ def get_port_from_device(device):
 
 
 def set_port_status(port_id, status):
-    """Set the port status"""
+    """Set the port status."""
     LOG.debug(_("set_port_status as %s called"), status)
     session = db.get_session()
     try:
index c6451fe3dcac3e6049d9e2c79b16d0f29765e4d7..d30485c99dd536828f58cb3fed097b5db21f6939 100644 (file)
@@ -19,7 +19,7 @@ from quantum.db import model_base
 
 
 class NetworkState(model_base.BASEV2):
-    """Represents state of vlan_id on physical network"""
+    """Represents state of vlan_id on physical network."""
     __tablename__ = 'network_states'
 
     physical_network = sa.Column(sa.String(64), nullable=False,
@@ -39,7 +39,7 @@ class NetworkState(model_base.BASEV2):
 
 
 class NetworkBinding(model_base.BASEV2):
-    """Represents binding of virtual network to physical_network and vlan_id"""
+    """Represents binding of virtual network to physical network and vlan."""
     __tablename__ = 'network_bindings'
 
     network_id = sa.Column(sa.String(36),
index 6993aa24dfbd62bd7ca6b0c213c7ab9e5e53efc9..28741516e31f4ecc1846ba0396b84842b4a9877e 100644 (file)
@@ -76,7 +76,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         return port
 
     def get_device_details(self, rpc_context, **kwargs):
-        """Agent requests device details"""
+        """Agent requests device details."""
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
@@ -101,8 +101,8 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         return entry
 
     def update_device_down(self, rpc_context, **kwargs):
-        """Device no longer exists on agent"""
-        # (TODO) garyk - live migration and port status
+        """Device no longer exists on agent."""
+        # TODO(garyk) - live migration and port status
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
@@ -121,7 +121,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         return entry
 
     def update_device_up(self, rpc_context, **kwargs):
-        """Device is up on agent"""
+        """Device is up on agent."""
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s up %(agent_id)s"),
index 913b36d8bdb58f0b0845b7ee887e42eda2be7dcc..37ee2ba0da136c705630c37c11ddd2b18d15b009 100644 (file)
@@ -166,7 +166,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
             try:
                 meta_db_v2.add_network_flavor_binding(context.session,
                                                       flavor, str(net['id']))
-            except:
+            except Exception:
                 LOG.exception(_('Failed to add flavor bindings'))
                 plugin.delete_network(context, net['id'])
                 raise FaildToAddFlavorBinding()
index 48f3cb5b8b13591f23f5a4fcbcc02e9bf8dacdb7..b9c603faf3a3409aa800b7f9d70db42312e05c6c 100644 (file)
@@ -54,7 +54,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         try:
             subnet_in_db = super(ProxyPluginV2, self).create_subnet(
                 context, subnet)
-        except:
+        except Exception:
             self._get_client().delete_subnet(subnet_remote['id'])
         return subnet_in_db
 
@@ -82,7 +82,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         try:
             network_in_db = super(ProxyPluginV2, self).create_network(
                 context, network)
-        except:
+        except Exception:
             self._get_client().delete_network(network_remote['id'])
         return network_in_db
 
@@ -110,7 +110,7 @@ class ProxyPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         try:
             port_in_db = super(ProxyPluginV2, self).create_port(
                 context, port)
-        except:
+        except Exception:
             self._get_client().delete_port(port_remote['id'])
         return port_in_db
 
index 7ee77c7e2bf80387a8ef9fff0b016d5aeb9d5e5c..b31b336835f8ff3ede60b98dd289180f4fff3781 100644 (file)
@@ -522,7 +522,7 @@ class MidonetPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         LOG.debug(_("MidonetPluginV2.create_router called: router=%r"), router)
 
         if router['router']['admin_state_up'] is False:
-            LOG.warning(_('Ignoreing admin_state_up=False for router=%r',
+            LOG.warning(_('Ignoring admin_state_up=False for router=%r.  '
                           'Overriding with True'), router)
             router['router']['admin_state_up'] = True
 
index 8e121a91ebd7be408267fb47c2fa9cfa1a41d8f6..0d1a7bf5d75179c4421f26f2d4bc9270f628db08 100755 (executable)
@@ -51,7 +51,7 @@ class NECPluginApi(agent_rpc.PluginApi):
 
     def update_ports(self, context, agent_id, datapath_id,
                      port_added, port_removed):
-        """RPC to update information of ports on Quantum Server"""
+        """RPC to update information of ports on Quantum Server."""
         LOG.info(_("Update ports: added=%(added)s, "
                    "removed=%(removed)s"),
                  {'added': port_added, 'removed': port_removed})
index a423b4dbf5c788304365c6e9f8d3fe7d8ba6c956..d6559dc86fec145d5c26348f9416c2b90505b13b 100644 (file)
@@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
 
 
 class OFCClient(object):
-    """A HTTP/HTTPS client for OFC Drivers"""
+    """A HTTP/HTTPS client for OFC Drivers."""
 
     def __init__(self, host="127.0.0.1", port=8888, use_ssl=False,
                  key_file=None, cert_file=None):
@@ -47,7 +47,7 @@ class OFCClient(object):
         self.connection = None
 
     def get_connection_type(self):
-        """Returns the proper connection type"""
+        """Returns the proper connection type."""
         if self.use_ssl:
             return httplib.HTTPSConnection
         else:
index 32ef259bbc990a4bc36c6480af9fd35dffd25ffe..1c74024be3345bc577ab83294e049a65aaa0142e 100644 (file)
@@ -203,7 +203,7 @@ def del_portinfo(session, id):
 
 
 def get_port_from_device(port_id):
-    """Get port from database"""
+    """Get port from database."""
     LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
     session = db.get_session()
     sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
index 893af153556a59d5814e0dc8ca0d49c765c006d5..614570c8726b81f3702afc77155dcecf1b29b7b1 100644 (file)
@@ -21,16 +21,16 @@ from quantum.db import model_base
 from quantum.db import models_v2
 
 
-"""New mapping tables"""
+"""New mapping tables."""
 
 
 class OFCId(object):
-    """Resource ID on OpenFlow Controller"""
+    """Resource ID on OpenFlow Controller."""
     ofc_id = sa.Column(sa.String(255), unique=True, nullable=False)
 
 
 class QuantumId(object):
-    """Logical ID on Quantum"""
+    """Logical ID on Quantum."""
     quantum_id = sa.Column(sa.String(36), primary_key=True)
 
 
@@ -50,11 +50,11 @@ class OFCFilterMapping(model_base.BASEV2, QuantumId, OFCId):
     """Represents a Filter on OpenFlow Network/Controller."""
 
 
-"""Old mapping tables"""
+"""Old mapping tables."""
 
 
 class HasQuantumId(object):
-    """Logical ID on Quantum"""
+    """Logical ID on Quantum."""
     quantum_id = sa.Column(sa.String(36), nullable=False)
 
 
@@ -83,7 +83,7 @@ class PortInfo(model_base.BASEV2, models_v2.HasId):
 
 
 class PacketFilter(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
-    """Represents a packet filter"""
+    """Represents a packet filter."""
     network_id = sa.Column(sa.String(36),
                            sa.ForeignKey('networks.id', ondelete="CASCADE"),
                            nullable=False)
index 820d2758d1f24e63300151b896579e95d2a78aae..56bdb575f1ef043484dac5e7ca93e855cee69bfe 100644 (file)
@@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__)
 
 class NECPluginV2Base(db_base_plugin_v2.QuantumDbPluginV2):
 
-    """ Base class of plugins that handle packet filters. """
+    """Base class of plugins that handle packet filters."""
 
     def _make_packet_filter_dict(self, packet_filter, fields=None):
         res = {'id': packet_filter['id'],
index 339199c327e16f02837a68177707b877db44fc02..f30f0c2fe5a0884f60de1b00a1b47678d2843c1f 100644 (file)
@@ -45,7 +45,7 @@ class PFCDriverBase(ofc_driver_base.OFCDriverBase):
         return False
 
     def _generate_pfc_str(self, raw_str):
-        """Generate PFC acceptable String"""
+        """Generate PFC acceptable String."""
         return re.sub(r'[^0-9a-zA-Z]', '_', raw_str)
 
     def _generate_pfc_id(self, id_str):
@@ -63,7 +63,7 @@ class PFCDriverBase(ofc_driver_base.OFCDriverBase):
             uuid_str = str(uuid.UUID(id_str)).replace('-', '')
             uuid_no_version = uuid_str[:12] + uuid_str[13:]
             return uuid_no_version[:31]
-        except:
+        except Exception:
             return self._generate_pfc_str(id_str)[:31]
 
     def _generate_pfc_description(self, desc):
index b97f81da98cbf48021cdb8d0b38478572dd7091f..9f55223e5984772d653f8843d518a6daafc94b71 100644 (file)
@@ -23,7 +23,7 @@ from quantum.plugins.nec import ofc_driver_base
 
 
 class TremaDriverBase(ofc_driver_base.OFCDriverBase):
-    """Common class for Trema (Sliceable Switch) Drivers"""
+    """Common class for Trema (Sliceable Switch) Drivers."""
     networks_path = "/networks"
     network_path = "/networks/%s"
 
@@ -75,7 +75,7 @@ class TremaDriverBase(ofc_driver_base.OFCDriverBase):
 
 
 class TremaFilterDriver(object):
-    """Trema (Sliceable Switch) PacketFilter Driver Mixin"""
+    """Trema (Sliceable Switch) PacketFilter Driver Mixin."""
     filters_path = "/filters"
     filter_path = "/filters/%s"
 
index c8852c0dd67dadd8ba95eaa7d38f366c43a55067..0e71acfcef5395d3063706c9e1a5c1a59f68ef87 100644 (file)
@@ -595,7 +595,7 @@ class NECPluginV2(nec_plugin_base.NECPluginV2Base,
 
 class NECPluginV2AgentNotifierApi(proxy.RpcProxy,
                                   sg_rpc.SecurityGroupAgentRpcApiMixin):
-    '''RPC API for NEC plugin agent'''
+    '''RPC API for NEC plugin agent.'''
 
     BASE_RPC_API_VERSION = '1.0'
 
index b12feb5812ee12d7cd8b7396b08d6b24dd42ca82..3f7d21aa9a6d96f33540b6bd2915a309bee29ddf 100644 (file)
@@ -31,10 +31,10 @@ from quantum.api.rpc.agentnotifiers import dhcp_rpc_agent_api
 from quantum.api.v2 import attributes as attr
 from quantum.api.v2 import base
 from quantum.common import constants
-from quantum import context as q_context
 from quantum.common import exceptions as q_exc
 from quantum.common import rpc as q_rpc
 from quantum.common import topics
+from quantum import context as q_context
 from quantum.db import agents_db
 from quantum.db import agentschedulers_db
 from quantum.db import api as db
@@ -51,11 +51,10 @@ from quantum.extensions import providernet as pnet
 from quantum.extensions import securitygroup as ext_sg
 from quantum.openstack.common import importutils
 from quantum.openstack.common import rpc
-from quantum.plugins.nicira.common import metadata_access as nvp_meta
-from quantum.plugins.nicira.common import securitygroups as nvp_sec
-from quantum import policy
 from quantum.plugins.nicira.common import config
 from quantum.plugins.nicira.common import exceptions as nvp_exc
+from quantum.plugins.nicira.common import metadata_access as nvp_meta
+from quantum.plugins.nicira.common import securitygroups as nvp_sec
 from quantum.plugins.nicira.extensions import nvp_networkgw as networkgw
 from quantum.plugins.nicira.extensions import nvp_qos as ext_qos
 from quantum.plugins.nicira import nicira_db
@@ -65,6 +64,7 @@ from quantum.plugins.nicira import nvp_cluster
 from quantum.plugins.nicira.nvp_plugin_version import PLUGIN_VERSION
 from quantum.plugins.nicira import NvpApiClient
 from quantum.plugins.nicira import nvplib
+from quantum import policy
 
 LOG = logging.getLogger("QuantumPlugin")
 NVP_NOSNAT_RULES_ORDER = 10
@@ -74,7 +74,7 @@ NVP_EXTGW_NAT_RULES_ORDER = 255
 
 # Provider network extension - allowed network types for the NVP Plugin
 class NetworkTypes:
-    """ Allowed provider network types for the NVP Plugin """
+    """Allowed provider network types for the NVP Plugin."""
     L3_EXT = 'l3_ext'
     STT = 'stt'
     GRE = 'gre'
@@ -315,7 +315,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
             raise
 
     def _build_ip_address_list(self, context, fixed_ips, subnet_ids=None):
-        """  Build ip_addresses data structure for logical router port
+        """Build ip_addresses data structure for logical router port
 
         No need to perform validation on IPs - this has already been
         done in the l3_db mixin class
@@ -392,7 +392,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                           'router_id': router_id}))
 
     def _get_port_by_device_id(self, context, device_id, device_owner):
-        """ Retrieve ports associated with a specific device id.
+        """Retrieve ports associated with a specific device id.
 
         Used for retrieving all quantum ports attached to a given router.
         """
@@ -402,7 +402,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
             device_owner=device_owner,).all()
 
     def _find_router_subnets_cidrs(self, context, router_id):
-        """ Retrieve subnets attached to the specified router """
+        """Retrieve subnets attached to the specified router."""
         ports = self._get_port_by_device_id(context, router_id,
                                             l3_db.DEVICE_OWNER_ROUTER_INTF)
         # No need to check for overlapping CIDRs
@@ -430,8 +430,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                 cluster, network, network_binding, max_ports,
                 allow_extra_lswitches)
         except NvpApiClient.NvpApiException:
-            err_desc = _(("An exception occured while selecting logical "
-                          "switch for the port"))
+            err_desc = _("An exception occured while selecting logical "
+                         "switch for the port")
             LOG.exception(err_desc)
             raise nvp_exc.NvpPluginException(err_msg=err_desc)
 
@@ -448,7 +448,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                                    port_data[ext_qos.QUEUE])
 
     def _nvp_create_port(self, context, port_data):
-        """ Driver for creating a logical switch port on NVP platform """
+        """Driver for creating a logical switch port on NVP platform."""
         # FIXME(salvatore-orlando): On the NVP platform we do not really have
         # external networks. So if as user tries and create a "regular" VIF
         # port on an external network we are unable to actually create.
@@ -540,7 +540,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         self._nvp_delete_port(context, port_data)
 
     def _nvp_create_router_port(self, context, port_data):
-        """ Driver for creating a switch port to be connected to a router """
+        """Driver for creating a switch port to be connected to a router."""
         # No router ports on external networks!
         if self._network_is_external(context, port_data['network_id']):
             raise nvp_exc.NvpPluginException(
@@ -586,7 +586,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         return lr_port
 
     def _nvp_create_ext_gw_port(self, context, port_data):
-        """ Driver for creating an external gateway port on NVP platform """
+        """Driver for creating an external gateway port on NVP platform."""
         # TODO(salvatore-orlando): Handle NVP resource
         # rollback when something goes not quite as expected
         lr_port = self._find_router_gw_port(context, port_data)
@@ -677,7 +677,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                    'router_id': router_id})
 
     def _nvp_create_l2_gw_port(self, context, port_data):
-        """ Create a switch port, and attach it to a L2 gateway attachment """
+        """Create a switch port, and attach it to a L2 gateway attachment."""
         # FIXME(salvatore-orlando): On the NVP platform we do not really have
         # external networks. So if as user tries and create a "regular" VIF
         # port on an external network we are unable to actually create.
@@ -727,10 +727,11 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         pass
 
     def _nvp_get_port_id(self, context, cluster, quantum_port):
-        """ Return the NVP port uuid for a given quantum port.
+        """Return the NVP port uuid for a given quantum port.
         First, look up the Quantum database. If not found, execute
         a query on NVP platform as the mapping might be missing because
-        the port was created before upgrading to grizzly. """
+        the port was created before upgrading to grizzly.
+        """
         nvp_port_id = nicira_db.get_nvp_port_id(context.session,
                                                 quantum_port['id'])
         if nvp_port_id:
@@ -747,12 +748,12 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                     quantum_port['id'],
                     nvp_port['uuid'])
                 return nvp_port['uuid']
-        except:
+        except Exception:
             LOG.exception(_("Unable to find NVP uuid for Quantum port %s"),
                           quantum_port['id'])
 
     def _extend_fault_map(self):
-        """ Extends the Quantum Fault Map
+        """Extends the Quantum Fault Map
 
         Exceptions specific to the NVP Plugin are mapped to standard
         HTTP Exceptions
@@ -777,7 +778,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         raise nvp_exc.NvpInvalidNovaZone(nova_zone=novazone_id)
 
     def _find_target_cluster(self, resource):
-        """ Return cluster where configuration should be applied
+        """Return cluster where configuration should be applied
 
         If the resource being configured has a paremeter expressing
         the zone id (nova_id), then select corresponding cluster,
@@ -863,7 +864,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                                   allow_extra_lswitches):
         lswitches = nvplib.get_lswitches(cluster, network.id)
         try:
-            # TODO find main_ls too!
+            # TODO(savatore-orlando) Find main_ls too!
             return [ls for ls in lswitches
                     if (ls['_relations']['LogicalSwitchStatus']
                         ['lport_count'] < max_ports)].pop(0)
@@ -1025,7 +1026,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def _get_lswitch_cluster_pairs(self, netw_id, tenant_id):
         """Figure out the set of lswitches on each cluster that maps to this
-           network id"""
+           network id
+        """
         pairs = []
         for c in self.clusters.itervalues():
             lswitches = []
@@ -1454,7 +1456,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         try:
             ret_port['status'] = nvplib.get_port_status(
                 self.default_cluster, ret_port['network_id'], nvp_port_id)
-        except:
+        except Exception:
             LOG.warn(_("Unable to retrieve port status for:%s."), nvp_port_id)
         return ret_port
 
@@ -1520,7 +1522,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
             # If there's no nvp IP do not bother going to NVP and put
             # the port in error state
             if nvp_id:
-                #TODO: pass the appropriate cluster here
+                #TODO(salvatore-orlando): pass the appropriate cluster here
                 try:
                     port = nvplib.get_logical_port_status(
                         self.default_cluster, quantum_db_port['network_id'],
@@ -1930,7 +1932,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                                        ips_to_remove=nvp_floating_ips)
 
     def _update_fip_assoc(self, context, fip, floatingip_db, external_port):
-        """ Update floating IP association data.
+        """Update floating IP association data.
 
         Overrides method from base class.
         The method is augmented for creating NAT rules in the process.
@@ -2048,7 +2050,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         super(NvpPluginV2, self).disassociate_floatingips(context, port_id)
 
     def create_network_gateway(self, context, network_gateway):
-        """ Create a layer-2 network gateway
+        """Create a layer-2 network gateway
 
         Create the gateway service on NVP platform and corresponding data
         structures in Quantum datase
@@ -2077,7 +2079,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                                                                network_gateway)
 
     def delete_network_gateway(self, context, id):
-        """ Remove a layer-2 network gateway
+        """Remove a layer-2 network gateway
 
         Remove the gateway service from NVP platform and corresponding data
         structures in Quantum datase
@@ -2156,12 +2158,12 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                 context, security_group_id)
 
     def create_security_group_rule(self, context, security_group_rule):
-        """create a single security group rule"""
+        """create a single security group rule."""
         bulk_rule = {'security_group_rules': [security_group_rule]}
         return self.create_security_group_rule_bulk(context, bulk_rule)[0]
 
     def create_security_group_rule_bulk(self, context, security_group_rule):
-        """ create security group rules
+        """create security group rules
         :param security_group_rule: list of rules to create
         """
         s = security_group_rule.get('security_group_rules')
@@ -2194,7 +2196,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                     context, security_group_rule)
 
     def delete_security_group_rule(self, context, sgrid):
-        """ Delete a security group rule
+        """Delete a security group rule
         :param sgrid: security group id to remove.
         """
         with context.session.begin(subtransactions=True):
index abfc838c3258cca032cd3f35bab0cfdf8f7e41cb..9ce9943a7b86f8862977b7def6a55da8131bbabd 100644 (file)
@@ -21,8 +21,8 @@
 
 from abc import ABCMeta
 import httplib
-import time
 import logging
+import time
 
 
 from quantum.plugins.nicira.api_client.common import (
index 0987991e0d3bc23e668d2cf598d3b7967025965f..da55356c885a362516dc470ffeccb5e51395197c 100644 (file)
@@ -23,8 +23,7 @@ import logging
 import time
 
 from quantum.plugins.nicira.api_client import client
-from quantum.plugins.nicira.api_client import (
-    request_eventlet)
+from quantum.plugins.nicira.api_client import request_eventlet
 
 eventlet.monkey_patch()
 
index 2bacc945117b6873243e42e7224f768c950bf0e3..db9f9c3d39ab750501601edec953914c9a6b2525 100644 (file)
@@ -15,7 +15,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-""" NVP Plugin exceptions """
+"""NVP Plugin exceptions"""
 
 from quantum.common import exceptions as q_exc
 
index fd5d65abd0c67da8b6df8dca5e7539fbe7ef37d3..444d4674f2891cd9b15f147f3a09351ebcddc5a5 100644 (file)
@@ -81,7 +81,7 @@ class NVPSecurityGroups(object):
         return self._convert_to_nvp_rules(rules, with_id)
 
     def _get_profile_uuid(self, context, remote_group_id):
-        """Return profile id from novas group id. """
+        """Return profile id from novas group id."""
         security_group = self.get_security_group(context, remote_group_id)
         if not security_group:
             raise ext_sg.SecurityGroupNotFound(id=remote_group_id)
index ae2295c0ae2cf1be1de6d8ebfb881b6660192d01..cff405798b66b5fb9797cc87968f10bc68d18384 100644 (file)
@@ -55,7 +55,7 @@ RESOURCE_ATTRIBUTE_MAP = {
 
 
 def _validate_device_list(data, valid_values=None):
-    """ Validate the list of service definitions. """
+    """Validate the list of service definitions."""
     if not data:
         # Devices must be provided
         msg = _("Cannot create a gateway with an empty device list")
@@ -89,7 +89,7 @@ attributes.validators['type:device_list'] = _validate_device_list
 
 
 class Nvp_networkgw(object):
-    """ API extension for Layer-2 Gateway support.
+    """API extension for Layer-2 Gateway support.
 
     The Layer-2 gateway feature allows for connecting quantum networks
     with external networks at the layer-2 level. No assumption is made on
@@ -122,7 +122,7 @@ class Nvp_networkgw(object):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         plugin = manager.QuantumManager.get_plugin()
         params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
 
index 9ecc7f86162c4f9354f49024267764b5ce69542b..45bf485893e0017709ef534a13d4eef291bdb97f 100644 (file)
@@ -20,9 +20,9 @@
 
 from abc import abstractmethod
 
+from quantum.api import extensions
 from quantum.api.v2 import attributes as attr
 from quantum.api.v2 import base
-from quantum.api import extensions
 from quantum.common import exceptions as qexception
 from quantum import manager
 
@@ -137,7 +137,7 @@ EXTENDED_ATTRIBUTES_2_0 = {
 
 
 class Nvp_qos(object):
-    """Port Queue extension"""
+    """Port Queue extension."""
 
     @classmethod
     def get_name(cls):
@@ -161,7 +161,7 @@ class Nvp_qos(object):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         exts = []
         plugin = manager.QuantumManager.get_plugin()
         resource_name = 'qos_queue'
index b4cdd5c7242371feb67a2279470870c2f8526aca..cc9d51b31536f476a0054829089f2466394c2bd0 100644 (file)
@@ -82,7 +82,7 @@ base.FAULT_MAP.update({GatewayInUse: web_exc.HTTPConflict,
 
 
 class NetworkConnection(model_base.BASEV2, models_v2.HasTenant):
-    """ Defines a connection between a network gateway and a network """
+    """Defines a connection between a network gateway and a network."""
     # We use port_id as the primary key as one can connect a gateway
     # to a network in multiple ways (and we cannot use the same port form
     # more than a single gateway)
@@ -115,7 +115,7 @@ class NetworkGatewayDevice(model_base.BASEV2):
 
 class NetworkGateway(model_base.BASEV2, models_v2.HasId,
                      models_v2.HasTenant):
-    """ Defines the data model for a network gateway """
+    """Defines the data model for a network gateway."""
     name = sa.Column(sa.String(255))
     # Tenant id is nullable for this resource
     tenant_id = sa.Column(sa.String(36))
@@ -194,7 +194,7 @@ class NetworkGatewayMixin(nvp_networkgw.NetworkGatewayPluginBase):
             gw['default'] = True
 
     def prevent_network_gateway_port_deletion(self, context, port):
-        """ Pre-deletion check.
+        """Pre-deletion check.
 
         Ensures a port will not be deleted if is being used by a network
         gateway. In that case an exception will be raised.
index b4e36eca105da76fe648114e6a69ac4189dcb249..0a5eadfd7dff161ac0c6d109e5cc79b0fcaa03a6 100644 (file)
@@ -153,7 +153,7 @@ def _check_and_truncate_name(display_name):
 
 
 def get_cluster_version(cluster):
-    """Return major/minor version #"""
+    """Return major/minor version #."""
     # Get control-cluster nodes
     uri = "/ws.v1/control-cluster/node?_page_length=1&fields=uuid"
     try:
@@ -199,7 +199,8 @@ def get_all_query_pages(path, c):
 
 def do_single_request(*args, **kwargs):
     """Issue a request to a specified cluster if specified via kwargs
-       (cluster=<cluster>)."""
+       (cluster=<cluster>).
+    """
     cluster = kwargs["cluster"]
     try:
         req = cluster.api_client.request(*args)
@@ -209,7 +210,7 @@ def do_single_request(*args, **kwargs):
 
 
 def do_multi_request(*args, **kwargs):
-    """Issue a request to all clusters"""
+    """Issue a request to all clusters."""
     results = []
     clusters = kwargs["clusters"]
     for x in clusters:
@@ -343,7 +344,7 @@ def update_lswitch(cluster, lswitch_id, display_name,
 
 
 def create_l2_gw_service(cluster, tenant_id, display_name, devices):
-    """ Create a NVP Layer-2 Network Gateway Service.
+    """Create a NVP Layer-2 Network Gateway Service.
 
         :param cluster: The target NVP cluster
         :param tenant_id: Identifier of the Openstack tenant for which
@@ -379,7 +380,7 @@ def create_l2_gw_service(cluster, tenant_id, display_name, devices):
 
 
 def create_lrouter(cluster, tenant_id, display_name, nexthop):
-    """ Create a NVP logical router on the specified cluster.
+    """Create a NVP logical router on the specified cluster.
 
         :param cluster: The target NVP cluster
         :param tenant_id: Identifier of the Openstack tenant for which
@@ -776,7 +777,7 @@ def create_lport(cluster, lswitch_uuid, tenant_id, quantum_port_id,
                  display_name, device_id, admin_status_enabled,
                  mac_address=None, fixed_ips=None, port_security_enabled=None,
                  security_profiles=None, queue_id=None):
-    """ Creates a logical port on the assigned logical switch """
+    """Creates a logical port on the assigned logical switch."""
     # device_id can be longer than 40 so we rehash it
     hashed_device_id = hashlib.sha1(device_id).hexdigest()
     display_name = _check_and_truncate_name(display_name)
@@ -810,7 +811,7 @@ def create_lport(cluster, lswitch_uuid, tenant_id, quantum_port_id,
 
 def create_router_lport(cluster, lrouter_uuid, tenant_id, quantum_port_id,
                         display_name, admin_status_enabled, ip_addresses):
-    """ Creates a logical port on the assigned logical router """
+    """Creates a logical port on the assigned logical router."""
     tags = [dict(scope='os_tid', tag=tenant_id),
             dict(scope='q_port_id', tag=quantum_port_id)]
     lport_obj = dict(
@@ -841,7 +842,7 @@ def create_router_lport(cluster, lrouter_uuid, tenant_id, quantum_port_id,
 def update_router_lport(cluster, lrouter_uuid, lrouter_port_uuid,
                         tenant_id, quantum_port_id, display_name,
                         admin_status_enabled, ip_addresses):
-    """ Updates a logical port on the assigned logical router """
+    """Updates a logical port on the assigned logical router."""
     lport_obj = dict(
         admin_status_enabled=admin_status_enabled,
         display_name=display_name,
@@ -874,7 +875,7 @@ def update_router_lport(cluster, lrouter_uuid, lrouter_port_uuid,
 
 
 def delete_router_lport(cluster, lrouter_uuid, lport_uuid):
-    """ Creates a logical port on the assigned logical router """
+    """Creates a logical port on the assigned logical router."""
     path = _build_uri_path(LROUTERPORT_RESOURCE, lport_uuid, lrouter_uuid)
     try:
         do_single_request(HTTP_DELETE, path, cluster=cluster)
@@ -906,7 +907,7 @@ def delete_peer_router_lport(cluster, lr_uuid, ls_uuid, lp_uuid):
 
 
 def find_router_gw_port(context, cluster, router_id):
-    """ Retrieves the external gateway port for a NVP logical router """
+    """Retrieves the external gateway port for a NVP logical router."""
 
     # Find the uuid of nvp ext gw logical router port
     # TODO(salvatore-orlando): Consider storing it in Quantum DB
@@ -959,7 +960,7 @@ def plug_router_port_attachment(cluster, router_id, port_id,
 
 
 def get_port_status(cluster, lswitch_id, port_id):
-    """Retrieve the operational status of the port"""
+    """Retrieve the operational status of the port."""
     try:
         r = do_single_request(HTTP_GET,
                               "/ws.v1/lswitch/%s/lport/%s/status" %
@@ -996,7 +997,7 @@ def _plug_interface(cluster, lswitch_id, lport_id, att_obj):
 
 def plug_l2_gw_service(cluster, lswitch_id, lport_id,
                        gateway_id, vlan_id=None):
-    """ Plug a Layer-2 Gateway Attachment object in a logical port """
+    """Plug a Layer-2 Gateway Attachment object in a logical port."""
     att_obj = {'type': 'L2GatewayAttachment',
                'l2_gateway_service_uuid': gateway_id}
     if vlan_id:
@@ -1005,7 +1006,7 @@ def plug_l2_gw_service(cluster, lswitch_id, lport_id,
 
 
 def plug_interface(cluster, lswitch_id, port, type, attachment=None):
-    """ Plug a VIF Attachment object in a logical port """
+    """Plug a VIF Attachment object in a logical port."""
     lport_obj = {}
     if attachment:
         lport_obj["vif_uuid"] = attachment
@@ -1044,7 +1045,8 @@ def do_request(*args, **kwargs):
     :param args: a list of positional arguments.
     :param kwargs: a list of keyworkds arguments.
     :returns: the result of do_single_request loaded into a python object
-        or None."""
+        or None.
+    """
     res = do_single_request(*args, **kwargs)
     if res:
         return json.loads(res)
@@ -1055,7 +1057,8 @@ def mk_body(**kwargs):
     """Convenience function creates and dumps dictionary to string.
 
     :param kwargs: the key/value pirs to be dumped into a json string.
-    :returns: a json string."""
+    :returns: a json string.
+    """
     return json.dumps(kwargs, ensure_ascii=False)
 
 
@@ -1065,7 +1068,8 @@ def set_tenant_id_tag(tenant_id, taglist=None):
     :param tenant_id: the tenant_id to set.
     :param taglist: the taglist to append to (or None).
     :returns: a new taglist that includes the old taglist with the new
-        tenant_id tag set."""
+        tenant_id tag set.
+    """
     new_taglist = []
     if taglist:
         new_taglist = [x for x in taglist if x['scope'] != TENANT_ID_SCOPE]
@@ -1402,7 +1406,7 @@ def delete_lqueue(cluster, id):
 # NVP API Calls for check_nvp_config utility
 # -----------------------------------------------------------------------------
 def check_cluster_connectivity(cluster):
-    """Make sure that we can issue a request to each of the cluster nodes"""
+    """Make sure that we can issue a request to each of the cluster nodes."""
     try:
         resp = do_single_request(HTTP_GET, "/ws.v1/control-cluster",
                                  cluster=cluster)
index a49cda34f48c95d340fe871b86eb451082f14f43..15244cda509ca5ab3fbe39a77d96992a22db9d77 100644 (file)
@@ -89,7 +89,7 @@ class Port(object):
             return (self and other
                     and self.id == other.id
                     and self.admin_state_up == other.admin_state_up)
-        except:
+        except Exception:
             return False
 
     def __ne__(self, other):
@@ -377,7 +377,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
 
         :param net_uuid: the network uuid associated with this vlan.
         :param lvm: a LocalVLANMapping object that tracks (vlan, lsw_id,
-            vif_ids) mapping.'''
+            vif_ids) mapping.
+        '''
         LOG.info(_("Reclaiming vlan = %(vlan_id)s from net-id = %(net_uuid)s"),
                  {'vlan_id': lvm.vlan,
                   'net_uuid': net_uuid})
@@ -457,7 +458,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
         VIF.
 
         :param vif_id: the id of the vif
-        :param net_uuid: the net_uuid this port is associated with.'''
+        :param net_uuid: the net_uuid this port is associated with.
+        '''
         if net_uuid is None:
             net_uuid = self.get_net_uuid(vif_id)
 
@@ -484,7 +486,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
     def port_dead(self, port):
         '''Once a port has no binding, put it on the "dead vlan".
 
-        :param port: a ovs_lib.VifPort object.'''
+        :param port: a ovs_lib.VifPort object.
+        '''
         self.int_br.set_db_attribute("Port", port.port_name, "tag",
                                      DEAD_VLAN_TAG)
         self.int_br.add_flow(priority=2, in_port=port.ofport, actions="drop")
@@ -510,7 +513,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
         Creates tunnel bridge, and links it to the integration bridge
         using a patch port.
 
-        :param tun_br: the name of the tunnel bridge.'''
+        :param tun_br: the name of the tunnel bridge.
+        '''
         self.tun_br = ovs_lib.OVSBridge(tun_br, self.root_helper)
         self.tun_br.reset_bridge()
         self.patch_tun_ofport = self.int_br.add_patch_port(
@@ -532,7 +536,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
         Creates physical network bridges and links them to the
         integration bridge using veths.
 
-        :param bridge_mappings: map physical network names to bridge names.'''
+        :param bridge_mappings: map physical network names to bridge names.
+        '''
         self.phys_brs = {}
         self.int_ofports = {}
         self.phys_ofports = {}
@@ -702,7 +707,7 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                     sync = self.process_network_ports(port_info)
                     ports = port_info['current']
 
-            except:
+            except Exception:
                 LOG.exception(_("Error in agent event loop"))
                 sync = True
                 tunnel_sync = True
index 5c6b68b36664d8ce192f77ad51a435f6f9ee3db1..a03dc732459eb001c5f456294cd6abb036690251 100644 (file)
@@ -56,7 +56,7 @@ def add_network_binding(session, network_id, network_type,
 
 
 def sync_vlan_allocations(network_vlan_ranges):
-    """Synchronize vlan_allocations table with configured VLAN ranges"""
+    """Synchronize vlan_allocations table with configured VLAN ranges."""
 
     session = db.get_session()
     with session.begin():
@@ -197,7 +197,7 @@ def release_vlan(session, physical_network, vlan_id, network_vlan_ranges):
 
 
 def sync_tunnel_allocations(tunnel_id_ranges):
-    """Synchronize tunnel_allocations table with configured tunnel ranges"""
+    """Synchronize tunnel_allocations table with configured tunnel ranges."""
 
     # determine current configured allocatable tunnels
     tunnel_ids = set()
@@ -310,7 +310,7 @@ def get_port(port_id):
 
 
 def get_port_from_device(port_id):
-    """Get port from database"""
+    """Get port from database."""
     LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
     session = db.get_session()
     sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
index 119bd8c7af647090ca06937e2735ae7d696a4c4b..e508e750f1828db9cdb38f6c24bf0dda397d0006 100644 (file)
@@ -23,7 +23,7 @@ from quantum.db.models_v2 import model_base
 
 
 class VlanAllocation(model_base.BASEV2):
-    """Represents allocation state of vlan_id on physical network"""
+    """Represents allocation state of vlan_id on physical network."""
     __tablename__ = 'ovs_vlan_allocations'
 
     physical_network = Column(String(64), nullable=False, primary_key=True)
@@ -42,7 +42,7 @@ class VlanAllocation(model_base.BASEV2):
 
 
 class TunnelAllocation(model_base.BASEV2):
-    """Represents allocation state of tunnel_id"""
+    """Represents allocation state of tunnel_id."""
     __tablename__ = 'ovs_tunnel_allocations'
 
     tunnel_id = Column(Integer, nullable=False, primary_key=True,
@@ -58,7 +58,7 @@ class TunnelAllocation(model_base.BASEV2):
 
 
 class NetworkBinding(model_base.BASEV2):
-    """Represents binding of virtual network to physical realization"""
+    """Represents binding of virtual network to physical realization."""
     __tablename__ = 'ovs_network_bindings'
 
     network_id = Column(String(36),
@@ -84,7 +84,7 @@ class NetworkBinding(model_base.BASEV2):
 
 
 class TunnelIP(model_base.BASEV2):
-    """Represents tunnel endpoint in DB mode"""
+    """Represents tunnel endpoint in DB mode."""
     __tablename__ = 'ovs_tunnel_ips'
 
     ip_address = Column(String(255), primary_key=True)
@@ -97,7 +97,7 @@ class TunnelIP(model_base.BASEV2):
 
 
 class TunnelEndpoint(model_base.BASEV2):
-    """Represents tunnel endpoint in RPC mode"""
+    """Represents tunnel endpoint in RPC mode."""
     __tablename__ = 'ovs_tunnel_endpoints'
 
     ip_address = Column(String(64), primary_key=True)
index 52072325984d10f6373cfe60bb5a7661f329d68f..faf8f65197dc14824f1b1059723cd1d07626f3ae 100644 (file)
@@ -85,7 +85,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         return port
 
     def get_device_details(self, rpc_context, **kwargs):
-        """Agent requests device details"""
+        """Agent requests device details."""
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
@@ -110,8 +110,8 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         return entry
 
     def update_device_down(self, rpc_context, **kwargs):
-        """Device no longer exists on agent"""
-        # (TODO) garyk - live migration and port status
+        """Device no longer exists on agent."""
+        # TODO(garyk) - live migration and port status
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
@@ -130,7 +130,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         return entry
 
     def update_device_up(self, rpc_context, **kwargs):
-        """Device is up on agent"""
+        """Device is up on agent."""
         agent_id = kwargs.get('agent_id')
         device = kwargs.get('device')
         LOG.debug(_("Device %(device)s up on %(agent_id)s"),
index 4201cce16884bc8f05117375e01b0e90e77bfc4b..015c6730e0884c775d09384da320c9ff3da65279 100644 (file)
@@ -17,7 +17,7 @@
 # @author: Edgar Magana, emagana@plumgrid.com, PLUMgrid, Inc.
 
 
-""" Quantum PLUMgrid Plugin exceptions """
+"""Quantum PLUMgrid Plugin exceptions"""
 
 from quantum.common import exceptions as base_exec
 
index ac026d0f4001236b0477ef92f839946c4f644da9..5b098d71cc63b9698e288feba6e564f7d5109f1a 100644 (file)
@@ -65,7 +65,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
         self.topology_name = cfg.CONF.PLUMgridNOS.topologyname
         self.snippets = plumgrid_nos_snippets.DataNOSPLUMgrid()
 
-        # TODO(Edgar) These are placeholders for next PLUMgrid release
+        # TODO(Edgar) These are placeholders for next PLUMgrid release
         cfg.CONF.PLUMgridNOS.username
         cfg.CONF.PLUMgridNOS.password
         self.rest_conn = rest_connection.RestConnection(nos_plumgrid,
@@ -104,15 +104,20 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                                                                       network)
 
             try:
-                LOG.debug(_('QuantumPluginPLUMgrid Status: %s, %s, %s'),
-                          tenant_id, network["network"], net["id"])
+                LOG.debug(_('QuantumPluginPLUMgrid Status: %(tenant_id)s, '
+                            '%(network)s, %(network_id)s'),
+                          dict(
+                              tenant_id=tenant_id,
+                              network=network["network"],
+                              network_id=net["id"],
+                          ))
                 nos_url = self.snippets.BASE_NOS_URL + net["id"]
                 headers = {}
                 body_data = self.snippets.create_domain_body_data(tenant_id)
                 self.rest_conn.nos_rest_conn(nos_url,
                                              'PUT', body_data, headers)
 
-            except:
+            except Exception:
                 err_message = _("PLUMgrid NOS communication failed")
                 LOG.Exception(err_message)
                 raise plum_excep.PLUMgridException(err_message)
@@ -146,7 +151,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                 body_data = self.snippets.create_domain_body_data(tenant_id)
                 self.rest_conn.nos_rest_conn(nos_url,
                                              'PUT', body_data, headers)
-            except:
+            except Exception:
                 err_message = _("PLUMgrid NOS communication failed")
                 LOG.Exception(err_message)
                 raise plum_excep.PLUMgridException(err_message)
@@ -172,7 +177,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                 body_data = {}
                 self.rest_conn.nos_rest_conn(nos_url,
                                              'DELETE', body_data, headers)
-            except:
+            except Exception:
                 err_message = _("PLUMgrid NOS communication failed")
                 LOG.Exception(err_message)
                 raise plum_excep.PLUMgridException(err_message)
@@ -240,7 +245,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                     tenant_id, self.topology_name)
                 self.rest_conn.nos_rest_conn(nos_url,
                                              'PUT', body_data, headers)
-            except:
+            except Exception:
                 err_message = _("PLUMgrid NOS communication failed: ")
                 LOG.Exception(err_message)
                 raise plum_excep.PLUMgridException(err_message)
@@ -265,7 +270,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                 body_data = {}
                 net_id = subnet_details["network_id"]
                 self._cleaning_nos_subnet_structure(body_data, headers, net_id)
-            except:
+            except Exception:
                 err_message = _("PLUMgrid NOS communication failed: ")
                 LOG.Exception(err_message)
                 raise plum_excep.PLUMgridException(err_message)
@@ -299,7 +304,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                 self.rest_conn.nos_rest_conn(nos_url,
                                              'PUT', body_data, headers)
 
-            except:
+            except Exception:
                 err_message = _("PLUMgrid NOS communication failed: ")
                 LOG.Exception(err_message)
                 raise plum_excep.PLUMgridException(err_message)
@@ -309,7 +314,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
     """
     Extension API implementation
     """
-    # TODO(Edgar) Complete extensions for PLUMgrid
+    # TODO(Edgar) Complete extensions for PLUMgrid
 
     """
     Internal PLUMgrid fuctions
@@ -332,7 +337,7 @@ class QuantumPluginPLUMgridV2(db_base_plugin_v2.QuantumDbPluginV2):
                     LOG.warning(_("Network with admin_state_up=False are not "
                                   "supported yet by this plugin. Ignoring "
                                   "setting for network %s"), network_name)
-        except:
+        except Exception:
             err_message = _("Network Admin State Validation Falied: ")
             LOG.Exception(err_message)
             raise plum_excep.PLUMgridException(err_message)
index f38b55df4cc706b3bdf450d6966de2ec044f784e..5d15c76272430b8ffd348375e8cfa37ee29b9044 100644 (file)
@@ -50,8 +50,8 @@ class RestConnection(object):
         headers['Content-type'] = 'application/json'
         headers['Accept'] = 'application/json'
 
-        LOG.debug(_("PLUMgrid_NOS_Server: %s %s %s"), self.server, self.port,
-                  action)
+        LOG.debug(_("PLUMgrid_NOS_Server: %(server)s %(port)s %(action)s"),
+                  dict(server=self.server, port=self.port, action=action))
 
         conn = httplib.HTTPConnection(self.server, self.port,
                                       timeout=self.timeout)
@@ -61,14 +61,19 @@ class RestConnection(object):
             return
 
         try:
-            LOG.debug(_("PLUMgrid_NOS_Server Sending Data: %s %s %s"),
-                      nos_url, body_data, headers)
+            LOG.debug(_("PLUMgrid_NOS_Server Sending Data: %(nos_url)s "
+                        "%(body_data)s %(headers)s"),
+                      dict(
+                          nos_url=nos_url,
+                          body_data=body_data,
+                          headers=headers,
+                      ))
             conn.request(action, nos_url, body_data, headers)
             resp = conn.getresponse()
             resp_str = resp.read()
 
-            LOG.debug(_("PLUMgrid_NOS_Server Connection Data: %s, %s"),
-                      resp, resp_str)
+            LOG.debug(_("PLUMgrid_NOS_Server Connection Data: %(resp)s, "
+                        "%(resp_str)s"), dict(resp=resp, resp_str=resp_str))
 
             if resp.status is httplib.OK:
                 try:
index 14243fa1628340e58533f0fb5fcfa0a2da6bcd31..f20cb5b306fe60afdc527c9f88f69abf22007260 100755 (executable)
@@ -260,7 +260,7 @@ class OVSQuantumOFPRyuAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                     LOG.debug(_("Agent loop has new device"))
                     self._process_devices_filter(port_info)
                     ports = port_info['current']
-            except:
+            except Exception:
                 LOG.exception(_("Error in agent event loop"))
 
             elapsed = max(time.time() - start, 0)
index 34ab0b9d95dca0356855520e39ee1d8179f14c6e..3c8c78d4788f7b9f9d19c8170cc6cd85f82302cf 100644 (file)
@@ -161,7 +161,7 @@ class RyuQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
             tunnel_key = self.tunnel_key.allocate(session, net['id'])
             try:
                 self._client_create_network(net['id'], tunnel_key)
-            except:
+            except Exception:
                 self._client_delete_network(net['id'])
                 raise
 
index f8c002c847fae12f839dc83b23cb231dbb218df3..8d49cf7de6aa157b87228229e1f7c0abd5169e5f 100644 (file)
@@ -57,7 +57,7 @@ class LogicalDeviceCache(object):
     """Manage a cache of known devices."""
 
     class Device(object):
-        """Inner classes used to hold values for weakref lookups"""
+        """Inner classes used to hold values for weakref lookups."""
         def __init__(self, port_id, pool_id):
             self.port_id = port_id
             self.pool_id = pool_id
index 7e1e267c309c0203b956dc6bac8383d06ed4dc69..c8570049355847c72b67bec834b8c7e28491aecd 100644 (file)
@@ -53,7 +53,7 @@ ACTIVE = qconstants.ACTIVE
 
 
 def save_config(conf_path, logical_config, socket_path=None):
-    """Convert a logical configuration to the HAProxy version"""
+    """Convert a logical configuration to the HAProxy version."""
     data = []
     data.extend(_build_global(logical_config, socket_path=socket_path))
     data.extend(_build_defaults(logical_config))
@@ -156,7 +156,7 @@ def _get_first_ip_from_port(port):
 
 
 def _get_server_health_option(config):
-    """return the first active health option"""
+    """return the first active health option."""
     for monitor in config['healthmonitors']:
         if monitor['status'] == ACTIVE and monitor['admin_state_up']:
             break
index a656ca8d6e08cceb838f31ac4eca33db107a4277..a347326961a68228eccb6ad2f6d05dcd824b242f 100644 (file)
@@ -175,7 +175,7 @@ class LoadBalancerCallbacks(object):
             LOG.debug(msg, port_id)
 
     def update_pool_stats(self, context, pool_id=None, stats=None, host=None):
-        # TODO (markmcclain): add stats collection
+        # TODO(markmcclain): add stats collection
         pass
 
 
index ef933c08a0fa67e14e0bdf59c23eba5a19c78870..936621ab3d6c6b3ea8eaf64f26cc98a686726048 100644 (file)
@@ -21,19 +21,20 @@ from quantum.api import extensions
 
 
 class ServicePluginBase(extensions.PluginInterface):
-    """ defines base interface for any Advanced Service plugin """
+    """defines base interface for any Advanced Service plugin."""
     __metaclass__ = abc.ABCMeta
     supported_extension_aliases = []
 
     @abc.abstractmethod
     def get_plugin_type(self):
-        """ returns one of predefine service types. see
-            quantum/plugins/common/constants.py """
+        """returns one of predefine service types. see
+            quantum/plugins/common/constants.py
+        """
         pass
 
     @abc.abstractmethod
     def get_plugin_name(self):
-        """ return a symbolic name for the plugin.
+        """return a symbolic name for the plugin.
 
         Each service plugin should have a symbolic name. This name
         will be used, for instance, by service definitions in service types
@@ -42,5 +43,5 @@ class ServicePluginBase(extensions.PluginInterface):
 
     @abc.abstractmethod
     def get_plugin_description(self):
-        """ returns string description of the plugin """
+        """returns string description of the plugin."""
         pass
index 67211611e67404e91567000ff55028d35acd5394..1683d5c7c093a87b799eef758d3d740fc95e654d 100644 (file)
@@ -57,7 +57,7 @@ def init():
 
 
 def get_resource_and_action(action):
-    """ Extract resource and action (write, read) from api operation """
+    """Extract resource and action (write, read) from api operation."""
     data = action.split(':', 1)[0].split('_', 1)
     return ("%ss" % data[-1], data[0] != 'get')
 
@@ -68,7 +68,7 @@ def _set_rules(data):
 
 
 def _is_attribute_explicitly_set(attribute_name, resource, target):
-    """Verify that an attribute is present and has a non-default value"""
+    """Verify that an attribute is present and has a non-default value."""
     return ('default' in resource[attribute_name] and
             attribute_name in target and
             target[attribute_name] is not attributes.ATTR_NOT_SPECIFIED and
index 58b3c183f471994e8fb9895462922b7ce4b38fb7..28b5e1bd34b4513293a28112c2d0dadebbdd95f6 100644 (file)
@@ -21,7 +21,7 @@ import re
 
 
 class CommandFilter(object):
-    """Command filter only checking that the 1st argument matches exec_path"""
+    """Command filter only checking that the 1st argument matches exec_path."""
 
     def __init__(self, exec_path, run_as, *args):
         self.exec_path = exec_path
@@ -29,7 +29,7 @@ class CommandFilter(object):
         self.args = args
 
     def match(self, userargs):
-        """Only check that the first argument (command) matches exec_path"""
+        """Only check that the first argument (command) matches exec_path."""
         return os.path.basename(self.exec_path) == userargs[0]
 
     def get_command(self, userargs):
@@ -40,7 +40,7 @@ class CommandFilter(object):
         return [self.exec_path] + userargs[1:]
 
     def get_environment(self, userargs):
-        """Returns specific environment to set, None if none"""
+        """Returns specific environment to set, None if none."""
         return None
 
 
@@ -50,7 +50,7 @@ class ExecCommandFilter(CommandFilter):
 
 
 class RegExpFilter(CommandFilter):
-    """Command filter doing regexp matching for every argument"""
+    """Command filter doing regexp matching for every argument."""
 
     def match(self, userargs):
         # Early skip if command or number of args don't match
@@ -74,7 +74,7 @@ class RegExpFilter(CommandFilter):
 
 
 class DnsmasqFilter(CommandFilter):
-    """Specific filter for the dnsmasq call (which includes env)"""
+    """Specific filter for the dnsmasq call (which includes env)."""
 
     def is_dnsmasq_cmd(self, argv):
         if (argv[0] == "dnsmasq"):
@@ -89,7 +89,8 @@ class DnsmasqFilter(CommandFilter):
 
     def match(self, userargs):
         """This matches the combination of the leading env
-        vars plus "dnsmasq" """
+        vars plus "dnsmasq"
+        """
         if (self.is_dnsmasq_env_vars(userargs) and
             self.is_dnsmasq_cmd(userargs[2:])):
             return True
@@ -106,7 +107,7 @@ class DnsmasqFilter(CommandFilter):
 
 
 class DnsmasqNetnsFilter(DnsmasqFilter):
-    """Specific filter for the dnsmasq call (which includes env)"""
+    """Specific filter for the dnsmasq call (which includes env)."""
 
     def is_ip_netns_cmd(self, argv):
         if ((argv[0] == "ip") and
@@ -117,7 +118,8 @@ class DnsmasqNetnsFilter(DnsmasqFilter):
 
     def match(self, userargs):
         """This matches the combination of the leading env
-        vars plus "ip" "netns" "exec" <foo> "dnsmasq" """
+        vars plus "ip" "netns" "exec" <foo> "dnsmasq"
+        """
         if (self.is_dnsmasq_env_vars(userargs) and
             self.is_ip_netns_cmd(userargs[2:]) and
             self.is_dnsmasq_cmd(userargs[6:])):
@@ -172,7 +174,7 @@ class KillFilter(CommandFilter):
 
 
 class ReadFileFilter(CommandFilter):
-    """Specific filter for the utils.read_file_as_root call"""
+    """Specific filter for the utils.read_file_as_root call."""
 
     def __init__(self, file_path, *args):
         self.file_path = file_path
index 85a2387fa482a7b157c664897f15e5a6c7b7ab37..92198c49fdc03e7879fad555fec79d615d8399fb 100644 (file)
@@ -27,7 +27,7 @@ from quantum.rootwrap import filters
 
 
 def build_filter(class_name, *args):
-    """Returns a filter object of class class_name"""
+    """Returns a filter object of class class_name."""
     if not hasattr(filters, class_name):
         # TODO(jrd): Log the error (whenever quantum-rootwrap has a log file)
         return None
@@ -36,7 +36,7 @@ def build_filter(class_name, *args):
 
 
 def load_filters(filters_path):
-    """Load filters from a list of directories"""
+    """Load filters from a list of directories."""
     filterlist = []
     for filterdir in filters_path:
         if not os.path.isdir(filterdir):
index d0b63d4f29171df2f79d74dfcd52c73ab6df483d..3133eb23f6925f49b6106b5b886992f6bcee7762 100644 (file)
@@ -21,9 +21,9 @@ from sqlalchemy.orm import exc
 from sqlalchemy.sql import exists
 
 from quantum.common import constants
-from quantum.db import models_v2
 from quantum.db import agents_db
 from quantum.db import agentschedulers_db
+from quantum.db import models_v2
 from quantum.openstack.common import log as logging
 
 
@@ -33,7 +33,8 @@ LOG = logging.getLogger(__name__)
 class ChanceScheduler(object):
     """Allocate a DHCP agent for a network in a random way.
     More sophisticated scheduler (similar to filter scheduler in nova?)
-    can be introduced later."""
+    can be introduced later.
+    """
 
     def schedule(self, plugin, context, network):
         """Schedule the network to an active DHCP agent if there
@@ -75,7 +76,8 @@ class ChanceScheduler(object):
 
     def auto_schedule_networks(self, plugin, context, host):
         """Schedule non-hosted networks to the DHCP agent on
-        the specified host."""
+        the specified host.
+        """
         with context.session.begin(subtransactions=True):
             query = context.session.query(agents_db.Agent)
             query = query.filter(agents_db.Agent.agent_type ==
index 73f5d224e5dbed8973e7189b17f763134ad871bf..f7a477ff3f78b068f43259072fa37b41d4755c56 100644 (file)
@@ -21,9 +21,9 @@ from sqlalchemy.orm import exc
 from sqlalchemy.sql import exists
 
 from quantum.common import constants
-from quantum.db import l3_db
 from quantum.db import agents_db
 from quantum.db import agentschedulers_db
+from quantum.db import l3_db
 from quantum.openstack.common import log as logging
 
 
@@ -33,7 +33,8 @@ LOG = logging.getLogger(__name__)
 class ChanceScheduler(object):
     """Allocate a L3 agent for a router in a random way.
     More sophisticated scheduler (similar to filter scheduler in nova?)
-    can be introduced later."""
+    can be introduced later.
+    """
 
     def auto_schedule_routers(self, plugin, context, host, router_id):
         """Schedule non-hosted routers to L3 Agent running on host.
index 33529288a3be30b85237445140d2f91c9e3dcf6a..2dc80e7fc615b78a8443a541ad20682fafa6df0c 100644 (file)
@@ -120,7 +120,8 @@ class Service(service.Service):
     """Service object for binaries running on hosts.
 
     A service takes a manager and enables rpc by listening to queues based
-    on topic. It also periodically runs tasks on the manager."""
+    on topic. It also periodically runs tasks on the manager.
+    """
 
     def __init__(self, host, binary, topic, manager, report_interval=None,
                  periodic_interval=None, periodic_fuzzy_delay=None,
index 9d53ff134616b579ab72a8ce53a64ced4a33b2de..88e1e3fc1c2974c3a013278da7387296a1b9143e 100644 (file)
@@ -29,7 +29,7 @@ TEST_VLAN = 1000
 
 
 class TestBrocadeDb(test_plugin.QuantumDbPluginV2TestCase):
-    """Test brocade db functionality"""
+    """Test brocade db functionality."""
 
     def test_create_network(self):
         """Test brocade specific network db."""
index 583f166013f84335200cbeb97e279447798f0efc..bfae58e98688aeb419c7c3aff1299710d87c35e4 100644 (file)
@@ -17,7 +17,7 @@
 #
 # @author: Rohit Agarwalla, Cisco Systems, Inc.
 
-""" stubs.py provides interface methods for the database test cases """
+"""stubs.py provides interface methods for the database test cases"""
 
 from quantum.db import api as db
 from quantum.openstack.common import log as logging
@@ -27,9 +27,9 @@ LOG = logging.getLogger(__name__)
 
 
 class QuantumDB(object):
-    """Class conisting of methods to call Quantum db methods"""
+    """Class conisting of methods to call Quantum db methods."""
     def get_all_networks(self, tenant_id):
-        """Get all networks"""
+        """Get all networks."""
         nets = []
         try:
             for net in db.network_list(tenant_id):
@@ -44,7 +44,7 @@ class QuantumDB(object):
         return nets
 
     def get_network(self, network_id):
-        """Get a network"""
+        """Get a network."""
         net = []
         try:
             for net in db.network_get(network_id):
@@ -59,7 +59,7 @@ class QuantumDB(object):
         return net
 
     def create_network(self, tenant_id, net_name):
-        """Create a network"""
+        """Create a network."""
         net_dict = {}
         try:
             res = db.network_create(tenant_id, net_name)
@@ -72,7 +72,7 @@ class QuantumDB(object):
             LOG.error("Failed to create network: %s", str(exc))
 
     def delete_network(self, net_id):
-        """Delete a network"""
+        """Delete a network."""
         try:
             net = db.network_destroy(net_id)
             LOG.debug("Deleted network: %s", net.uuid)
@@ -83,7 +83,7 @@ class QuantumDB(object):
             LOG.error("Failed to delete network: %s", str(exc))
 
     def update_network(self, tenant_id, net_id, param_data):
-        """Rename a network"""
+        """Rename a network."""
         try:
             print param_data
             net = db.network_update(net_id, tenant_id, **param_data)
@@ -96,7 +96,7 @@ class QuantumDB(object):
             LOG.error("Failed to update network: %s", str(exc))
 
     def get_all_ports(self, net_id):
-        """Get all ports"""
+        """Get all ports."""
         ports = []
         try:
             for port in db.port_list(net_id):
@@ -112,7 +112,7 @@ class QuantumDB(object):
             LOG.error("Failed to get all ports: %s", str(exc))
 
     def get_port(self, net_id, port_id):
-        """Get a port"""
+        """Get a port."""
         port_list = []
         port = db.port_get(port_id, net_id)
         try:
@@ -128,7 +128,7 @@ class QuantumDB(object):
             LOG.error("Failed to get port: %s", str(exc))
 
     def create_port(self, net_id):
-        """Add a port"""
+        """Add a port."""
         port_dict = {}
         try:
             port = db.port_create(net_id)
@@ -142,7 +142,7 @@ class QuantumDB(object):
             LOG.error("Failed to create port: %s", str(exc))
 
     def delete_port(self, net_id, port_id):
-        """Delete a port"""
+        """Delete a port."""
         try:
             port = db.port_destroy(port_id, net_id)
             LOG.debug("Deleted port %s", port.uuid)
@@ -153,7 +153,7 @@ class QuantumDB(object):
             LOG.error("Failed to delete port: %s", str(exc))
 
     def update_port(self, net_id, port_id, **kwargs):
-        """Update a port"""
+        """Update a port."""
         try:
             port = db.port_update(port_id, net_id, **kwargs)
             LOG.debug("Updated port %s", port.uuid)
@@ -167,7 +167,7 @@ class QuantumDB(object):
             LOG.error("Failed to update port state: %s", str(exc))
 
     def plug_interface(self, net_id, port_id, int_id):
-        """Plug interface to a port"""
+        """Plug interface to a port."""
         try:
             port = db.port_set_attachment(port_id, net_id, int_id)
             LOG.debug("Attached interface to port %s", port.uuid)
@@ -181,7 +181,7 @@ class QuantumDB(object):
             LOG.error("Failed to plug interface: %s", str(exc))
 
     def unplug_interface(self, net_id, port_id):
-        """Unplug interface to a port"""
+        """Unplug interface to a port."""
         try:
             db.port_unset_attachment(port_id, net_id)
             LOG.debug("Detached interface from port %s", port_id)
index 08e251259e672a8b83c2be7e3aafe1534ec9c771..590ac6907f6b428ad05702942753121dffd146cb 100644 (file)
@@ -20,10 +20,10 @@ import testtools
 
 import webob.exc
 
-from quantum import context
 from quantum.api.extensions import ExtensionMiddleware
 from quantum.api.extensions import PluginAwareExtensionManager
 from quantum.common import config
+from quantum import context
 from quantum.db.loadbalancer import loadbalancer_db as ldb
 import quantum.extensions
 from quantum.extensions import loadbalancer
@@ -291,7 +291,7 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
             return vip
 
     def test_create_vip_twice_for_same_pool(self):
-        """ Test loadbalancer db plugin via extension and directly """
+        """Test loadbalancer db plugin via extension and directly."""
         with self.subnet() as subnet:
             with self.pool(name="pool1") as pool:
                 with self.vip(name='vip1', subnet=subnet, pool=pool):
index 1bbc5dbba5e64d9c99c64ea71e064c7e1d6b09a1..b4bbb01acf55be261a177c8b250f2d88b2271fcc 100644 (file)
@@ -76,7 +76,7 @@ class Dummy(object):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Extended Resource for dummy management """
+        """Returns Extended Resource for dummy management."""
         q_mgr = manager.QuantumManager.get_instance()
         dummy_inst = q_mgr.get_service_plugins()['DUMMY']
         controller = base.create_resource(
@@ -87,7 +87,7 @@ class Dummy(object):
 
 
 class DummyServicePlugin(ServicePluginBase):
-    """ This is a simple plugin for managing instantes of a fictional 'dummy'
+    """This is a simple plugin for managing instantes of a fictional 'dummy'
         service. This plugin is provided as a proof-of-concept of how
         advanced service might leverage the service type extension.
         Ideally, instances of real advanced services, such as load balancing
index 4f8d5fd7f1b04f6279b98eee04884a3c9659c079..6d3355f527f8cc2861d387ff2cd16cf4788c90a9 100644 (file)
@@ -71,7 +71,7 @@ class Extensionattribute(extensions.ExtensionDescriptor):
 
     @classmethod
     def get_resources(cls):
-        """ Returns Ext Resources """
+        """Returns Ext Resources."""
         exts = []
         plugin = manager.QuantumManager.get_plugin()
         resource_name = 'ext_test_resource'
index 1cd0a91eefb7ffa41ed09e54312d6eb0615cbaf7..4506f60688276d9b5bd23ca64918ede70d5b55a6 100644 (file)
@@ -13,8 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from quantum.tests.unit.openvswitch import test_agent_scheduler
 from quantum.tests.unit.linuxbridge import test_linuxbridge_plugin
+from quantum.tests.unit.openvswitch import test_agent_scheduler
 
 
 class LbAgentSchedulerTestCase(
index e1d5cf540a10ffa332a79cbe662bd47e1881023b..8a1a815a52b77decc517ee0ebb853252896a77c1 100644 (file)
@@ -68,7 +68,7 @@ def setup_metaplugin_conf():
 
 
 class MetaQuantumPluginV2Test(base.BaseTestCase):
-    """Class conisting of MetaQuantumPluginV2 unit tests"""
+    """Class conisting of MetaQuantumPluginV2 unit tests."""
 
     def setUp(self):
         super(MetaQuantumPluginV2Test, self).setUp()
@@ -300,7 +300,7 @@ class MetaQuantumPluginV2Test(base.BaseTestCase):
             self.plugin.not_implemented()
         except AttributeError:
             return
-        except:
+        except Exception:
             self.fail("AttributeError Error is not raised")
 
         self.fail("No Error is not raised")
index 9356cb02367e79ef615fb6bd0dea4793e37d4990..fadbc777b1390f421f1bf0e44ac2de0b5b6c768e 100644 (file)
@@ -15,8 +15,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from quantum.tests.unit.openvswitch import test_agent_scheduler
 from quantum.tests.unit.nec import test_nec_plugin
+from quantum.tests.unit.openvswitch import test_agent_scheduler
 
 
 class NecAgentSchedulerTestCase(
index 296caffe5cce2525bd92c4c4b8f1e30b9e1f71a3..08a2f8c3fb0e54b4719b5591b93b703d6f700030 100644 (file)
@@ -26,24 +26,24 @@ from quantum.tests import base
 
 
 class NECPluginV2DBTestBase(base.BaseTestCase):
-    """Class conisting of NECPluginV2 DB unit tests"""
+    """Class conisting of NECPluginV2 DB unit tests."""
 
     def setUp(self):
-        """Setup for tests"""
+        """Setup for tests."""
         super(NECPluginV2DBTestBase, self).setUp()
         ndb.initialize()
         self.session = db_api.get_session()
         self.addCleanup(ndb.clear_db)
 
     def get_ofc_item_random_params(self):
-        """create random parameters for ofc_item test"""
+        """create random parameters for ofc_item test."""
         ofc_id = uuidutils.generate_uuid()
         quantum_id = uuidutils.generate_uuid()
         none = uuidutils.generate_uuid()
         return ofc_id, quantum_id, none
 
     def get_portinfo_random_params(self):
-        """create random parameters for portinfo test"""
+        """create random parameters for portinfo test."""
         port_id = uuidutils.generate_uuid()
         datapath_id = hex(random.randint(0, 0xffffffff))
         port_no = random.randint(1, 100)
@@ -56,7 +56,7 @@ class NECPluginV2DBTestBase(base.BaseTestCase):
 class NECPluginV2DBTest(NECPluginV2DBTestBase):
 
     def testa_add_ofc_item(self):
-        """test add OFC item"""
+        """test add OFC item."""
         o, q, n = self.get_ofc_item_random_params()
         tenant = ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
         self.assertEqual(tenant.ofc_id, o)
@@ -67,7 +67,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
                           self.session, 'ofc_tenant', q, o)
 
     def testb_get_ofc_item(self):
-        """test get OFC item"""
+        """test get OFC item."""
         o, q, n = self.get_ofc_item_random_params()
         ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
         tenant = ndb.get_ofc_item(self.session, 'ofc_tenant', q)
@@ -78,7 +78,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertEqual(None, tenant_none)
 
     def testb_get_ofc_id(self):
-        """test get OFC d"""
+        """test get OFC d."""
         o, q, n = self.get_ofc_item_random_params()
         ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
         tenant_id = ndb.get_ofc_id(self.session, 'ofc_tenant', q)
@@ -88,7 +88,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertEqual(None, tenant_none)
 
     def testb_exists_ofc_item(self):
-        """test get OFC d"""
+        """test get OFC d."""
         o, q, n = self.get_ofc_item_random_params()
         ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
         ret = ndb.exists_ofc_item(self.session, 'ofc_tenant', q)
@@ -98,7 +98,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertEqual(None, tenant_none)
 
     def testc_find_ofc_item(self):
-        """test find OFC item"""
+        """test find OFC item."""
         o, q, n = self.get_ofc_item_random_params()
         ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
         tenant = ndb.find_ofc_item(self.session, 'ofc_tenant', o)
@@ -109,7 +109,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertEqual(None, tenant_none)
 
     def testc_del_ofc_item(self):
-        """test delete OFC item"""
+        """test delete OFC item."""
         o, q, n = self.get_ofc_item_random_params()
         ndb.add_ofc_item(self.session, 'ofc_tenant', q, o)
         ndb.del_ofc_item(self.session, 'ofc_tenant', q)
@@ -122,7 +122,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertEqual(None, tenant_none)
 
     def testd_add_portinfo(self):
-        """test add portinfo"""
+        """test add portinfo."""
         i, d, p, v, m, n = self.get_portinfo_random_params()
         portinfo = ndb.add_portinfo(self.session, i, d, p, v, m)
         self.assertEqual(portinfo.id, i)
@@ -139,7 +139,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertTrue(exception_raised)
 
     def teste_get_portinfo(self):
-        """test get portinfo"""
+        """test get portinfo."""
         i, d, p, v, m, n = self.get_portinfo_random_params()
         ndb.add_portinfo(self.session, i, d, p, v, m)
         portinfo = ndb.get_portinfo(self.session, i)
@@ -153,7 +153,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
         self.assertEqual(None, portinfo_none)
 
     def testf_del_portinfo(self):
-        """test delete portinfo"""
+        """test delete portinfo."""
         i, d, p, v, m, n = self.get_portinfo_random_params()
         ndb.add_portinfo(self.session, i, d, p, v, m)
         portinfo = ndb.get_portinfo(self.session, i)
@@ -164,7 +164,7 @@ class NECPluginV2DBTest(NECPluginV2DBTestBase):
 
 
 class NECPluginV2DBOldMappingTest(NECPluginV2DBTestBase):
-    """Test related to old ID mapping"""
+    """Test related to old ID mapping."""
 
     # Mapping Table mode
     OLD = True
index cc5d004537435f73d4c53ff1bed9afc015afea2e..cb8c5971c8e1c4f297c668f497008d900cd191e5 100644 (file)
 
 import mock
 
-from quantum import context as q_context
-from quantum import manager
 from quantum.common import topics
+from quantum import context as q_context
 from quantum.extensions import portbindings
+from quantum import manager
 from quantum.plugins.nec import nec_plugin
 from quantum.tests.unit import _test_extension_portbindings as test_bindings
 from quantum.tests.unit import test_db_plugin as test_plugin
index 78c082d21e812651cc85be10f8e252ab4d59855a..74d7e460c4056f8dc3d5c8d7c467556306ec9924 100644 (file)
@@ -25,7 +25,7 @@ from quantum.tests import base
 
 
 class OFCManagerTestBase(base.BaseTestCase):
-    """Class conisting of OFCManager unit tests"""
+    """Class conisting of OFCManager unit tests."""
 
     def setUp(self):
         super(OFCManagerTestBase, self).setUp()
@@ -37,7 +37,7 @@ class OFCManagerTestBase(base.BaseTestCase):
         self.ctx = context.get_admin_context()
 
     def get_random_params(self):
-        """create random parameters for portinfo test"""
+        """create random parameters for portinfo test."""
         tenant = uuidutils.generate_uuid()
         network = uuidutils.generate_uuid()
         port = uuidutils.generate_uuid()
@@ -48,7 +48,7 @@ class OFCManagerTestBase(base.BaseTestCase):
 
 class OFCManagerTest(OFCManagerTestBase):
     def testa_create_ofc_tenant(self):
-        """test create ofc_tenant"""
+        """test create ofc_tenant."""
         t, n, p, f, none = self.get_random_params()
         self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
         self.ofc.create_ofc_tenant(self.ctx, t)
@@ -57,14 +57,14 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertEqual(tenant.ofc_id, "ofc-" + t[:-4])
 
     def testb_exists_ofc_tenant(self):
-        """test exists_ofc_tenant"""
+        """test exists_ofc_tenant."""
         t, n, p, f, none = self.get_random_params()
         self.assertFalse(self.ofc.exists_ofc_tenant(self.ctx, t))
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.assertTrue(self.ofc.exists_ofc_tenant(self.ctx, t))
 
     def testc_delete_ofc_tenant(self):
-        """test delete ofc_tenant"""
+        """test delete ofc_tenant."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
@@ -72,7 +72,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))
 
     def testd_create_ofc_network(self):
-        """test create ofc_network"""
+        """test create ofc_network."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
@@ -82,7 +82,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertEqual(network.ofc_id, "ofc-" + n[:-4])
 
     def teste_exists_ofc_network(self):
-        """test exists_ofc_network"""
+        """test exists_ofc_network."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.assertFalse(self.ofc.exists_ofc_network(self.ctx, n))
@@ -90,7 +90,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertTrue(self.ofc.exists_ofc_network(self.ctx, n))
 
     def testf_delete_ofc_network(self):
-        """test delete ofc_network"""
+        """test delete ofc_network."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
@@ -99,7 +99,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))
 
     def testg_create_ofc_port(self):
-        """test create ofc_port"""
+        """test create ofc_port."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
@@ -113,7 +113,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertEqual(port.ofc_id, "ofc-" + p[:-4])
 
     def testh_exists_ofc_port(self):
-        """test exists_ofc_port"""
+        """test exists_ofc_port."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
@@ -125,7 +125,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertTrue(self.ofc.exists_ofc_port(self.ctx, p))
 
     def testi_delete_ofc_port(self):
-        """test delete ofc_port"""
+        """test delete ofc_port."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
@@ -138,7 +138,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))
 
     def testj_create_ofc_packet_filter(self):
-        """test create ofc_filter"""
+        """test create ofc_filter."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
@@ -152,7 +152,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertEqual(_filter.ofc_id, "ofc-" + f[:-4])
 
     def testk_exists_ofc_packet_filter(self):
-        """test exists_ofc_packet_filter"""
+        """test exists_ofc_packet_filter."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
@@ -162,7 +162,7 @@ class OFCManagerTest(OFCManagerTestBase):
         self.assertTrue(self.ofc.exists_ofc_packet_filter(self.ctx, f))
 
     def testl_delete_ofc_packet_filter(self):
-        """test delete ofc_filter"""
+        """test delete ofc_filter."""
         t, n, p, f, none = self.get_random_params()
         self.ofc.create_ofc_tenant(self.ctx, t)
         self.ofc.create_ofc_network(self.ctx, t, n)
index c78f89d7d3e15545274855810474e04fe886d2b4..bc0f81cc6df2152342b298bb5e3eac46fc31a396 100644 (file)
@@ -30,7 +30,7 @@ from quantum.tests import base
 
 
 class TestConfig(object):
-    """Configuration for this test"""
+    """Configuration for this test."""
     host = '127.0.0.1'
     port = 8888
     use_ssl = False
@@ -39,7 +39,7 @@ class TestConfig(object):
 
 
 def _ofc(id):
-    """OFC ID converter"""
+    """OFC ID converter."""
     return "ofc-%s" % id
 
 
@@ -55,7 +55,7 @@ class PFCDriverTestBase(base.BaseTestCase):
         self.addCleanup(self.mox.UnsetStubs)
 
     def get_ofc_item_random_params(self):
-        """create random parameters for ofc_item test"""
+        """create random parameters for ofc_item test."""
         tenant_id = uuidutils.generate_uuid()
         network_id = uuidutils.generate_uuid()
         port_id = uuidutils.generate_uuid()
index 68420cb33d57e9f991240ed4a1399153260ada2b..3b79176c52eaf74a0c4fc0ffd912024d0d31b06c 100644 (file)
@@ -27,7 +27,7 @@ from quantum.tests import base
 
 
 class TestConfig(object):
-    """Configuration for this test"""
+    """Configuration for this test."""
     host = '127.0.0.1'
     port = 8888
 
@@ -44,7 +44,7 @@ class TremaDriverTestBase(base.BaseTestCase):
         self.addCleanup(self.mox.UnsetStubs)
 
     def get_ofc_item_random_params(self):
-        """create random parameters for ofc_item test"""
+        """create random parameters for ofc_item test."""
         tenant_id = uuidutils.generate_uuid()
         network_id = uuidutils.generate_uuid()
         port_id = uuidutils.generate_uuid()
@@ -181,7 +181,7 @@ class TremaMACBaseDriverTest(TremaDriverNetworkTestBase):
 class TremaFilterDriverTest(TremaDriverTestBase):
 
     def get_ofc_item_random_params(self):
-        """create random parameters for ofc_item test"""
+        """create random parameters for ofc_item test."""
         t, n, p = (super(TremaFilterDriverTest, self).
                    get_ofc_item_random_params())
         filter_id = uuidutils.generate_uuid()
index 4794f469f499352b72234a69e7fa53f4d47eba44..6b20ab6fd1de32b31db928ce79eb3fc64f46ea89 100644 (file)
@@ -354,7 +354,7 @@ class FakeClient:
             def _lswitch_match(res_uuid):
                 # verify that the switch exist
                 if parent_uuid and not parent_uuid in self._fake_lswitch_dict:
-                    raise Exception(_("lswitch:%s not found" % parent_uuid))
+                    raise Exception(_("lswitch:%s not found") % parent_uuid)
                 if (not parent_uuid
                     or res_dict[res_uuid].get('ls_uuid') == parent_uuid):
                     return True
@@ -363,7 +363,7 @@ class FakeClient:
             def _lrouter_match(res_uuid):
                 # verify that the router exist
                 if parent_uuid and not parent_uuid in self._fake_lrouter_dict:
-                    raise Exception(_("lrouter:%s not found" % parent_uuid))
+                    raise Exception(_("lrouter:%s not found") % parent_uuid)
                 if (not parent_uuid or
                     res_dict[res_uuid].get('lr_uuid') == parent_uuid):
                     return True
index 2f806e37539325d8fdb08c3e7dfec480b492b1ef..bc1e00c246a999e309426d2188d80ee01db7f85d 100644 (file)
@@ -209,7 +209,7 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase):
 
 
 class NetworkGatewayDbTestCase(test_db_plugin.QuantumDbPluginV2TestCase):
-    """ Unit tests for Network Gateway DB support """
+    """Unit tests for Network Gateway DB support."""
 
     def setUp(self):
         test_config['plugin_name_v2'] = '%s.%s' % (
@@ -511,7 +511,7 @@ class NetworkGatewayDbTestCase(test_db_plugin.QuantumDbPluginV2TestCase):
 
 class TestNetworkGatewayPlugin(db_base_plugin_v2.QuantumDbPluginV2,
                                nicira_networkgw_db.NetworkGatewayMixin):
-    """ Simple plugin class for testing db support for network gateway ext """
+    """Simple plugin class for testing db support for network gateway ext."""
 
     supported_extension_aliases = ["network-gateway"]
 
index 494cd81d3dc65420a5a3b5a4075f42ae360df01d..f7667974b481b34b3e97e398ac57e026eec6c8b7 100644 (file)
@@ -335,8 +335,9 @@ class TestNiciraL3NatTestCase(test_l3_plugin.L3NatDBTestCase,
                 self.assertEqual(net['network'][k], v)
 
     def _nvp_validate_ext_gw(self, router_id, l3_gw_uuid, vlan_id):
-        """ Verify data on fake NVP API client in order to validate
-        plugin did set them properly"""
+        """Verify data on fake NVP API client in order to validate
+        plugin did set them properly
+        """
         ports = [port for port in self.fc._fake_lrouter_lport_dict.values()
                  if (port['lr_uuid'] == router_id and
                      port['att_type'] == "L3GatewayAttachment")]
index f02377f27529a4dadff2056abe4096f9a9d576ad..4ab15a88a8de20b8a60307784ced21dffd4e8226 100644 (file)
@@ -31,10 +31,10 @@ from quantum import manager
 from quantum.openstack.common import timeutils
 from quantum.openstack.common import uuidutils
 from quantum.tests.unit import test_agent_ext_plugin
-from quantum.tests.unit.testlib_api import create_request
 from quantum.tests.unit import test_db_plugin as test_plugin
 from quantum.tests.unit import test_extensions
 from quantum.tests.unit import test_l3_plugin
+from quantum.tests.unit.testlib_api import create_request
 from quantum.wsgi import Serializer
 
 L3_HOSTA = 'hosta'
index 9b8ebdd94897ca73636433b0b680106403387844..74b4001b432cbb1aebe3da7027a02fd605c702a9 100644 (file)
@@ -41,7 +41,7 @@ class OVS_Lib_Test(base.BaseTestCase):
         self.addCleanup(self.mox.UnsetStubs)
 
     def test_vifport(self):
-        """create and stringify vif port, confirm no exceptions"""
+        """create and stringify vif port, confirm no exceptions."""
         self.mox.ReplayAll()
 
         pname = "vif1.0"
index e547b24e0b485029a7f032d954d8fefdf5123c0b..0d0bd60f1db67a13bf3e2cfe98232617ba25077f 100644 (file)
@@ -387,7 +387,7 @@ class TunnelTest(base.BaseTestCase):
         # If something goes wrong, mox.VerifyAll() will catch it
         try:
             q_agent.daemon_loop()
-        except:
+        except Exception:
             pass
 
         self.mox.VerifyAll()
index 095b251311eb70a2f250be7a97421228f9a81731..2f0e02a52e5328e649bda7a57592ddffb327a844 100644 (file)
@@ -22,7 +22,7 @@ from quantum.tests import base
 
 
 class ConfigurationTest(base.BaseTestCase):
-    """Configuration file Tests"""
+    """Configuration file Tests."""
     def test_defaults(self):
         self.assertEqual('br-int', cfg.CONF.OVS.integration_bridge)
         self.assertEqual(2, cfg.CONF.AGENT.polling_interval)
index 1c583562cdd914b3f1b81d82d990453fff4831b9..eb6be9018f47aca5f53d66fc99ff0a0a4e4a1064 100644 (file)
@@ -20,8 +20,8 @@
 import mock
 
 from quantum import context
-from quantum import manager
 from quantum.db.loadbalancer import loadbalancer_db as ldb
+from quantum import manager
 from quantum.openstack.common import uuidutils
 from quantum.plugins.common import constants
 from quantum.plugins.services.agent_loadbalancer import plugin
index 99fa378a2267dc59329098f638186da79f2166fd..d31744497309f80e8ea015b71396e503330507ac 100644 (file)
@@ -119,7 +119,7 @@ class APIv2TestBase(base.BaseTestCase):
 
 
 class _ArgMatcher(object):
-    """ An adapter to assist mock assertions, used to custom compare """
+    """An adapter to assist mock assertions, used to custom compare."""
 
     def __init__(self, cmp, obj):
         self.cmp = cmp
index 76f99c96fb9352856005ce7197a8cfdac02e9e0b..f3415aefcdb7664c8e1cf4dbaac140139dfde987 100644 (file)
@@ -25,7 +25,7 @@ from quantum.tests import base
 class TestAttributes(base.BaseTestCase):
 
     def _construct_dict_and_constraints(self):
-        """ Constructs a test dictionary and a definition of constraints.
+        """Constructs a test dictionary and a definition of constraints.
         :return: A (dictionary, constraint) tuple
         """
         constraints = {'key1': {'type:values': ['val1', 'val2'],
index 6d18227dcfec66ce080ee46efff97e1452cebcd1..0e760b1f568f064e2457c1a73a898df931f02002 100644 (file)
@@ -249,7 +249,7 @@ class QuantumDbPluginV2TestCase(testlib_api.WebTestCase):
         return data
 
     def _create_bulk_from_list(self, fmt, resource, objects, **kwargs):
-        """ Creates a bulk request from a list of objects """
+        """Creates a bulk request from a list of objects."""
         collection = "%ss" % resource
         req_data = {collection: objects}
         req = self.new_create_request(collection, req_data, fmt)
@@ -264,7 +264,7 @@ class QuantumDbPluginV2TestCase(testlib_api.WebTestCase):
         return req.get_response(self.api)
 
     def _create_bulk(self, fmt, number, resource, data, name='test', **kwargs):
-        """ Creates a bulk request for any kind of resource """
+        """Creates a bulk request for any kind of resource."""
         objects = []
         collection = "%ss" % resource
         for i in range(0, number):
@@ -487,7 +487,7 @@ class QuantumDbPluginV2TestCase(testlib_api.WebTestCase):
         return self.deserialize(fmt, res)
 
     def _do_side_effect(self, patched_plugin, orig, *args, **kwargs):
-        """ Invoked by test cases for injecting failures in plugin """
+        """Invoked by test cases for injecting failures in plugin."""
         def second_call(*args, **kwargs):
             raise q_exc.QuantumException
         patched_plugin.side_effect = second_call
@@ -718,7 +718,7 @@ class TestV2HTTPResponse(QuantumDbPluginV2TestCase):
         self._check_list_with_fields(res, 'name')
 
     def test_list_with_fields_noadmin_and_policy_field(self):
-        """ If a field used by policy is selected, do not duplicate it.
+        """If a field used by policy is selected, do not duplicate it.
 
         Verifies that if the field parameter explicitly specifies a field
         which is used by the policy engine, then it is not duplicated
@@ -1254,7 +1254,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
         cfg.CONF.set_override('base_mac', "bad_mac")
         try:
             self.plugin._check_base_mac_format()
-        except:
+        except Exception:
             return
         self.fail("No exception for illegal base_mac format")
 
@@ -3410,9 +3410,9 @@ class TestSubnetsV2(QuantumDbPluginV2TestCase):
 
 
 class DbModelTestCase(base.BaseTestCase):
-    """ DB model tests """
+    """DB model tests."""
     def test_repr(self):
-        """ testing the string representation of 'model' classes """
+        """testing the string representation of 'model' classes."""
         network = models_v2.Network(name="net_net", status="OK",
                                     admin_state_up=True)
         actual_repr_output = repr(network)
index 7a611cc46436a670d36a0782c111bec946611dc2..38bf670ba6b271d8e65ef132853080609b7f44f6 100644 (file)
@@ -20,8 +20,8 @@ from quantum import context
 from quantum.db import db_base_plugin_v2
 from quantum.db import portsecurity_db
 from quantum.db import securitygroups_db
-from quantum.extensions import securitygroup as ext_sg
 from quantum.extensions import portsecurity as psec
+from quantum.extensions import securitygroup as ext_sg
 from quantum.manager import QuantumManager
 from quantum import policy
 from quantum.tests.unit import test_db_plugin
@@ -48,7 +48,7 @@ class PortSecurityTestPlugin(db_base_plugin_v2.QuantumDbPluginV2,
                              securitygroups_db.SecurityGroupDbMixin,
                              portsecurity_db.PortSecurityDbMixin):
 
-    """ Test plugin that implements necessary calls on create/delete port for
+    """Test plugin that implements necessary calls on create/delete port for
     associating ports with security groups and port security.
     """
 
index 461907884278b800f1e73008c66d4a88fd9a2030..b768ef51d4bbd98bfe2a444891a64008ce3fc8d7 100644 (file)
@@ -148,7 +148,7 @@ class SecurityGroupsTestCase(test_db_plugin.QuantumDbPluginV2TestCase):
                              security_group_rule['security_group_rule']['id'])
 
     def _delete_default_security_group_egress_rules(self, security_group_id):
-        """Deletes default egress rules given a security group ID"""
+        """Deletes default egress rules given a security group ID."""
         res = self._list(
             'security-group-rules',
             query_params='security_group_id=%s' % security_group_id)
@@ -173,7 +173,7 @@ class SecurityGroupsTestCaseXML(SecurityGroupsTestCase):
 
 class SecurityGroupTestPlugin(db_base_plugin_v2.QuantumDbPluginV2,
                               securitygroups_db.SecurityGroupDbMixin):
-    """ Test plugin that implements necessary calls on create/delete port for
+    """Test plugin that implements necessary calls on create/delete port for
     associating ports with security groups.
     """
 
index 5f2ee5a4ae9306a135875b2e5a7193f797608b6b..aea7e6da4ed4757f08cd10a894b666b70c233854 100644 (file)
@@ -21,8 +21,9 @@ from oslo.config import cfg
 
 from quantum.agent.common import config as a_cfg
 from quantum.agent.linux.iptables_firewall import IptablesFirewallDriver
-from quantum.tests.unit import test_api_v2
 from quantum.tests import base
+from quantum.tests.unit import test_api_v2
+
 
 _uuid = test_api_v2._uuid
 FAKE_PREFIX = {'IPv4': '10.0.0.0/24',
@@ -909,7 +910,7 @@ class IptablesFirewallTestCase(base.BaseTestCase):
         try:
             with self.firewall.defer_apply():
                 raise Exception("same exception")
-        except:
+        except Exception:
             pass
         self.iptables_inst.assert_has_calls([call.defer_apply_on(),
                                              call.defer_apply_off()])
index 5052b849d9a4fbe90871621b2081595f731677b3..2aadb3f57fc175a493680ad42e543ccb445adf28 100644 (file)
@@ -308,7 +308,7 @@ class TestL3NatPlugin(db_base_plugin_v2.QuantumDbPluginV2,
 class L3NatTestCaseMixin(object):
 
     def _create_network(self, fmt, name, admin_state_up, **kwargs):
-        """ Override the routine for allowing the router:external attribute """
+        """Override the routine for allowing the router:external attribute."""
         # attributes containing a colon should be passed with
         # a double underscore
         new_args = dict(itertools.izip(map(lambda x: x.replace('__', ':'),
@@ -1496,7 +1496,7 @@ class L3NatDBTestCase(L3NatTestCaseBase):
                 kargs = [item for item in args]
                 kargs.append(notifyApi)
                 target_func(*kargs)
-        except:
+        except Exception:
             l3_rpc_agent_api.L3AgentNotify = oldNotify
             raise
         else:
index 36e1f2d119d1a9ab89b13a634db8d5f29875879b..25e42f0d2a4c447b70be22cff6db3ed9bb4b2b3a 100644 (file)
@@ -172,7 +172,7 @@ class LoadBalancerExtensionTestCase(testlib_api.WebTestCase):
         self.assertEqual(res['vip'], return_value)
 
     def _test_entity_delete(self, entity):
-        """ does the entity deletion based on naming convention  """
+        """Does the entity deletion based on naming convention."""
         entity_id = _uuid()
         res = self.api.delete(_get_path('lb/' + entity + 's', id=entity_id,
                                         fmt=self.fmt))
index 791871ce9bcb7e6f07b27a289f044b4524531d12..ec0f4585c085ab1f6eb89a5c78a8890063d9a3f0 100644 (file)
@@ -23,8 +23,8 @@ import testtools
 import webob
 
 from quantum.agent.metadata import agent
-from quantum.tests import base
 from quantum.common import utils
+from quantum.tests import base
 
 
 class FakeConf(object):
index d0b9a7b5b0cdc69cdbeff1a7ffcc71c3b5859d84..dc9e0ee5422f8639b42be02fd2ed55fbc3fa2310 100644 (file)
@@ -23,8 +23,8 @@ import testtools
 import webob
 
 from quantum.agent.metadata import namespace_proxy as ns_proxy
-from quantum.tests import base
 from quantum.common import utils
+from quantum.tests import base
 
 
 class FakeConf(object):
index 6f23b4955054986006d2db523a42744f0997eb94..4933f44674fcf47e1bd2e5d621f946937c7e89d8 100644 (file)
@@ -106,7 +106,7 @@ class RootwrapTestCase(base.BaseTestCase):
         self.assertTrue(f.match(usercmd) or f2.match(usercmd))
 
     def test_KillFilter_no_raise(self):
-        """Makes sure ValueError from bug 926412 is gone"""
+        """Makes sure ValueError from bug 926412 is gone."""
         f = filters.KillFilter("root", "")
         # Providing anything other than kill should be False
         usercmd = ['notkill', 999999]
@@ -116,7 +116,7 @@ class RootwrapTestCase(base.BaseTestCase):
         self.assertFalse(f.match(usercmd))
 
     def test_KillFilter_deleted_exe(self):
-        """Makes sure deleted exe's are killed correctly"""
+        """Makes sure deleted exe's are killed correctly."""
         # See bug #1073768.
         with mock.patch('os.readlink') as mock_readlink:
             mock_readlink.return_value = '/bin/commandddddd (deleted)'
index 1e2a9ce87b5ae9a0ba8f3123a2a7913a05dc294c..1871ed3949bbc10d67f8cfc91b0cfd9afe656649 100644 (file)
@@ -48,7 +48,7 @@ _get_path = test_api_v2._get_path
 
 
 class TestServiceTypeExtensionManager(object):
-    """ Mock extensions manager """
+    """Mock extensions manager."""
 
     def get_resources(self):
         return (servicetype.Servicetype.get_resources() +
index b775a83eca92d244272720702401c50121ba433d..956a4e0c7a398cb3068a0b9ca2e0f5ba4ff2b408 100644 (file)
@@ -20,8 +20,8 @@ import socket
 import urllib2
 
 import mock
-import testtools
 from oslo.config import cfg
+import testtools
 import webob
 import webob.exc
 
index 8558729f8553ae50a4daa555755132561fd6c225..f3986becfcddee045bf47319e9a9d63e8d2c9a1c 100644 (file)
@@ -100,7 +100,7 @@ class Server(object):
                                       socket.SOCK_STREAM)[0]
             family = info[0]
             bind_addr = info[-1]
-        except:
+        except Exception:
             LOG.exception(_("Unable to listen on %(host)s:%(port)s") %
                           {'host': host, 'port': port})
             sys.exit(1)
@@ -321,7 +321,7 @@ class ActionDispatcher(object):
 
 
 class DictSerializer(ActionDispatcher):
-    """Default request body serialization"""
+    """Default request body serialization."""
 
     def serialize(self, data, action='default'):
         return self.dispatch(data, action=action)
@@ -331,7 +331,7 @@ class DictSerializer(ActionDispatcher):
 
 
 class JSONDictSerializer(DictSerializer):
-    """Default JSON request body serialization"""
+    """Default JSON request body serialization."""
 
     def default(self, data):
         def sanitizer(obj):
@@ -483,7 +483,7 @@ class XMLDictSerializer(DictSerializer):
 
 
 class ResponseHeaderSerializer(ActionDispatcher):
-    """Default response headers serialization"""
+    """Default response headers serialization."""
 
     def serialize(self, response, data, action):
         self.dispatch(response, data, action=action)
@@ -493,7 +493,7 @@ class ResponseHeaderSerializer(ActionDispatcher):
 
 
 class ResponseSerializer(object):
-    """Encode the necessary pieces into a response object"""
+    """Encode the necessary pieces into a response object."""
 
     def __init__(self, body_serializers=None, headers_serializer=None):
         self.body_serializers = {
@@ -534,7 +534,7 @@ class ResponseSerializer(object):
 
 
 class TextDeserializer(ActionDispatcher):
-    """Default request body deserialization"""
+    """Default request body deserialization."""
 
     def deserialize(self, datastring, action='default'):
         return self.dispatch(datastring, action=action)
@@ -703,7 +703,7 @@ class XMLDeserializer(TextDeserializer):
 
 
 class RequestHeadersDeserializer(ActionDispatcher):
-    """Default request headers deserializer"""
+    """Default request headers deserializer."""
 
     def deserialize(self, request, action):
         return self.dispatch(request, action=action)
@@ -1077,7 +1077,7 @@ def _default_body_function(wrapped_exc):
 
 
 class Fault(webob.exc.HTTPException):
-    """ Generates an HTTP response from a webob HTTP exception"""
+    """Generates an HTTP response from a webob HTTP exception."""
 
     def __init__(self, exception, xmlns=None, body_function=None):
         """Creates a Fault for the given webob.exc.exception."""
index e49002126472148eb83e207b87b7df0e5ec25ab8..eb5c6aa036a8dec5a7b08f20c33e259c9b131a27 100755 (executable)
@@ -44,10 +44,10 @@ To run a single functional test module::
 import os
 import sys
 
-from quantum.common.test_lib import run_tests
 from nose import config
 from nose import core
 
+from quantum.common.test_lib import run_tests
 import quantum.tests.unit
 
 
index 705b2d3ddc8be8503a4df24459c7ff97f580228a..b33055172300111a16e1634dd5a43001407812b0 100644 (file)
@@ -21,7 +21,7 @@ import sys
 
 
 def is_localized(node):
-    """ Check message wrapped by _() """
+    """Check message wrapped by _()"""
     if isinstance(node.parent, compiler.ast.CallFunc):
         if isinstance(node.parent.node, compiler.ast.Name):
             if node.parent.node.name == '_':
@@ -119,7 +119,7 @@ if __name__ == '__main__':
     cfg_path = sys.argv[2]
     try:
         cfg_mod = imp.load_source('', cfg_path)
-    except:
+    except Exception:
         print >> sys.stderr, "Load cfg module failed"
         sys.exit(1)
 
index 23894a938af53201c007817c9931f4cc7fe8c0db..92e70772641ea9a5ea5554718bb43f30d80e2f94 100644 (file)
@@ -3,7 +3,7 @@ import re
 
 
 def is_log_callfunc(n):
-    """ LOG.xxx('hello %s' % xyz) and LOG('hello') """
+    """LOG.xxx('hello %s' % xyz) and LOG('hello')"""
     if isinstance(n.parent, compiler.ast.Mod):
         n = n.parent
     if isinstance(n.parent, compiler.ast.CallFunc):
@@ -16,7 +16,7 @@ def is_log_callfunc(n):
 
 
 def is_log_i18n_msg_with_mod(n):
-    """ LOG.xxx("Hello %s" % xyz) should be LOG.xxx("Hello %s", xyz) """
+    """LOG.xxx("Hello %s" % xyz) should be LOG.xxx("Hello %s", xyz)"""
     if not isinstance(n.parent.parent, compiler.ast.Mod):
         return False
     n = n.parent.parent
@@ -30,7 +30,7 @@ def is_log_i18n_msg_with_mod(n):
 
 
 def is_wrong_i18n_format(n):
-    """ Check _('hello %s' % xyz) """
+    """Check _('hello %s' % xyz)"""
     if isinstance(n.parent, compiler.ast.Mod):
         n = n.parent
     if isinstance(n.parent, compiler.ast.CallFunc):
index a92a6d26fe35dd072b41fbe092e2d5b2bb308833..706f878d6a717e52c1c48eb58b7eb96607d28974 100644 (file)
@@ -5,6 +5,7 @@ discover
 distribute>=0.6.24
 fixtures>=0.3.12
 flake8
+hacking
 mock>=1.0b1
 mox==0.5.3
 nose
diff --git a/tox.ini b/tox.ini
index 99cd84376de1c97b425f76f8e6f1f657d7a78f5e..b638c0d42c3d1b94ceb7aac06651f302cfe5fa74 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -38,8 +38,12 @@ commands = {posargs}
 # E711/E712 comparison to False should be 'if cond is False:' or 'if not cond:'
 #        query = query.filter(Component.disabled == False)
 # E125 continuation line does not distinguish itself from next logical line
-# H hacking.py - automatic checks of rules in HACKING.rst
-ignore = E711,E712,E125,H
+# H301 one import per line
+# H302 import only modules
+# TODO(marun) H404 multi line docstring should start with a summary
+# TODO(marun) H901,902 use the not operator inline for clarity
+# TODO(markmcclain) H202 assertRaises Exception too broad
+ignore = E711,E712,E125,H301,H302,H404,H901,H902,H202
 show-source = true
 builtins = _
 exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools