PEP8 fixes

Change-Id: Iab4c2ada2bfcb99452f940666b25cb1f7d4d7e58
This commit is contained in:
Jason Kölker 2012-06-01 10:50:36 -05:00
parent 6d14917e76
commit 7b38df15a1
16 changed files with 37 additions and 37 deletions

View 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']

View 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

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

View 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

View 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

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

View 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

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

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

View 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"]]))

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

View File

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

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

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

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

View File

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