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] data = body[self._resource_name]
except KeyError: except KeyError:
# raise if _resource_name is not in req body. # 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) % self._resource_name)
for param in params: for param in params:
param_name = param['param-name'] 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): def _filter_port_has_interface(port, has_interface, **kwargs):
# convert to bool # convert to bool
match_has_interface = has_interface.lower() == 'true' 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 return match_has_interface == really_has_interface

View File

@ -57,13 +57,14 @@ def import_object(import_str):
return cls() return cls()
# NOTE(jkoelker) Since to_primitive isn't used anywhere can we just drop it
def to_primitive(value): def to_primitive(value):
if type(value) is type([]) or type(value) is type((None,)): if isinstance(value, (list, tuple)):
o = [] o = []
for v in value: for v in value:
o.append(to_primitive(v)) o.append(to_primitive(v))
return o return o
elif type(value) is type({}): elif isinstance(value, dict):
o = {} o = {}
for k, v in value.iteritems(): for k, v in value.iteritems():
o[k] = to_primitive(v) 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, obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
result = None result = None
if process_input != None: if process_input is not None:
result = obj.communicate(process_input) result = obj.communicate(process_input)
else: else:
result = obj.communicate() result = obj.communicate()

View File

@ -31,8 +31,8 @@ def parse_mailmap(mailmap='.mailmap'):
for l in fp: for l in fp:
l = l.strip() l = l.strip()
if not l.startswith('#') and ' ' in l: if not l.startswith('#') and ' ' in l:
canonical_email, alias = [x for x in l.split(' ') \ canonical_email, alias = [x for x in l.split(' ')
if x.startswith('<')] if x.startswith('<')]
mapping[alias] = canonical_email mapping[alias] = canonical_email
return mapping return mapping

View File

@ -340,8 +340,8 @@ def add_pp_binding(tenantid, portid, ppid, default):
raise c_exc.PortProfileBindingAlreadyExists(pp_id=ppid, raise c_exc.PortProfileBindingAlreadyExists(pp_id=ppid,
port_id=portid) port_id=portid)
except exc.NoResultFound: except exc.NoResultFound:
binding = l2network_models.PortProfileBinding(tenantid, portid, \ binding = l2network_models.PortProfileBinding(tenantid, portid,
ppid, default) ppid, default)
session.add(binding) session.add(binding)
session.flush() session.flush()
return binding return binding

View File

@ -55,7 +55,7 @@ def add_services_binding(service_id, mngnet_id, nbnet_id, sbnet_id):
"""Adds a services binding""" """Adds a services binding"""
LOG.debug("add_services_binding() called") LOG.debug("add_services_binding() called")
session = db.get_session() session = db.get_session()
binding = services_models.ServicesBinding(service_id, mngnet_id, \ binding = services_models.ServicesBinding(service_id, mngnet_id,
nbnet_id, sbnet_id) nbnet_id, sbnet_id)
session.add(binding) session.add(binding)
session.flush() session.flush()

View File

@ -61,8 +61,9 @@ def add_portbinding(port_id, blade_intf_dn, portprofile_name,
one() one()
raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id) raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id)
except exc.NoResultFound: except exc.NoResultFound:
port_binding = ucs_models.PortBinding(port_id, blade_intf_dn, \ port_binding = ucs_models.PortBinding(port_id, blade_intf_dn,
portprofile_name, vlan_name, vlan_id, qos) portprofile_name, vlan_name,
vlan_id, qos)
session.add(port_binding) session.add(port_binding)
session.flush() session.flush()
return port_binding return port_binding

View File

@ -265,7 +265,7 @@ class L2Network(QuantumPluginBase):
attachment_id = attachment_id[:const.UUID_LENGTH] attachment_id = attachment_id[:const.UUID_LENGTH]
remote_interface_id = remote_interface_id[:const.UUID_LENGTH] remote_interface_id = remote_interface_id[:const.UUID_LENGTH]
if remote_interface_id != attachment_id: 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)) (attachment_id, remote_interface_id))
raise exc.PortInUse(port_id=port_id, net_id=net_id, raise exc.PortInUse(port_id=port_id, net_id=net_id,
att_id=attachment_id) att_id=attachment_id)

View File

