diff --git a/nova/api/openstack/compute/plugins/v3/agents.py b/nova/api/openstack/compute/plugins/v3/agents.py index 285d196a3d1..da6297c36df 100644 --- a/nova/api/openstack/compute/plugins/v3/agents.py +++ b/nova/api/openstack/compute/plugins/v3/agents.py @@ -168,5 +168,6 @@ def get_resources(self): def get_controller_extensions(self): """It's an abstract function V3APIExtensionBase and the extension - will not be loaded without it.""" + will not be loaded without it. + """ return [] diff --git a/nova/api/openstack/compute/plugins/v3/coverage.py b/nova/api/openstack/compute/plugins/v3/coverage.py index 9f21caac8bd..b8e1ec6be0e 100644 --- a/nova/api/openstack/compute/plugins/v3/coverage.py +++ b/nova/api/openstack/compute/plugins/v3/coverage.py @@ -39,9 +39,9 @@ authorize = extensions.extension_authorizer('compute', 'v3:' + ALIAS) CONF = cfg.CONF + def _import_coverage(): - """ This function ensure loading coverage module from python-coverage. - """ + """This function ensure loading coverage module from python-coverage.""" try: path = sys.path[:] if os.getcwd() in path: diff --git a/nova/api/openstack/compute/plugins/v3/extension_info.py b/nova/api/openstack/compute/plugins/v3/extension_info.py index c626f6104ad..e862054c31a 100644 --- a/nova/api/openstack/compute/plugins/v3/extension_info.py +++ b/nova/api/openstack/compute/plugins/v3/extension_info.py @@ -69,7 +69,7 @@ def _translate(self, ext): return ext_data def _get_extensions(self, context): - """Filter extensions list based on policy""" + """Filter extensions list based on policy.""" discoverable_extensions = dict() for alias, ext in self.extension_info.get_extensions().iteritems(): @@ -78,7 +78,8 @@ def _get_extensions(self, context): if authorize(context, action='discoverable'): discoverable_extensions[alias] = ext else: - LOG.debug(_("Filter out extension %s from discover list"), alias) + LOG.debug(_("Filter out extension %s from discover list"), + alias) return discoverable_extensions @wsgi.serializers(xml=ExtensionsTemplate) diff --git a/nova/api/openstack/compute/plugins/v3/flavors.py b/nova/api/openstack/compute/plugins/v3/flavors.py index 31c0fa8b746..57125ad4507 100644 --- a/nova/api/openstack/compute/plugins/v3/flavors.py +++ b/nova/api/openstack/compute/plugins/v3/flavors.py @@ -146,7 +146,7 @@ def _get_flavors(self, req): class Flavors(extensions.V3APIExtensionBase): - """ Flavors Extension. """ + """Flavors Extension.""" name = "flavors" alias = "flavors" namespace = "http://docs.openstack.org/compute/core/flavors/v3" diff --git a/nova/api/openstack/compute/plugins/v3/hosts.py b/nova/api/openstack/compute/plugins/v3/hosts.py index e0ea1203b20..88f351120cb 100644 --- a/nova/api/openstack/compute/plugins/v3/hosts.py +++ b/nova/api/openstack/compute/plugins/v3/hosts.py @@ -201,7 +201,8 @@ def read_enabled(orig_val, msg): def _set_host_maintenance(self, context, host_name, mode=True): """Start/Stop host maintenance window. On start, it triggers - guest VMs evacuation.""" + guest VMs evacuation. + """ LOG.audit(_("Putting host %(host_name)s in maintenance mode " "%(mode)s."), {'host_name': host_name, 'mode': mode}) @@ -219,7 +220,8 @@ def _set_host_maintenance(self, context, host_name, mode=True): def _set_enabled_status(self, context, host_name, enabled): """Sets the specified host's ability to accept new instances. :param enabled: a boolean - if False no new VMs will be able to start - on the host""" + on the host. + """ if enabled: LOG.audit(_("Enabling host %s.") % host_name) else: diff --git a/nova/api/openstack/compute/plugins/v3/instance_usage_audit_log.py b/nova/api/openstack/compute/plugins/v3/instance_usage_audit_log.py index d74c999153b..93327b3c5cf 100644 --- a/nova/api/openstack/compute/plugins/v3/instance_usage_audit_log.py +++ b/nova/api/openstack/compute/plugins/v3/instance_usage_audit_log.py @@ -138,5 +138,6 @@ def get_resources(self): def get_controller_extensions(self): """It's an abstract function V3APIExtensionBase and the extension - will not be loaded without it.""" + will not be loaded without it. + """ return [] diff --git a/nova/api/openstack/compute/plugins/v3/scheduler_hints.py b/nova/api/openstack/compute/plugins/v3/scheduler_hints.py index 142c7bb6488..4c01baa3afc 100644 --- a/nova/api/openstack/compute/plugins/v3/scheduler_hints.py +++ b/nova/api/openstack/compute/plugins/v3/scheduler_hints.py @@ -21,6 +21,7 @@ ALIAS = "os-scheduler-hints" + class SchedulerHintsController(wsgi.Controller): @staticmethod diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index bca1994408d..57f1d1ac096 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -462,7 +462,7 @@ def check_whiteblack_lists(ext): # Check whitelist is either empty or if not then the extension # is in the whitelist if (not CONF.osapi_v3.extensions_whitelist or - ext.obj.alias in CONF.osapi_v3.extensions_whitelist): + ext.obj.alias in CONF.osapi_v3.extensions_whitelist): # Check the extension is not in the blacklist if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist: diff --git a/nova/api/openstack/compute/plugins/v3/simple_tenant_usage.py b/nova/api/openstack/compute/plugins/v3/simple_tenant_usage.py index e386b02f829..491e3f58af2 100644 --- a/nova/api/openstack/compute/plugins/v3/simple_tenant_usage.py +++ b/nova/api/openstack/compute/plugins/v3/simple_tenant_usage.py @@ -289,5 +289,6 @@ def get_resources(self): def get_controller_extensions(self): """It's an abstract function V3APIExtensionBase and the extension - will not be loaded without it.""" + will not be loaded without it. + """ return [] diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_cells.py b/nova/tests/api/openstack/compute/plugins/v3/test_cells.py index f369c06e3b0..65b14e7606b 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_cells.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_cells.py @@ -19,7 +19,6 @@ from webob import exc from nova.api.openstack.compute.plugins.v3 import cells as cells_ext -from nova.api.openstack import extensions from nova.api.openstack import xmlutil from nova.cells import rpcapi as cells_rpcapi from nova import context diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_config_drive.py b/nova/tests/api/openstack/compute/plugins/v3/test_config_drive.py index 98be4ce1bee..fc5efba3ba7 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_config_drive.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_config_drive.py @@ -19,8 +19,8 @@ from oslo.config import cfg import webob -from nova.api.openstack.compute.plugins.v3 import config_drive from nova.api.openstack.compute import plugins +from nova.api.openstack.compute.plugins.v3 import config_drive from nova.api.openstack.compute.plugins.v3 import servers from nova.compute import api as compute_api from nova.compute import flavors @@ -62,7 +62,7 @@ def test_show(self): req = webob.Request.blank('/v3/servers/1') req.headers['Content-Type'] = 'application/json' response = req.get_response(fakes.wsgi_app_v3( - init_only=('servers','os-config-drive'))) + init_only=('servers', 'os-config-drive'))) self.assertEquals(response.status_int, 200) res_dict = jsonutils.loads(response.body) self.assertTrue('config_drive' in res_dict['server']) @@ -141,7 +141,7 @@ def instance_update(context, uuid, values): def rpc_call_wrapper(context, topic, msg, timeout=None): """Stub out the scheduler creating the instance entry.""" if (topic == CONF.scheduler_topic and - msg['method'] == 'run_instance'): + msg['method'] == 'run_instance'): request_spec = msg['args']['request_spec'] num_instances = request_spec.get('num_instances', 1) instances = [] @@ -213,8 +213,8 @@ def create(*args, **kwargs): return old_create(*args, **kwargs) self.stubs.Set(compute_api.API, 'create', create) - self._test_create_extra(params, override_controller - =self.no_config_drive_controller) + self._test_create_extra(params, + override_controller=self.no_config_drive_controller) def test_create_instance_with_config_drive(self): def create(*args, **kwargs): @@ -324,4 +324,3 @@ def test_request_with_config_drive(self): }, } self.assertEquals(request['body'], expected) - diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_extension_info.py b/nova/tests/api/openstack/compute/plugins/v3/test_extension_info.py index a19d2806449..1a5ba4154cb 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_extension_info.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_extension_info.py @@ -40,9 +40,11 @@ def __init__(self, name, alias, description, namespace, version): 'ext3 namespace', 1) } + def fake_policy_enforce(context, action, target, do_raise=True): return True + def fake_policy_enforce_selective(context, action, target, do_raise=True): if action == 'compute_extension:v3:ext1-alias:discoverable': raise exception.NotAuthorized diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py b/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py index 7d9ec93df24..bbbaf8df8e0 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py @@ -18,8 +18,8 @@ from lxml import etree from webob import exc -from nova.api.openstack.compute.plugins.v3 import flavor_access from nova.api.openstack.compute import flavors as flavors_api +from nova.api.openstack.compute.plugins.v3 import flavor_access from nova.compute import flavors from nova import context from nova import exception diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_hypervisors.py b/nova/tests/api/openstack/compute/plugins/v3/test_hypervisors.py index 393e8fba41b..8c45f40a175 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_hypervisors.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_hypervisors.py @@ -17,7 +17,6 @@ from webob import exc from nova.api.openstack.compute.plugins.v3 import hypervisors -from nova import context from nova import db from nova.db.sqlalchemy import api as db_api from nova import exception @@ -324,8 +323,8 @@ def test_uptime_non_integer_id(self): def test_uptime_non_admin(self): req = fakes.HTTPRequestV3.blank('/os-hypervisors/1/uptime') - self.assertRaises(exception.PolicyNotAuthorized, self.controller.uptime, - req, '1') + self.assertRaises(exception.PolicyNotAuthorized, + self.controller.uptime, req, '1') def test_search(self): req = fakes.HTTPRequestV3.blank('/os-hypervisors/hyper/search', diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_images.py b/nova/tests/api/openstack/compute/plugins/v3/test_images.py index 712e3c8a576..264a7d90944 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_images.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_images.py @@ -649,8 +649,10 @@ def detail(self, *args, **kwargs): raise exception.Invalid('meow') request = fakes.HTTPRequestV3.blank('/v3/os-images?marker=invalid') - controller = images.ImagesController(image_service=InvalidImageService()) - self.assertRaises(webob.exc.HTTPBadRequest, controller.detail, request) + controller = images.ImagesController( + image_service=InvalidImageService()) + self.assertRaises(webob.exc.HTTPBadRequest, controller.detail, + request) def test_generate_alternate_link(self): view = images_view.ViewBuilder() diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_quota_sets.py b/nova/tests/api/openstack/compute/plugins/v3/test_quota_sets.py index 48dee4f442a..3fdbf79572e 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_quota_sets.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_quota_sets.py @@ -20,7 +20,6 @@ import webob from nova.api.openstack.compute.plugins.v3 import quota_sets as quotas -from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova import context as context_maker from nova import quota diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_scheduler_hints.py b/nova/tests/api/openstack/compute/plugins/v3/test_scheduler_hints.py index 049b3ec6b53..b35b21eeb2b 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_scheduler_hints.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_scheduler_hints.py @@ -180,7 +180,7 @@ def instance_update(context, uuid, values): def rpc_call_wrapper(context, topic, msg, timeout=None): """Stub out the scheduler creating the instance entry.""" if (topic == CONF.scheduler_topic and - msg['method'] == 'run_instance'): + msg['method'] == 'run_instance'): request_spec = msg['args']['request_spec'] num_instances = request_spec.get('num_instances', 1) instances = [] @@ -253,8 +253,8 @@ def create(*args, **kwargs): return old_create(*args, **kwargs) self.stubs.Set(compute_api.API, 'create', create) - self._test_create_extra(params, override_controller - =self.no_scheduler_hints_controller) + self._test_create_extra(params, + override_controller=self.no_scheduler_hints_controller) def test_create_instance_with_scheduler_hints_enabled(self): hints = {'a': 'b'} @@ -268,6 +268,7 @@ def create(*args, **kwargs): self.stubs.Set(compute_api.API, 'create', create) self._test_create_extra(params) + class TestServerCreateRequestXMLDeserializer(test.TestCase): def setUp(self): @@ -306,4 +307,3 @@ def test_request_with_scheduler_hints_and_alternate_namespace_prefix(self): } } self.assertEquals(request['body'], expected) - diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py b/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py index 61b78fea87e..ff6b8ee80e5 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_server_diagnostics.py @@ -45,7 +45,8 @@ def setUp(self): fake_get_diagnostics) self.stubs.Set(compute_api.API, 'get', fake_instance_get) - self.router = compute.APIRouterV3(init_only=('servers', 'os-server-diagnostics')) + self.router = compute.APIRouterV3(init_only=('servers', + 'os-server-diagnostics')) def test_get_diagnostics(self): req = fakes.HTTPRequestV3.blank( diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_servers.py b/nova/tests/api/openstack/compute/plugins/v3/test_servers.py index 66642868911..cbadbe3b256 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_servers.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_servers.py @@ -234,7 +234,8 @@ def test_get_server_by_uuid(self): def test_unique_host_id(self): """Create two servers with the same host and different - project_ids and check that the hostId's are unique""" + project_ids and check that the hostId's are unique. + """ def return_instance_with_host(self, *args): project_id = str(uuid.uuid4()) return fakes.stub_instance(id=1, uuid=FAKE_UUID, diff --git a/tox.ini b/tox.ini index dcdd4bc3922..a46d87dbd6d 100644 --- a/tox.ini +++ b/tox.ini @@ -41,7 +41,7 @@ commands = {posargs} [flake8] ignore = E121,E122,E123,E124,E126,E127,E128,E711,E712,H302,H303,H404,F403,F811,F841,N309 builtins = _ -exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,plugins,tools +exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*plugins/xenserver*,tools [hacking] local-check-factory = nova.hacking.checks.factory