]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
PEP8 fixes
authorJason Kölker <jason@koelker.net>
Fri, 1 Jun 2012 15:50:36 +0000 (10:50 -0500)
committerJason Kölker <jason@koelker.net>
Fri, 1 Jun 2012 15:50:36 +0000 (10:50 -0500)
Change-Id: Iab4c2ada2bfcb99452f940666b25cb1f7d4d7e58

16 files changed:
quantum/api/api_common.py
quantum/api/views/filters.py
quantum/common/utils.py
quantum/openstack/common/setup.py
quantum/plugins/cisco/db/l2network_db.py
quantum/plugins/cisco/db/services_db.py
quantum/plugins/cisco/db/ucs_db.py
quantum/plugins/cisco/l2network_plugin.py
quantum/plugins/cisco/nova/vifdirect.py
quantum/plugins/cisco/services/service_insertion.py
quantum/plugins/linuxbridge/LinuxBridgePlugin.py
quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py
quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py
quantum/plugins/nicira/nicira_nvp_plugin/cli.py
quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py
setup.py

index 5007ba9ebc5577c9422ae4d91d3a3ce5de301138..49a16b440c8f7116b1c8e929666287199da0d15e 100644 (file)
@@ -185,7 +185,7 @@ class QuantumController(object):
             data = body[self._resource_name]
         except KeyError:
             # raise if _resource_name is not in req body.