@ -74,7 +74,7 @@ class Libvirt802dot1QbhDriver(VIFDriver):
"for the VIF driver." % name) "for the VIF driver." % name)
return return
LOG.error("Quantum plugin does not support required \"%s\" extension" 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) % CSCO_EXT_NAME)
raise excp.ServiceUnavailable() raise excp.ServiceUnavailable()
@ -86,13 +86,13 @@ class Libvirt802dot1QbhDriver(VIFDriver):
project_id = instance['project_id'] project_id = instance['project_id']
vif_id = mapping['vif_uuid'] vif_id = mapping['vif_uuid']
instance_data_dict = \ instance_data_dict = {
{'novatenant': \ 'novatenant': {
{'instance_id': instance_id, 'instance_id': instance_id,
'instance_desc': \ 'instance_desc': {
{'user_id': user_id, 'user_id': user_id,
'project_id': project_id, 'project_id': project_id,
'vif_id': vif_id}}} 'vif_id': vif_id}}}
client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION, client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
uri_prefix=URI_PREFIX_CSCO, tenant=TENANT_ID, 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() service_logic = servlogcs.ServicesLogistics()
net_list = {} net_list = {}
multiport_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] southbound_net_name]
client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id) client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
for net in networks_name_list: 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"]])) cmd, " ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
sys.exit() sys.exit()
if len(arglist) > 0: 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))) % (cmd, len(cmdargs), len(orig_arglist)))
print "Service Insertion Usage:\n %s %s" % ( print "Service Insertion Usage:\n %s %s" % (
cmd, " ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]])) 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) db.validate_port_ownership(tenant_id, net_id, port_id)
port = db.port_get(port_id, net_id) port = db.port_get(port_id, net_id)
attachment_id = port[const.INTERFACEID] attachment_id = port[const.INTERFACEID]
if attachment_id == None: if attachment_id is None:
return return
db.port_unset_attachment(port_id, net_id) db.port_unset_attachment(port_id, net_id)
db.port_update(port_id, net_id, op_status=OperationalStatus.DOWN) 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): def get_bridge_name(self, network_id):
if not 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") "name")
bridge_name = self.br_name_prefix + network_id[0:11] bridge_name = self.br_name_prefix + network_id[0:11]
return bridge_name return bridge_name
def get_subinterface_name(self, vlan_id): def get_subinterface_name(self, vlan_id):
if not 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")
subinterface_name = '%s.%s' % (self.physical_interface, vlan_id) subinterface_name = '%s.%s' % (self.physical_interface, vlan_id)
return subinterface_name return subinterface_name
def get_tap_device_name(self, interface_id): def get_tap_device_name(self, interface_id):
if not 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_device_name = TAP_INTERFACE_PREFIX + interface_id[0:11] tap_device_name = TAP_INTERFACE_PREFIX + interface_id[0:11]
return tap_device_name return tap_device_name

View File

@ -52,13 +52,13 @@ CONFIG_KEYS = ["DEFAULT_TZ_UUID", "NVP_CONTROLLER_IP", "PORT", "USER",
def initConfig(cfile=None): def initConfig(cfile=None):
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
if cfile == None: if cfile is None:
if os.path.exists(CONFIG_FILE): if os.path.exists(CONFIG_FILE):
cfile = CONFIG_FILE cfile = CONFIG_FILE
else: else:
cfile = find_config(os.path.abspath(os.path.dirname(__file__))) 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)) raise Exception("Configuration file \"%s\" doesn't exist" % (cfile))
LOG.info("Using configuration file: %s" % cfile) LOG.info("Using configuration file: %s" % cfile)
config.read(cfile) config.read(cfile)

View File

@ -115,7 +115,7 @@ def main():
LOG.debug("Executing command \"%s\" with args: %s" % (CMD, args)) LOG.debug("Executing command \"%s\" with args: %s" % (CMD, args))
manager = None manager = None
if COMMANDS[CMD]["need_login"] == True: if COMMANDS[CMD]["need_login"] is True:
if not os.path.exists(options.configfile): if not os.path.exists(options.configfile):
LOG.error("NVP plugin configuration file \"%s\" doesn't exist!" % LOG.error("NVP plugin configuration file \"%s\" doesn't exist!" %
options.configfile) 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)) LOG.error("Port or Network not found, Error: %s" % str(e))
raise exception.PortNotFound(port_id=port, net_id=network) raise exception.PortNotFound(port_id=port, net_id=network)
except NvpApiClient.Conflict as e: 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)) "Error: %s" % str(e))
raise exception.AlreadyAttached(att_id=attachment, raise exception.AlreadyAttached(att_id=attachment,
port_id=port, 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_git_changelog
from quantum.openstack.common.setup import write_vcsversion from quantum.openstack.common.setup import write_vcsversion
import sys
import os
import subprocess
requires = parse_requirements() requires = parse_requirements()
depend_links = parse_dependency_links() depend_links = parse_dependency_links()
@ -98,11 +95,11 @@ setup(
eager_resources=EagerResources, eager_resources=EagerResources,
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'quantum-linuxbridge-agent =' \ 'quantum-linuxbridge-agent ='
'quantum.plugins.linuxbridge.agent.linuxbridge_quantum_agent:main', 'quantum.plugins.linuxbridge.agent.linuxbridge_quantum_agent:main',
'quantum-openvswitch-agent =' \ 'quantum-openvswitch-agent ='
'quantum.plugins.openvswitch.agent.ovs_quantum_agent:main', 'quantum.plugins.openvswitch.agent.ovs_quantum_agent:main',
'quantum-ryu-agent = ' \ 'quantum-ryu-agent = '
'quantum.plugins.ryu.agent.ryu_quantum_agent:main', 'quantum.plugins.ryu.agent.ryu_quantum_agent:main',
'quantum-server = quantum.server:main', 'quantum-server = quantum.server:main',
] ]