diff --git a/quantum/agent/dhcp_agent.py b/quantum/agent/dhcp_agent.py index e29e963af..804983a6e 100644 --- a/quantum/agent/dhcp_agent.py +++ b/quantum/agent/dhcp_agent.py @@ -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) diff --git a/quantum/agent/firewall.py b/quantum/agent/firewall.py index 029dd35b3..8ca671502 100644 --- a/quantum/agent/firewall.py +++ b/quantum/agent/firewall.py @@ -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. diff --git a/quantum/agent/l3_agent.py b/quantum/agent/l3_agent.py index 549fb6c14..07eecc675 100644 --- a/quantum/agent/l3_agent.py +++ b/quantum/agent/l3_agent.py @@ -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: diff --git a/quantum/agent/linux/daemon.py b/quantum/agent/linux/daemon.py index cdd6dc292..7902868db 100644 --- a/quantum/agent/linux/daemon.py +++ b/quantum/agent/linux/daemon.py @@ -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() diff --git a/quantum/agent/linux/dhcp.py b/quantum/agent/linux/dhcp.py index b91de9fca..b154fd258 100644 --- a/quantum/agent/linux/dhcp.py +++ b/quantum/agent/linux/dhcp.py @@ -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' % diff --git a/quantum/agent/linux/ip_lib.py b/quantum/agent/linux/ip_lib.py index 5207c230e..88294d1be 100644 --- a/quantum/agent/linux/ip_lib.py +++ b/quantum/agent/linux/ip_lib.py @@ -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)) diff --git a/quantum/agent/linux/iptables_firewall.py b/quantum/agent/linux/iptables_firewall.py index 83c65f08b..8205b52ba 100644 --- a/quantum/agent/linux/iptables_firewall.py +++ b/quantum/agent/linux/iptables_firewall.py @@ -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) diff --git a/quantum/agent/ovs_cleanup_util.py b/quantum/agent/ovs_cleanup_util.py index 3f9601827..74544430c 100644 --- a/quantum/agent/ovs_cleanup_util.py +++ b/quantum/agent/ovs_cleanup_util.py @@ -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) diff --git a/quantum/agent/securitygroups_rpc.py b/quantum/agent/securitygroups_rpc.py index 51cc0fecd..2ca2c4197 100644 --- a/quantum/agent/securitygroups_rpc.py +++ b/quantum/agent/securitygroups_rpc.py @@ -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, diff --git a/quantum/api/api_common.py b/quantum/api/api_common.py index dfabb3c68..d408182b4 100644 --- a/quantum/api/api_common.py +++ b/quantum/api/api_common.py @@ -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 diff --git a/quantum/api/extensions.py b/quantum/api/extensions.py index e6c730cd7..ce562ca8d 100644 --- a/quantum/api/extensions.py +++ b/quantum/api/extensions.py @@ -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 diff --git a/quantum/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py b/quantum/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py index 21115576a..fbb1bbb2f 100644 --- a/quantum/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py +++ b/quantum/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py @@ -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), diff --git a/quantum/api/rpc/agentnotifiers/l3_rpc_agent_api.py b/quantum/api/rpc/agentnotifiers/l3_rpc_agent_api.py index 9f716d65f..4dc56f940 100644 --- a/quantum/api/rpc/agentnotifiers/l3_rpc_agent_api.py +++ b/quantum/api/rpc/agentnotifiers/l3_rpc_agent_api.py @@ -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, diff --git a/quantum/api/v2/attributes.py b/quantum/api/v2/attributes.py index 14496037d..fa3e81cfb 100644 --- a/quantum/api/v2/attributes.py +++ b/quantum/api/v2/attributes.py @@ -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. diff --git a/quantum/api/v2/base.py b/quantum/api/v2/base.py index 8ddb19118..33b16973b 100644 --- a/quantum/api/v2/base.py +++ b/quantum/api/v2/base.py @@ -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 diff --git a/quantum/common/rpc.py b/quantum/common/rpc.py index a381db9a2..06803873c 100644 --- a/quantum/common/rpc.py +++ b/quantum/common/rpc.py @@ -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) diff --git a/quantum/common/test_lib.py b/quantum/common/test_lib.py index e6c440c4c..21e82272a 100644 --- a/quantum/common/test_lib.py +++ b/quantum/common/test_lib.py @@ -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 diff --git a/quantum/common/utils.py b/quantum/common/utils.py index 6df3cce89..8c3467a84 100644 --- a/quantum/common/utils.py +++ b/quantum/common/utils.py @@ -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 """ diff --git a/quantum/db/agents_db.py b/quantum/db/agents_db.py index 90f8cf504..055380bcf 100644 --- a/quantum/db/agents_db.py +++ b/quantum/db/agents_db.py @@ -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: diff --git a/quantum/db/agentschedulers_db.py b/quantum/db/agentschedulers_db.py index c84d7fa95..2fcaa0c43 100644 --- a/quantum/db/agentschedulers_db.py +++ b/quantum/db/agentschedulers_db.py @@ -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: diff --git a/quantum/db/api.py b/quantum/db/api.py index 2629b2937..826b93efe 100644 --- a/quantum/db/api.py +++ b/quantum/db/api.py @@ -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) diff --git a/quantum/db/db_base_plugin_v2.py b/quantum/db/db_base_plugin_v2.py index 7c3738cbc..6f2172d24 100644 --- a/quantum/db/db_base_plugin_v2.py +++ b/quantum/db/db_base_plugin_v2.py @@ -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) diff --git a/quantum/db/extraroute_db.py b/quantum/db/extraroute_db.py index 45854ad22..a29a98a3c 100644 --- a/quantum/db/extraroute_db.py +++ b/quantum/db/extraroute_db.py @@ -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): diff --git a/quantum/db/l3_db.py b/quantum/db/l3_db.py index b428fa581..6e140bb82 100644 --- a/quantum/db/l3_db.py +++ b/quantum/db/l3_db.py @@ -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, @@ -717,7 +717,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 diff --git a/quantum/db/loadbalancer/loadbalancer_db.py b/quantum/db/loadbalancer/loadbalancer_db.py index 031a5a09a..ee504059a 100644 --- a/quantum/db/loadbalancer/loadbalancer_db.py +++ b/quantum/db/loadbalancer/loadbalancer_db.py @@ -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': diff --git a/quantum/db/model_base.py b/quantum/db/model_base.py index 194fdb96d..51b762b50 100644 --- a/quantum/db/model_base.py +++ b/quantum/db/model_base.py @@ -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__, diff --git a/quantum/db/securitygroups_db.py b/quantum/db/securitygroups_db.py index c2b42b50f..285f80d72 100644 --- a/quantum/db/securitygroups_db.py +++ b/quantum/db/securitygroups_db.py @@ -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] != [])): diff --git a/quantum/db/securitygroups_rpc_base.py b/quantum/db/securitygroups_rpc_base.py index 78a4c7e7b..7c15ea501 100644 --- a/quantum/db/securitygroups_rpc_base.py +++ b/quantum/db/securitygroups_rpc_base.py @@ -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 diff --git a/quantum/db/servicetype_db.py b/quantum/db/servicetype_db.py index fff5f6356..bfd95d492 100644 --- a/quantum/db/servicetype_db.py +++ b/quantum/db/servicetype_db.py @@ -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 diff --git a/quantum/debug/commands.py b/quantum/debug/commands.py index e6f2f0a84..079eef28a 100644 --- a/quantum/debug/commands.py +++ b/quantum/debug/commands.py @@ -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') diff --git a/quantum/debug/debug_agent.py b/quantum/debug/debug_agent.py index 8701c73f3..ba32f7194 100644 --- a/quantum/debug/debug_agent.py +++ b/quantum/debug/debug_agent.py @@ -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), diff --git a/quantum/extensions/agent.py b/quantum/extensions/agent.py index 430068255..f466f4789 100644 --- a/quantum/extensions/agent.py +++ b/quantum/extensions/agent.py @@ -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: diff --git a/quantum/extensions/agentscheduler.py b/quantum/extensions/agentscheduler.py index adf430c23..f5b072f8b 100644 --- a/quantum/extensions/agentscheduler.py +++ b/quantum/extensions/agentscheduler.py @@ -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. """ diff --git a/quantum/extensions/l3.py b/quantum/extensions/l3.py index e430e9310..d91cde103 100644 --- a/quantum/extensions/l3.py +++ b/quantum/extensions/l3.py @@ -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 = [] diff --git a/quantum/extensions/quotasv2.py b/quantum/extensions/quotasv2.py index eb981ceb3..d49ffd3c4 100644 --- a/quantum/extensions/quotasv2.py +++ b/quantum/extensions/quotasv2.py @@ -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) diff --git a/quantum/extensions/securitygroup.py b/quantum/extensions/securitygroup.py index 8162218a6..de4f0664a 100644 --- a/quantum/extensions/securitygroup.py +++ b/quantum/extensions/securitygroup.py @@ -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 = [] diff --git a/quantum/extensions/servicetype.py b/quantum/extensions/servicetype.py index 0468d1f88..270bbb5db 100644 --- a/quantum/extensions/servicetype.py +++ b/quantum/extensions/servicetype.py @@ -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()] diff --git a/quantum/manager.py b/quantum/manager.py index c7cc8a13e..f9430cbd5 100644 --- a/quantum/manager.py +++ b/quantum/manager.py @@ -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() diff --git a/quantum/plugins/bigswitch/plugin.py b/quantum/plugins/bigswitch/plugin.py index 9239c25ad..849c38e26 100644 --- a/quantum/plugins/bigswitch/plugin.py +++ b/quantum/plugins/bigswitch/plugin.py @@ -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): diff --git a/quantum/plugins/bigswitch/tests/test_server.py b/quantum/plugins/bigswitch/tests/test_server.py index 26afa6a17..5b38dcb2a 100755 --- a/quantum/plugins/bigswitch/tests/test_server.py +++ b/quantum/plugins/bigswitch/tests/test_server.py @@ -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 diff --git a/quantum/plugins/brocade/QuantumPlugin.py b/quantum/plugins/brocade/QuantumPlugin.py index 895a967ef..5639dc40e 100644 --- a/quantum/plugins/brocade/QuantumPlugin.py +++ b/quantum/plugins/brocade/QuantumPlugin.py @@ -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 """ diff --git a/quantum/plugins/brocade/nos/nosdriver.py b/quantum/plugins/brocade/nos/nosdriver.py index be0c7880f..c8362a13b 100644 --- a/quantum/plugins/brocade/nos/nosdriver.py +++ b/quantum/plugins/brocade/nos/nosdriver.py @@ -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): diff --git a/quantum/plugins/cisco/common/cisco_credentials_v2.py b/quantum/plugins/cisco/common/cisco_credentials_v2.py index 203c2498e..bfc8a76c5 100644 --- a/quantum/plugins/cisco/common/cisco_credentials_v2.py +++ b/quantum/plugins/cisco/common/cisco_credentials_v2.py @@ -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) diff --git a/quantum/plugins/cisco/common/cisco_exceptions.py b/quantum/plugins/cisco/common/cisco_exceptions.py index cf1d20206..de400582f 100644 --- a/quantum/plugins/cisco/common/cisco_exceptions.py +++ b/quantum/plugins/cisco/common/cisco_exceptions.py @@ -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") diff --git a/quantum/plugins/cisco/common/cisco_faults.py b/quantum/plugins/cisco/common/cisco_faults.py index 48d9001ae..2ffc984a0 100644 --- a/quantum/plugins/cisco/common/cisco_faults.py +++ b/quantum/plugins/cisco/common/cisco_faults.py @@ -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") diff --git a/quantum/plugins/cisco/common/cisco_utils.py b/quantum/plugins/cisco/common/cisco_utils.py index 080493250..7baa1d687 100644 --- a/quantum/plugins/cisco/common/cisco_utils.py +++ b/quantum/plugins/cisco/common/cisco_utils.py @@ -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 diff --git a/quantum/plugins/cisco/common/config.py b/quantum/plugins/cisco/common/config.py index ba6bbc554..d9ad2a60f 100644 --- a/quantum/plugins/cisco/common/config.py +++ b/quantum/plugins/cisco/common/config.py @@ -87,7 +87,7 @@ nexus_dictionary = {} class CiscoConfigOptions(): - """ Cisco Configuration Options Class """ + """Cisco Configuration Options Class.""" def __init__(self): self._create_nexus_dictionary() diff --git a/quantum/plugins/cisco/db/api.py b/quantum/plugins/cisco/db/api.py index 708b01661..7b3018971 100644 --- a/quantum/plugins/cisco/db/api.py +++ b/quantum/plugins/cisco/db/api.py @@ -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) diff --git a/quantum/plugins/cisco/db/l2network_db.py b/quantum/plugins/cisco/db/l2network_db.py index 74b8350c9..8c2e87c25 100644 --- a/quantum/plugins/cisco/db/l2network_db.py +++ b/quantum/plugins/cisco/db/l2network_db.py @@ -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). diff --git a/quantum/plugins/cisco/db/l2network_models.py b/quantum/plugins/cisco/db/l2network_models.py index 45ccc9f1d..e39ef1e68 100644 --- a/quantum/plugins/cisco/db/l2network_models.py +++ b/quantum/plugins/cisco/db/l2network_models.py @@ -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)) diff --git a/quantum/plugins/cisco/db/models.py b/quantum/plugins/cisco/db/models.py index 99ae98c5c..82062a659 100644 --- a/quantum/plugins/cisco/db/models.py +++ b/quantum/plugins/cisco/db/models.py @@ -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) diff --git a/quantum/plugins/cisco/db/network_db_v2.py b/quantum/plugins/cisco/db/network_db_v2.py index e5339d4a4..f2a089cd1 100644 --- a/quantum/plugins/cisco/db/network_db_v2.py +++ b/quantum/plugins/cisco/db/network_db_v2.py @@ -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). diff --git a/quantum/plugins/cisco/db/network_models_v2.py b/quantum/plugins/cisco/db/network_models_v2.py index f9c018987..fadbbfef8 100644 --- a/quantum/plugins/cisco/db/network_models_v2.py +++ b/quantum/plugins/cisco/db/network_models_v2.py @@ -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)) diff --git a/quantum/plugins/cisco/db/nexus_db_v2.py b/quantum/plugins/cisco/db/nexus_db_v2.py index 0f9512048..bdae9f7b7 100644 --- a/quantum/plugins/cisco/db/nexus_db_v2.py +++ b/quantum/plugins/cisco/db/nexus_db_v2.py @@ -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: diff --git a/quantum/plugins/cisco/db/nexus_models_v2.py b/quantum/plugins/cisco/db/nexus_models_v2.py index e1cfd4b3c..e787c4c86 100644 --- a/quantum/plugins/cisco/db/nexus_models_v2.py +++ b/quantum/plugins/cisco/db/nexus_models_v2.py @@ -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) diff --git a/quantum/plugins/cisco/extensions/_credential_view.py b/quantum/plugins/cisco/extensions/_credential_view.py index 3a5e7f222..4456a7378 100644 --- a/quantum/plugins/cisco/extensions/_credential_view.py +++ b/quantum/plugins/cisco/extensions/_credential_view.py @@ -19,7 +19,7 @@ def get_view_builder(req): - """get view builder """ + """get view builder.""" base_url = req.application_url return ViewBuilder(base_url) diff --git a/quantum/plugins/cisco/extensions/_qos_view.py b/quantum/plugins/cisco/extensions/_qos_view.py index 354fa413d..06d8e3178 100644 --- a/quantum/plugins/cisco/extensions/_qos_view.py +++ b/quantum/plugins/cisco/extensions/_qos_view.py @@ -19,7 +19,7 @@ def get_view_builder(req): - """get view builder""" + """get view builder.""" base_url = req.application_url return ViewBuilder(base_url) diff --git a/quantum/plugins/cisco/extensions/credential.py b/quantum/plugins/cisco/extensions/credential.py index 2bf56a2d5..b9d53fc65 100644 --- a/quantum/plugins/cisco/extensions/credential.py +++ b/quantum/plugins/cisco/extensions/credential.py @@ -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() diff --git a/quantum/plugins/cisco/extensions/qos.py b/quantum/plugins/cisco/extensions/qos.py index 2729bb673..1c53b378c 100644 --- a/quantum/plugins/cisco/extensions/qos.py +++ b/quantum/plugins/cisco/extensions/qos.py @@ -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() diff --git a/quantum/plugins/cisco/models/virt_phy_sw_v2.py b/quantum/plugins/cisco/models/virt_phy_sw_v2.py index 5ac8bdd2d..1623153f1 100644 --- a/quantum/plugins/cisco/models/virt_phy_sw_v2.py +++ b/quantum/plugins/cisco/models/virt_phy_sw_v2.py @@ -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 diff --git a/quantum/plugins/cisco/network_plugin.py b/quantum/plugins/cisco/network_plugin.py index a54d5951e..9c599d404 100644 --- a/quantum/plugins/cisco/network_plugin.py +++ b/quantum/plugins/cisco/network_plugin.py @@ -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] diff --git a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py index 5776249ec..7eb0af954 100644 --- a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py +++ b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py @@ -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 diff --git a/quantum/plugins/cisco/tests/unit/test_database.py b/quantum/plugins/cisco/tests/unit/test_database.py index ac5b4e7a2..798ad045b 100644 --- a/quantum/plugins/cisco/tests/unit/test_database.py +++ b/quantum/plugins/cisco/tests/unit/test_database.py @@ -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: diff --git a/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py b/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py index 1ffdc9123..b340d2421 100644 --- a/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py +++ b/quantum/plugins/hyperv/agent/hyperv_quantum_agent.py @@ -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) diff --git a/quantum/plugins/hyperv/agent/utils.py b/quantum/plugins/hyperv/agent/utils.py index 703b61765..1c0468b63 100644 --- a/quantum/plugins/hyperv/agent/utils.py +++ b/quantum/plugins/hyperv/agent/utils.py @@ -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) diff --git a/quantum/plugins/hyperv/db.py b/quantum/plugins/hyperv/db.py index 361315b2f..b88d286a1 100644 --- a/quantum/plugins/hyperv/db.py +++ b/quantum/plugins/hyperv/db.py @@ -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(): diff --git a/quantum/plugins/hyperv/model.py b/quantum/plugins/hyperv/model.py index 57b4ff939..fac657a4c 100644 --- a/quantum/plugins/hyperv/model.py +++ b/quantum/plugins/hyperv/model.py @@ -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), diff --git a/quantum/plugins/hyperv/rpc_callbacks.py b/quantum/plugins/hyperv/rpc_callbacks.py index 02df0c2ad..f2e17f16a 100644 --- a/quantum/plugins/hyperv/rpc_callbacks.py +++ b/quantum/plugins/hyperv/rpc_callbacks.py @@ -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 diff --git a/quantum/plugins/linuxbridge/db/l2network_db_v2.py b/quantum/plugins/linuxbridge/db/l2network_db_v2.py index 3e48b855d..8a5631e53 100644 --- a/quantum/plugins/linuxbridge/db/l2network_db_v2.py +++ b/quantum/plugins/linuxbridge/db/l2network_db_v2.py @@ -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: diff --git a/quantum/plugins/linuxbridge/db/l2network_models_v2.py b/quantum/plugins/linuxbridge/db/l2network_models_v2.py index c6451fe3d..d30485c99 100644 --- a/quantum/plugins/linuxbridge/db/l2network_models_v2.py +++ b/quantum/plugins/linuxbridge/db/l2network_models_v2.py @@ -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), diff --git a/quantum/plugins/linuxbridge/lb_quantum_plugin.py b/quantum/plugins/linuxbridge/lb_quantum_plugin.py index 6993aa24d..28741516e 100644 --- a/quantum/plugins/linuxbridge/lb_quantum_plugin.py +++ b/quantum/plugins/linuxbridge/lb_quantum_plugin.py @@ -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"), diff --git a/quantum/plugins/metaplugin/meta_quantum_plugin.py b/quantum/plugins/metaplugin/meta_quantum_plugin.py index 913b36d8b..37ee2ba0d 100644 --- a/quantum/plugins/metaplugin/meta_quantum_plugin.py +++ b/quantum/plugins/metaplugin/meta_quantum_plugin.py @@ -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() diff --git a/quantum/plugins/metaplugin/proxy_quantum_plugin.py b/quantum/plugins/metaplugin/proxy_quantum_plugin.py index 48f3cb5b8..b9c603faf 100644 --- a/quantum/plugins/metaplugin/proxy_quantum_plugin.py +++ b/quantum/plugins/metaplugin/proxy_quantum_plugin.py @@ -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 diff --git a/quantum/plugins/midonet/plugin.py b/quantum/plugins/midonet/plugin.py index 7ee77c7e2..b31b33683 100644 --- a/quantum/plugins/midonet/plugin.py +++ b/quantum/plugins/midonet/plugin.py @@ -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 diff --git a/quantum/plugins/nec/agent/nec_quantum_agent.py b/quantum/plugins/nec/agent/nec_quantum_agent.py index 82b76d7a2..00f1dd687 100755 --- a/quantum/plugins/nec/agent/nec_quantum_agent.py +++ b/quantum/plugins/nec/agent/nec_quantum_agent.py @@ -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}) diff --git a/quantum/plugins/nec/common/ofc_client.py b/quantum/plugins/nec/common/ofc_client.py index a423b4dbf..d6559dc86 100644 --- a/quantum/plugins/nec/common/ofc_client.py +++ b/quantum/plugins/nec/common/ofc_client.py @@ -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: diff --git a/quantum/plugins/nec/db/api.py b/quantum/plugins/nec/db/api.py index 32ef259bb..1c74024be 100644 --- a/quantum/plugins/nec/db/api.py +++ b/quantum/plugins/nec/db/api.py @@ -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 diff --git a/quantum/plugins/nec/db/models.py b/quantum/plugins/nec/db/models.py index 893af1535..614570c87 100644 --- a/quantum/plugins/nec/db/models.py +++ b/quantum/plugins/nec/db/models.py @@ -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) diff --git a/quantum/plugins/nec/db/nec_plugin_base.py b/quantum/plugins/nec/db/nec_plugin_base.py index 820d2758d..56bdb575f 100644 --- a/quantum/plugins/nec/db/nec_plugin_base.py +++ b/quantum/plugins/nec/db/nec_plugin_base.py @@ -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'], diff --git a/quantum/plugins/nec/drivers/pfc.py b/quantum/plugins/nec/drivers/pfc.py index 339199c32..f30f0c2fe 100644 --- a/quantum/plugins/nec/drivers/pfc.py +++ b/quantum/plugins/nec/drivers/pfc.py @@ -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): diff --git a/quantum/plugins/nec/drivers/trema.py b/quantum/plugins/nec/drivers/trema.py index b97f81da9..9f55223e5 100644 --- a/quantum/plugins/nec/drivers/trema.py +++ b/quantum/plugins/nec/drivers/trema.py @@ -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" diff --git a/quantum/plugins/nec/nec_plugin.py b/quantum/plugins/nec/nec_plugin.py index c8852c0dd..0e71acfce 100644 --- a/quantum/plugins/nec/nec_plugin.py +++ b/quantum/plugins/nec/nec_plugin.py @@ -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' diff --git a/quantum/plugins/nicira/QuantumPlugin.py b/quantum/plugins/nicira/QuantumPlugin.py index b12feb581..3f7d21aa9 100644 --- a/quantum/plugins/nicira/QuantumPlugin.py +++ b/quantum/plugins/nicira/QuantumPlugin.py @@ -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): diff --git a/quantum/plugins/nicira/api_client/client.py b/quantum/plugins/nicira/api_client/client.py index abfc838c3..9ce9943a7 100644 --- a/quantum/plugins/nicira/api_client/client.py +++ b/quantum/plugins/nicira/api_client/client.py @@ -21,8 +21,8 @@ from abc import ABCMeta import httplib -import time import logging +import time from quantum.plugins.nicira.api_client.common import ( diff --git a/quantum/plugins/nicira/api_client/client_eventlet.py b/quantum/plugins/nicira/api_client/client_eventlet.py index 0987991e0..da55356c8 100644 --- a/quantum/plugins/nicira/api_client/client_eventlet.py +++ b/quantum/plugins/nicira/api_client/client_eventlet.py @@ -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() diff --git a/quantum/plugins/nicira/common/exceptions.py b/quantum/plugins/nicira/common/exceptions.py index 2bacc9451..db9f9c3d3 100644 --- a/quantum/plugins/nicira/common/exceptions.py +++ b/quantum/plugins/nicira/common/exceptions.py @@ -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 diff --git a/quantum/plugins/nicira/common/securitygroups.py b/quantum/plugins/nicira/common/securitygroups.py index fd5d65abd..444d4674f 100644 --- a/quantum/plugins/nicira/common/securitygroups.py +++ b/quantum/plugins/nicira/common/securitygroups.py @@ -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) diff --git a/quantum/plugins/nicira/extensions/nvp_networkgw.py b/quantum/plugins/nicira/extensions/nvp_networkgw.py index ae2295c0a..cff405798 100644 --- a/quantum/plugins/nicira/extensions/nvp_networkgw.py +++ b/quantum/plugins/nicira/extensions/nvp_networkgw.py @@ -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()) diff --git a/quantum/plugins/nicira/extensions/nvp_qos.py b/quantum/plugins/nicira/extensions/nvp_qos.py index 9ecc7f861..45bf48589 100644 --- a/quantum/plugins/nicira/extensions/nvp_qos.py +++ b/quantum/plugins/nicira/extensions/nvp_qos.py @@ -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' diff --git a/quantum/plugins/nicira/nicira_networkgw_db.py b/quantum/plugins/nicira/nicira_networkgw_db.py index b4cdd5c72..cc9d51b31 100644 --- a/quantum/plugins/nicira/nicira_networkgw_db.py +++ b/quantum/plugins/nicira/nicira_networkgw_db.py @@ -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. diff --git a/quantum/plugins/nicira/nvplib.py b/quantum/plugins/nicira/nvplib.py index b4e36eca1..0a5eadfd7 100644 --- a/quantum/plugins/nicira/nvplib.py +++ b/quantum/plugins/nicira/nvplib.py @@ -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 = 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) diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index 8efce182f..b278fef8c 100644 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -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): @@ -378,7 +378,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}) @@ -458,7 +459,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) @@ -485,7 +487,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") @@ -511,7 +514,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( @@ -533,7 +537,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 = {} @@ -703,7 +708,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 diff --git a/quantum/plugins/openvswitch/ovs_db_v2.py b/quantum/plugins/openvswitch/ovs_db_v2.py index 5c6b68b36..a03dc7324 100644 --- a/quantum/plugins/openvswitch/ovs_db_v2.py +++ b/quantum/plugins/openvswitch/ovs_db_v2.py @@ -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 diff --git a/quantum/plugins/openvswitch/ovs_models_v2.py b/quantum/plugins/openvswitch/ovs_models_v2.py index 119bd8c7a..e508e750f 100644 --- a/quantum/plugins/openvswitch/ovs_models_v2.py +++ b/quantum/plugins/openvswitch/ovs_models_v2.py @@ -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) diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index 520723259..faf8f6519 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -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"), diff --git a/quantum/plugins/plumgrid/common/exceptions.py b/quantum/plugins/plumgrid/common/exceptions.py index 4201cce16..015c6730e 100644 --- a/quantum/plugins/plumgrid/common/exceptions.py +++ b/quantum/plugins/plumgrid/common/exceptions.py @@ -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 diff --git a/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py b/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py index ac026d0f4..5b098d71c 100644 --- a/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py +++ b/quantum/plugins/plumgrid/plumgrid_nos_plugin/plumgrid_plugin.py @@ -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) diff --git a/quantum/plugins/plumgrid/plumgrid_nos_plugin/rest_connection.py b/quantum/plugins/plumgrid/plumgrid_nos_plugin/rest_connection.py index f38b55df4..5d15c7627 100644 --- a/quantum/plugins/plumgrid/plumgrid_nos_plugin/rest_connection.py +++ b/quantum/plugins/plumgrid/plumgrid_nos_plugin/rest_connection.py @@ -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: diff --git a/quantum/plugins/ryu/agent/ryu_quantum_agent.py b/quantum/plugins/ryu/agent/ryu_quantum_agent.py index 14243fa16..f20cb5b30 100755 --- a/quantum/plugins/ryu/agent/ryu_quantum_agent.py +++ b/quantum/plugins/ryu/agent/ryu_quantum_agent.py @@ -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) diff --git a/quantum/plugins/ryu/ryu_quantum_plugin.py b/quantum/plugins/ryu/ryu_quantum_plugin.py index 34ab0b9d9..3c8c78d47 100644 --- a/quantum/plugins/ryu/ryu_quantum_plugin.py +++ b/quantum/plugins/ryu/ryu_quantum_plugin.py @@ -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 diff --git a/quantum/plugins/services/agent_loadbalancer/agent/manager.py b/quantum/plugins/services/agent_loadbalancer/agent/manager.py index f8c002c84..8d49cf7de 100644 --- a/quantum/plugins/services/agent_loadbalancer/agent/manager.py +++ b/quantum/plugins/services/agent_loadbalancer/agent/manager.py @@ -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 diff --git a/quantum/plugins/services/agent_loadbalancer/drivers/haproxy/cfg.py b/quantum/plugins/services/agent_loadbalancer/drivers/haproxy/cfg.py index 7e1e267c3..c85700493 100644 --- a/quantum/plugins/services/agent_loadbalancer/drivers/haproxy/cfg.py +++ b/quantum/plugins/services/agent_loadbalancer/drivers/haproxy/cfg.py @@ -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 diff --git a/quantum/plugins/services/agent_loadbalancer/plugin.py b/quantum/plugins/services/agent_loadbalancer/plugin.py index 5b7378fc6..7ffe22530 100644 --- a/quantum/plugins/services/agent_loadbalancer/plugin.py +++ b/quantum/plugins/services/agent_loadbalancer/plugin.py @@ -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 diff --git a/quantum/plugins/services/service_base.py b/quantum/plugins/services/service_base.py index ef933c08a..936621ab3 100644 --- a/quantum/plugins/services/service_base.py +++ b/quantum/plugins/services/service_base.py @@ -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 diff --git a/quantum/policy.py b/quantum/policy.py index 67211611e..1683d5c7c 100644 --- a/quantum/policy.py +++ b/quantum/policy.py @@ -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 diff --git a/quantum/rootwrap/filters.py b/quantum/rootwrap/filters.py index 58b3c183f..28b5e1bd3 100644 --- a/quantum/rootwrap/filters.py +++ b/quantum/rootwrap/filters.py @@ -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" "dnsmasq" """ + vars plus "ip" "netns" "exec" "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 diff --git a/quantum/rootwrap/wrapper.py b/quantum/rootwrap/wrapper.py index 85a2387fa..92198c49f 100644 --- a/quantum/rootwrap/wrapper.py +++ b/quantum/rootwrap/wrapper.py @@ -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): diff --git a/quantum/scheduler/dhcp_agent_scheduler.py b/quantum/scheduler/dhcp_agent_scheduler.py index d0b63d4f2..3133eb23f 100644 --- a/quantum/scheduler/dhcp_agent_scheduler.py +++ b/quantum/scheduler/dhcp_agent_scheduler.py @@ -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 == diff --git a/quantum/scheduler/l3_agent_scheduler.py b/quantum/scheduler/l3_agent_scheduler.py index 73f5d224e..f7a477ff3 100644 --- a/quantum/scheduler/l3_agent_scheduler.py +++ b/quantum/scheduler/l3_agent_scheduler.py @@ -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. diff --git a/quantum/service.py b/quantum/service.py index 2856020a0..fb97cbd71 100644 --- a/quantum/service.py +++ b/quantum/service.py @@ -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, diff --git a/quantum/tests/unit/brocade/test_brocade_db.py b/quantum/tests/unit/brocade/test_brocade_db.py index 9d53ff134..88e1e3fc1 100644 --- a/quantum/tests/unit/brocade/test_brocade_db.py +++ b/quantum/tests/unit/brocade/test_brocade_db.py @@ -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.""" diff --git a/quantum/tests/unit/database_stubs.py b/quantum/tests/unit/database_stubs.py index 583f16601..bfae58e98 100644 --- a/quantum/tests/unit/database_stubs.py +++ b/quantum/tests/unit/database_stubs.py @@ -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) diff --git a/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py b/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py index 08e251259..590ac6907 100644 --- a/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py +++ b/quantum/tests/unit/db/loadbalancer/test_db_loadbalancer.py @@ -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): diff --git a/quantum/tests/unit/dummy_plugin.py b/quantum/tests/unit/dummy_plugin.py index 1bbc5dbba..b4bbb01ac 100644 --- a/quantum/tests/unit/dummy_plugin.py +++ b/quantum/tests/unit/dummy_plugin.py @@ -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 diff --git a/quantum/tests/unit/extensions/extensionattribute.py b/quantum/tests/unit/extensions/extensionattribute.py index 4f8d5fd7f..6d3355f52 100644 --- a/quantum/tests/unit/extensions/extensionattribute.py +++ b/quantum/tests/unit/extensions/extensionattribute.py @@ -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' diff --git a/quantum/tests/unit/linuxbridge/test_agent_scheduler.py b/quantum/tests/unit/linuxbridge/test_agent_scheduler.py index 1cd0a91ee..4506f6068 100644 --- a/quantum/tests/unit/linuxbridge/test_agent_scheduler.py +++ b/quantum/tests/unit/linuxbridge/test_agent_scheduler.py @@ -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( diff --git a/quantum/tests/unit/metaplugin/test_metaplugin.py b/quantum/tests/unit/metaplugin/test_metaplugin.py index e1d5cf540..8a1a815a5 100644 --- a/quantum/tests/unit/metaplugin/test_metaplugin.py +++ b/quantum/tests/unit/metaplugin/test_metaplugin.py @@ -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") diff --git a/quantum/tests/unit/nec/test_agent_scheduler.py b/quantum/tests/unit/nec/test_agent_scheduler.py index 9356cb023..fadbc777b 100644 --- a/quantum/tests/unit/nec/test_agent_scheduler.py +++ b/quantum/tests/unit/nec/test_agent_scheduler.py @@ -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( diff --git a/quantum/tests/unit/nec/test_db.py b/quantum/tests/unit/nec/test_db.py index 296caffe5..08a2f8c3f 100644 --- a/quantum/tests/unit/nec/test_db.py +++ b/quantum/tests/unit/nec/test_db.py @@ -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 diff --git a/quantum/tests/unit/nec/test_nec_plugin.py b/quantum/tests/unit/nec/test_nec_plugin.py index cc5d00453..cb8c5971c 100644 --- a/quantum/tests/unit/nec/test_nec_plugin.py +++ b/quantum/tests/unit/nec/test_nec_plugin.py @@ -15,10 +15,10 @@ 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 diff --git a/quantum/tests/unit/nec/test_ofc_manager.py b/quantum/tests/unit/nec/test_ofc_manager.py index 78c082d21..74d7e460c 100644 --- a/quantum/tests/unit/nec/test_ofc_manager.py +++ b/quantum/tests/unit/nec/test_ofc_manager.py @@ -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) diff --git a/quantum/tests/unit/nec/test_pfc_driver.py b/quantum/tests/unit/nec/test_pfc_driver.py index c78f89d7d..bc0f81cc6 100644 --- a/quantum/tests/unit/nec/test_pfc_driver.py +++ b/quantum/tests/unit/nec/test_pfc_driver.py @@ -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() diff --git a/quantum/tests/unit/nec/test_trema_driver.py b/quantum/tests/unit/nec/test_trema_driver.py index 68420cb33..3b79176c5 100644 --- a/quantum/tests/unit/nec/test_trema_driver.py +++ b/quantum/tests/unit/nec/test_trema_driver.py @@ -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() diff --git a/quantum/tests/unit/nicira/fake_nvpapiclient.py b/quantum/tests/unit/nicira/fake_nvpapiclient.py index 4794f469f..6b20ab6fd 100644 --- a/quantum/tests/unit/nicira/fake_nvpapiclient.py +++ b/quantum/tests/unit/nicira/fake_nvpapiclient.py @@ -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 diff --git a/quantum/tests/unit/nicira/test_networkgw.py b/quantum/tests/unit/nicira/test_networkgw.py index 2f806e375..bc1e00c24 100644 --- a/quantum/tests/unit/nicira/test_networkgw.py +++ b/quantum/tests/unit/nicira/test_networkgw.py @@ -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"] diff --git a/quantum/tests/unit/nicira/test_nicira_plugin.py b/quantum/tests/unit/nicira/test_nicira_plugin.py index 494cd81d3..f7667974b 100644 --- a/quantum/tests/unit/nicira/test_nicira_plugin.py +++ b/quantum/tests/unit/nicira/test_nicira_plugin.py @@ -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")] diff --git a/quantum/tests/unit/openvswitch/test_agent_scheduler.py b/quantum/tests/unit/openvswitch/test_agent_scheduler.py index f02377f27..4ab15a88a 100644 --- a/quantum/tests/unit/openvswitch/test_agent_scheduler.py +++ b/quantum/tests/unit/openvswitch/test_agent_scheduler.py @@ -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' diff --git a/quantum/tests/unit/openvswitch/test_ovs_lib.py b/quantum/tests/unit/openvswitch/test_ovs_lib.py index 9b8ebdd94..74b4001b4 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_lib.py +++ b/quantum/tests/unit/openvswitch/test_ovs_lib.py @@ -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" diff --git a/quantum/tests/unit/openvswitch/test_ovs_tunnel.py b/quantum/tests/unit/openvswitch/test_ovs_tunnel.py index e3bdcee84..31d0ba458 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_tunnel.py +++ b/quantum/tests/unit/openvswitch/test_ovs_tunnel.py @@ -399,7 +399,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() diff --git a/quantum/tests/unit/ryu/test_defaults.py b/quantum/tests/unit/ryu/test_defaults.py index 095b25131..2f0e02a52 100644 --- a/quantum/tests/unit/ryu/test_defaults.py +++ b/quantum/tests/unit/ryu/test_defaults.py @@ -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) diff --git a/quantum/tests/unit/services/agent_loadbalancer/test_plugin.py b/quantum/tests/unit/services/agent_loadbalancer/test_plugin.py index 1c583562c..eb6be9018 100644 --- a/quantum/tests/unit/services/agent_loadbalancer/test_plugin.py +++ b/quantum/tests/unit/services/agent_loadbalancer/test_plugin.py @@ -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 diff --git a/quantum/tests/unit/test_api_v2.py b/quantum/tests/unit/test_api_v2.py index 99fa378a2..d31744497 100644 --- a/quantum/tests/unit/test_api_v2.py +++ b/quantum/tests/unit/test_api_v2.py @@ -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 diff --git a/quantum/tests/unit/test_attributes.py b/quantum/tests/unit/test_attributes.py index 76f99c96f..f3415aefc 100644 --- a/quantum/tests/unit/test_attributes.py +++ b/quantum/tests/unit/test_attributes.py @@ -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'], diff --git a/quantum/tests/unit/test_db_plugin.py b/quantum/tests/unit/test_db_plugin.py index 4801813b3..3cf5430f9 100644 --- a/quantum/tests/unit/test_db_plugin.py +++ b/quantum/tests/unit/test_db_plugin.py @@ -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") @@ -3426,9 +3426,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) diff --git a/quantum/tests/unit/test_extension_portsecurity.py b/quantum/tests/unit/test_extension_portsecurity.py index 7a611cc46..38bf670ba 100644 --- a/quantum/tests/unit/test_extension_portsecurity.py +++ b/quantum/tests/unit/test_extension_portsecurity.py @@ -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. """ diff --git a/quantum/tests/unit/test_extension_security_group.py b/quantum/tests/unit/test_extension_security_group.py index 461907884..b768ef51d 100644 --- a/quantum/tests/unit/test_extension_security_group.py +++ b/quantum/tests/unit/test_extension_security_group.py @@ -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. """ diff --git a/quantum/tests/unit/test_iptables_firewall.py b/quantum/tests/unit/test_iptables_firewall.py index 5f2ee5a4a..aea7e6da4 100644 --- a/quantum/tests/unit/test_iptables_firewall.py +++ b/quantum/tests/unit/test_iptables_firewall.py @@ -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()]) diff --git a/quantum/tests/unit/test_l3_plugin.py b/quantum/tests/unit/test_l3_plugin.py index 4c7f66e06..0152830fa 100644 --- a/quantum/tests/unit/test_l3_plugin.py +++ b/quantum/tests/unit/test_l3_plugin.py @@ -307,7 +307,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: diff --git a/quantum/tests/unit/test_loadbalancer_plugin.py b/quantum/tests/unit/test_loadbalancer_plugin.py index 36e1f2d11..25e42f0d2 100644 --- a/quantum/tests/unit/test_loadbalancer_plugin.py +++ b/quantum/tests/unit/test_loadbalancer_plugin.py @@ -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)) diff --git a/quantum/tests/unit/test_metadata_agent.py b/quantum/tests/unit/test_metadata_agent.py index 791871ce9..ec0f4585c 100644 --- a/quantum/tests/unit/test_metadata_agent.py +++ b/quantum/tests/unit/test_metadata_agent.py @@ -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): diff --git a/quantum/tests/unit/test_metadata_namespace_proxy.py b/quantum/tests/unit/test_metadata_namespace_proxy.py index d0b9a7b5b..dc9e0ee54 100644 --- a/quantum/tests/unit/test_metadata_namespace_proxy.py +++ b/quantum/tests/unit/test_metadata_namespace_proxy.py @@ -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): diff --git a/quantum/tests/unit/test_rootwrap.py b/quantum/tests/unit/test_rootwrap.py index 6f23b4955..4933f4467 100644 --- a/quantum/tests/unit/test_rootwrap.py +++ b/quantum/tests/unit/test_rootwrap.py @@ -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)' diff --git a/quantum/tests/unit/test_servicetype.py b/quantum/tests/unit/test_servicetype.py index 1e2a9ce87..1871ed394 100644 --- a/quantum/tests/unit/test_servicetype.py +++ b/quantum/tests/unit/test_servicetype.py @@ -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() + diff --git a/quantum/tests/unit/test_wsgi.py b/quantum/tests/unit/test_wsgi.py index b775a83ec..956a4e0c7 100644 --- a/quantum/tests/unit/test_wsgi.py +++ b/quantum/tests/unit/test_wsgi.py @@ -20,8 +20,8 @@ import socket import urllib2 import mock -import testtools from oslo.config import cfg +import testtools import webob import webob.exc diff --git a/quantum/wsgi.py b/quantum/wsgi.py index 8558729f8..f3986becf 100644 --- a/quantum/wsgi.py +++ b/quantum/wsgi.py @@ -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.""" diff --git a/run_tests.py b/run_tests.py index e49002126..eb5c6aa03 100755 --- a/run_tests.py +++ b/run_tests.py @@ -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 diff --git a/tools/check_i18n.py b/tools/check_i18n.py index 705b2d3dd..b33055172 100644 --- a/tools/check_i18n.py +++ b/tools/check_i18n.py @@ -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) diff --git a/tools/i18n_cfg.py b/tools/i18n_cfg.py index 23894a938..92e707726 100644 --- a/tools/i18n_cfg.py +++ b/tools/i18n_cfg.py @@ -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): diff --git a/tools/test-requires b/tools/test-requires index a92a6d26f..706f878d6 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -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 357960782..5754ebd43 100644 --- a/tox.ini +++ b/tox.ini @@ -41,8 +41,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