-            raise exc.HTTPBadRequest("Unable to find '%s' in request body"\
+            raise exc.HTTPBadRequest("Unable to find '%s' in request body"
                                      % self._resource_name)
         for param in params:
             param_name = param['param-name']
index e2d1449a5b84832cce26ac86e2f4799d8371d479..e989d46e651e0e161094b14681f46bd585cdfb90 100644 (file)
@@ -93,7 +93,8 @@ def _filter_port_by_interface(port, interface_id, **kwargs):
 def _filter_port_has_interface(port, has_interface, **kwargs):
     # convert to bool
     match_has_interface = has_interface.lower() == 'true'
-    really_has_interface = 'attachment' in port and port['attachment'] != None
+    really_has_interface = ('attachment' in port and
+                            port['attachment'] is not None)
     return match_has_interface == really_has_interface
 
 
index 92b37193740566b95930755b0cfa258627291fb0..a44a2e4bb51e261e5c6e95f6d8922290a75d33ec 100644 (file)
@@ -57,13 +57,14 @@ def import_object(import_str):
         return cls()
 
 
+# NOTE(jkoelker) Since to_primitive isn't used anywhere can we just drop it
 def to_primitive(value):
-    if type(value) is type([]) or type(value) is type((None,)):
+    if isinstance(value, (list, tuple)):
         o = []
         for v in value:
             o.append(to_primitive(v))
         return o
-    elif type(value) is type({}):
+    elif isinstance(value, dict):
         o = {}
         for k, v in value.iteritems():
             o[k] = to_primitive(v)
@@ -145,7 +146,7 @@ def execute(cmd, process_input=None, addl_env=None, check_exit_code=True):
     obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
         stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
     result = None
-    if process_input != None:
+    if process_input is not None:
         result = obj.communicate(process_input)
     else:
         result = obj.communicate()
index 2c16b5b3525540ec8e23471bc560aea42276f990..16e53b98bf807d98eb61e2a3cd1b7e04558aa03d 100644 (file)
@@ -31,8 +31,8 @@ def parse_mailmap(mailmap='.mailmap'):
         for l in fp:
             l = l.strip()
             if not l.startswith('#') and ' ' in l:
-                canonical_email, alias = [x for x in l.split(' ') \
-                                         if x.startswith('<')]
+                canonical_email, alias = [x for x in l.split(' ')
+                                          if x.startswith('<')]
                 mapping[alias] = canonical_email
     return mapping
 
index c6962f7dd6f5af9c994619bbf6301d9ba02cc896..f0489646275a80d50946112f2ae5316fb1d6313d 100644 (file)
@@ -340,8 +340,8 @@ def add_pp_binding(tenantid, portid, ppid, default):
         raise c_exc.PortProfileBindingAlreadyExists(pp_id=ppid,
                                                     port_id=portid)
     except exc.NoResultFound:
-        binding = l2network_models.PortProfileBinding(tenantid, portid, \
-                                                            ppid, default)
+        binding = l2network_models.PortProfileBinding(tenantid, portid,
+                                                      ppid, default)
         session.add(binding)
         session.flush()
         return binding
index 7235cfb41f12e63768659131ef05f6fed77de2d2..7c5a92247a36029eda6305b3b703ff8f79615508 100644 (file)
@@ -55,7 +55,7 @@ def add_services_binding(service_id, mngnet_id, nbnet_id, sbnet_id):
     """Adds a services binding"""
     LOG.debug("add_services_binding() called")
     session = db.get_session()
-    binding = services_models.ServicesBinding(service_id, mngnet_id, \
+    binding = services_models.ServicesBinding(service_id, mngnet_id,
                                               nbnet_id, sbnet_id)
     session.add(binding)
     session.flush()
index 617542ffa4a028eca6115b85d9860d923327903b..039ee7968401d517252d5f069ee23ec41f7bbd2e 100644 (file)
@@ -61,8 +61,9 @@ def add_portbinding(port_id, blade_intf_dn, portprofile_name,
           one()
         raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id)
     except exc.NoResultFound:
-        port_binding = ucs_models.PortBinding(port_id, blade_intf_dn, \
-                                    portprofile_name, vlan_name, vlan_id, qos)
+        port_binding = ucs_models.PortBinding(port_id, blade_intf_dn,
+                                              portprofile_name, vlan_name,
+                                              vlan_id, qos)
         session.add(port_binding)
         session.flush()
         return port_binding
index 0a7e115a27782565f78c1a8c0fc678abb60ac29c..6d6810a50af6cabd7919d9744c7e3ab5cf44feb2 100644 (file)
@@ -265,7 +265,7 @@ class L2Network(QuantumPluginBase):
         attachment_id = attachment_id[:const.UUID_LENGTH]
         remote_interface_id = remote_interface_id[:const.UUID_LENGTH]
         if remote_interface_id != attachment_id:
-            LOG.debug("Existing attachment_id:%s, remote_interface_id:%s" % \
+            LOG.debug("Existing attachment_id:%s, remote_interface_id:%s" %
                       (attachment_id, remote_interface_id))
             raise exc.PortInUse(port_id=port_id, net_id=net_id,
                                 att_id=attachment_id)
index 67a4148e60d96914e02ac8de75b918835d2dbc3d..785a5cbd074cbf1086bf63eddf2a2ef99bfe44c5 100644 (file)
@@ -74,7 +74,7 @@ class Libvirt802dot1QbhDriver(VIFDriver):
                           "for the VIF driver." % name)
                 return
         LOG.error("Quantum plugin does not support required \"%s\" extension"
-                  " for the VIF driver. nova-compute will quit." \
+                  " for the VIF driver. nova-compute will quit."
                   % CSCO_EXT_NAME)
         raise excp.ServiceUnavailable()
 
@@ -86,13 +86,13 @@ class Libvirt802dot1QbhDriver(VIFDriver):
         project_id = instance['project_id']
         vif_id = mapping['vif_uuid']
 
-        instance_data_dict = \
-                {'novatenant': \
-                 {'instance_id': instance_id,
-                  'instance_desc': \
-                  {'user_id': user_id,
-                   'project_id': project_id,
-                   'vif_id': vif_id}}}
+        instance_data_dict = {
+            'novatenant': {
+                'instance_id': instance_id,
+                'instance_desc': {
+                    'user_id': user_id,
+                    'project_id': project_id,
+                    'vif_id': vif_id}}}
 
         client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
                         uri_prefix=URI_PREFIX_CSCO, tenant=TENANT_ID,
index 02aec9ffc2c70df97c3a8269e061939cb5593f65..1a1496a0e26eae3b03f80cef8c95fce585753ba3 100644 (file)
@@ -54,7 +54,7 @@ def insert_inpath_service(tenant_id, service_image_id,
     service_logic = servlogcs.ServicesLogistics()
     net_list = {}
     multiport_net_list = []
-    networks_name_list = [management_net_name, northbound_net_name, \
+    networks_name_list = [management_net_name, northbound_net_name,
                           southbound_net_name]
     client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
     for net in networks_name_list:
@@ -257,7 +257,7 @@ def build_args(cmd, cmdargs, arglist):
             cmd, " ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
         sys.exit()
     if len(arglist) > 0:
-        LOG.debug("Too many arguments for \"%s\" (expected: %d, got: %d)" \
+        LOG.debug("Too many arguments for \"%s\" (expected: %d, got: %d)"
                   % (cmd, len(cmdargs), len(orig_arglist)))
         print "Service Insertion Usage:\n    %s %s" % (
             cmd, " ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
index dbe5d3ab62c95a85254b750f82acc77bc4512e94..cfbdcfe453c26f264a8fa27c9f5b5bee5b443cc8 100644 (file)
@@ -252,7 +252,7 @@ class LinuxBridgePlugin(QuantumPluginBase):
         db.validate_port_ownership(tenant_id, net_id, port_id)
         port = db.port_get(port_id, net_id)
         attachment_id = port[const.INTERFACEID]
-        if attachment_id == None:
+        if attachment_id is None:
             return
         db.port_unset_attachment(port_id, net_id)
         db.port_update(port_id, net_id, op_status=OperationalStatus.DOWN)
index 1d5887afb28eb9a68ca3507b446d17327f75cec1..20eaf1e8a25b8bc8d1027cbbf5cddf2eb0143658 100755 (executable)
@@ -89,21 +89,21 @@ class LinuxBridge:
 
     def get_bridge_name(self, network_id):
         if not network_id:
-            LOG.warning("Invalid Network ID, will lead to incorrect bridge" \
+            LOG.warning("Invalid Network ID, will lead to incorrect bridge"
                         "name")
         bridge_name = self.br_name_prefix + network_id[0:11]
         return bridge_name
 
     def get_subinterface_name(self, vlan_id):
         if not vlan_id:
-            LOG.warning("Invalid VLAN ID, will lead to incorrect " \
+            LOG.warning("Invalid VLAN ID, will lead to incorrect "
                         "subinterface name")
         subinterface_name = '%s.%s' % (self.physical_interface, vlan_id)
         return subinterface_name
 
     def get_tap_device_name(self, interface_id):
         if not interface_id:
-            LOG.warning("Invalid Interface ID, will lead to incorrect " \
+            LOG.warning("Invalid Interface ID, will lead to incorrect "
                         "tap device name")
         tap_device_name = TAP_INTERFACE_PREFIX + interface_id[0:11]
         return tap_device_name
index 1cb53af339e7218247348c012fee8a274cb6ab0e..85c36bdbf9d257ba6695f0b6c94c5302a572b45a 100644 (file)
@@ -52,13 +52,13 @@ CONFIG_KEYS = ["DEFAULT_TZ_UUID", "NVP_CONTROLLER_IP", "PORT", "USER",
 
 def initConfig(cfile=None):
     config = ConfigParser.ConfigParser()
-    if cfile == None:
+    if cfile is None:
         if os.path.exists(CONFIG_FILE):
             cfile = CONFIG_FILE
         else:
             cfile = find_config(os.path.abspath(os.path.dirname(__file__)))
 
-    if cfile == None:
+    if cfile is None:
         raise Exception("Configuration file \"%s\" doesn't exist" % (cfile))
     LOG.info("Using configuration file: %s" % cfile)
     config.read(cfile)
index b4647a5b98def339efd9f1ac19b3f5d7b3a696c7..397ee1a439fe57f4dcee2fab4860785f732cffbe 100644 (file)
@@ -115,7 +115,7 @@ def main():
     LOG.debug("Executing command \"%s\" with args: %s" % (CMD, args))
 
     manager = None
-    if COMMANDS[CMD]["need_login"] == True:
+    if COMMANDS[CMD]["need_login"] is True:
         if not os.path.exists(options.configfile):
             LOG.error("NVP plugin configuration file \"%s\" doesn't exist!" %
                       options.configfile)
index 37899cf44d1a2aa19a892a8be84f6b559ad14444..5f3d210bf1dd3bd14c4dc05b2a389b5eaeb47d06 100644 (file)
@@ -298,7 +298,7 @@ def plug_interface(controller, network, port, type, attachment=None):
         LOG.error("Port or Network not found, Error: %s" % str(e))
         raise exception.PortNotFound(port_id=port, net_id=network)
     except NvpApiClient.Conflict as e:
-        LOG.error("Conflict while making attachment to port, " \
+        LOG.error("Conflict while making attachment to port, "
                   "Error: %s" % str(e))
         raise exception.AlreadyAttached(att_id=attachment,
                                         port_id=port,
index 409a3385167024dc07b5587252570cf23ef68735..e46e710593ce0aaf35ae953159a56b5c654a15cc 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -21,9 +21,6 @@ from quantum.openstack.common.setup import write_requirements
 from quantum.openstack.common.setup import write_git_changelog
 from quantum.openstack.common.setup import write_vcsversion
 
-import sys
-import os
-import subprocess
 
 requires = parse_requirements()
 depend_links = parse_dependency_links()
@@ -98,11 +95,11 @@ setup(
     eager_resources=EagerResources,
     entry_points={
         'console_scripts': [
-            'quantum-linuxbridge-agent =' \
+            'quantum-linuxbridge-agent ='
             'quantum.plugins.linuxbridge.agent.linuxbridge_quantum_agent:main',
-            'quantum-openvswitch-agent =' \
+            'quantum-openvswitch-agent ='
             'quantum.plugins.openvswitch.agent.ovs_quantum_agent:main',
-            'quantum-ryu-agent = ' \
+            'quantum-ryu-agent = '
             'quantum.plugins.ryu.agent.ryu_quantum_agent:main',
             'quantum-server = quantum.server:main',
         ]