Enable automatic validation of many HACKING rules.

* 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
changes/74/26274/3
Maru Newby 10 years ago
parent 0446eaccbf
commit a13295b9a8
  1. 14
      quantum/agent/dhcp_agent.py
  2. 14
      quantum/agent/firewall.py
  3. 8
      quantum/agent/l3_agent.py
  4. 2
      quantum/agent/linux/daemon.py
  5. 6
      quantum/agent/linux/dhcp.py
  6. 4
      quantum/agent/linux/ip_lib.py
  7. 4
      quantum/agent/linux/iptables_firewall.py
  8. 2
      quantum/agent/ovs_cleanup_util.py
  9. 14
      quantum/agent/securitygroups_rpc.py
  10. 6
      quantum/api/api_common.py
  11. 3
      quantum/api/extensions.py
  12. 6
      quantum/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py
  13. 6
      quantum/api/rpc/agentnotifiers/l3_rpc_agent_api.py
  14. 2
      quantum/api/v2/attributes.py
  15. 16
      quantum/api/v2/base.py
  16. 3
      quantum/common/rpc.py
  17. 2
      quantum/common/test_lib.py
  18. 2
      quantum/common/utils.py
  19. 4
      quantum/db/agents_db.py
  20. 9
      quantum/db/agentschedulers_db.py
  21. 8
      quantum/db/api.py
  22. 13
      quantum/db/db_base_plugin_v2.py
  23. 2
      quantum/db/extraroute_db.py
  24. 4
      quantum/db/l3_db.py
  25. 4
      quantum/db/loadbalancer/loadbalancer_db.py
  26. 7
      quantum/db/model_base.py
  27. 8
      quantum/db/securitygroups_db.py
  28. 8
      quantum/db/securitygroups_rpc_base.py
  29. 22
      quantum/db/servicetype_db.py
  30. 6
      quantum/debug/commands.py
  31. 2
      quantum/debug/debug_agent.py
  32. 8
      quantum/extensions/agent.py
  33. 4
      quantum/extensions/agentscheduler.py
  34. 2
      quantum/extensions/l3.py
  35. 4
      quantum/extensions/quotasv2.py
  36. 4
      quantum/extensions/securitygroup.py
  37. 6
      quantum/extensions/servicetype.py
  38. 2
      quantum/manager.py
  39. 2
      quantum/plugins/bigswitch/plugin.py
  40. 4
      quantum/plugins/bigswitch/tests/test_server.py
  41. 2
      quantum/plugins/brocade/QuantumPlugin.py
  42. 3
      quantum/plugins/brocade/nos/nosdriver.py
  43. 14
      quantum/plugins/cisco/common/cisco_credentials_v2.py
  44. 42
      quantum/plugins/cisco/common/cisco_exceptions.py
  45. 5
      quantum/plugins/cisco/common/cisco_faults.py
  46. 4
      quantum/plugins/cisco/common/cisco_utils.py
  47. 2
      quantum/plugins/cisco/common/config.py
  48. 6
      quantum/plugins/cisco/db/api.py
  49. 48
      quantum/plugins/cisco/db/l2network_db.py
  50. 23
      quantum/plugins/cisco/db/l2network_models.py
  51. 9
      quantum/plugins/cisco/db/models.py
  52. 46
      quantum/plugins/cisco/db/network_db_v2.py
  53. 23
      quantum/plugins/cisco/db/network_models_v2.py
  54. 16
      quantum/plugins/cisco/db/nexus_db_v2.py
  55. 2
      quantum/plugins/cisco/db/nexus_models_v2.py
  56. 2
      quantum/plugins/cisco/extensions/_credential_view.py
  57. 2
      quantum/plugins/cisco/extensions/_qos_view.py
  58. 29
      quantum/plugins/cisco/extensions/credential.py
  59. 29
      quantum/plugins/cisco/extensions/qos.py
  60. 40
      quantum/plugins/cisco/models/virt_phy_sw_v2.py
  61. 42
      quantum/plugins/cisco/network_plugin.py
  62. 58
      quantum/plugins/cisco/tests/unit/test_cisco_extension.py
  63. 108
      quantum/plugins/cisco/tests/unit/test_database.py
  64. 25
      quantum/plugins/hyperv/agent/hyperv_quantum_agent.py
  65. 8
      quantum/plugins/hyperv/agent/utils.py
  66. 2
      quantum/plugins/hyperv/db.py
  67. 4
      quantum/plugins/hyperv/model.py
  68. 9
      quantum/plugins/hyperv/rpc_callbacks.py
  69. 6
      quantum/plugins/linuxbridge/db/l2network_db_v2.py
  70. 4
      quantum/plugins/linuxbridge/db/l2network_models_v2.py
  71. 8
      quantum/plugins/linuxbridge/lb_quantum_plugin.py
  72. 2
      quantum/plugins/metaplugin/meta_quantum_plugin.py
  73. 6
      quantum/plugins/metaplugin/proxy_quantum_plugin.py
  74. 2
      quantum/plugins/midonet/plugin.py
  75. 2
      quantum/plugins/nec/agent/nec_quantum_agent.py
  76. 4
      quantum/plugins/nec/common/ofc_client.py
  77. 2
      quantum/plugins/nec/db/api.py
  78. 12
      quantum/plugins/nec/db/models.py
  79. 2
      quantum/plugins/nec/db/nec_plugin_base.py
  80. 4
      quantum/plugins/nec/drivers/pfc.py
  81. 4
      quantum/plugins/nec/drivers/trema.py
  82. 2
      quantum/plugins/nec/nec_plugin.py
  83. 60
      quantum/plugins/nicira/QuantumPlugin.py
  84. 2
      quantum/plugins/nicira/api_client/client.py
  85. 3
      quantum/plugins/nicira/api_client/client_eventlet.py
  86. 2
      quantum/plugins/nicira/common/exceptions.py
  87. 2
      quantum/plugins/nicira/common/securitygroups.py
  88. 6
      quantum/plugins/nicira/extensions/nvp_networkgw.py
  89. 6
      quantum/plugins/nicira/extensions/nvp_qos.py
  90. 6
      quantum/plugins/nicira/nicira_networkgw_db.py
  91. 38
      quantum/plugins/nicira/nvplib.py
  92. 19
      quantum/plugins/openvswitch/agent/ovs_quantum_agent.py
  93. 6
      quantum/plugins/openvswitch/ovs_db_v2.py
  94. 10
      quantum/plugins/openvswitch/ovs_models_v2.py
  95. 8
      quantum/plugins/openvswitch/ovs_quantum_plugin.py
  96. 2
      quantum/plugins/plumgrid/common/exceptions.py
  97. 27
      quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py
  98. 17
      quantum/plugins/plumgrid/plumgrid_nos_plugin/rest_connection.py
  99. 2
      quantum/plugins/ryu/agent/ryu_quantum_agent.py
  100. 2
      quantum/plugins/ryu/ryu_quantum_plugin.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -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)

@ -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.

@ -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:

@ -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()

@ -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' %

@ -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))

@ -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)

@ -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)

@ -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,

@ -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

@ -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

@ -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),

@ -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,

@ -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.

@ -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

@ -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)

@ -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

@ -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
"""

@ -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:

@ -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:

@ -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)

@ -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)

@ -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):

@ -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

@ -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':

@ -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__,

@ -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] != [])):

@ -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

@ -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

@ -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')

@ -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),

@ -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:

@ -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.
"""

@ -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 = []

@ -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)

@ -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