diff --git a/quantum/agent/linux/ovs_lib.py b/quantum/agent/linux/ovs_lib.py index 92422c0ddc..4e8c2c06bb 100644 --- a/quantum/agent/linux/ovs_lib.py +++ b/quantum/agent/linux/ovs_lib.py @@ -58,7 +58,7 @@ class OVSBridge: def delete_port(self, port_name): self.run_vsctl(["--", "--if-exists", "del-port", self.br_name, - port_name]) + port_name]) def set_db_attribute(self, table_name, record, column, value): args = ["set", table_name, record, "%s=%s" % (column, value)] @@ -87,10 +87,10 @@ class OVSBridge: is_delete_expr = kwargs.get('delete', False) print "kwargs = %s" % kwargs if not is_delete_expr: - prefix = ("hard_timeout=%s,idle_timeout=%s,priority=%s" - % (kwargs.get('hard_timeout', '0'), - kwargs.get('idle_timeout', '0'), - kwargs.get('priority', '1'))) + prefix = ("hard_timeout=%s,idle_timeout=%s,priority=%s" % + (kwargs.get('hard_timeout', '0'), + kwargs.get('idle_timeout', '0'), + kwargs.get('priority', '1'))) flow_expr_arr.append(prefix) elif 'priority' in kwargs: raise Exception("Cannot match priority on flow deletion") @@ -179,7 +179,7 @@ class OVSBridge: return utils.execute(["xe", "vif-param-get", "param-name=other-config", "param-key=nicira-iface-id", "uuid=%s" % xs_vif_uuid], - root_helper=self.root_helper).strip() + root_helper=self.root_helper).strip() # returns a VIF object for each VIF port def get_vif_ports(self): diff --git a/quantum/api/attachments.py b/quantum/api/attachments.py index 69588be05a..b9cb2ec455 100644 --- a/quantum/api/attachments.py +++ b/quantum/api/attachments.py @@ -31,7 +31,7 @@ def create_resource(plugin, version): '1.1': [ControllerV11(plugin), ControllerV11._serialization_metadata, common.XML_NS_V11], - } + } return common.create_resource(version, controller_dict) @@ -44,16 +44,16 @@ class Controller(common.QuantumController): { 'param-name': 'id', 'required': True, - }, - ] + }, + ] _serialization_metadata = { "application/xml": { "attributes": { "attachment": ["id"], - }, }, - } + }, + } @common.APIFaultWrapper([exception.NetworkNotFound, exception.PortNotFound]) diff --git a/quantum/api/faults.py b/quantum/api/faults.py index a9e373fcb7..3497540c44 100644 --- a/quantum/api/faults.py +++ b/quantum/api/faults.py @@ -47,8 +47,8 @@ def fault_body_function_v10(wrapped_exc): 'code': code, 'message': wrapped_exc.explanation, 'detail': str(wrapped_exc.detail), - }, - } + }, + } metadata = {'attributes': {fault_name: ['code']}} return fault_data, metadata @@ -71,8 +71,8 @@ def fault_body_function_v11(wrapped_exc): 'type': fault_name, 'message': wrapped_exc.explanation, 'detail': str(wrapped_exc.detail), - }, - } + }, + } # Metadata not required for v11 return fault_data, None @@ -90,41 +90,41 @@ def fault_body_function(version): class Quantum10HTTPError(webob.exc.HTTPClientError): _fault_dict = { - exceptions.NetworkNotFound: { - 'code': 420, - 'title': 'networkNotFound', - 'explanation': _NETNOTFOUND_EXPL - }, - exceptions.NetworkInUse: { - 'code': 421, - 'title': 'networkInUse', - 'explanation': _NETINUSE_EXPL - }, - exceptions.PortNotFound: { - 'code': 430, - 'title': 'portNotFound', - 'explanation': _PORTNOTFOUND_EXPL - }, - exceptions.StateInvalid: { - 'code': 431, - 'title': 'requestedStateInvalid', - 'explanation': _STATEINVALID_EXPL - }, - exceptions.PortInUse: { - 'code': 432, - 'title': 'portInUse', - 'explanation': _PORTINUSE_EXPL - }, - exceptions.AlreadyAttached: { - 'code': 440, - 'title': 'alreadyAttached', - 'explanation': _ALREADYATTACHED_EXPL - }, - exceptions.NotImplementedError: { - 'code': 501, - 'title': 'notImplemented', - 'explanation': _NOTIMPLEMENTED_EXPL - } + exceptions.NetworkNotFound: { + 'code': 420, + 'title': 'networkNotFound', + 'explanation': _NETNOTFOUND_EXPL + }, + exceptions.NetworkInUse: { + 'code': 421, + 'title': 'networkInUse', + 'explanation': _NETINUSE_EXPL + }, + exceptions.PortNotFound: { + 'code': 430, + 'title': 'portNotFound', + 'explanation': _PORTNOTFOUND_EXPL + }, + exceptions.StateInvalid: { + 'code': 431, + 'title': 'requestedStateInvalid', + 'explanation': _STATEINVALID_EXPL + }, + exceptions.PortInUse: { + 'code': 432, + 'title': 'portInUse', + 'explanation': _PORTINUSE_EXPL + }, + exceptions.AlreadyAttached: { + 'code': 440, + 'title': 'alreadyAttached', + 'explanation': _ALREADYATTACHED_EXPL + }, + exceptions.NotImplementedError: { + 'code': 501, + 'title': 'notImplemented', + 'explanation': _NOTIMPLEMENTED_EXPL + } } def __init__(self, inner_exc): @@ -139,42 +139,42 @@ class Quantum10HTTPError(webob.exc.HTTPClientError): class Quantum11HTTPError(webob.exc.HTTPClientError): _fault_dict = { - exceptions.NetworkNotFound: { - 'code': webob.exc.HTTPNotFound.code, - 'title': webob.exc.HTTPNotFound.title, - 'type': 'NetworkNotFound', - 'explanation': _NETNOTFOUND_EXPL - }, - exceptions.NetworkInUse: { - 'code': webob.exc.HTTPConflict.code, - 'title': webob.exc.HTTPConflict.title, - 'type': 'NetworkInUse', - 'explanation': _NETINUSE_EXPL - }, - exceptions.PortNotFound: { - 'code': webob.exc.HTTPNotFound.code, - 'title': webob.exc.HTTPNotFound.title, - 'type': 'PortNotFound', - 'explanation': _PORTNOTFOUND_EXPL - }, - exceptions.StateInvalid: { - 'code': webob.exc.HTTPBadRequest.code, - 'title': webob.exc.HTTPBadRequest.title, - 'type': 'RequestedStateInvalid', - 'explanation': _STATEINVALID_EXPL - }, - exceptions.PortInUse: { - 'code': webob.exc.HTTPConflict.code, - 'title': webob.exc.HTTPConflict.title, - 'type': 'PortInUse', - 'explanation': _PORTINUSE_EXPL - }, - exceptions.AlreadyAttached: { - 'code': webob.exc.HTTPConflict.code, - 'title': webob.exc.HTTPConflict.title, - 'type': 'AlreadyAttached', - 'explanation': _ALREADYATTACHED_EXPL - } + exceptions.NetworkNotFound: { + 'code': webob.exc.HTTPNotFound.code, + 'title': webob.exc.HTTPNotFound.title, + 'type': 'NetworkNotFound', + 'explanation': _NETNOTFOUND_EXPL + }, + exceptions.NetworkInUse: { + 'code': webob.exc.HTTPConflict.code, + 'title': webob.exc.HTTPConflict.title, + 'type': 'NetworkInUse', + 'explanation': _NETINUSE_EXPL + }, + exceptions.PortNotFound: { + 'code': webob.exc.HTTPNotFound.code, + 'title': webob.exc.HTTPNotFound.title, + 'type': 'PortNotFound', + 'explanation': _PORTNOTFOUND_EXPL + }, + exceptions.StateInvalid: { + 'code': webob.exc.HTTPBadRequest.code, + 'title': webob.exc.HTTPBadRequest.title, + 'type': 'RequestedStateInvalid', + 'explanation': _STATEINVALID_EXPL + }, + exceptions.PortInUse: { + 'code': webob.exc.HTTPConflict.code, + 'title': webob.exc.HTTPConflict.title, + 'type': 'PortInUse', + 'explanation': _PORTINUSE_EXPL + }, + exceptions.AlreadyAttached: { + 'code': webob.exc.HTTPConflict.code, + 'title': webob.exc.HTTPConflict.title, + 'type': 'AlreadyAttached', + 'explanation': _ALREADYATTACHED_EXPL + } } def __init__(self, inner_exc): diff --git a/quantum/api/networks.py b/quantum/api/networks.py index ad0606ef31..74ef3dd616 100644 --- a/quantum/api/networks.py +++ b/quantum/api/networks.py @@ -33,7 +33,7 @@ def create_resource(plugin, version): '1.1': [ControllerV11(plugin), ControllerV11._serialization_metadata, common.XML_NS_V11], - } + } return common.create_resource(version, controller_dict) @@ -44,7 +44,7 @@ class Controller(common.QuantumController): version = None _network_ops_param_list = [ {'param-name': 'name', 'required': True}, - ] + ] def _item(self, request, tenant_id, network_id, net_details=True, port_details=False): @@ -154,12 +154,12 @@ class ControllerV10(Controller): "network": ["id", "name"], "port": ["id", "state"], "attachment": ["id"], - }, + }, "plurals": { "networks": "network", "ports": "port", - }, - } + }, + } version = "1.0" @@ -178,11 +178,11 @@ class ControllerV11(Controller): "network": ["id", "name", "op-status"], "port": ["id", "state", "op-status"], "attachment": ["id"], - }, + }, "plurals": { "networks": "network", "ports": "port", - }, - } + }, + } version = "1.1" diff --git a/quantum/api/ports.py b/quantum/api/ports.py index 27075f046d..3f423a0d08 100644 --- a/quantum/api/ports.py +++ b/quantum/api/ports.py @@ -32,7 +32,7 @@ def create_resource(plugin, version): '1.1': [ControllerV11(plugin), ControllerV11._serialization_metadata, common.XML_NS_V11], - } + } return common.create_resource(version, controller_dict) @@ -43,7 +43,7 @@ class Controller(common.QuantumController): version = None _port_ops_param_list = [ {'param-name': 'state', 'default-value': 'DOWN', 'required': False}, - ] + ] def _items(self, request, tenant_id, network_id, port_details=False): @@ -160,11 +160,11 @@ class ControllerV10(Controller): "attributes": { "port": ["id", "state"], "attachment": ["id"], - }, + }, "plurals": { "ports": "port", - }, - } + }, + } version = "1.0" @@ -176,10 +176,10 @@ class ControllerV11(Controller): "attributes": { "port": ["id", "state", "op-status"], "attachment": ["id"], - }, + }, "plurals": { "ports": "port", - }, - } + }, + } version = "1.1" diff --git a/quantum/api/v2/base.py b/quantum/api/v2/base.py index cde4f62f80..ffc10603a7 100644 --- a/quantum/api/v2/base.py +++ b/quantum/api/v2/base.py @@ -158,9 +158,9 @@ class Controller(object): if self._resource not in ['network', 'port']: return - if ('tenant_id' in res_dict and - res_dict['tenant_id'] != context.tenant_id and - not context.is_admin): + if (('tenant_id' in res_dict and + res_dict['tenant_id'] != context.tenant_id and + not context.is_admin)): msg = _("Specifying 'tenant_id' other than authenticated" "tenant in request requires admin privileges") raise webob.exc.HTTPBadRequest(msg) @@ -170,7 +170,7 @@ class Controller(object): res_dict['tenant_id'] = context.tenant_id else: msg = _("Running without keystyone AuthN requires " - " that tenant_id is specified") + " that tenant_id is specified") raise webob.exc.HTTPBadRequest(msg) def _prepare_request_body(self, context, body, is_create, @@ -242,13 +242,11 @@ def create_resource(collection, resource, plugin, conf, params): # NOTE(jkoelker) To anyone wishing to add "proper" xml support # this is where you do it - serializers = { + serializers = {} # 'application/xml': wsgi.XMLDictSerializer(metadata, XML_NS_V20), - } - deserializers = { + deserializers = {} # 'application/xml': wsgi.XMLDeserializer(metadata), - } return wsgi_resource.Resource(controller, FAULT_MAP, deserializers, serializers) diff --git a/quantum/api/v2/router.py b/quantum/api/v2/router.py index 938ea200ef..04b2ff7f60 100644 --- a/quantum/api/v2/router.py +++ b/quantum/api/v2/router.py @@ -95,13 +95,9 @@ class Index(wsgi.Application): @webob.dec.wsgify(RequestClass=wsgi.Request) def __call__(self, req): - metadata = {'application/xml': { - 'attributes': { - 'resource': ['name', 'collection'], - 'link': ['href', 'rel'], - } - } - } + metadata = {'application/xml': {'attributes': { + 'resource': ['name', 'collection'], + 'link': ['href', 'rel']}}} layout = [] for name, collection in self.resources.iteritems(): @@ -153,6 +149,6 @@ class APIRouter(wsgi.Router): for resource in resources: _map_resource(resources[resource], resource, RESOURCE_ATTRIBUTE_MAP.get(resources[resource], - dict())) + dict())) super(APIRouter, self).__init__(mapper) diff --git a/quantum/api/versions.py b/quantum/api/versions.py index 73a0c569d3..a2fa135e82 100644 --- a/quantum/api/versions.py +++ b/quantum/api/versions.py @@ -65,8 +65,8 @@ class Versions(object): } content_type = req.best_match_content_type() - body = wsgi.Serializer(metadata=metadata). \ - serialize(response, content_type) + body = (wsgi.Serializer(metadata=metadata). + serialize(response, content_type)) response = webob.Response() response.content_type = content_type diff --git a/quantum/api/views/filters.py b/quantum/api/views/filters.py index e989d46e65..349088cc17 100644 --- a/quantum/api/views/filters.py +++ b/quantum/api/views/filters.py @@ -30,8 +30,8 @@ def _load_network_ports_details(network, **kwargs): # Don't pass filter options, don't care about unused filters port_list = plugin.get_all_ports(tenant_id, network['net-id']) ports_data = [plugin.get_port_details( - tenant_id, network['net-id'], - port['port-id']) + tenant_id, network['net-id'], + port['port-id']) for port in port_list] network['net-ports'] = ports_data @@ -150,8 +150,7 @@ def filter_ports(ports, plugin, tenant_id, network_id, filter_opts): 'attachment': _filter_port_by_interface} # port details are need for filtering ports = [plugin.get_port_details(tenant_id, network_id, - port['port-id']) - for port in ports] + port['port-id']) for port in ports] # filter ports return _do_filtering(ports, filters, diff --git a/quantum/api/views/networks.py b/quantum/api/views/networks.py index 40b0b35bde..fecf467f81 100644 --- a/quantum/api/views/networks.py +++ b/quantum/api/views/networks.py @@ -54,7 +54,7 @@ class ViewBuilder10(object): def _build_detail(self, network_data): """Return a detailed model of a network.""" return dict(network=dict(id=network_data['net-id'], - name=network_data['net-name'])) + name=network_data['net-name'])) def _build_port(self, port_data): """Return details about a specific logical port.""" @@ -82,7 +82,7 @@ class ViewBuilder11(ViewBuilder10): def _build_port(self, port_data): """Return details about a specific logical port.""" op_status = port_data.get('port-op-status', - OperationalStatus.UNKNOWN) + OperationalStatus.UNKNOWN) port_dict = {'id': port_data['port-id'], 'state': port_data['port-state'], 'op-status': op_status} diff --git a/quantum/api/views/ports.py b/quantum/api/views/ports.py index 919e9f5c49..0b210778fa 100644 --- a/quantum/api/views/ports.py +++ b/quantum/api/views/ports.py @@ -53,7 +53,8 @@ class ViewBuilder11(ViewBuilder10): if port_details: port['port']['state'] = port_data['port-state'] port['port']['op-status'] = port_data.get('port-op-status', - OperationalStatus.UNKNOWN) + OperationalStatus. + UNKNOWN) if att_details and port_data['attachment']: port['port']['attachment'] = dict(id=port_data['attachment']) return port diff --git a/quantum/common/config.py b/quantum/common/config.py index 6fda8eb936..f426b4594a 100644 --- a/quantum/common/config.py +++ b/quantum/common/config.py @@ -106,18 +106,18 @@ def add_log_options(parser): "the Python logging module documentation for " "details on logging configuration files.") group.add_option('--log-date-format', metavar="FORMAT", - default=DEFAULT_LOG_DATE_FORMAT, - help="Format string for %(asctime)s in log records. " - "Default: %default") + default=DEFAULT_LOG_DATE_FORMAT, + help="Format string for %(asctime)s in log records. " + "Default: %default") group.add_option('--use-syslog', default=False, - action="store_true", - help="Output logs to syslog.") + action="store_true", + help="Output logs to syslog.") group.add_option('--log-file', default=None, metavar="PATH", - help="(Optional) Name of log file to output to. " - "If not set, logging will go to stdout.") + help="(Optional) Name of log file to output to. " + "If not set, logging will go to stdout.") group.add_option("--log-dir", default=None, - help="(Optional) The directory to keep log files in " - "(will be prepended to --logfile)") + help="(Optional) The directory to keep log files in " + "(will be prepended to --logfile)") parser.add_option_group(group) @@ -237,10 +237,9 @@ def find_config_file(options, args, config_file='quantum.conf'): '/etc'] if 'plugin' in options: - config_file_dirs = [ - os.path.join(x, 'quantum', 'plugins', options['plugin']) - for x in config_file_dirs - ] + config_file_dirs = [os.path.join(x, 'quantum', + 'plugins', options['plugin']) + for x in config_file_dirs] if os.path.exists(os.path.join(root, 'plugins')): plugins = [fix_path(os.path.join(root, 'plugins', p, 'etc')) @@ -282,7 +281,7 @@ def load_paste_config(app_name, options, args): conf_file = find_config_file(options, args) if not conf_file: raise RuntimeError("Unable to locate any configuration file. " - "Cannot load application %s" % app_name) + "Cannot load application %s" % app_name) try: conf = deploy.appconfig("config:%s" % conf_file, name=app_name) return conf_file, conf diff --git a/quantum/common/test_lib.py b/quantum/common/test_lib.py index 8e8fc67f4a..cbad6e80e7 100644 --- a/quantum/common/test_lib.py +++ b/quantum/common/test_lib.py @@ -99,9 +99,9 @@ class _Win32Colorizer(object): See _AnsiColorizer docstring. """ def __init__(self, stream): - from win32console import GetStdHandle, STD_OUT_HANDLE, \ - FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \ - FOREGROUND_INTENSITY + from win32console import GetStdHandle, STD_OUT_HANDLE + from win32console import FOREGROUND_RED, FOREGROUND_BLUE + from win32console import FOREGROUND_GREEN, FOREGROUND_INTENSITY red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN, FOREGROUND_BLUE, FOREGROUND_INTENSITY) self.stream = stream @@ -251,9 +251,9 @@ class QuantumTestResult(result.TextTestResult): class QuantumTestRunner(core.TextTestRunner): def _makeResult(self): return QuantumTestResult(self.stream, - self.descriptions, - self.verbosity, - self.config) + self.descriptions, + self.verbosity, + self.config) def run_tests(c=None): @@ -273,8 +273,8 @@ def run_tests(c=None): return True runner = QuantumTestRunner(stream=c.stream, - verbosity=c.verbosity, - config=c) + verbosity=c.verbosity, + config=c) return not core.run(config=c, testRunner=runner) # describes parameters used by different unit/functional tests diff --git a/quantum/common/utils.py b/quantum/common/utils.py index 931a82c41b..7df4bbcfc7 100644 --- a/quantum/common/utils.py +++ b/quantum/common/utils.py @@ -91,7 +91,8 @@ def execute(cmd, process_input=None, addl_env=None, check_exit_code=True): if addl_env: env.update(addl_env) 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 if process_input is not None: result = obj.communicate(process_input) diff --git a/quantum/context.py b/quantum/context.py index b284d349e4..7e9d4a341b 100644 --- a/quantum/context.py +++ b/quantum/context.py @@ -42,8 +42,8 @@ class Context(object): *only* deleted records are visible. """ if kwargs: - LOG.warn(_('Arguments dropped when creating context: %s') % - str(kwargs)) + LOG.warn(_('Arguments dropped when creating ' + 'context: %s') % str(kwargs)) self.user_id = user_id self.tenant_id = tenant_id diff --git a/quantum/db/db_base_plugin_v2.py b/quantum/db/db_base_plugin_v2.py index 4825724aba..94c767814d 100644 --- a/quantum/db/db_base_plugin_v2.py +++ b/quantum/db/db_base_plugin_v2.py @@ -137,7 +137,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2): 'admin_state_up': network['admin_state_up'], 'status': network['status'], 'subnets': [subnet['id'] - for subnet in network['subnets']]} + for subnet in network['subnets']]} return self._fields(res, fields) diff --git a/quantum/db/models.py b/quantum/db/models.py index 4fe9b28493..177cba3cf0 100644 --- a/quantum/db/models.py +++ b/quantum/db/models.py @@ -73,5 +73,5 @@ class Network(model_base.BASE): self.op_status = op_status def __repr__(self): - return "" % \ - (self.uuid, self.name, self.op_status, self.tenant_id) + return "" % (self.uuid, self.name, + self.op_status, self.tenant_id) diff --git a/quantum/db/models_v2.py b/quantum/db/models_v2.py index f03a784567..96b5413d2c 100644 --- a/quantum/db/models_v2.py +++ b/quantum/db/models_v2.py @@ -32,14 +32,14 @@ class IPAllocation(model_base.BASEV2): port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id')) address = sa.Column(sa.String(16), nullable=False, primary_key=True) subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id'), - primary_key=True) + primary_key=True) allocated = sa.Column(sa.Boolean(), nullable=False) class Port(model_base.BASEV2, HasTenant): """Represents a port on a quantum v2 network""" network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"), - nullable=False) + nullable=False) fixed_ips = orm.relationship(IPAllocation, backref='ports') mac_address = sa.Column(sa.String(32), nullable=False) admin_state_up = sa.Column(sa.Boolean(), nullable=False) diff --git a/quantum/extensions/_pprofiles.py b/quantum/extensions/_pprofiles.py index 3be2e24334..6b47c46195 100644 --- a/quantum/extensions/_pprofiles.py +++ b/quantum/extensions/_pprofiles.py @@ -50,14 +50,12 @@ class ViewBuilder(object): """Return a detailed info of a portprofile.""" if (portprofile_data['assignment'] is None): return dict(portprofile=dict( - id=portprofile_data['profile_id'], - name=portprofile_data['profile_name'], - qos_name=portprofile_data['qos_name'], - )) + id=portprofile_data['profile_id'], + name=portprofile_data['profile_name'], + qos_name=portprofile_data['qos_name'])) else: return dict(portprofile=dict( - id=portprofile_data['profile_id'], - name=portprofile_data['profile_name'], - qos_name=portprofile_data['qos_name'], - assignment=portprofile_data['assignment'], - )) + id=portprofile_data['profile_id'], + name=portprofile_data['profile_name'], + qos_name=portprofile_data['qos_name'], + assignment=portprofile_data['assignment'])) diff --git a/quantum/extensions/credential.py b/quantum/extensions/credential.py index 4816d30d8f..45e9ddcd3f 100644 --- a/quantum/extensions/credential.py +++ b/quantum/extensions/credential.py @@ -80,7 +80,7 @@ class CredentialController(common.QuantumController, wsgi.Controller): {'param-name': 'credential_name', 'required': True}, {'param-name': 'user_name', 'required': True}, {'param-name': 'password', 'required': True}, - ] + ] _serialization_metadata = { "application/xml": { diff --git a/quantum/extensions/extensions.py b/quantum/extensions/extensions.py index 83090d4192..26aebc246e 100644 --- a/quantum/extensions/extensions.py +++ b/quantum/extensions/extensions.py @@ -228,7 +228,7 @@ class ExtensionMiddleware(wsgi.Middleware): # extended resources for resource in self.ext_mgr.get_resources(): LOG.debug(_('Extended resource: %s'), - resource.collection) + resource.collection) for action, method in resource.collection_actions.iteritems(): path_prefix = "" parent = resource.parent @@ -459,8 +459,8 @@ class ExtensionManager(object): LOG.warn(_('Loaded extension: %s'), alias) if alias in self.extensions: - raise exceptions.Error("Found duplicate extension: %s" - % alias) + raise exceptions.Error("Found duplicate extension: %s" % + alias) self.extensions[alias] = ext @@ -474,7 +474,7 @@ class PluginAwareExtensionManager(ExtensionManager): """Checks if plugin supports extension and implements the extension contract.""" extension_is_valid = super(PluginAwareExtensionManager, - self)._check_extension(extension) + self)._check_extension(extension) return (extension_is_valid and self._plugin_supports(extension) and self._plugin_implements_interface(extension)) diff --git a/quantum/extensions/multiport.py b/quantum/extensions/multiport.py index 6cffc04f56..3be8854626 100644 --- a/quantum/extensions/multiport.py +++ b/quantum/extensions/multiport.py @@ -79,7 +79,7 @@ class MultiportController(common.QuantumController, wsgi.Controller): {'param-name': 'net_id_list', 'required': True}, {'param-name': 'status', 'required': True}, {'param-name': 'ports_desc', 'required': True}, - ] + ] _serialization_metadata = { "application/xml": { diff --git a/quantum/extensions/novatenant.py b/quantum/extensions/novatenant.py index 84ad52c58f..17a1593dae 100644 --- a/quantum/extensions/novatenant.py +++ b/quantum/extensions/novatenant.py @@ -77,12 +77,12 @@ class NovatenantsController(common.QuantumController, wsgi.Controller): _Novatenant_ops_param_list = [ {'param-name': 'novatenant_name', 'required': True}, - ] + ] _schedule_host_ops_param_list = [ {'param-name': 'instance_id', 'required': True}, {'param-name': 'instance_desc', 'required': True}, - ] + ] _serialization_metadata = { "application/xml": { diff --git a/quantum/extensions/portprofile.py b/quantum/extensions/portprofile.py index 05ea91fb2a..67a4268d8c 100644 --- a/quantum/extensions/portprofile.py +++ b/quantum/extensions/portprofile.py @@ -80,26 +80,28 @@ class PortprofilesController(common.QuantumController, wsgi.Controller): self._plugin = plugin self._portprofile_ops_param_list = [{ - 'param-name': 'portprofile_name', - 'required': True}, { - 'param-name': 'qos_name', - 'required': True}, { - 'param-name': 'assignment', - 'required': False}] + 'param-name': 'portprofile_name', + 'required': True}, { + 'param-name': 'qos_name', + 'required': True}, { + 'param-name': 'assignment', + 'required': False} + ] self._assignprofile_ops_param_list = [{ - 'param-name': 'network-id', - 'required': True}, { - 'param-name': 'port-id', - 'required': True}] + 'param-name': 'network-id', + 'required': True}, { + 'param-name': 'port-id', + 'required': True} + ] self._serialization_metadata = { - "application/xml": { - "attributes": { - "portprofile": ["id", "name"], + "application/xml": { + "attributes": { + "portprofile": ["id", "name"], + }, }, - }, - } + } def index(self, request, tenant_id): """ Returns a list of portprofile ids """ @@ -117,8 +119,7 @@ class PortprofilesController(common.QuantumController, wsgi.Controller): def show(self, request, tenant_id, id): """ Returns portprofile details for the given portprofile id """ try: - portprofile = self._plugin.get_portprofile_details( - tenant_id, id) + portprofile = self._plugin.get_portprofile_details(tenant_id, id) builder = pprofiles_view.get_view_builder(request) #build response with details result = builder.build(portprofile, True) @@ -137,10 +138,10 @@ class PortprofilesController(common.QuantumController, wsgi.Controller): req_params = req_body[self._resource_name] except exc.HTTPError as exp: return faults.Fault(exp) - portprofile = self._plugin.\ - create_portprofile(tenant_id, - req_params['portprofile_name'], - req_params['qos_name']) + portprofile = \ + self._plugin.create_portprofile(tenant_id, + req_params['portprofile_name'], + req_params['qos_name']) builder = pprofiles_view.get_view_builder(request) result = builder.build(portprofile) return dict(portprofiles=result) @@ -156,9 +157,9 @@ class PortprofilesController(common.QuantumController, wsgi.Controller): except exc.HTTPError as exp: return faults.Fault(exp) try: - portprofile = self._plugin.\ - rename_portprofile(tenant_id, - id, req_params['portprofile_name']) + portprofile = \ + self._plugin.rename_portprofile(tenant_id, id, + req_params['portprofile_name']) builder = pprofiles_view.get_view_builder(request) result = builder.build(portprofile, True) @@ -190,8 +191,8 @@ class PortprofilesController(common.QuantumController, wsgi.Controller): port_id = req_params['port-id'].strip() try: self._plugin.associate_portprofile(tenant_id, - net_id, port_id, - id) + net_id, port_id, + id) return exc.HTTPOk() except exception.PortProfileNotFound as exp: return faults.Fault(faults.PortprofileNotFound(exp)) @@ -212,9 +213,8 @@ class PortprofilesController(common.QuantumController, wsgi.Controller): net_id = req_params['network-id'].strip() port_id = req_params['port-id'].strip() try: - self._plugin. \ - disassociate_portprofile(tenant_id, - net_id, port_id, id) + self._plugin.disassociate_portprofile(tenant_id, + net_id, port_id, id) return exc.HTTPOk() except exception.PortProfileNotFound as exp: return faults.Fault(faults.PortprofileNotFound(exp)) diff --git a/quantum/extensions/portstats.py b/quantum/extensions/portstats.py index 164687542d..ff87b29531 100644 --- a/quantum/extensions/portstats.py +++ b/quantum/extensions/portstats.py @@ -69,10 +69,10 @@ class StatsController(wsgi.Controller): "application/xml": { "attributes": { "stats": ["rx_bytes", "rx_packets", "rx_errors", - "tx_bytes", "tx_packets", "tx_errors"], - }, - }, + "tx_bytes", "tx_packets", "tx_errors"] + } } + } def __init__(self, plugin): self._resource_name = 'stats' diff --git a/quantum/extensions/qos.py b/quantum/extensions/qos.py index 79606c9496..c596f1ffb3 100644 --- a/quantum/extensions/qos.py +++ b/quantum/extensions/qos.py @@ -80,7 +80,7 @@ class QosController(common.QuantumController, wsgi.Controller): _qos_ops_param_list = [ {'param-name': 'qos_name', 'required': True}, {'param-name': 'qos_desc', 'required': True}, - ] + ] _serialization_metadata = { "application/xml": { diff --git a/quantum/openstack/common/cfg.py b/quantum/openstack/common/cfg.py index 2276475a24..80345a6d2a 100644 --- a/quantum/openstack/common/cfg.py +++ b/quantum/openstack/common/cfg.py @@ -375,7 +375,7 @@ def _get_config_dirs(project=None): fix_path('~'), os.path.join('/etc', project) if project else None, '/etc' - ] + ] return filter(bool, cfg_dirs) @@ -575,11 +575,9 @@ class Opt(object): dest = self.dest if group is not None: dest = group.name + '_' + dest - kwargs.update({ - 'dest': dest, - 'metavar': self.metavar, - 'help': self.help, - }) + kwargs.update({'dest': dest, + 'metavar': self.metavar, + 'help': self.help}) return kwargs def _get_optparse_prefix(self, prefix, group): @@ -892,14 +890,14 @@ class ConfigOpts(collections.Mapping): self.__cache = {} opts = [ - MultiStrOpt('config-file', - default=self.default_config_files, - metavar='PATH', - help='Path to a config file to use. Multiple config ' - 'files can be specified, with values in later ' - 'files taking precedence. The default files ' - ' used are: %s' % - (self.default_config_files, )), + MultiStrOpt('config-file', + default=self.default_config_files, + metavar='PATH', + help='Path to a config file to use. Multiple config ' + 'files can be specified, with values in later ' + 'files taking precedence. The default files ' + ' used are: %s' % + (self.default_config_files)), StrOpt('config-dir', metavar='DIR', help='Path to a config directory to pull *.conf ' @@ -909,7 +907,7 @@ class ConfigOpts(collections.Mapping): 'the file(s), if any, specified via --config-file, ' 'hence over-ridden options in the directory take ' 'precedence.'), - ] + ] self.register_cli_opts(opts) def __clear_cache(f): @@ -1352,8 +1350,7 @@ class ConfigOpts(collections.Mapping): default, opt, override = [info[k] for k in sorted(info.keys())] if opt.required: - if (default is not None or - override is not None): + if (default is not None or override is not None): continue if self._get(opt.name, group) is None: @@ -1447,7 +1444,7 @@ class CommonConfigOpts(ConfigOpts): short='v', default=False, help='Print more verbose output'), - ] + ] logging_cli_opts = [ StrOpt('log-config', @@ -1481,7 +1478,7 @@ class CommonConfigOpts(ConfigOpts): StrOpt('syslog-log-facility', default='LOG_USER', help='syslog facility to receive log lines') - ] + ] def __init__(self, **kwargs): super(CommonConfigOpts, self).__init__(**kwargs) diff --git a/quantum/openstack/common/importutils.py b/quantum/openstack/common/importutils.py index 7654af5b95..ce92ff7af9 100644 --- a/quantum/openstack/common/importutils.py +++ b/quantum/openstack/common/importutils.py @@ -30,7 +30,7 @@ def import_class(import_str): return getattr(sys.modules[mod_str], class_str) except (ImportError, ValueError, AttributeError), exc: raise ImportError('Class %s cannot be found (%s)' % - (class_str, str(exc))) + (class_str, str(exc))) def import_object(import_str, *args, **kwargs): diff --git a/quantum/plugins/cisco/client/cli.py b/quantum/plugins/cisco/client/cli.py index 7fe2b8adb3..9a455624c5 100644 --- a/quantum/plugins/cisco/client/cli.py +++ b/quantum/plugins/cisco/client/cli.py @@ -99,9 +99,9 @@ def schedule_host(tenant_id, instance_id, user_id=None): 'instance_desc': { 'user_id': user_id, 'project_id': project_id, - }, }, - } + }, + } request_url = "/novatenants/" + project_id + "/schedule_host" client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID, @@ -138,16 +138,16 @@ COMMANDS = { "func": create_multiport, "args": ["tenant-id", "net-id-list (comma separated list of netword IDs)"], - }, + }, "list_extensions": { "func": list_extensions, "args": [], - }, + }, "schedule_host": { "func": schedule_host, "args": ["tenant-id", "instance-id"], - }, - } + }, +} def main(): diff --git a/quantum/plugins/cisco/common/cisco_exceptions.py b/quantum/plugins/cisco/common/cisco_exceptions.py index f5a717274b..149da5d361 100644 --- a/quantum/plugins/cisco/common/cisco_exceptions.py +++ b/quantum/plugins/cisco/common/cisco_exceptions.py @@ -27,7 +27,7 @@ from quantum.common import exceptions class NoMoreNics(exceptions.QuantumException): """No more dynamic nics are available in the system""" message = _("Unable to complete operation. No more dynamic nics are " - "available in the system.") + "available in the system.") class PortProfileLimit(exceptions.QuantumException): @@ -83,7 +83,7 @@ class PortProfileAlreadyExists(exceptions.QuantumException): class PortProfileBindingAlreadyExists(exceptions.QuantumException): """Binding cannot be created, since it already exists""" message = _("PortProfileBinding for port profile %(pp_id)s to " - "port %(port_id) already exists") + "port %(port_id) already exists") class VlanIDNotFound(exceptions.QuantumException): diff --git a/quantum/plugins/cisco/common/cisco_faults.py b/quantum/plugins/cisco/common/cisco_faults.py index f5e9440810..4abe8a7418 100644 --- a/quantum/plugins/cisco/common/cisco_faults.py +++ b/quantum/plugins/cisco/common/cisco_faults.py @@ -25,16 +25,17 @@ class Fault(webob.exc.HTTPException): """Error codes for API faults""" _fault_names = { - 400: "malformedRequest", - 401: "unauthorized", - 421: "PortprofileInUse", - 450: "PortprofileNotFound", - 451: "CredentialNotFound", - 452: "QoSNotFound", - 453: "NovatenantNotFound", - 454: "MultiportNotFound", - 470: "serviceUnavailable", - 471: "pluginFault"} + 400: "malformedRequest", + 401: "unauthorized", + 421: "PortprofileInUse", + 450: "PortprofileNotFound", + 451: "CredentialNotFound", + 452: "QoSNotFound", + 453: "NovatenantNotFound", + 454: "MultiportNotFound", + 470: "serviceUnavailable", + 471: "pluginFault" + } def __init__(self, exception): """Create a Fault for the given webob.exc.exception.""" diff --git a/quantum/plugins/cisco/common/cisco_utils.py b/quantum/plugins/cisco/common/cisco_utils.py index 1a28be885b..816dc54112 100644 --- a/quantum/plugins/cisco/common/cisco_utils.py +++ b/quantum/plugins/cisco/common/cisco_utils.py @@ -49,8 +49,8 @@ def make_port_dict(port_id, port_state, net_id, attachment): return res -def make_portprofile_dict(tenant_id, profile_id, profile_name, - qos): +def make_portprofile_dict(tenant_id, profile_id, + profile_name, qos): """Helper funciton""" profile_associations = make_portprofile_assc_list(tenant_id, profile_id) diff --git a/quantum/plugins/cisco/db/api.py b/quantum/plugins/cisco/db/api.py index b4fc23f006..25e051bf9c 100644 --- a/quantum/plugins/cisco/db/api.py +++ b/quantum/plugins/cisco/db/api.py @@ -88,19 +88,19 @@ def network_create(tenant_id, name): def network_list(tenant_id): session = get_session() - return session.query(models.Network).\ - options(joinedload(models.Network.ports)). \ - filter_by(tenant_id=tenant_id).\ - all() + return (session.query(models.Network). + options(joinedload(models.Network.ports)). + filter_by(tenant_id=tenant_id). + all()) def network_id(net_name): session = get_session() try: - return session.query(models.Network).\ - options(joinedload(models.Network.ports)). \ - filter_by(name=net_name).\ - all() + return (session.query(models.Network). + options(joinedload(models.Network.ports)). + filter_by(name=net_name). + all()) except exc.NoResultFound, e: raise q_exc.NetworkNotFound(net_name=net_name) @@ -129,9 +129,9 @@ def network_update(net_id, tenant_id, **kwargs): def network_destroy(net_id): session = get_session() try: - net = session.query(models.Network).\ - filter_by(uuid=net_id).\ - one() + net = (session.query(models.Network). + filter_by(uuid=net_id). + one()) session.delete(net) session.flush() return net @@ -142,10 +142,10 @@ def network_destroy(net_id): def validate_network_ownership(tenant_id, net_id): session = get_session() try: - return session.query(models.Network).\ - filter_by(uuid=net_id).\ - filter_by(tenant_id=tenant_id).\ - one() + return (session.query(models.Network). + filter_by(uuid=net_id). + filter_by(tenant_id=tenant_id). + one()) except exc.NoResultFound, e: raise q_exc.NetworkNotFound(net_id=net_id) @@ -165,10 +165,10 @@ def port_create(net_id, state=None): def port_list(net_id): session = get_session() - return session.query(models.Port).\ - options(joinedload(models.Port.network)). \ - filter_by(network_id=net_id).\ - all() + return (session.query(models.Port). + options(joinedload(models.Port.network)). + filter_by(network_id=net_id). + all()) def port_get(net_id, port_id): @@ -176,10 +176,10 @@ def port_get(net_id, port_id): network_get(net_id) session = get_session() try: - return session.query(models.Port).\ - filter_by(uuid=port_id).\ - filter_by(network_id=net_id).\ - one() + return (session.query(models.Port). + filter_by(uuid=port_id). + filter_by(network_id=net_id). + one()) except exc.NoResultFound: raise q_exc.PortNotFound(net_id=net_id, port_id=port_id) @@ -211,16 +211,16 @@ def port_set_attachment(net_id, port_id, new_interface_id): # We are setting, not clearing, the attachment-id if port['interface_id']: raise q_exc.PortInUse(net_id=net_id, port_id=port_id, - att_id=port['interface_id']) + att_id=port['interface_id']) try: - port = session.query(models.Port).\ - filter_by(interface_id=new_interface_id).\ - one() + port = (session.query(models.Port). + filter_by(interface_id=new_interface_id). + one()) raise q_exc.AlreadyAttached(net_id=net_id, - port_id=port_id, - att_id=new_interface_id, - att_port_id=port['uuid']) + port_id=port_id, + att_id=new_interface_id, + att_port_id=port['uuid']) except exc.NoResultFound: # this is what should happen pass @@ -248,13 +248,13 @@ def port_destroy(net_id, port_id): session = get_session() try: - port = session.query(models.Port).\ - filter_by(uuid=port_id).\ - filter_by(network_id=net_id).\ - one() + port = (session.query(models.Port). + filter_by(uuid=port_id). + filter_by(network_id=net_id). + one()) if port['interface_id']: raise q_exc.PortInUse(net_id=net_id, port_id=port_id, - att_id=port['interface_id']) + att_id=port['interface_id']) session.delete(port) session.flush() return port @@ -266,8 +266,8 @@ def port_destroy(net_id, port_id): def port_get_by_id(port_id): session = get_session() try: - return session.query(models.Port).\ - filter_by(uuid=port_id).one() + return (session.query(models.Port). + filter_by(uuid=port_id).one()) except exc.NoResultFound: raise q_exc.PortNotFound(port_id=port_id) @@ -286,8 +286,8 @@ def port_set_attachment_by_id(port_id, new_interface_id): filter_by(interface_id=new_interface_id).\ one() raise q_exc.AlreadyAttached(port_id=port_id, - att_id=new_interface_id, - att_port_id=port['uuid']) + att_id=new_interface_id, + att_port_id=port['uuid']) except exc.NoResultFound: pass port.interface_id = new_interface_id diff --git a/quantum/plugins/cisco/db/l2network_db.py b/quantum/plugins/cisco/db/l2network_db.py index 5e7a85c8fe..5aba53272c 100644 --- a/quantum/plugins/cisco/db/l2network_db.py +++ b/quantum/plugins/cisco/db/l2network_db.py @@ -29,7 +29,7 @@ import quantum.plugins.cisco.db.api as db def initialize(): 'Establish database connection and load models' options = {"sql_connection": "mysql://%s:%s@%s/%s" % (conf.DB_USER, - conf.DB_PASS, conf.DB_HOST, conf.DB_NAME)} + conf.DB_PASS, conf.DB_HOST, conf.DB_NAME)} db.configure_db(options) @@ -38,8 +38,7 @@ def create_vlanids(): LOG.debug("create_vlanids() called") session = db.get_session() try: - vlanid = session.query(l2network_models.VlanID).\ - one() + vlanid = session.query(l2network_models.VlanID).one() except exc.MultipleResultsFound: pass except exc.NoResultFound: @@ -58,8 +57,7 @@ def get_all_vlanids(): LOG.debug("get_all_vlanids() called") session = db.get_session() try: - vlanids = session.query(l2network_models.VlanID).\ - all() + vlanids = session.query(l2network_models.VlanID).all() return vlanids except exc.NoResultFound: return [] @@ -70,9 +68,8 @@ def is_vlanid_used(vlan_id): LOG.debug("is_vlanid_used() called") session = db.get_session() try: - vlanid = session.query(l2network_models.VlanID).\ - filter_by(vlan_id=vlan_id).\ - one() + vlanid = (session.query(l2network_models.VlanID). + filter_by(vlan_id=vlan_id).one()) return vlanid["vlan_used"] except exc.NoResultFound: raise c_exc.VlanIDNotFound(vlan_id=vlan_id) @@ -83,9 +80,8 @@ def release_vlanid(vlan_id): LOG.debug("release_vlanid() called") session = db.get_session() try: - vlanid = session.query(l2network_models.VlanID).\ - filter_by(vlan_id=vlan_id).\ - one() + vlanid = (session.query(l2network_models.VlanID). + filter_by(vlan_id=vlan_id).one()) vlanid["vlan_used"] = False session.merge(vlanid) session.flush() @@ -100,9 +96,8 @@ def delete_vlanid(vlan_id): LOG.debug("delete_vlanid() called") session = db.get_session() try: - vlanid = session.query(l2network_models.VlanID).\ - filter_by(vlan_id=vlan_id).\ - one() + vlanid = (session.query(l2network_models.VlanID). + filter_by(vlan_id=vlan_id).one()) session.delete(vlanid) session.flush() return vlanid @@ -115,14 +110,12 @@ def reserve_vlanid(): LOG.debug("reserve_vlanid() called") session = db.get_session() try: - rvlan = session.query(l2network_models.VlanID).\ - filter_by(vlan_used=False).\ - first() + rvlan = (session.query(l2network_models.VlanID). + filter_by(vlan_used=False).first()) if not rvlan: raise exc.NoResultFound - rvlanid = session.query(l2network_models.VlanID).\ - filter_by(vlan_id=rvlan["vlan_id"]).\ - one() + rvlanid = (session.query(l2network_models.VlanID). + filter_by(vlan_id=rvlan["vlan_id"]).one()) rvlanid["vlan_used"] = True session.merge(rvlanid) session.flush() @@ -136,9 +129,8 @@ def get_all_vlanids_used(): LOG.debug("get_all_vlanids() called") session = db.get_session() try: - vlanids = session.query(l2network_models.VlanID).\ - filter_by(vlan_used=True).\ - all() + vlanids = (session.query(l2network_models.VlanID). + filter_by(vlan_used=True).all()) return vlanids except exc.NoResultFound: return [] @@ -149,8 +141,7 @@ def get_all_vlan_bindings(): LOG.debug("get_all_vlan_bindings() called") session = db.get_session() try: - bindings = session.query(l2network_models.VlanBinding).\ - all() + bindings = session.query(l2network_models.VlanBinding).all() return bindings except exc.NoResultFound: return [] @@ -161,9 +152,8 @@ def get_vlan_binding(netid): LOG.debug("get_vlan_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.VlanBinding).\ - filter_by(network_id=netid).\ - one() + binding = (session.query(l2network_models.VlanBinding). + filter_by(network_id=netid).one()) return binding except exc.NoResultFound: raise q_exc.NetworkNotFound(net_id=netid) @@ -174,9 +164,8 @@ def add_vlan_binding(vlanid, vlanname, netid): LOG.debug("add_vlan_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.VlanBinding).\ - filter_by(vlan_id=vlanid).\ - one() + binding = (session.query(l2network_models.VlanBinding). + filter_by(vlan_id=vlanid).one()) raise c_exc.NetworkVlanBindingAlreadyExists(vlan_id=vlanid, network_id=netid) except exc.NoResultFound: @@ -191,9 +180,8 @@ def remove_vlan_binding(netid): LOG.debug("remove_vlan_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.VlanBinding).\ - filter_by(network_id=netid).\ - one() + binding = (session.query(l2network_models.VlanBinding). + filter_by(network_id=netid).one()) session.delete(binding) session.flush() return binding @@ -206,9 +194,8 @@ def update_vlan_binding(netid, newvlanid=None, newvlanname=None): LOG.debug("update_vlan_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.VlanBinding).\ - filter_by(network_id=netid).\ - one() + binding = (session.query(l2network_models.VlanBinding). + filter_by(network_id=netid).one()) if newvlanid: binding["vlan_id"] = newvlanid if newvlanname: @@ -225,8 +212,7 @@ def get_all_portprofiles(): LOG.debug("get_all_portprofiles() called") session = db.get_session() try: - pps = session.query(l2network_models.PortProfile).\ - all() + pps = session.query(l2network_models.PortProfile).all() return pps except exc.NoResultFound: return [] @@ -237,13 +223,12 @@ def get_portprofile(tenantid, ppid): LOG.debug("get_portprofile() called") session = db.get_session() try: - pp = session.query(l2network_models.PortProfile).\ - filter_by(uuid=ppid).\ - one() + pp = (session.query(l2network_models.PortProfile). + filter_by(uuid=ppid).one()) return pp except exc.NoResultFound: raise c_exc.PortProfileNotFound(tenant_id=tenantid, - portprofile_id=ppid) + portprofile_id=ppid) def add_portprofile(tenantid, ppname, vlanid, qos): @@ -251,11 +236,10 @@ def add_portprofile(tenantid, ppname, vlanid, qos): LOG.debug("add_portprofile() called") session = db.get_session() try: - pp = session.query(l2network_models.PortProfile).\ - filter_by(name=ppname).\ - one() + pp = (session.query(l2network_models.PortProfile). + filter_by(name=ppname).one()) raise c_exc.PortProfileAlreadyExists(tenant_id=tenantid, - pp_name=ppname) + pp_name=ppname) except exc.NoResultFound: pp = l2network_models.PortProfile(ppname, vlanid, qos) session.add(pp) @@ -268,9 +252,8 @@ def remove_portprofile(tenantid, ppid): LOG.debug("remove_portprofile() called") session = db.get_session() try: - pp = session.query(l2network_models.PortProfile).\ - filter_by(uuid=ppid).\ - one() + pp = (session.query(l2network_models.PortProfile). + filter_by(uuid=ppid).one()) session.delete(pp) session.flush() return pp @@ -284,9 +267,8 @@ def update_portprofile(tenantid, ppid, newppname=None, newvlanid=None, LOG.debug("update_portprofile() called") session = db.get_session() try: - pp = session.query(l2network_models.PortProfile).\ - filter_by(uuid=ppid).\ - one() + pp = (session.query(l2network_models.PortProfile). + filter_by(uuid=ppid).one()) if newppname: pp["name"] = newppname if newvlanid: @@ -298,7 +280,7 @@ def update_portprofile(tenantid, ppid, newppname=None, newvlanid=None, return pp except exc.NoResultFound: raise c_exc.PortProfileNotFound(tenant_id=tenantid, - portprofile_id=ppid) + portprofile_id=ppid) def get_all_pp_bindings(): @@ -306,8 +288,7 @@ def get_all_pp_bindings(): LOG.debug("get_all_pp_bindings() called") session = db.get_session() try: - bindings = session.query(l2network_models.PortProfileBinding).\ - all() + bindings = session.query(l2network_models.PortProfileBinding).all() return bindings except exc.NoResultFound: return [] @@ -318,9 +299,8 @@ def get_pp_binding(tenantid, ppid): LOG.debug("get_pp_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.PortProfileBinding).\ - filter_by(portprofile_id=ppid).\ - one() + binding = (session.query(l2network_models.PortProfileBinding). + filter_by(portprofile_id=ppid).one()) return binding except exc.NoResultFound: return [] @@ -331,9 +311,8 @@ def add_pp_binding(tenantid, portid, ppid, default): LOG.debug("add_pp_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.PortProfileBinding).\ - filter_by(portprofile_id=ppid).\ - one() + binding = (session.query(l2network_models.PortProfileBinding). + filter_by(portprofile_id=ppid).one()) raise c_exc.PortProfileBindingAlreadyExists(pp_id=ppid, port_id=portid) except exc.NoResultFound: @@ -349,10 +328,9 @@ def remove_pp_binding(tenantid, portid, ppid): LOG.debug("remove_pp_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.PortProfileBinding).\ - filter_by(portprofile_id=ppid).\ - filter_by(port_id=portid).\ - one() + binding = (session.query(l2network_models.PortProfileBinding). + filter_by(portprofile_id=ppid).filter_by(port_id=portid). + one()) session.delete(binding) session.flush() return binding @@ -360,15 +338,14 @@ def remove_pp_binding(tenantid, portid, ppid): pass -def update_pp_binding(tenantid, ppid, newtenantid=None, newportid=None, - newdefault=None): +def update_pp_binding(tenantid, ppid, newtenantid=None, + newportid=None, newdefault=None): """Updates port profile binding""" LOG.debug("update_pp_binding() called") session = db.get_session() try: - binding = session.query(l2network_models.PortProfileBinding).\ - filter_by(portprofile_id=ppid).\ - one() + binding = (session.query(l2network_models.PortProfileBinding). + filter_by(portprofile_id=ppid).one()) if newtenantid: binding["tenant_id"] = newtenantid if newportid: @@ -380,7 +357,7 @@ def update_pp_binding(tenantid, ppid, newtenantid=None, newportid=None, return binding except exc.NoResultFound: raise c_exc.PortProfileNotFound(tenant_id=tenantid, - portprofile_id=ppid) + portprofile_id=ppid) def get_all_qoss(tenant_id): @@ -388,9 +365,8 @@ def get_all_qoss(tenant_id): LOG.debug("get_all_qoss() called") session = db.get_session() try: - qoss = session.query(l2network_models.QoS).\ - filter_by(tenant_id=tenant_id).\ - all() + qoss = (session.query(l2network_models.QoS). + filter_by(tenant_id=tenant_id).all()) return qoss except exc.NoResultFound: return [] @@ -401,10 +377,9 @@ def get_qos(tenant_id, qos_id): LOG.debug("get_qos() called") session = db.get_session() try: - qos = session.query(l2network_models.QoS).\ - filter_by(tenant_id=tenant_id).\ - filter_by(qos_id=qos_id).\ - one() + qos = (session.query(l2network_models.QoS). + filter_by(tenant_id=tenant_id). + filter_by(qos_id=qos_id).one()) return qos except exc.NoResultFound: raise c_exc.QosNotFound(qos_id=qos_id, @@ -416,12 +391,11 @@ def add_qos(tenant_id, qos_name, qos_desc): LOG.debug("add_qos() called") session = db.get_session() try: - qos = session.query(l2network_models.QoS).\ - filter_by(tenant_id=tenant_id).\ - filter_by(qos_name=qos_name).\ - one() + qos = (session.query(l2network_models.QoS). + filter_by(tenant_id=tenant_id). + filter_by(qos_name=qos_name).one()) raise c_exc.QosNameAlreadyExists(qos_name=qos_name, - tenant_id=tenant_id) + tenant_id=tenant_id) except exc.NoResultFound: qos = l2network_models.QoS(tenant_id, qos_name, qos_desc) session.add(qos) @@ -433,10 +407,9 @@ def remove_qos(tenant_id, qos_id): """Removes a qos to tenant association""" session = db.get_session() try: - qos = session.query(l2network_models.QoS).\ - filter_by(tenant_id=tenant_id).\ - filter_by(qos_id=qos_id).\ - one() + qos = (session.query(l2network_models.QoS). + filter_by(tenant_id=tenant_id). + filter_by(qos_id=qos_id).one()) session.delete(qos) session.flush() return qos @@ -448,10 +421,9 @@ def update_qos(tenant_id, qos_id, new_qos_name=None): """Updates a qos to tenant association""" session = db.get_session() try: - qos = session.query(l2network_models.QoS).\ - filter_by(tenant_id=tenant_id).\ - filter_by(qos_id=qos_id).\ - one() + qos = (session.query(l2network_models.QoS). + filter_by(tenant_id=tenant_id). + filter_by(qos_id=qos_id).one()) if new_qos_name: qos["qos_name"] = new_qos_name session.merge(qos) @@ -466,9 +438,8 @@ def get_all_credentials(tenant_id): """Lists all the creds for a tenant""" session = db.get_session() try: - creds = session.query(l2network_models.Credential).\ - filter_by(tenant_id=tenant_id).\ - all() + creds = (session.query(l2network_models.Credential). + filter_by(tenant_id=tenant_id).all()) return creds except exc.NoResultFound: return [] @@ -478,43 +449,40 @@ def get_credential(tenant_id, credential_id): """Lists the creds for given a cred_id and tenant_id""" session = db.get_session() try: - cred = session.query(l2network_models.Credential).\ - filter_by(tenant_id=tenant_id).\ - filter_by(credential_id=credential_id).\ - one() + cred = (session.query(l2network_models.Credential). + filter_by(tenant_id=tenant_id). + filter_by(credential_id=credential_id).one()) return cred except exc.NoResultFound: raise c_exc.CredentialNotFound(credential_id=credential_id, - tenant_id=tenant_id) + tenant_id=tenant_id) def get_credential_name(tenant_id, credential_name): """Lists the creds for given a cred_name and tenant_id""" session = db.get_session() try: - cred = session.query(l2network_models.Credential).\ - filter_by(tenant_id=tenant_id).\ - filter_by(credential_name=credential_name).\ - one() + cred = (session.query(l2network_models.Credential). + filter_by(tenant_id=tenant_id). + filter_by(credential_name=credential_name).one()) return cred except exc.NoResultFound: raise c_exc.CredentialNameNotFound(credential_name=credential_name, - tenant_id=tenant_id) + tenant_id=tenant_id) def add_credential(tenant_id, credential_name, user_name, password): """Adds a qos to tenant association""" session = db.get_session() try: - cred = session.query(l2network_models.Credential).\ - filter_by(tenant_id=tenant_id).\ - filter_by(credential_name=credential_name).\ - one() + cred = (session.query(l2network_models.Credential). + filter_by(tenant_id=tenant_id). + filter_by(credential_name=credential_name).one()) raise c_exc.CredentialAlreadyExists(credential_name=credential_name, tenant_id=tenant_id) except exc.NoResultFound: - cred = l2network_models.Credential(tenant_id, - credential_name, user_name, password) + cred = l2network_models.Credential(tenant_id, credential_name, + user_name, password) session.add(cred) session.flush() return cred @@ -524,10 +492,9 @@ def remove_credential(tenant_id, credential_id): """Removes a credential from a tenant""" session = db.get_session() try: - cred = session.query(l2network_models.Credential).\ - filter_by(tenant_id=tenant_id).\ - filter_by(credential_id=credential_id).\ - one() + cred = (session.query(l2network_models.Credential). + filter_by(tenant_id=tenant_id). + filter_by(credential_id=credential_id).one()) session.delete(cred) session.flush() return cred @@ -540,10 +507,9 @@ def update_credential(tenant_id, credential_id, """Updates a credential for a tenant""" session = db.get_session() try: - cred = session.query(l2network_models.Credential).\ - filter_by(tenant_id=tenant_id).\ - filter_by(credential_id=credential_id).\ - one() + cred = (session.query(l2network_models.Credential). + filter_by(tenant_id=tenant_id). + filter_by(credential_id=credential_id).one()) if new_user_name: cred["user_name"] = new_user_name if new_password: @@ -553,4 +519,4 @@ def update_credential(tenant_id, credential_id, return cred except exc.NoResultFound: raise c_exc.CredentialNotFound(credential_id=credential_id, - tenant_id=tenant_id) + tenant_id=tenant_id) diff --git a/quantum/plugins/cisco/db/l2network_models.py b/quantum/plugins/cisco/db/l2network_models.py index c8a5a1e4c2..c011c1acc2 100644 --- a/quantum/plugins/cisco/db/l2network_models.py +++ b/quantum/plugins/cisco/db/l2network_models.py @@ -60,7 +60,7 @@ class L2NetworkBase(object): Includes attributes from joins.""" local = dict(self) joined = dict([(k, v) for k, v in self.__dict__.iteritems() - if not k[0] == '_']) + if not k[0] == '_']) local.update(joined) return local.iteritems() @@ -77,8 +77,7 @@ class VlanID(BASE, L2NetworkBase): self.vlan_used = False def __repr__(self): - return "" % \ - (self.vlan_id, self.vlan_used) + return "" % (self.vlan_id, self.vlan_used) class VlanBinding(BASE, L2NetworkBase): @@ -96,8 +95,9 @@ class VlanBinding(BASE, L2NetworkBase): self.network_id = network_id def __repr__(self): - return "" % \ - (self.vlan_id, self.vlan_name, self.network_id) + return "" % (self.vlan_id, + self.vlan_name, + self.network_id) class PortProfile(BASE, L2NetworkBase): @@ -116,8 +116,10 @@ class PortProfile(BASE, L2NetworkBase): self.qos = qos def __repr__(self): - return "" % \ - (self.uuid, self.name, self.vlan_id, self.qos) + return "" % (self.uuid, + self.name, + self.vlan_id, + self.qos) class PortProfileBinding(BASE, L2NetworkBase): @@ -127,8 +129,7 @@ class PortProfileBinding(BASE, L2NetworkBase): id = Column(Integer, primary_key=True, autoincrement=True) tenant_id = Column(String(255)) - port_id = Column(String(255), ForeignKey("ports.uuid"), - nullable=False) + port_id = Column(String(255), ForeignKey("ports.uuid"), nullable=False) portprofile_id = Column(String(255), ForeignKey("portprofiles.uuid"), nullable=False) default = Column(Boolean) @@ -142,8 +143,10 @@ class PortProfileBinding(BASE, L2NetworkBase): self.default = default def __repr__(self): - return "" % \ - (self.tenant_id, self.port_id, self.portprofile_id, self.default) + return "" % (self.tenant_id, + self.port_id, + self.portprofile_id, + self.default) class QoS(BASE, L2NetworkBase): @@ -162,8 +165,8 @@ class QoS(BASE, L2NetworkBase): self.qos_desc = qos_desc def __repr__(self): - return "" % \ - (self.qos_id, self.tenant_id, self.qos_name, self.qos_desc) + return "" % (self.qos_id, self.tenant_id, + self.qos_name, self.qos_desc) class Credential(BASE, L2NetworkBase): @@ -184,6 +187,8 @@ class Credential(BASE, L2NetworkBase): self.password = password def __repr__(self): - return "" % \ - (self.credential_id, self.tenant_id, self.credential_name, - self.user_name, self.password) + return "" % (self.credential_id, + self.tenant_id, + self.credential_name, + self.user_name, + self.password) diff --git a/quantum/plugins/cisco/db/models.py b/quantum/plugins/cisco/db/models.py index 81ac773a68..1dca18d81a 100644 --- a/quantum/plugins/cisco/db/models.py +++ b/quantum/plugins/cisco/db/models.py @@ -57,7 +57,7 @@ class QuantumBase(object): Includes attributes from joins.""" local = dict(self) joined = dict([(k, v) for k, v in self.__dict__.iteritems() - if not k[0] == '_']) + if not k[0] == '_']) local.update(joined) return local.iteritems() @@ -80,7 +80,7 @@ class Port(BASE, QuantumBase): def __repr__(self): return "" % (self.uuid, self.network_id, - self.state, self.interface_id) + self.state, self.interface_id) class Network(BASE, QuantumBase): @@ -98,5 +98,4 @@ class Network(BASE, QuantumBase): self.name = name def __repr__(self): - return "" % \ - (self.uuid, self.name, self.tenant_id) + return "" % (self.uuid, self.name, self.tenant_id) diff --git a/quantum/plugins/cisco/db/nexus_db.py b/quantum/plugins/cisco/db/nexus_db.py index f2410990cc..0bba4a95f7 100644 --- a/quantum/plugins/cisco/db/nexus_db.py +++ b/quantum/plugins/cisco/db/nexus_db.py @@ -30,8 +30,7 @@ def get_all_nexusport_bindings(): LOG.debug("get_all_nexusport_bindings() called") session = db.get_session() try: - bindings = session.query(nexus_models.NexusPortBinding).\ - all() + bindings = session.query(nexus_models.NexusPortBinding).all() return bindings except exc.NoResultFound: return [] @@ -42,9 +41,8 @@ def get_nexusport_binding(vlan_id): LOG.debug("get_nexusport_binding() called") session = db.get_session() try: - binding = session.query(nexus_models.NexusPortBinding).\ - filter_by(vlan_id=vlan_id).\ - all() + binding = (session.query(nexus_models.NexusPortBinding). + filter_by(vlan_id=vlan_id).all()) return binding except exc.NoResultFound: raise c_exc.NexusPortBindingNotFound(vlan_id=vlan_id) @@ -65,9 +63,8 @@ def remove_nexusport_binding(vlan_id): LOG.debug("remove_nexusport_binding() called") session = db.get_session() try: - binding = session.query(nexus_models.NexusPortBinding).\ - filter_by(vlan_id=vlan_id).\ - all() + binding = (session.query(nexus_models.NexusPortBinding). + filter_by(vlan_id=vlan_id).all()) for bind in binding: session.delete(bind) session.flush() @@ -81,9 +78,8 @@ def update_nexusport_binding(port_id, new_vlan_id): LOG.debug("update_nexusport_binding called") session = db.get_session() try: - binding = session.query(nexus_models.NexusPortBinding).\ - filter_by(port_id=port_id).\ - one() + binding = (session.query(nexus_models.NexusPortBinding). + filter_by(port_id=port_id).one()) if new_vlan_id: binding["vlan_id"] = new_vlan_id session.merge(binding) diff --git a/quantum/plugins/cisco/db/nexus_models.py b/quantum/plugins/cisco/db/nexus_models.py index bd6c765ec9..876092398c 100644 --- a/quantum/plugins/cisco/db/nexus_models.py +++ b/quantum/plugins/cisco/db/nexus_models.py @@ -34,5 +34,4 @@ class NexusPortBinding(BASE, L2NetworkBase): self.vlan_id = vlan_id def __repr__(self): - return "" % \ - (self.port_id, self.vlan_id) + return "" % (self.port_id, self.vlan_id) diff --git a/quantum/plugins/cisco/db/services_db.py b/quantum/plugins/cisco/db/services_db.py index ca9eef6253..d38d817a3f 100644 --- a/quantum/plugins/cisco/db/services_db.py +++ b/quantum/plugins/cisco/db/services_db.py @@ -30,8 +30,7 @@ def get_all_services_bindings(): LOG.debug("get_all_services_bindings() called") session = db.get_session() try: - bindings = session.query(services_models.ServicesBinding).\ - all() + bindings = session.query(services_models.ServicesBinding).all() return bindings except exc.NoResultFound: return [] @@ -42,9 +41,8 @@ def get_service_bindings(service_id): LOG.debug("get_service_bindings() called") session = db.get_session() try: - bindings = session.query(services_models.ServicesBinding).\ - filter_by(service_id=service_id).\ - one() + bindings = (session.query(services_models.ServicesBinding). + filter_by(service_id=service_id).one()) return bindings except exc.NoResultFound: return [] @@ -66,9 +64,8 @@ def remove_services_binding(service_id): LOG.debug("remove_services_binding() called") session = db.get_session() try: - binding = session.query(services_models.ServicesBinding).\ - filter_by(service_id=service_id).\ - all() + binding = (session.query(services_models.ServicesBinding). + filter_by(service_id=service_id).all()) for bind in binding: session.delete(bind) session.flush() diff --git a/quantum/plugins/cisco/db/services_models.py b/quantum/plugins/cisco/db/services_models.py index 8a3b927b1a..c25c495eab 100644 --- a/quantum/plugins/cisco/db/services_models.py +++ b/quantum/plugins/cisco/db/services_models.py @@ -38,5 +38,5 @@ class ServicesBinding(BASE, L2NetworkBase): self.sbnet_id = sbnet_id def __repr__(self): - return "" % \ - (self.service_id, self.mngnet_id, self.nbnet_id, self.sbnet_id) + return "" % (self.service_id, self.mngnet_id, + self.nbnet_id, self.sbnet_id) diff --git a/quantum/plugins/cisco/db/ucs_db.py b/quantum/plugins/cisco/db/ucs_db.py index 039ee79684..a8e94a4f1e 100644 --- a/quantum/plugins/cisco/db/ucs_db.py +++ b/quantum/plugins/cisco/db/ucs_db.py @@ -30,8 +30,7 @@ def get_all_portbindings(): LOG.debug("db get_all_portbindings() called") session = db.get_session() try: - port_bindings = session.query(ucs_models.PortBinding).\ - all() + port_bindings = session.query(ucs_models.PortBinding).all() return port_bindings except exc.NoResultFound: return [] @@ -42,23 +41,21 @@ def get_portbinding(port_id): LOG.debug("get_portbinding() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(port_id=port_id).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(port_id=port_id).one()) return port_binding except exc.NoResultFound: raise c_exc.PortVnicNotFound(port_id=port_id) def add_portbinding(port_id, blade_intf_dn, portprofile_name, - vlan_name, vlan_id, qos): + vlan_name, vlan_id, qos): """Adds a port binding""" LOG.debug("add_portbinding() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(port_id=port_id).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(port_id=port_id).one()) raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id) except exc.NoResultFound: port_binding = ucs_models.PortBinding(port_id, blade_intf_dn, @@ -74,9 +71,8 @@ def remove_portbinding(port_id): LOG.debug("db remove_portbinding() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(port_id=port_id).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(port_id=port_id).one()) session.delete(port_binding) session.flush() return port_binding @@ -92,9 +88,8 @@ def update_portbinding(port_id, blade_intf_dn=None, portprofile_name=None, LOG.debug("db update_portbinding() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(port_id=port_id).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(port_id=port_id).one()) if blade_intf_dn: port_binding.blade_intf_dn = blade_intf_dn if portprofile_name: @@ -123,9 +118,8 @@ def update_portbinding_instance_id(port_id, instance_id): LOG.debug("db update_portbinding_instance_id() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(port_id=port_id).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(port_id=port_id).one()) port_binding.instance_id = instance_id session.merge(port_binding) session.flush() @@ -139,9 +133,8 @@ def update_portbinding_vif_id(port_id, vif_id): LOG.debug("db update_portbinding_vif_id() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(port_id=port_id).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(port_id=port_id).one()) port_binding.vif_id = vif_id session.merge(port_binding) session.flush() @@ -155,9 +148,8 @@ def get_portbinding_dn(blade_intf_dn): LOG.debug("get_portbinding_dn() called") session = db.get_session() try: - port_binding = session.query(ucs_models.PortBinding).\ - filter_by(blade_intf_dn=blade_intf_dn).\ - one() + port_binding = (session.query(ucs_models.PortBinding). + filter_by(blade_intf_dn=blade_intf_dn).one()) return port_binding except exc.NoResultFound: return [] diff --git a/quantum/plugins/cisco/db/ucs_models.py b/quantum/plugins/cisco/db/ucs_models.py index b799bb244f..e219e6caef 100644 --- a/quantum/plugins/cisco/db/ucs_models.py +++ b/quantum/plugins/cisco/db/ucs_models.py @@ -50,6 +50,6 @@ class PortBinding(BASE, L2NetworkBase): self.qos = qos def __repr__(self): - return "" % \ - (self.port_id, self.blade_intf_dn, self.portprofile_name, - self.vlan_name, self.vlan_id, self.qos) + return "" % ( + self.port_id, self.blade_intf_dn, self.portprofile_name, + self.vlan_name, self.vlan_id, self.qos) diff --git a/quantum/plugins/cisco/l2network_plugin.py b/quantum/plugins/cisco/l2network_plugin.py index 1edecab810..b6eac458ca 100644 --- a/quantum/plugins/cisco/l2network_plugin.py +++ b/quantum/plugins/cisco/l2network_plugin.py @@ -391,7 +391,7 @@ class L2Network(QuantumPluginBase): portprofile = cdb.get_portprofile(tenant_id, portprofile_id) except Exception: raise cexc.PortProfileNotFound(tenant_id=tenant_id, - portprofile_id=portprofile_id) + portprofile_id=portprofile_id) cdb.remove_pp_binding(tenant_id, port_id, portprofile_id) diff --git a/quantum/plugins/cisco/models/l2network_single_blade.py b/quantum/plugins/cisco/models/l2network_single_blade.py index 304f411ed4..7bbc82ef88 100644 --- a/quantum/plugins/cisco/models/l2network_single_blade.py +++ b/quantum/plugins/cisco/models/l2network_single_blade.py @@ -89,8 +89,8 @@ class L2NetworkSingleBlade(L2NetworkModelBase): if args and isinstance(args[-1], dict): kwargs.update(args.pop()) - return getattr(self._plugins[plugin_key], function_name)(*args, - **kwargs) + return getattr(self._plugins[plugin_key], + function_name)(*args, **kwargs) def get_all_networks(self, args): """Not implemented for this model""" diff --git a/quantum/plugins/cisco/nova/quantum_port_aware_scheduler.py b/quantum/plugins/cisco/nova/quantum_port_aware_scheduler.py index 351191c615..8d4bd42c2d 100644 --- a/quantum/plugins/cisco/nova/quantum_port_aware_scheduler.py +++ b/quantum/plugins/cisco/nova/quantum_port_aware_scheduler.py @@ -43,7 +43,7 @@ quantum_opts = [ cfg.StrOpt('quantum_default_tenant_id', default="default", help='Default tenant id when creating quantum networks'), - ] +] FLAGS = flags.FLAGS diff --git a/quantum/plugins/cisco/nova/vifdirect.py b/quantum/plugins/cisco/nova/vifdirect.py index 785a5cbd07..f3dec246a4 100644 --- a/quantum/plugins/cisco/nova/vifdirect.py +++ b/quantum/plugins/cisco/nova/vifdirect.py @@ -39,7 +39,7 @@ quantum_opts = [ cfg.StrOpt('quantum_default_tenant_id', default="default", help='Default tenant id when creating quantum networks'), - ] +] FLAGS = flags.FLAGS FLAGS.register_opts(quantum_opts) diff --git a/quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py b/quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py index 2e06fcab8a..5cb268b689 100644 --- a/quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py +++ b/quantum/plugins/cisco/segmentation/l2network_vlan_mgr.py @@ -23,7 +23,7 @@ from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.db import l2network_db as cdb from quantum.plugins.cisco.l2network_segmentation_base import ( L2NetworkSegmentationMgrBase, - ) +) LOG = logging.getLogger(__name__) diff --git a/quantum/plugins/cisco/services/service_insertion.py b/quantum/plugins/cisco/services/service_insertion.py index 1a1496a0e2..2c04e2916d 100644 --- a/quantum/plugins/cisco/services/service_insertion.py +++ b/quantum/plugins/cisco/services/service_insertion.py @@ -270,20 +270,20 @@ SERVICE_COMMANDS = { "func": insert_inpath_service, "args": ["tenant_id", "service_image_id", "management_net_name", "northbound_net_name", "southbound_net_name"], - }, + }, "delete_service": { "func": delete_service, "args": ["tenant_id", "service_instance_id"], - }, + }, "connect_vm": { "func": connect_vm, "args": ["tenant_id", "vm_image_id", "service_instance_id"], - }, + }, "disconnect_vm": { "func": disconnect_vm, "args": ["vm_instance_id"], - }, - } + }, +} if __name__ == "__main__": diff --git a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py index 38e1f0ce15..f0d92496f7 100644 --- a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py +++ b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py @@ -35,11 +35,11 @@ from quantum.extensions import ( novatenant, portprofile, qos, - ) +) from quantum.extensions.extensions import ( ExtensionMiddleware, PluginAwareExtensionManager, - ) +) from quantum.manager import QuantumManager from quantum.openstack.common import jsonutils from quantum.plugins.cisco.db import api as db @@ -93,8 +93,8 @@ class PortprofileExtensionTest(unittest.TestCase): 'portprofile': { 'portprofile_name': 'cisco_test_portprofile', 'qos_name': 'test-qos1', - }, - } + }, + } self.tenant_id = "test_tenant" self.network_name = "test_network" options = {} @@ -111,13 +111,14 @@ class PortprofileExtensionTest(unittest.TestCase): req_body1 = jsonutils.dumps(self.test_port_profile) create_response1 = self.test_app.post( self.profile_path, req_body1, - content_type=self.contenttype) + content_type=self.contenttype + ) req_body2 = jsonutils.dumps({ 'portprofile': { 'portprofile_name': 'cisco_test_portprofile2', 'qos_name': 'test-qos2', - }, - }) + }, + }) create_response2 = self.test_app.post( self.profile_path, req_body2, content_type=self.contenttype) @@ -236,8 +237,8 @@ class PortprofileExtensionTest(unittest.TestCase): 'portprofile': { 'portprofile_name': 'cisco_rename_portprofile', 'qos_name': 'test-qos1', - }, - } + }, + } rename_req_body = jsonutils.dumps(rename_port_profile) rename_path_temp = (self.portprofile_path + resp_body['portprofiles']['portprofile']['id']) @@ -289,8 +290,8 @@ class PortprofileExtensionTest(unittest.TestCase): 'portprofile': { 'portprofile_name': 'cisco_rename_portprofile', 'qos_name': 'test-qos1', - }, - } + }, + } rename_req_body = jsonutils.dumps(rename_port_profile) update_path_temp = self.portprofile_path + portprofile_id update_path = str(update_path_temp) @@ -416,8 +417,8 @@ class PortprofileExtensionTest(unittest.TestCase): 'portprofile': { 'network-id': net_id, 'port-id': port_id, - }, - } + }, + } req_assign_body = jsonutils.dumps(test_port_assign_data) associate_path_temp = ( self.portprofile_path + @@ -452,8 +453,8 @@ class PortprofileExtensionTest(unittest.TestCase): 'portprofile': { 'network-id': '001', 'port-id': '1', - }, - } + }, + } req_assign_body = jsonutils.dumps(test_port_assign_data) associate_path = (self.portprofile_path + portprofile_id + @@ -483,8 +484,8 @@ class PortprofileExtensionTest(unittest.TestCase): 'portprofile': { 'network-id': net_id, 'port-id': port_id, - }, - } + }, + } req_assign_body = jsonutils.dumps(test_port_assign_data) associate_path_temp = (self.portprofile_path + resp_body['portprofiles']['portprofile']['id'] + @@ -565,18 +566,18 @@ class NovatenantExtensionTest(unittest.TestCase): 'project_id': 'demo', 'user_id': 'root', 'vif_id': '23432423', - }, }, - } + }, + } self.test_associate_data = { 'novatenant': { 'instance_id': 1, 'instance_desc': { 'project_id': 'demo', 'user_id': 'root', - }, }, - } + }, + } self._l2network_plugin = l2network_plugin.L2Network() def test_schedule_host(self): @@ -640,9 +641,9 @@ class QosExtensionTest(unittest.TestCase): 'qos_desc': { 'PPS': 50, 'TTL': 5, - }, }, - } + }, + } self._l2network_plugin = l2network_plugin.L2Network() def test_create_qos(self): @@ -690,9 +691,9 @@ class QosExtensionTest(unittest.TestCase): 'qos_desc': { 'PPS': 50, 'TTL': 5, - }, }, - }) + }, + }) create_resp2 = self.test_app.post(self.qos_path, req_body2, content_type=self.contenttype) index_response = self.test_app.get(self.qos_path) @@ -767,9 +768,9 @@ class QosExtensionTest(unittest.TestCase): 'qos_desc': { 'PPS': 50, 'TTL': 5, - }, }, - }) + }, + }) rename_path_temp = (self.qos_second_path + resp_body['qoss']['qos']['id']) rename_path = str(rename_path_temp) @@ -778,9 +779,8 @@ class QosExtensionTest(unittest.TestCase): self.assertEqual(200, rename_response.status_int) rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body, self.contenttype) - self.assertEqual( - rename_resp_dict['qoss']['qos']['name'], - 'cisco_rename_qos') + self.assertEqual(rename_resp_dict['qoss']['qos']['name'], + 'cisco_rename_qos') self.tearDownQos(rename_path) LOG.debug("test_update_qos - END") @@ -795,9 +795,9 @@ class QosExtensionTest(unittest.TestCase): 'qos_desc': { 'PPS': 50, 'TTL': 5, - }, }, - }) + }, + }) rename_path_temp = self.qos_second_path + qos_id rename_path = str(rename_path_temp) rename_response = self.test_app.put(rename_path, rename_req_body, @@ -838,9 +838,9 @@ class QosExtensionTest(unittest.TestCase): 'qos_desc': { 'PPS': 50, 'TTL': 5, - }, }, - }) + }, + }) index_response = self.test_app.post(self.qos_path, req_body, content_type=self.contenttype) resp_body = wsgi.Serializer().deserialize(index_response.body, @@ -881,12 +881,12 @@ class CredentialExtensionTest(unittest.TestCase): parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") - controller = credential.CredentialController( - QuantumManager.get_plugin()) + controller = credential.CredentialController(QuantumManager. + get_plugin()) res_ext = extensions.ResourceExtension('credentials', controller, parent=parent_resource) - self.test_app = setup_extensions_test_app( - SimpleExtensionManager(res_ext)) + self.test_app = setup_extensions_test_app(SimpleExtensionManager( + res_ext)) self.contenttype = 'application/json' self.credential_path = '/extensions/csco/tenants/tt/credentials' self.cred_second_path = '/extensions/csco/tenants/tt/credentials/' @@ -895,8 +895,8 @@ class CredentialExtensionTest(unittest.TestCase): 'credential_name': 'cred8', 'user_name': 'newUser2', 'password': 'newPasswd1', - }, - } + }, + } self._l2network_plugin = l2network_plugin.L2Network() def test_list_credentials(self): @@ -914,8 +914,8 @@ class CredentialExtensionTest(unittest.TestCase): 'credential_name': 'cred9', 'user_name': 'newUser2', 'password': 'newPasswd2', - }, - }) + }, + }) create_response2 = self.test_app.post( self.credential_path, req_body2, content_type=self.contenttype) @@ -1027,8 +1027,8 @@ class CredentialExtensionTest(unittest.TestCase): 'credential_name': 'cred3', 'user_name': 'RenamedUser', 'password': 'Renamedpassword', - }, - }) + }, + }) rename_path_temp = (self.cred_second_path + resp_body['credentials']['credential']['id']) rename_path = str(rename_path_temp) @@ -1075,8 +1075,8 @@ class CredentialExtensionTest(unittest.TestCase): 'credential_name': 'cred3', 'user_name': 'RenamedUser', 'password': 'Renamedpassword', - }, - }) + }, + }) rename_path_temp = self.cred_second_path + credential_id rename_path = str(rename_path_temp) rename_response = self.test_app.put(rename_path, rename_req_body, @@ -1143,8 +1143,8 @@ class MultiPortExtensionTest(unittest.TestCase): 'net_id_list': '1', 'status': 'test-qos1', 'ports_desc': 'Port Descr', - }, - } + }, + } self.tenant_id = "test_tenant" self.network_name = "test_network" options = {} @@ -1209,9 +1209,9 @@ class MultiPortExtensionTest(unittest.TestCase): 'status': 'ACTIVE', 'ports_desc': { 'key': 'value', - }, }, - } + }, + } req_body = jsonutils.dumps(test_multi_port) index_response = self.test_app.post(self.multiport_path, req_body, content_type=self.contenttype) diff --git a/quantum/plugins/cisco/tests/unit/test_database.py b/quantum/plugins/cisco/tests/unit/test_database.py index 0b752f81f1..c41a1d2a3d 100644 --- a/quantum/plugins/cisco/tests/unit/test_database.py +++ b/quantum/plugins/cisco/tests/unit/test_database.py @@ -178,7 +178,7 @@ class NexusDB(object): return bindings except Exception, exc: raise Exception("Failed to delete nexus port binding: %s" - % str(exc)) + % str(exc)) def update_nexusport_binding(self, port_id, new_vlan_id): """update nexus port binding""" @@ -244,7 +244,7 @@ class ServicesDB(object): LOG.debug("Deleted service binding: %s" % res.service_id) except Exception, exc: raise Exception("Failed to delete service binding: %s" - % str(exc)) + % str(exc)) class L2networkDB(object): @@ -309,7 +309,7 @@ class L2networkDB(object): """Update a vlan binding""" try: res = l2network_db.update_vlan_binding(network_id, vlan_id, - vlan_name) + vlan_name) LOG.debug("Updating vlan binding for vlan: %s" % res.vlan_id) vlan_dict = {} vlan_dict["vlan-id"] = str(res.vlan_id) @@ -1166,7 +1166,7 @@ class QuantumDBTest(unittest.TestCase): 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"], - name="plugin_test1_renamed") + name="plugin_test1_renamed") self.assertTrue(net["net-name"] == "plugin_test1_renamed") self.teardown_network_port() diff --git a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py index cf53b1ce98..fa3824ff0c 100644 --- a/quantum/plugins/cisco/tests/unit/test_l2networkApi.py +++ b/quantum/plugins/cisco/tests/unit/test_l2networkApi.py @@ -90,10 +90,11 @@ class CoreAPITestFunc(unittest.TestCase): tenant_id, net_id) LOG.debug("test_delete_network_not_found - END") - def test_delete_networkInUse( - self, tenant_id='test_tenant', instance_tenant_id='nova', - nova_user_id='novaadmin', instance_id=10, - vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'): + def test_delete_networkInUse(self, tenant_id='test_tenant', + instance_tenant_id='nova', + nova_user_id='novaadmin', instance_id=10, + vif_id='fe701ddf-26a2-' + '42ea-b9e6-7313d1c522cc'): """ Tests deletion of a Virtual Network when Network is in Use. @@ -492,10 +493,11 @@ class CoreAPITestFunc(unittest.TestCase): """ LOG.debug("test_plug_interface - START") - new_net_dict = self._l2network_plugin.create_network( - tenant_id, self.network_name) - port_dict = self._l2network_plugin.create_port( - tenant_id, new_net_dict[const.NET_ID], self.state) + new_net_dict = self._l2network_plugin.create_network(tenant_id, + self.network_name) + port_dict = self._l2network_plugin.create_port(tenant_id, + new_net_dict[const. + NET_ID], self.state) instance_desc = {'project_id': tenant_id, 'user_id': nova_user_id} host_list = self._l2network_plugin.schedule_host(instance_tenant_id, @@ -551,11 +553,13 @@ class CoreAPITestFunc(unittest.TestCase): self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID]) LOG.debug("test_plug_interface_portDNE - END") - def test_plug_interface_portInUse( - self, tenant_id='test_tenant', instance_tenant_id='nova', - nova_user_id='novaadmin', instance_id=10, - vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc', - remote_interface='new_interface'): + def test_plug_interface_portInUse(self, tenant_id='test_tenant', + instance_tenant_id='nova', + nova_user_id='novaadmin', + instance_id=10, + vif_id='fe701ddf-26a2-42ea-' + 'b9e6-7313d1c522cc', + remote_interface='new_interface'): """ Tests attachment of new interface to the port when there is an existing attachment @@ -588,10 +592,10 @@ class CoreAPITestFunc(unittest.TestCase): LOG.debug("test_plug_interface_portInUse - END") - def test_unplug_interface( - self, tenant_id='test_tenant', instance_tenant_id='nova', - nova_user_id='novaadmin', instance_id=10, - vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'): + def test_unplug_interface(self, tenant_id='test_tenant', + instance_tenant_id='nova', + nova_user_id='novaadmin', instance_id=10, + vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'): """ Tests detaachment of an interface to a port """ @@ -730,8 +734,8 @@ class CoreAPITestFunc(unittest.TestCase): port_profile_dict = self._l2network_plugin.create_portprofile( tenant_id, self.profile_name, self.qos) port_profile_id = port_profile_dict['profile_id'] - new_net_dict = self._l2network_plugin.create_network( - tenant_id, 'test_network') + new_net_dict = self._l2network_plugin.create_network(tenant_id, + 'test_network') port_dict = self._l2network_plugin.create_port( tenant_id, new_net_dict[const.NET_ID], const.PORT_UP) @@ -919,7 +923,8 @@ class CoreAPITestFunc(unittest.TestCase): LOG.debug("test_disassociate_portprofile - END") def test_disassociate_portprofileDNE(self, tenant_id='test_tenant', - net_id='0005', port_id='p00005', profile_id='pr0005'): + net_id='0005', port_id='p00005', + profile_id='pr0005'): """ Tests disassociation of a port-profile when network does not exist """ @@ -1010,8 +1015,8 @@ class CoreAPITestFunc(unittest.TestCase): self.tearDownNetwork(tenant_id, network_dict_id) def tearDownNetworkPortInterface(self, tenant_id, instance_tenant_id, - instance_id, instance_desc, network_dict_id, - port_id): + instance_id, instance_desc, + network_dict_id, port_id): """ Tear down Network Port Interface """ @@ -1061,7 +1066,7 @@ class CoreAPITestFunc(unittest.TestCase): const.PROFILE_ASSOCIATIONS: profile_associations, const.PROFILE_VLAN_ID: None, const.PROFILE_QOS: qos, - } + } return res def _make_portprofile_assc_list(self, tenant_id, profile_id): diff --git a/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py b/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py index 1b0d1a2477..a074ac4adb 100644 --- a/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py +++ b/quantum/plugins/cisco/tests/unit/test_l2network_multi_blade.py @@ -116,7 +116,7 @@ class TestMultiBlade(unittest.TestCase): self.net_id, vlan_name(self.net_id), vlan_id, - ]) + ]) cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id) for network in networks: @@ -177,7 +177,7 @@ class TestMultiBlade(unittest.TestCase): tenant_id, self.net_id, {'name': new_net_name}, - ]) + ]) for network in networks: self.assertEqual(network[const.NET_ID], self.net_id) diff --git a/quantum/plugins/cisco/tests/unit/test_ucs_driver.py b/quantum/plugins/cisco/tests/unit/test_ucs_driver.py index e6673a6ffe..cf6e75ef8e 100644 --- a/quantum/plugins/cisco/tests/unit/test_ucs_driver.py +++ b/quantum/plugins/cisco/tests/unit/test_ucs_driver.py @@ -26,50 +26,63 @@ from quantum.plugins.cisco.ucs import cisco_ucs_network_driver LOG = logging.getLogger('quantum.tests.test_ucs_driver') -CREATE_VLAN_OUTPUT = (" " -" " -"") +CREATE_VLAN_OUTPUT = (' ' + ' ' + ' ') -CREATE_PROFILE_OUTPUT = (" " -" ") +CREATE_PROFILE_OUTPUT = (' ' + ' ' + ' ') -CHANGE_VLAN_OUTPUT = (" " -" " -" ") +CHANGE_VLAN_OUTPUT = (' ' + ' ' + ' ' + ' ') -DELETE_VLAN_OUTPUT = (" " -" " -" ") +DELETE_VLAN_OUTPUT = (' ' + ' ' + ' ') -DELETE_PROFILE_OUTPUT = (" " -" ") +DELETE_PROFILE_OUTPUT = (' ' + ' ') -ASSOCIATE_PROFILE_OUTPUT = (" " -" " -" ") +ASSOCIATE_PROFILE_OUTPUT = (' ' + ' ') class TestUCSDriver(unittest.TestCase): @@ -94,8 +107,8 @@ class TestUCSDriver(unittest.TestCase): self.assertEqual(vlan_details, expected_output) LOG.debug("test_create_vlan - END") - def test_create_profile_post_data( - self, expected_output=CREATE_PROFILE_OUTPUT): + def test_create_profile_post_data(self, + expected_output=CREATE_PROFILE_OUTPUT): """ Tests creation of profile post Data """ @@ -106,8 +119,8 @@ class TestUCSDriver(unittest.TestCase): self.assertEqual(profile_details, expected_output) LOG.debug("test_create_profile_post - END") - def test_change_vlan_profile_data( - self, expected_output=CHANGE_VLAN_OUTPUT): + def test_change_vlan_profile_data(self, + expected_output=CHANGE_VLAN_OUTPUT): """ Tests creation of change vlan in profile post Data """ @@ -146,8 +159,9 @@ class TestUCSDriver(unittest.TestCase): self.assertEqual(profile_delete_details, expected_output) LOG.debug("test_create_profile_post - END") - def test_create_profile_client_data( - self, expected_output=ASSOCIATE_PROFILE_OUTPUT): + def test_create_profile_client_data(self, + expected_output= + ASSOCIATE_PROFILE_OUTPUT): """ Tests creation of profile client post Data """ diff --git a/quantum/plugins/cisco/tests/unit/test_vlan_mgr.py b/quantum/plugins/cisco/tests/unit/test_vlan_mgr.py index 461bee6719..dfa2ec913d 100644 --- a/quantum/plugins/cisco/tests/unit/test_vlan_mgr.py +++ b/quantum/plugins/cisco/tests/unit/test_vlan_mgr.py @@ -27,7 +27,7 @@ from quantum.plugins.cisco.db import l2network_db as cdb from quantum.plugins.cisco import l2network_plugin_configuration as conf from quantum.plugins.cisco.segmentation.l2network_vlan_mgr import ( L2NetworkVLANMgr, - ) +) logging.basicConfig(level=logging.WARN) diff --git a/quantum/plugins/cisco/ucs/cisco_ucs_inventory.py b/quantum/plugins/cisco/ucs/cisco_ucs_inventory.py index 90b5983b10..a08a09c8b2 100644 --- a/quantum/plugins/cisco/ucs/cisco_ucs_inventory.py +++ b/quantum/plugins/cisco/ucs/cisco_ucs_inventory.py @@ -66,7 +66,7 @@ import logging from quantum.common import exceptions as exc from quantum.plugins.cisco.l2device_inventory_base import ( L2NetworkDeviceInventoryBase, - ) +) from quantum.plugins.cisco.common import cisco_constants as const from quantum.plugins.cisco.common import cisco_credentials as cred from quantum.plugins.cisco.common import cisco_exceptions as cexc @@ -74,7 +74,7 @@ from quantum.plugins.cisco.db import api as db from quantum.plugins.cisco.db import ucs_db as udb from quantum.plugins.cisco.ucs import ( cisco_ucs_inventory_configuration as conf, - ) +) from quantum.plugins.cisco.ucs import cisco_ucs_network_driver @@ -198,8 +198,8 @@ class UCSInventory(L2NetworkDeviceInventoryBase): # need to change it, and also load the state from the DB for # other associations intf_data = blade_intf_data[blade_intf] - if (intf_data[const.BLADE_INTF_RESERVATION] == - const.BLADE_INTF_UNRESERVED): + if ((intf_data[const.BLADE_INTF_RESERVATION] == const. + BLADE_INTF_UNRESERVED)): unreserved_counter -= 1 intf_data[const.BLADE_INTF_RESERVATION] = ( const.BLADE_INTF_RESERVED) @@ -334,7 +334,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase): dynamicnic_details = { const.DEVICENAME: device_name, const.UCSPROFILE: profile_name, - } + } LOG.debug(("Found reserved dynamic nic: %s" "associated with port %s") % (intf_data, port_id)) @@ -398,8 +398,8 @@ class UCSInventory(L2NetworkDeviceInventoryBase): blade_data = ucsm[chassis_id][blade_id] blade_intf_data = blade_data[const.BLADE_INTF_DATA] for blade_intf in blade_intf_data.keys(): - if (not blade_intf_data[blade_intf][const.PORTID] or - not blade_intf_data[blade_intf][const.TENANTID]): + if ((not blade_intf_data[blade_intf][const.PORTID] or + not blade_intf_data[blade_intf][const.TENANTID])): continue intf_data = blade_intf_data[blade_intf] if (intf_data[const.BLADE_INTF_RESERVATION] == @@ -430,8 +430,8 @@ class UCSInventory(L2NetworkDeviceInventoryBase): for chassis_id in ucsm.keys(): for blade_id in ucsm[chassis_id]: blade_data = ucsm[chassis_id][blade_id] - if (blade_data[const.BLADE_UNRESERVED_INTF_COUNT] > - unreserved_interface_count): + if ((blade_data[const.BLADE_UNRESERVED_INTF_COUNT] > + unreserved_interface_count)): unreserved_interface_count = ( blade_data[const.BLADE_UNRESERVED_INTF_COUNT]) least_reserved_blade_ucsm = ucsm_ip @@ -450,7 +450,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase): const.LEAST_RSVD_BLADE_CHASSIS: least_reserved_blade_chassis, const.LEAST_RSVD_BLADE_ID: least_reserved_blade_id, const.LEAST_RSVD_BLADE_DATA: least_reserved_blade_data, - } + } LOG.debug("Found dynamic nic %s available for reservation", least_reserved_blade_dict) return least_reserved_blade_dict @@ -519,7 +519,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase): const.RESERVED_NIC_HOSTNAME: host_name, const.RESERVED_NIC_NAME: dev_eth_name, const.BLADE_INTF_DN: blade_intf, - } + } port_binding = udb.add_portbinding(port_id, blade_intf, None, None, None, None) udb.update_portbinding(port_id, @@ -597,7 +597,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase): const.DEVICE_IP: [ucsm_ip], const.UCS_INVENTORY: self, const.LEAST_RSVD_BLADE_DICT: least_reserved_blade_dict, - } + } return device_params def delete_port(self, args): @@ -612,7 +612,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase): rsvd_info = self._get_rsvd_blade_intf_by_port(tenant_id, port_id) if not rsvd_info: LOG.warn("UCSInventory: Port not found: net_id: %s, port_id: %s" % - (net_id, port_id)) + (net_id, port_id)) return {const.DEVICE_IP: []} device_params = { const.DEVICE_IP: [rsvd_info[const.UCSM_IP]], @@ -620,7 +620,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase): const.CHASSIS_ID: rsvd_info[const.CHASSIS_ID], const.BLADE_ID: rsvd_info[const.BLADE_ID], const.BLADE_INTF_DN: rsvd_info[const.BLADE_INTF_DN], - } + } return device_params def update_port(self, args): @@ -709,5 +709,5 @@ class UCSInventory(L2NetworkDeviceInventoryBase): const.UCS_INVENTORY: self, const.LEAST_RSVD_BLADE_DICT: least_reserved_blade_dict, - } + } return device_params diff --git a/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py b/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py index 522ae6e59b..23f7715f37 100644 --- a/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py +++ b/quantum/plugins/cisco/ucs/cisco_ucs_network_driver.py @@ -48,89 +48,90 @@ HEADERS = {"Content-Type": "text/xml"} METHOD = "POST" URL = "/nuova" -CREATE_VLAN = " " \ -" " \ -" " +CREATE_VLAN = (' ' + ' ' + ' ') -CREATE_PROFILE = " " \ -" " \ -" " \ -" " +CREATE_PROFILE = (' ' + ' ' + ' ' + ' ') -ASSOCIATE_PROFILE = " " \ -" " +ASSOCIATE_PROFILE = (' ' + ' ') -CHANGE_VLAN_IN_PROFILE = " " \ -" " \ -" " \ -" " +CHANGE_VLAN_IN_PROFILE = (' ') -DELETE_VLAN = " " \ -" " \ -"" +DELETE_VLAN = (' " \ -" " \ -" " +DELETE_PROFILE = (' " + \ - " " +GET_BLADE_INTERFACE_STATE = ('' + + ' " + \ - " " + \ - " " +GET_BLADE_INTERFACE = (' ' + + ' " + \ - " " +GET_BLADE_INTERFACES = (' " % y for y in COMMANDS[key]["args"]])) + print " %s %s" % + (key, " ".join(["<%s>" % y for y in COMMANDS[key]["args"]])) def build_args(cmd, cmdargs, arglist): @@ -45,15 +45,15 @@ def build_args(cmd, cmdargs, arglist): del arglist[0] except: LOG.error("Not enough arguments for \"%s\" (expected: %d, got: %d)" % ( - cmd, len(cmdargs), len(orig_arglist))) - print "Usage:\n %s %s" % (cmd, - " ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]])) + cmd, len(cmdargs), len(orig_arglist))) + print "Usage:\n %s %s" % + (cmd, " ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]])) sys.exit() if len(arglist) > 0: LOG.error("Too many arguments for \"%s\" (expected: %d, got: %d)" % ( - cmd, len(cmdargs), len(orig_arglist))) - print "Usage:\n %s %s" % (cmd, - " ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]])) + cmd, len(cmdargs), len(orig_arglist))) + print "Usage:\n %s %s" % + (cmd, " ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]])) sys.exit() return args @@ -76,21 +76,23 @@ def check_config(manager): COMMANDS = { - "check_config": { - "need_login": True, - "func": check_config, - "args": []}, - } + "check_config": { + "need_login": True, + "func": check_config, + "args": [] + }, +} def main(): usagestr = "Usage: %prog [OPTIONS] [args]" PARSER = OptionParser(usage=usagestr) PARSER.add_option("-v", "--verbose", dest="verbose", - action="store_true", default=False, help="turn on verbose logging") - PARSER.add_option("-c", "--configfile", dest="configfile", - type="string", default="/etc/quantum/plugins/nvp/nvp.ini", - help="nvp plugin config file path (nvp.ini)") + action="store_true", default=False, + help="turn on verbose logging") + PARSER.add_option("-c", "--configfile", dest="configfile", type="string", + default="/etc/quantum/plugins/nvp/nvp.ini", + help="nvp plugin config file path (nvp.ini)") options, args = PARSER.parse_args() loglevel = logging.INFO diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py b/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py index 42e2b5bd5e..fae21a11bc 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/nvplib.py @@ -178,18 +178,16 @@ def create_network(tenant_id, net_name, **kwargs): controller = kwargs["controller"] transport_zone = kwargs.get("transport_zone", - controller.default_tz_uuid) + controller.default_tz_uuid) transport_type = kwargs.get("transport_type", "gre") lswitch_obj = { "display_name": net_name, - "transport_zones": [ - { - "zone_uuid": transport_zone, - "transport_type": transport_type, - }, - ], + "transport_zones": [{ + "zone_uuid": transport_zone, + "transport_type": transport_type, + }], "tags": [{"tag": tenant_id, "scope": "os_tid"}], - } + } net = create_lswitch(controller, lswitch_obj) net['net-op-status'] = "UP" @@ -237,8 +235,7 @@ def query_ports(controller, network, relations=None, fields="*", filters=None): if filters and "attachment" in filters: uri += "&attachment_vif_uuid=%s" % filters["attachment"] try: - resp_obj = do_single_request("GET", uri, - controller=controller) + resp_obj = do_single_request("GET", uri, controller=controller) except NvpApiClient.ResourceNotFound as e: LOG.error("Network not found, Error: %s" % str(e)) raise exception.NetworkNotFound(net_id=network) @@ -259,9 +256,8 @@ def delete_port(controller, network, port): def delete_all_ports(controller, ls_uuid): - res = do_single_request("GET", - "/ws.v1/lswitch/%s/lport?fields=uuid" % ls_uuid, - controller=controller) + res = do_single_request("GET", "/ws.v1/lswitch/%s/lport?fields=uuid" % + ls_uuid, controller=controller) res = jsonutils.loads(res) for r in res["results"]: do_single_request( diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_config.py b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_config.py index d8f732a6d4..a811aaef15 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_config.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_config.py @@ -19,7 +19,7 @@ import unittest from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import ( NVPCluster, parse_config, - ) +) class ConfigParserTest(unittest.TestCase): diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_network.py b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_network.py index c8f3ba6c95..33b4fdae9f 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_network.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_network.py @@ -25,7 +25,7 @@ from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import NvpPlugin from quantum.plugins.nicira.nicira_nvp_plugin import ( NvpApiClient, nvplib, - ) +) logging.basicConfig(level=logging.DEBUG) @@ -55,8 +55,8 @@ class NvpTests(unittest.TestCase): body = {"display_name": name, "tags": [{"tag": "plugin-test"}]} try: - resp_obj = self.quantum.api_client.request("POST", - post_uri, jsonutils.dumps(body)) + resp_obj = self.quantum.api_client.request("POST", post_uri, + jsonutils.dumps(body)) except NvpApiClient.NvpApiException as e: print("Unknown API Error: %s" % str(e)) raise exception.QuantumException() @@ -130,7 +130,7 @@ class NvpTests(unittest.TestCase): def test_update_network(self): resp = self.quantum.create_network("quantum-test-tenant", - "quantum-Private-TenantA") + "quantum-Private-TenantA") net_id = resp["net-id"] try: resp = self.quantum.update_network("quantum-test-tenant", net_id, diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_nvp_api_request_eventlet.py b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_nvp_api_request_eventlet.py index 07f6e94fdd..d9d4ce7218 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_nvp_api_request_eventlet.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_nvp_api_request_eventlet.py @@ -26,7 +26,7 @@ from mock import patch from quantum.plugins.nicira.nicira_nvp_plugin.api_client import ( client_eventlet as nace, request_eventlet as nare, - ) +) logging.basicConfig(level=logging.DEBUG) diff --git a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_port.py b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_port.py index 494915be84..e0bce783df 100644 --- a/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_port.py +++ b/quantum/plugins/nicira/nicira_nvp_plugin/tests/test_port.py @@ -24,7 +24,7 @@ from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import NvpPlugin from quantum.plugins.nicira.nicira_nvp_plugin import ( NvpApiClient, nvplib, - ) +) logging.basicConfig(level=logging.DEBUG) @@ -142,12 +142,12 @@ class NvpTests(unittest.TestCase): { "ip_address": "172.168.17.5", "mac_address": "10:9a:dd:61:4e:89", - }, + }, { "ip_address": "172.168.17.6", "mac_address": "10:9a:dd:61:4e:88", - }, - ] + }, + ] resp = self.quantum.create_port("quantum-test-tenant", net_id, "ACTIVE", **params) port_id = resp["port-id"] @@ -186,7 +186,7 @@ class NvpTests(unittest.TestCase): old_vic = resp["attachment"] self.assertTrue(old_vic == "None") self.quantum.plug_interface("quantum-test-tenant", net_id, port_id, - "nova-instance-test-%s" % os.getpid()) + "nova-instance-test-%s" % os.getpid()) resp = self.quantum.get_port_details("quantum-test-tenant", net_id, port_id) new_vic = resp["attachment"] @@ -202,9 +202,10 @@ class NvpTests(unittest.TestCase): self.assertTrue(True) def test_create_multi_port_attachment(self): - resp = self.quantum.create_custom_network( - "quantum-test-tenant", "quantum-Private-TenantA", - self.BRIDGE_TZ_UUID, self.quantum.controller) + resp = self.quantum.create_custom_network("quantum-test-tenant", + "quantum-Private-TenantA", + self.BRIDGE_TZ_UUID, + self.quantum.controller) net_id = resp["net-id"] resp = self.quantum.create_port("quantum-test-tenant", net_id, @@ -216,7 +217,7 @@ class NvpTests(unittest.TestCase): self.assertTrue(old_vic == "None") self.quantum.plug_interface("quantum-test-tenant", net_id, port_id1, - "nova-instance-test-%s" % os.getpid()) + "nova-instance-test-%s" % os.getpid()) resp = self.quantum.get_port_details("quantum-test-tenant", net_id, port_id1) new_vic = resp["attachment"] @@ -231,7 +232,7 @@ class NvpTests(unittest.TestCase): self.assertTrue(old_vic2 == "None") self.quantum.plug_interface("quantum-test-tenant", net_id, port_id2, - "nova-instance-test2-%s" % os.getpid()) + "nova-instance-test2-%s" % os.getpid()) resp = self.quantum.get_port_details("quantum-test-tenant", net_id, port_id2) new_vic = resp["attachment"] @@ -508,7 +509,8 @@ class NvpTests(unittest.TestCase): # Make sure we only get the filtered ones back ports = self.quantum.get_all_ports("quantum-test-tenant", net_id, - filter_opts={"attachment": "attachment2"}) + filter_opts={"attachment": + "attachment2"}) self.assertTrue(len(ports) == 1) self.assertTrue(ports[0]["port-id"] == port_id2) diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index ee9a164801..77b639663c 100755 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -174,7 +174,7 @@ class OVSQuantumAgent(object): if old_b != new_b: if old_b is not None: LOG.info("Removing binding to net-id = %s for %s" - % (old_b, str(p))) + % (old_b, str(p))) self.port_unbound(p, True) if p.vif_id in all_bindings: all_bindings[p.vif_id].op_status = OP_STATUS_DOWN @@ -475,9 +475,9 @@ class OVSQuantumTunnelAgent(object): lsw_id = lsw_id_bindings[new_net_uuid] self.port_bound(p, new_net_uuid, lsw_id) all_bindings[p.vif_id].op_status = OP_STATUS_UP - LOG.info("Port " + str(p) + " on net-id = " - + new_net_uuid + " bound to " + - str(self.local_vlan_map[new_net_uuid])) + LOG.info("Port %s on net-id = %s bound to %s " % ( + str(p), new_net_uuid, + str(self.local_vlan_map[new_net_uuid]))) for vif_id in disappeared_vif_ports_ids: LOG.info("Port Disappeared: " + vif_id) @@ -506,7 +506,8 @@ def main(): usagestr = "%prog [OPTIONS] " parser = OptionParser(usage=usagestr) parser.add_option("-v", "--verbose", dest="verbose", - action="store_true", default=False, help="turn on verbose logging") + action="store_true", default=False, + help="turn on verbose logging") options, args = parser.parse_args() diff --git a/quantum/plugins/openvswitch/ovs_models.py b/quantum/plugins/openvswitch/ovs_models.py index 3bb7ede2ad..52555e1750 100644 --- a/quantum/plugins/openvswitch/ovs_models.py +++ b/quantum/plugins/openvswitch/ovs_models.py @@ -34,8 +34,7 @@ class VlanBinding(BASE): self.vlan_id = vlan_id def __repr__(self): - return "" % \ - (self.vlan_id, self.network_id) + return "" % (self.vlan_id, self.network_id) class TunnelIP(BASE): diff --git a/quantum/plugins/openvswitch/ovs_quantum_plugin.py b/quantum/plugins/openvswitch/ovs_quantum_plugin.py index aae2f29921..bb5db8efa0 100644 --- a/quantum/plugins/openvswitch/ovs_quantum_plugin.py +++ b/quantum/plugins/openvswitch/ovs_quantum_plugin.py @@ -125,7 +125,7 @@ class OVSQuantumPlugin(QuantumPluginBase): 'net-id': net_id, 'net-name': net_name, 'net-op-status': op_status, - } + } if ports: res['net-ports'] = ports return res @@ -176,7 +176,7 @@ class OVSQuantumPlugin(QuantumPluginBase): 'port-op-status': op_status, 'net-id': port.network_id, 'attachment': port.interface_id, - } + } def get_all_ports(self, tenant_id, net_id, **kwargs): ids = [] diff --git a/quantum/plugins/openvswitch/tests/unit/test_tunnel.py b/quantum/plugins/openvswitch/tests/unit/test_tunnel.py index 48a31db471..35e5fe19c0 100644 --- a/quantum/plugins/openvswitch/tests/unit/test_tunnel.py +++ b/quantum/plugins/openvswitch/tests/unit/test_tunnel.py @@ -31,8 +31,8 @@ LV_IDS = [42, 43] LVM = ovs_quantum_agent.LocalVLANMapping(LV_ID, LS_ID, LV_IDS) VIF_ID = '404deaec-5d37-11e1-a64b-000c29d5f0a8' VIF_MAC = '3c:09:24:1e:78:23' -VIF_PORT = ovs_lib.VifPort('port', 'ofport', VIF_ID, VIF_MAC, - 'switch') +VIF_PORT = ovs_lib.VifPort('port', 'ofport', + VIF_ID, VIF_MAC, 'switch') class DummyPort: @@ -57,16 +57,14 @@ class TunnelTest(unittest.TestCase): self.TUN_OFPORT = 'PATCH_TUN_OFPORT' self.mox.StubOutClassWithMocks(ovs_lib, 'OVSBridge') - self.mock_int_bridge = ovs_lib.OVSBridge(self.INT_BRIDGE, - 'sudo') + self.mock_int_bridge = ovs_lib.OVSBridge(self.INT_BRIDGE, 'sudo') self.mock_int_bridge.delete_port('patch-tun') self.mock_int_bridge.add_patch_port( 'patch-tun', 'patch-int').AndReturn(self.TUN_OFPORT) self.mock_int_bridge.remove_all_flows() self.mock_int_bridge.add_flow(priority=1, actions='normal') - self.mock_tun_bridge = ovs_lib.OVSBridge(self.TUN_BRIDGE, - 'sudo') + self.mock_tun_bridge = ovs_lib.OVSBridge(self.TUN_BRIDGE, 'sudo') self.mock_tun_bridge.reset_bridge() self.mock_tun_bridge.add_patch_port( 'patch-int', 'patch-tun').AndReturn(self.INT_OFPORT) diff --git a/quantum/plugins/openvswitch/tests/unit/test_vlan_map.py b/quantum/plugins/openvswitch/tests/unit/test_vlan_map.py index dc54a73a2d..ec8a870bfa 100644 --- a/quantum/plugins/openvswitch/tests/unit/test_vlan_map.py +++ b/quantum/plugins/openvswitch/tests/unit/test_vlan_map.py @@ -19,7 +19,7 @@ import unittest from quantum.plugins.openvswitch.ovs_quantum_plugin import ( NoFreeVLANException, VlanMap, - ) +) class VlanMapTest(unittest.TestCase): diff --git a/quantum/plugins/ryu/agent/ryu_quantum_agent.py b/quantum/plugins/ryu/agent/ryu_quantum_agent.py index ea3ab63998..3fa8b507c7 100755 --- a/quantum/plugins/ryu/agent/ryu_quantum_agent.py +++ b/quantum/plugins/ryu/agent/ryu_quantum_agent.py @@ -112,7 +112,7 @@ class OVSBridge: "param-name=other-config", "param-key=nicira-iface-id", "uuid=%s" % xs_vif_uuid], - root_helper=self.root_helper).strip() + root_helper=self.root_helper).strip() def _vifport(self, name, external_ids): ofport = self.db_get_val("Interface", name, "ofport") @@ -271,7 +271,8 @@ def main(): usagestr = "%prog [OPTIONS] " parser = OptionParser(usage=usagestr) parser.add_option("-v", "--verbose", dest="verbose", - action="store_true", default=False, help="turn on verbose logging") + action="store_true", default=False, + help="turn on verbose logging") options, args = parser.parse_args() diff --git a/quantum/rootwrap/filters.py b/quantum/rootwrap/filters.py index 127cb442de..510d10f391 100644 --- a/quantum/rootwrap/filters.py +++ b/quantum/rootwrap/filters.py @@ -72,9 +72,9 @@ class DnsmasqFilter(CommandFilter): """Specific filter for the dnsmasq call (which includes env)""" def match(self, userargs): - if (userargs[0].startswith("FLAGFILE=") and - userargs[1].startswith("NETWORK_ID=") and - userargs[2] == "dnsmasq"): + if ((userargs[0].startswith("FLAGFILE=") and + userargs[1].startswith("NETWORK_ID=") and + userargs[2] == "dnsmasq")): return True return False diff --git a/quantum/rootwrap/linuxbridge-agent.py b/quantum/rootwrap/linuxbridge-agent.py index 5421ff1f8f..326f088556 100644 --- a/quantum/rootwrap/linuxbridge-agent.py +++ b/quantum/rootwrap/linuxbridge-agent.py @@ -43,4 +43,4 @@ filterlist = [ # 'ip', 'tuntap' filters.CommandFilter("/usr/sbin/ip", "root"), filters.CommandFilter("/sbin/ip", "root"), - ] +] diff --git a/quantum/rootwrap/openvswitch-agent.py b/quantum/rootwrap/openvswitch-agent.py index 0c00968dd3..9d4d2ef35d 100644 --- a/quantum/rootwrap/openvswitch-agent.py +++ b/quantum/rootwrap/openvswitch-agent.py @@ -33,4 +33,4 @@ filterlist = [ # "xe", "vif-param-get", ... filters.CommandFilter("/usr/bin/xe", "root"), filters.CommandFilter("/usr/sbin/xe", "root"), - ] +] diff --git a/quantum/rootwrap/ryu-agent.py b/quantum/rootwrap/ryu-agent.py index d413ccf13c..54581d168c 100644 --- a/quantum/rootwrap/ryu-agent.py +++ b/quantum/rootwrap/ryu-agent.py @@ -28,4 +28,4 @@ filterlist = [ # "xe", "vif-param-get", ... filters.CommandFilter("/usr/bin/xe", "root"), filters.CommandFilter("/usr/sbin/xe", "root"), - ] +] diff --git a/quantum/rootwrap/wrapper.py b/quantum/rootwrap/wrapper.py index bcb0122fb4..5ab8d7a3a3 100644 --- a/quantum/rootwrap/wrapper.py +++ b/quantum/rootwrap/wrapper.py @@ -22,8 +22,7 @@ import sys FILTERS_MODULES = ['quantum.rootwrap.linuxbridge-agent', 'quantum.rootwrap.openvswitch-agent', - 'quantum.rootwrap.ryu-agent', - ] + 'quantum.rootwrap.ryu-agent'] def load_filters(): diff --git a/quantum/tests/unit/_test_api.py b/quantum/tests/unit/_test_api.py index d30c4bf7bf..46f77f2437 100644 --- a/quantum/tests/unit/_test_api.py +++ b/quantum/tests/unit/_test_api.py @@ -219,8 +219,9 @@ class BaseAPIOperationsTest(AbstractAPITest): # Create a network and a port network_id = self._create_network(fmt) port_id = self._create_port(network_id, "ACTIVE", fmt) - show_network_req = testlib.show_network_detail_request( - self.tenant_id, network_id, fmt) + show_network_req = testlib.show_network_detail_request(self.tenant_id, + network_id, + fmt) show_network_res = show_network_req.get_response(self.api) self.assertEqual(show_network_res.status_int, 200) network_data = self._deserialize_net_response(content_type, @@ -371,7 +372,7 @@ class BaseAPIOperationsTest(AbstractAPITest): def _test_list_ports_networknotfound(self, fmt): LOG.debug("_test_list_ports_networknotfound" - " - fmt:%s - START", fmt) + " - fmt:%s - START", fmt) list_port_req = testlib.port_list_request(self.tenant_id, "A_BAD_ID", fmt) list_port_res = list_port_req.get_response(self.api) @@ -414,7 +415,7 @@ class BaseAPIOperationsTest(AbstractAPITest): port_data = self._deserialize_port_response(content_type, show_port_res) self.assert_port(id=port_id, state=port_state, - port_data=port_data['port']) + port_data=port_data['port']) LOG.debug("_test_show_port - fmt:%s - END", fmt) def _test_show_port_detail(self, fmt): diff --git a/quantum/tests/unit/extensions/foxinsocks.py b/quantum/tests/unit/extensions/foxinsocks.py index c458d869c9..e0ac2eda66 100644 --- a/quantum/tests/unit/extensions/foxinsocks.py +++ b/quantum/tests/unit/extensions/foxinsocks.py @@ -67,11 +67,11 @@ class Foxinsocks(object): def get_actions(self): return [extensions.ActionExtension('dummy_resources', - 'FOXNSOX:add_tweedle', - self._add_tweedle_handler), + 'FOXNSOX:add_tweedle', + self._add_tweedle_handler), extensions.ActionExtension('dummy_resources', - 'FOXNSOX:delete_tweedle', - self._delete_tweedle_handler)] + 'FOXNSOX:delete_tweedle', + self._delete_tweedle_handler)] def get_request_extensions(self): request_exts = [] diff --git a/quantum/tests/unit/test_agent_utils.py b/quantum/tests/unit/test_agent_utils.py index 2f4f760dd1..5859f1f4b4 100644 --- a/quantum/tests/unit/test_agent_utils.py +++ b/quantum/tests/unit/test_agent_utils.py @@ -32,7 +32,7 @@ class AgentUtilsExecuteTest(unittest.TestCase): def test_with_helper(self): result = utils.execute(["ls", self.test_file], - self.root_helper) + self.root_helper) self.assertEqual(result, "ls %s\n" % self.test_file) def test_stderr(self): diff --git a/quantum/tests/unit/test_api.py b/quantum/tests/unit/test_api.py index 67fc622fc8..82aef8f854 100644 --- a/quantum/tests/unit/test_api.py +++ b/quantum/tests/unit/test_api.py @@ -62,7 +62,8 @@ class APITestV10(test_api.BaseAPIOperationsTest): test_api.NETS: nets.ControllerV10._serialization_metadata, test_api.PORTS: ports.ControllerV10._serialization_metadata, test_api.ATTS: atts.ControllerV10._serialization_metadata, - }) + } + ) self._successful_create_code = exc.HTTPOk.code self._network_not_found_code = 420 self._network_in_use_code = 421 @@ -112,7 +113,8 @@ class APITestV11(test_api.BaseAPIOperationsTest): test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata, - }) + } + ) self._successful_create_code = exc.HTTPAccepted.code self._network_not_found_code = exc.HTTPNotFound.code self._network_in_use_code = exc.HTTPConflict.code @@ -155,7 +157,8 @@ class APIFiltersTest(test_api.AbstractAPITest): test_api.NETS: nets.ControllerV11._serialization_metadata, test_api.PORTS: ports.ControllerV11._serialization_metadata, test_api.ATTS: atts.ControllerV11._serialization_metadata, - }) + } + ) self._successful_create_code = exc.HTTPAccepted.code self.net_op_status = test_config.get('default_net_op_status', 'UNKNOWN') diff --git a/quantum/tests/unit/test_db_plugin.py b/quantum/tests/unit/test_db_plugin.py index 2c0dcafa30..55b137803c 100644 --- a/quantum/tests/unit/test_db_plugin.py +++ b/quantum/tests/unit/test_db_plugin.py @@ -80,8 +80,7 @@ class QuantumDbPluginV2TestCase(unittest.TestCase): def deserialize(self, content_type, response): ctype = 'application/%s' % content_type - data = self._deserializers[ctype].\ - deserialize(response.body)['body'] + data = self._deserializers[ctype].deserialize(response.body)['body'] return data def _create_network(self, fmt, name, admin_status_up): diff --git a/quantum/tests/unit/test_extensions.py b/quantum/tests/unit/test_extensions.py index 5191612219..ecda049ea2 100644 --- a/quantum/tests/unit/test_extensions.py +++ b/quantum/tests/unit/test_extensions.py @@ -28,7 +28,7 @@ from quantum.extensions.extensions import ( ExtensionManager, ExtensionMiddleware, PluginAwareExtensionManager, - ) +) from quantum.openstack.common import jsonutils from quantum.plugins.sample.SamplePlugin import QuantumEchoPlugin from quantum.tests.unit import BaseTest @@ -37,7 +37,7 @@ from quantum.tests.unit.extension_stubs import ( StubBaseAppController, StubExtension, StubPlugin, - ) +) import quantum.tests.unit.extensions from quantum import wsgi @@ -300,7 +300,7 @@ class RequestExtensionTest(BaseTest): self.assertEqual(response.json['uneditable'], "original_value") ext_app = self._setup_app_with_request_handler(_update_handler, - 'PUT') + 'PUT') ext_response = ext_app.put("/dummy_resources/1", {'uneditable': "new_value"}) self.assertEqual(ext_response.json['uneditable'], "new_value") diff --git a/quantum/tests/unit/test_ovs_lib.py b/quantum/tests/unit/test_ovs_lib.py index caabb030cc..2cd6fdc087 100644 --- a/quantum/tests/unit/test_ovs_lib.py +++ b/quantum/tests/unit/test_ovs_lib.py @@ -67,7 +67,7 @@ class OVS_Lib_Test(unittest.TestCase): def test_reset_bridge(self): utils.execute(["ovs-vsctl", self.TO, "--", "--if-exists", "del-br", self.BR_NAME], - root_helper=self.root_helper) + root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "add-br", self.BR_NAME], root_helper=self.root_helper) self.mox.ReplayAll() @@ -79,7 +79,7 @@ class OVS_Lib_Test(unittest.TestCase): pname = "tap5" utils.execute(["ovs-vsctl", self.TO, "--", "--if-exists", "del-port", self.BR_NAME, pname], - root_helper=self.root_helper) + root_helper=self.root_helper) self.mox.ReplayAll() self.br.delete_port(pname) @@ -93,25 +93,25 @@ class OVS_Lib_Test(unittest.TestCase): "hard_timeout=0,idle_timeout=0," "priority=2,dl_src=ca:fe:de:ad:be:ef" ",actions=strip_vlan,output:0"], - root_helper=self.root_helper) + root_helper=self.root_helper) utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME, "hard_timeout=0,idle_timeout=0," "priority=1,actions=normal"], - root_helper=self.root_helper) + root_helper=self.root_helper) utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME, "hard_timeout=0,idle_timeout=0," "priority=2,actions=drop"], - root_helper=self.root_helper) + root_helper=self.root_helper) utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME, "hard_timeout=0,idle_timeout=0," "priority=2,in_port=%s,actions=drop" % ofport], - root_helper=self.root_helper) + root_helper=self.root_helper) utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME, "hard_timeout=0,idle_timeout=0," "priority=4,in_port=%s,dl_vlan=%s," "actions=strip_vlan,set_tunnel:%s,normal" % (ofport, vid, lsw_id)], - root_helper=self.root_helper) + root_helper=self.root_helper) utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME, "hard_timeout=0,idle_timeout=0," "priority=3,tun_id=%s,actions=" @@ -120,17 +120,17 @@ class OVS_Lib_Test(unittest.TestCase): self.mox.ReplayAll() self.br.add_flow(priority=2, dl_src="ca:fe:de:ad:be:ef", - actions="strip_vlan,output:0") + actions="strip_vlan,output:0") self.br.add_flow(priority=1, actions="normal") self.br.add_flow(priority=2, actions="drop") self.br.add_flow(priority=2, in_port=ofport, actions="drop") self.br.add_flow(priority=4, in_port=ofport, dl_vlan=vid, - actions="strip_vlan,set_tunnel:%s,normal" % - (lsw_id)) + actions="strip_vlan,set_tunnel:%s,normal" % + (lsw_id)) self.br.add_flow(priority=3, tun_id=lsw_id, - actions="mod_vlan_vid:%s,output:%s" % - (vid, ofport)) + actions="mod_vlan_vid:%s,output:%s" % + (vid, ofport)) self.mox.VerifyAll() def test_get_port_ofport(self): @@ -138,7 +138,7 @@ class OVS_Lib_Test(unittest.TestCase): ofport = "6" utils.execute(["ovs-vsctl", self.TO, "get", "Interface", pname, "ofport"], - root_helper=self.root_helper).AndReturn(ofport) + root_helper=self.root_helper).AndReturn(ofport) self.mox.ReplayAll() self.assertEqual(self.br.get_port_ofport(pname), ofport) @@ -146,8 +146,8 @@ class OVS_Lib_Test(unittest.TestCase): def test_count_flows(self): utils.execute(["ovs-ofctl", "dump-flows", self.BR_NAME], - root_helper=self.root_helper).\ - AndReturn("ignore\nflow-1\n") + root_helper=self.root_helper).AndReturn('ignore' + '\nflow-1\n') self.mox.ReplayAll() # counts the number of flows as total lines of output - 2 @@ -159,11 +159,11 @@ class OVS_Lib_Test(unittest.TestCase): lsw_id = 40 vid = 39 utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME, - "in_port=" + ofport], root_helper=self.root_helper) + "in_port=" + ofport], root_helper=self.root_helper) utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME, - "tun_id=%s" % lsw_id], root_helper=self.root_helper) + "tun_id=%s" % lsw_id], root_helper=self.root_helper) utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME, - "dl_vlan=%s" % vid], root_helper=self.root_helper) + "dl_vlan=%s" % vid], root_helper=self.root_helper) self.mox.ReplayAll() self.br.delete_flows(in_port=ofport) @@ -177,20 +177,20 @@ class OVS_Lib_Test(unittest.TestCase): ofport = "6" utils.execute(["ovs-vsctl", self.TO, "add-port", - self.BR_NAME, pname], root_helper=self.root_helper) + self.BR_NAME, pname], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "set", "Interface", - pname, "type=gre"], root_helper=self.root_helper) + pname, "type=gre"], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "set", "Interface", - pname, "options:remote_ip=" + ip], + pname, "options:remote_ip=" + ip], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "set", "Interface", - pname, "options:in_key=flow"], + pname, "options:in_key=flow"], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "set", "Interface", - pname, "options:out_key=flow"], + pname, "options:out_key=flow"], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "get", - "Interface", pname, "ofport"], + "Interface", pname, "ofport"], root_helper=self.root_helper).AndReturn(ofport) self.mox.ReplayAll() @@ -203,14 +203,14 @@ class OVS_Lib_Test(unittest.TestCase): ofport = "6" utils.execute(["ovs-vsctl", self.TO, "add-port", - self.BR_NAME, pname], root_helper=self.root_helper) + self.BR_NAME, pname], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "set", "Interface", - pname, "type=patch"], root_helper=self.root_helper) + pname, "type=patch"], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "set", - "Interface", pname, "options:peer=" + peer], + "Interface", pname, "options:peer=" + peer], root_helper=self.root_helper) utils.execute(["ovs-vsctl", self.TO, "get", - "Interface", pname, "ofport"], + "Interface", pname, "ofport"], root_helper=self.root_helper).AndReturn(ofport) self.mox.ReplayAll() @@ -234,14 +234,14 @@ class OVS_Lib_Test(unittest.TestCase): % (vif_id, mac)) utils.execute(["ovs-vsctl", self.TO, "get", - "Interface", pname, "external_ids"], + "Interface", pname, "external_ids"], root_helper=self.root_helper).AndReturn(external_ids) utils.execute(["ovs-vsctl", self.TO, "get", - "Interface", pname, "ofport"], + "Interface", pname, "ofport"], root_helper=self.root_helper).AndReturn(ofport) if is_xen: utils.execute(["xe", "vif-param-get", "param-name=other-config", - "param-key=nicira-iface-id", "uuid=" + vif_id], + "param-key=nicira-iface-id", "uuid=" + vif_id], root_helper=self.root_helper).AndReturn(vif_id) self.mox.ReplayAll() @@ -263,7 +263,7 @@ class OVS_Lib_Test(unittest.TestCase): def test_clear_db_attribute(self): pname = "tap77" utils.execute(["ovs-vsctl", self.TO, "clear", "Port", - pname, "tag"], root_helper=self.root_helper) + pname, "tag"], root_helper=self.root_helper) self.mox.ReplayAll() self.br.clear_db_attribute("Port", pname, "tag") self.mox.VerifyAll() diff --git a/quantum/tests/unit/test_setup.py b/quantum/tests/unit/test_setup.py index 1c8773891f..e8a50ae5fa 100644 --- a/quantum/tests/unit/test_setup.py +++ b/quantum/tests/unit/test_setup.py @@ -38,19 +38,19 @@ class SetupTest(unittest.TestCase): with open(self.mailmap, 'w') as mm_fh: mm_fh.write("Foo Bar Foo Bar \n") self.assertEqual({'': ''}, - parse_mailmap(self.mailmap)) + parse_mailmap(self.mailmap)) def test_mailmap_with_firstname(self): with open(self.mailmap, 'w') as mm_fh: mm_fh.write("Foo Foo \n") self.assertEqual({'': ''}, - parse_mailmap(self.mailmap)) + parse_mailmap(self.mailmap)) def test_mailmap_with_noname(self): with open(self.mailmap, 'w') as mm_fh: mm_fh.write(" \n") self.assertEqual({'': ''}, - parse_mailmap(self.mailmap)) + parse_mailmap(self.mailmap)) def tearDown(self): if os.path.exists(self.mailmap): diff --git a/quantum/wsgi.py b/quantum/wsgi.py index c0e0aff6de..c0728730e1 100644 --- a/quantum/wsgi.py +++ b/quantum/wsgi.py @@ -485,8 +485,8 @@ class RequestDeserializer(object): } self.body_deserializers.update(body_deserializers or {}) - self.headers_deserializer = headers_deserializer or \ - RequestHeadersDeserializer() + self.headers_deserializer = (headers_deserializer or + RequestHeadersDeserializer()) def deserialize(self, request): """Extract necessary pieces of the request. @@ -767,7 +767,7 @@ class Resource(Application): """WSGI method that controls (de)serialization and method dispatch.""" LOG.info("%(method)s %(url)s" % {"method": request.method, - "url": request.url}) + "url": request.url}) try: action, args, accept = self.deserializer.deserialize(request) diff --git a/tools/install_venv.py b/tools/install_venv.py index 50b1a3a486..a8314f5df5 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -61,15 +61,15 @@ def run_command(cmd, redirect_output=True, check_exit_code=True): HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'], check_exit_code=False).strip()) HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'], - check_exit_code=False).strip()) + check_exit_code=False).strip()) def check_dependencies(): """Make sure virtualenv is in the path.""" if not HAS_VIRTUALENV: - raise Exception('Virtualenv not found. ' + - 'Try installing python-virtualenv') + raise Exception('Virtualenv not found. ' + 'Try installing python-virtualenv') print 'done.'