summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/api/ec2/cloud.py2
-rw-r--r--nova/api/openstack/compute/contrib/flavorextraspecs.py10
-rw-r--r--nova/api/openstack/compute/contrib/keypairs.py4
-rw-r--r--nova/api/openstack/compute/server_metadata.py8
-rw-r--r--nova/block_device.py2
-rw-r--r--nova/compute/api.py7
-rw-r--r--nova/compute/manager.py2
-rw-r--r--nova/db/sqlalchemy/session.py6
-rw-r--r--nova/network/dns_driver.py2
-rw-r--r--nova/network/linux_net.py6
-rw-r--r--nova/network/minidns.py18
-rw-r--r--nova/network/noop_dns_driver.py2
-rw-r--r--nova/servicegroup/api.py2
-rw-r--r--nova/tests/api/openstack/compute/test_servers.py9
-rw-r--r--nova/tests/api/openstack/test_common.py38
-rw-r--r--nova/tests/compute/test_compute.py6
-rw-r--r--nova/tests/integrated/test_api_samples.py2
-rw-r--r--nova/tests/monkey_patch_example/__init__.py2
-rw-r--r--nova/tests/test_api.py2
-rw-r--r--nova/tests/test_db_api.py4
-rw-r--r--nova/tests/test_libvirt.py10
-rw-r--r--nova/tests/test_xenapi.py2
-rw-r--r--nova/tests/xenapi/stubs.py10
-rw-r--r--nova/utils.py2
-rw-r--r--nova/virt/fake.py3
-rw-r--r--nova/virt/firewall.py2
-rw-r--r--nova/virt/hyperv/hostops.py4
-rw-r--r--nova/virt/hyperv/vmops.py6
-rw-r--r--nova/virt/hyperv/volumeutils.py4
-rw-r--r--nova/virt/hyperv/volumeutilsV2.py2
-rw-r--r--nova/virt/libvirt/driver.py9
-rw-r--r--nova/virt/libvirt/vif.py2
-rw-r--r--nova/virt/libvirt/volume_nfs.py4
-rw-r--r--nova/virt/xenapi/driver.py26
-rw-r--r--nova/virt/xenapi/firewall.py5
-rw-r--r--nova/virt/xenapi/vmops.py10
-rwxr-xr-xrun_tests.sh2
-rwxr-xr-xtools/hacking.py17
-rw-r--r--tox.ini4
39 files changed, 130 insertions, 128 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index d40f25c4d..a764a99bf 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -201,7 +201,7 @@ def _format_mappings(properties, result):
class CloudController(object):
- """ CloudController provides the critical dispatch between
+ """CloudController provides the critical dispatch between
inbound API calls through the endpoint and messages
sent to the other nodes.
"""
diff --git a/nova/api/openstack/compute/contrib/flavorextraspecs.py b/nova/api/openstack/compute/contrib/flavorextraspecs.py
index 77af25c9f..1abb525ad 100644
--- a/nova/api/openstack/compute/contrib/flavorextraspecs.py
+++ b/nova/api/openstack/compute/contrib/flavorextraspecs.py
@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-""" The instance type extra specs extension"""
+"""The instance type extra specs extension"""
from webob import exc
@@ -35,7 +35,7 @@ class ExtraSpecsTemplate(xmlutil.TemplateBuilder):
class FlavorExtraSpecsController(object):
- """ The flavor extra specs API controller for the OpenStack API """
+ """The flavor extra specs API controller for the OpenStack API """
def _get_extra_specs(self, context, flavor_id):
extra_specs = db.instance_type_extra_specs_get(context, flavor_id)
@@ -51,7 +51,7 @@ class FlavorExtraSpecsController(object):
@wsgi.serializers(xml=ExtraSpecsTemplate)
def index(self, req, flavor_id):
- """ Returns the list of extra specs for a givenflavor """
+ """Returns the list of extra specs for a givenflavor """
context = req.environ['nova.context']
authorize(context)
return self._get_extra_specs(context, flavor_id)
@@ -92,7 +92,7 @@ class FlavorExtraSpecsController(object):
@wsgi.serializers(xml=ExtraSpecsTemplate)
def show(self, req, flavor_id, id):
- """ Return a single extra spec item """
+ """Return a single extra spec item """
context = req.environ['nova.context']
authorize(context)
specs = self._get_extra_specs(context, flavor_id)
@@ -102,7 +102,7 @@ class FlavorExtraSpecsController(object):
raise exc.HTTPNotFound()
def delete(self, req, flavor_id, id):
- """ Deletes an existing extra spec """
+ """Deletes an existing extra spec """
context = req.environ['nova.context']
authorize(context)
db.instance_type_extra_specs_delete(context, flavor_id, id)
diff --git a/nova/api/openstack/compute/contrib/keypairs.py b/nova/api/openstack/compute/contrib/keypairs.py
index e5e1e37fd..9b3b39384 100644
--- a/nova/api/openstack/compute/contrib/keypairs.py
+++ b/nova/api/openstack/compute/contrib/keypairs.py
@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-""" Keypair management extension"""
+"""Keypair management extension"""
import webob
import webob.exc
@@ -49,7 +49,7 @@ class KeypairsTemplate(xmlutil.TemplateBuilder):
class KeypairController(object):
- """ Keypair API controller for the OpenStack API """
+ """Keypair API controller for the OpenStack API """
def __init__(self):
self.api = compute_api.KeypairAPI()
diff --git a/nova/api/openstack/compute/server_metadata.py b/nova/api/openstack/compute/server_metadata.py
index 4e5a3ee02..910d88c30 100644
--- a/nova/api/openstack/compute/server_metadata.py
+++ b/nova/api/openstack/compute/server_metadata.py
@@ -24,7 +24,7 @@ from nova import exception
class Controller(object):
- """ The server metadata API controller for the OpenStack API """
+ """The server metadata API controller for the OpenStack API """
def __init__(self):
self.compute_api = compute.API()
@@ -45,7 +45,7 @@ class Controller(object):
@wsgi.serializers(xml=common.MetadataTemplate)
def index(self, req, server_id):
- """ Returns the list of metadata for a given instance """
+ """Returns the list of metadata for a given instance """
context = req.environ['nova.context']
return {'metadata': self._get_metadata(context, server_id)}
@@ -138,7 +138,7 @@ class Controller(object):
@wsgi.serializers(xml=common.MetaItemTemplate)
def show(self, req, server_id, id):
- """ Return a single metadata item """
+ """Return a single metadata item """
context = req.environ['nova.context']
data = self._get_metadata(context, server_id)
@@ -150,7 +150,7 @@ class Controller(object):
@wsgi.response(204)
def delete(self, req, server_id, id):
- """ Deletes an existing metadata """
+ """Deletes an existing metadata """
context = req.environ['nova.context']
metadata = self._get_metadata(context, server_id)
diff --git a/nova/block_device.py b/nova/block_device.py
index ea4ff9c3b..7e1e5374a 100644
--- a/nova/block_device.py
+++ b/nova/block_device.py
@@ -83,7 +83,7 @@ _pref = re.compile('^((x?v|s)d)')
def strip_prefix(device_name):
- """ remove both leading /dev/ and xvd or sd or vd """
+ """remove both leading /dev/ and xvd or sd or vd """
device_name = strip_dev(device_name)
return _pref.sub('', device_name)
diff --git a/nova/compute/api.py b/nova/compute/api.py
index abbc0bd92..f42891f89 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -313,9 +313,10 @@ class API(base.Base):
raise exception.InvalidMetadataSize(reason=msg)
def _check_requested_networks(self, context, requested_networks):
- """ Check if the networks requested belongs to the project
- and the fixed IP address for each network provided is within
- same the network block
+ """
+ Check if the networks requested belongs to the project
+ and the fixed IP address for each network provided is within
+ same the network block
"""
if not requested_networks:
return
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index b161f504c..f1a68345c 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -2809,7 +2809,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_ref, dest)
def rollback_live_migration_at_destination(self, context, instance):
- """ Cleaning up image directory that is created pre_live_migration.
+ """Cleaning up image directory that is created pre_live_migration.
:param context: security context
:param instance: an Instance dict sent over rpc
diff --git a/nova/db/sqlalchemy/session.py b/nova/db/sqlalchemy/session.py
index 5263b9674..7c52cd36c 100644
--- a/nova/db/sqlalchemy/session.py
+++ b/nova/db/sqlalchemy/session.py
@@ -335,8 +335,10 @@ _RE_DB = {
def raise_if_duplicate_entry_error(integrity_error, engine_name):
- """ In this function will be raised DBDuplicateEntry exception if integrity
- error wrap unique constraint violation. """
+ """
+ In this function will be raised DBDuplicateEntry exception if integrity
+ error wrap unique constraint violation.
+ """
def get_columns_from_uniq_cons_or_name(columns):
# note(boris-42): UniqueConstraint name convention: "uniq_c1_x_c2_x_c3"
diff --git a/nova/network/dns_driver.py b/nova/network/dns_driver.py
index 09335b7cc..6e7cbf556 100644
--- a/nova/network/dns_driver.py
+++ b/nova/network/dns_driver.py
@@ -14,7 +14,7 @@
class DNSDriver(object):
- """ Defines the DNS manager interface. Does nothing. """
+ """Defines the DNS manager interface. Does nothing. """
def __init__(self):
pass
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 77a1014a3..215dd0092 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -1134,8 +1134,10 @@ def get_dev(network):
class LinuxNetInterfaceDriver(object):
- """Abstract class that defines generic network host API"""
- """ for for all Linux interface drivers."""
+ """
+ Abstract class that defines generic network host API
+ for for all Linux interface drivers.
+ """
def plug(self, network, mac_address):
"""Create Linux device, return device name"""
diff --git a/nova/network/minidns.py b/nova/network/minidns.py
index 11c59dcc9..c565f368e 100644
--- a/nova/network/minidns.py
+++ b/nova/network/minidns.py
@@ -27,14 +27,16 @@ LOG = logging.getLogger(__name__)
class MiniDNS(dns_driver.DNSDriver):
- """ Trivial DNS driver. This will read/write to a local, flat file
- and have no effect on your actual DNS system. This class is
- strictly for testing purposes, and should keep you out of dependency
- hell.
-
- Note that there is almost certainly a race condition here that
- will manifest anytime instances are rapidly created and deleted.
- A proper implementation will need some manner of locking."""
+ """
+ Trivial DNS driver. This will read/write to a local, flat file
+ and have no effect on your actual DNS system. This class is
+ strictly for testing purposes, and should keep you out of dependency
+ hell.
+
+ Note that there is almost certainly a race condition here that
+ will manifest anytime instances are rapidly created and deleted.
+ A proper implementation will need some manner of locking.
+ """
def __init__(self):
if CONF.log_dir:
diff --git a/nova/network/noop_dns_driver.py b/nova/network/noop_dns_driver.py
index 23d1d1f3e..be29f4d9a 100644
--- a/nova/network/noop_dns_driver.py
+++ b/nova/network/noop_dns_driver.py
@@ -19,7 +19,7 @@ from nova.network import dns_driver
class NoopDNSDriver(dns_driver.DNSDriver):
- """ No-op DNS manager. Does nothing. """
+ """No-op DNS manager. Does nothing. """
def __init__(self):
pass
diff --git a/nova/servicegroup/api.py b/nova/servicegroup/api.py
index 59afb68e0..895fc8490 100644
--- a/nova/servicegroup/api.py
+++ b/nova/servicegroup/api.py
@@ -110,7 +110,7 @@ class ServiceGroupDriver(object):
raise NotImplementedError()
def is_up(self, member):
- """ Check whether the given member is up. """
+ """Check whether the given member is up. """
raise NotImplementedError()
def leave(self, member_id, group_id):
diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py
index f916925fd..938783be7 100644
--- a/nova/tests/api/openstack/compute/test_servers.py
+++ b/nova/tests/api/openstack/compute/test_servers.py
@@ -1782,17 +1782,12 @@ class ServersControllerCreateTest(test.TestCase):
fake_method)
def _check_admin_pass_len(self, server_dict):
- """ utility function - check server_dict for adminPass
- length.
-
- """
+ """utility function - check server_dict for adminPass length."""
self.assertEqual(CONF.password_length,
len(server_dict["adminPass"]))
def _check_admin_pass_missing(self, server_dict):
- """ utility function - check server_dict for absence
- of adminPass
- """
+ """utility function - check server_dict for absence of adminPass."""
self.assertTrue("adminPass" not in server_dict)
def _test_create_instance(self):
diff --git a/nova/tests/api/openstack/test_common.py b/nova/tests/api/openstack/test_common.py
index 28bbb3d25..db1c9ede2 100644
--- a/nova/tests/api/openstack/test_common.py
+++ b/nova/tests/api/openstack/test_common.py
@@ -43,7 +43,7 @@ class LimiterTest(test.TestCase):
"""
def setUp(self):
- """ Run before each test. """
+ """Run before each test. """
super(LimiterTest, self).setUp()
self.tiny = range(1)
self.small = range(10)
@@ -51,7 +51,7 @@ class LimiterTest(test.TestCase):
self.large = range(10000)
def test_limiter_offset_zero(self):
- """ Test offset key works with 0. """
+ """Test offset key works with 0. """
req = webob.Request.blank('/?offset=0')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@@ -59,7 +59,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_offset_medium(self):
- """ Test offset key works with a medium sized number. """
+ """Test offset key works with a medium sized number. """
req = webob.Request.blank('/?offset=10')
self.assertEqual(common.limited(self.tiny, req), [])
self.assertEqual(common.limited(self.small, req), self.small[10:])
@@ -67,7 +67,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[10:1010])
def test_limiter_offset_over_max(self):
- """ Test offset key works with a number over 1000 (max_limit). """
+ """Test offset key works with a number over 1000 (max_limit). """
req = webob.Request.blank('/?offset=1001')
self.assertEqual(common.limited(self.tiny, req), [])
self.assertEqual(common.limited(self.small, req), [])
@@ -76,19 +76,19 @@ class LimiterTest(test.TestCase):
common.limited(self.large, req), self.large[1001:2001])
def test_limiter_offset_blank(self):
- """ Test offset key works with a blank offset. """
+ """Test offset key works with a blank offset. """
req = webob.Request.blank('/?offset=')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
def test_limiter_offset_bad(self):
- """ Test offset key works with a BAD offset. """
+ """Test offset key works with a BAD offset. """
req = webob.Request.blank(u'/?offset=\u0020aa')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
def test_limiter_nothing(self):
- """ Test request with no offset or limit """
+ """Test request with no offset or limit """
req = webob.Request.blank('/')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@@ -96,7 +96,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_limit_zero(self):
- """ Test limit of zero. """
+ """Test limit of zero. """
req = webob.Request.blank('/?limit=0')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@@ -104,7 +104,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_limit_medium(self):
- """ Test limit of 10. """
+ """Test limit of 10. """
req = webob.Request.blank('/?limit=10')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@@ -112,7 +112,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:10])
def test_limiter_limit_over_max(self):
- """ Test limit of 3000. """
+ """Test limit of 3000. """
req = webob.Request.blank('/?limit=3000')
self.assertEqual(common.limited(self.tiny, req), self.tiny)
self.assertEqual(common.limited(self.small, req), self.small)
@@ -120,7 +120,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(self.large, req), self.large[:1000])
def test_limiter_limit_and_offset(self):
- """ Test request with both limit and offset. """
+ """Test request with both limit and offset. """
items = range(2000)
req = webob.Request.blank('/?offset=1&limit=3')
self.assertEqual(common.limited(items, req), items[1:4])
@@ -132,7 +132,7 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(items, req), [])
def test_limiter_custom_max_limit(self):
- """ Test a max_limit other than 1000. """
+ """Test a max_limit other than 1000. """
items = range(2000)
req = webob.Request.blank('/?offset=1&limit=3')
self.assertEqual(
@@ -147,13 +147,13 @@ class LimiterTest(test.TestCase):
self.assertEqual(common.limited(items, req, max_limit=2000), [])
def test_limiter_negative_limit(self):
- """ Test a negative limit. """
+ """Test a negative limit. """
req = webob.Request.blank('/?limit=-3000')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
def test_limiter_negative_offset(self):
- """ Test a negative offset. """
+ """Test a negative offset. """
req = webob.Request.blank('/?offset=-30')
self.assertRaises(
webob.exc.HTTPBadRequest, common.limited, self.tiny, req)
@@ -167,30 +167,30 @@ class PaginationParamsTest(test.TestCase):
"""
def test_no_params(self):
- """ Test no params. """
+ """Test no params. """
req = webob.Request.blank('/')
self.assertEqual(common.get_pagination_params(req), {})
def test_valid_marker(self):
- """ Test valid marker param. """
+ """Test valid marker param. """
req = webob.Request.blank(
'/?marker=263abb28-1de6-412f-b00b-f0ee0c4333c2')
self.assertEqual(common.get_pagination_params(req),
{'marker': '263abb28-1de6-412f-b00b-f0ee0c4333c2'})
def test_valid_limit(self):
- """ Test valid limit param. """
+ """Test valid limit param. """
req = webob.Request.blank('/?limit=10')
self.assertEqual(common.get_pagination_params(req), {'limit': 10})
def test_invalid_limit(self):
- """ Test invalid limit param. """
+ """Test invalid limit param. """
req = webob.Request.blank('/?limit=-2')
self.assertRaises(
webob.exc.HTTPBadRequest, common.get_pagination_params, req)
def test_valid_limit_and_marker(self):
- """ Test valid limit and marker parameters. """
+ """Test valid limit and marker parameters. """
marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2'
req = webob.Request.blank('/?limit=20&marker=%s' % marker)
self.assertEqual(common.get_pagination_params(req),
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index dabb8bb89..9d8114ea2 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -573,7 +573,7 @@ class ComputeTestCase(BaseTestCase):
'task_state': task_states.SCHEDULING})
def test_run_instance_setup_block_device_mapping_fail(self):
- """ block device mapping failure test.
+ """block device mapping failure test.
Make sure that when there is a block device mapping problem,
the instance goes to ERROR state, keeping the task state
@@ -593,7 +593,7 @@ class ComputeTestCase(BaseTestCase):
'task_state': None})
def test_run_instance_spawn_fail(self):
- """ spawn failure test.
+ """spawn failure test.
Make sure that when there is a spawning problem,
the instance goes to ERROR state, keeping the task state"""
@@ -611,7 +611,7 @@ class ComputeTestCase(BaseTestCase):
'task_state': None})
def test_run_instance_dealloc_network_instance_not_found(self):
- """ spawn network deallocate test.
+ """spawn network deallocate test.
Make sure that when an instance is not found during spawn
that the network is deallocated"""
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index 8347f9bca..ef1f35a52 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -1533,7 +1533,7 @@ class AgentsJsonTest(ApiSampleTestBase):
return project
def test_agent_list(self):
- """ Return a list of all agent builds."""
+ """Return a list of all agent builds."""
response = self._do_get('os-agents')
self.assertEqual(response.status, 200)
project = {'url': 'xxxxxxxxxxxx',
diff --git a/nova/tests/monkey_patch_example/__init__.py b/nova/tests/monkey_patch_example/__init__.py
index 25cf9ccfe..779dc72f3 100644
--- a/nova/tests/monkey_patch_example/__init__.py
+++ b/nova/tests/monkey_patch_example/__init__.py
@@ -21,7 +21,7 @@ CALLED_FUNCTION = []
def example_decorator(name, function):
- """ decorator for notify which is used from utils.monkey_patch()
+ """decorator for notify which is used from utils.monkey_patch()
:param name: name of the function
:param function: - object of the function
diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py
index 163afda7d..0835df51d 100644
--- a/nova/tests/test_api.py
+++ b/nova/tests/test_api.py
@@ -350,7 +350,7 @@ class ApiEc2TestCase(test.TestCase):
self.ec2.delete_security_group(security_group_name)
def test_group_name_valid_chars_security_group(self):
- """ Test that we sanely handle invalid security group names.
+ """Test that we sanely handle invalid security group names.
EC2 API Spec states we should only accept alphanumeric characters,
spaces, dashes, and underscores. Amazon implementation
accepts more characters - so, [:print:] is ok. """
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index a17113a42..6ebfe6d3c 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -321,7 +321,7 @@ class DbApiTestCase(test.TestCase):
inst['uuid'], 'vm_state', [None, 'disable'], 'run')
def test_instance_update_with_instance_uuid(self):
- """ test instance_update() works when an instance UUID is passed """
+ """test instance_update() works when an instance UUID is passed """
ctxt = context.get_admin_context()
# Create an instance with some metadata
@@ -481,7 +481,7 @@ class DbApiTestCase(test.TestCase):
self.assertEqual(404, faults[uuid][0]['code'])
def test_instance_fault_get_by_instance(self):
- """ ensure we can retrieve an instance fault by instance UUID """
+ """ensure we can retrieve an instance fault by instance UUID """
ctxt = context.get_admin_context()
instance1 = db.instance_create(ctxt, {})
instance2 = db.instance_create(ctxt, {})
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 6bc18251f..a64b72695 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -4303,12 +4303,12 @@ class LibvirtDriverTestCase(test.TestCase):
self.stubs.Set(utils, 'execute', fake_execute)
ins_ref = self._create_instance()
- """ dest is different host case """
+ # dest is different host case
out = self.libvirtconnection.migrate_disk_and_power_off(
None, ins_ref, '10.0.0.2', None, None)
self.assertEquals(out, disk_info_text)
- """ dest is same host case """
+ # dest is same host case
out = self.libvirtconnection.migrate_disk_and_power_off(
None, ins_ref, '10.0.0.1', None, None)
self.assertEquals(out, disk_info_text)
@@ -4325,19 +4325,19 @@ class LibvirtDriverTestCase(test.TestCase):
self.stubs.Set(self.libvirtconnection, 'get_info',
fake_get_info)
- """ instance not found case """
+ # instance not found case
self.assertRaises(exception.NotFound,
self.libvirtconnection._wait_for_running,
{'name': 'not_found',
'uuid': 'not_found_uuid'})
- """ instance is running case """
+ # instance is running case
self.assertRaises(utils.LoopingCallDone,
self.libvirtconnection._wait_for_running,
{'name': 'running',
'uuid': 'running_uuid'})
- """ else case """
+ # else case
self.libvirtconnection._wait_for_running({'name': 'else',
'uuid': 'other_uuid'})
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 8b57dfef4..5b347fc0f 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -2509,7 +2509,7 @@ class StubDependencies(object):
class ResourcePoolWithStubs(StubDependencies, pool.ResourcePool):
- """ A ResourcePool, use stub dependencies """
+ """A ResourcePool, use stub dependencies """
class HypervisorPoolTestCase(test.TestCase):
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index ca8281295..a44f3e9fd 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -98,7 +98,7 @@ def stubout_determine_is_pv_objectstore(stubs):
def stubout_is_snapshot(stubs):
- """ Always returns true
+ """Always returns true
xenapi fake driver does not create vmrefs for snapshots """
def f(*args):
@@ -158,7 +158,7 @@ def _make_fake_vdi():
class FakeSessionForVMTests(fake.SessionBase):
- """ Stubs out a XenAPISession for VM tests """
+ """Stubs out a XenAPISession for VM tests """
_fake_iptables_save_output = ("# Generated by iptables-save v1.4.10 on "
"Sun Nov 6 22:49:02 2011\n"
@@ -204,7 +204,7 @@ class FakeSessionForVMTests(fake.SessionBase):
class FakeSessionForFirewallTests(FakeSessionForVMTests):
- """ Stubs out a XenApi Session for doing IPTable Firewall tests """
+ """Stubs out a XenApi Session for doing IPTable Firewall tests """
def __init__(self, uri, test_case=None):
super(FakeSessionForFirewallTests, self).__init__(uri)
@@ -270,7 +270,7 @@ def stub_out_vm_methods(stubs):
class FakeSessionForVolumeTests(fake.SessionBase):
- """ Stubs out a XenAPISession for Volume tests """
+ """Stubs out a XenAPISession for Volume tests """
def VDI_introduce(self, _1, uuid, _2, _3, _4, _5,
_6, _7, _8, _9, _10, _11):
valid_vdi = False
@@ -284,7 +284,7 @@ class FakeSessionForVolumeTests(fake.SessionBase):
class FakeSessionForVolumeFailedTests(FakeSessionForVolumeTests):
- """ Stubs out a XenAPISession for Volume tests: it injects failures """
+ """Stubs out a XenAPISession for Volume tests: it injects failures """
def VDI_introduce(self, _1, uuid, _2, _3, _4, _5,
_6, _7, _8, _9, _10, _11):
# This is for testing failure
diff --git a/nova/utils.py b/nova/utils.py
index 1056a6e2d..b9e8e239c 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -913,7 +913,7 @@ def is_valid_cidr(address):
def monkey_patch():
- """ If the Flags.monkey_patch set as True,
+ """If the Flags.monkey_patch set as True,
this function patches a decorator
for all functions in specified modules.
You can set decorators for each modules
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 5d3b3c926..c044a9abf 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -349,7 +349,7 @@ class FakeDriver(driver.ComputeDriver):
raise NotImplementedError('This method is supported only by libvirt.')
def test_remove_vm(self, instance_name):
- """ Removes the named VM, as if it crashed. For testing"""
+ """Removes the named VM, as if it crashed. For testing"""
self.instances.pop(instance_name)
def get_host_stats(self, refresh=False):
@@ -386,7 +386,6 @@ class FakeDriver(driver.ComputeDriver):
return 'disabled'
def get_disk_available_least(self):
- """ """
pass
def get_volume_connector(self, instance):
diff --git a/nova/virt/firewall.py b/nova/virt/firewall.py
index d7a5cbc31..178d35882 100644
--- a/nova/virt/firewall.py
+++ b/nova/virt/firewall.py
@@ -50,7 +50,7 @@ def load_driver(default, *args, **kwargs):
class FirewallDriver(object):
- """ Firewall Driver base class.
+ """Firewall Driver base class.
Defines methods that any driver providing security groups
and provider firewall functionality should implement.
diff --git a/nova/virt/hyperv/hostops.py b/nova/virt/hyperv/hostops.py
index 8c501ab30..5cbe46c1c 100644
--- a/nova/virt/hyperv/hostops.py
+++ b/nova/virt/hyperv/hostops.py
@@ -39,7 +39,7 @@ class HostOps(baseops.BaseOps):
self._stats = None
def _get_cpu_info(self):
- """ Get the CPU information.
+ """Get the CPU information.
:returns: A dictionary containing the main properties
of the central processor in the hypervisor.
"""
@@ -107,7 +107,7 @@ class HostOps(baseops.BaseOps):
return total_gb, used_gb
def _get_vcpu_used(self):
- """ Get vcpu usage number of physical computer.
+ """Get vcpu usage number of physical computer.
:returns: The total number of vcpu that currently used.
"""
#TODO(jordanrinke) figure out a way to count assigned VCPUs
diff --git a/nova/virt/hyperv/vmops.py b/nova/virt/hyperv/vmops.py
index 46fbd6cbc..680d57ce1 100644
--- a/nova/virt/hyperv/vmops.py
+++ b/nova/virt/hyperv/vmops.py
@@ -69,7 +69,7 @@ class VMOps(baseops.BaseOps):
self._volumeops = volumeops
def list_instances(self):
- """ Return the names of all the instances known to Hyper-V. """
+ """Return the names of all the instances known to Hyper-V. """
vms = [v.ElementName
for v in self._conn.Msvm_ComputerSystem(['ElementName'],
Caption="Virtual Machine")]
@@ -118,7 +118,7 @@ class VMOps(baseops.BaseOps):
def spawn(self, context, instance, image_meta, injected_files,
admin_password, network_info, block_device_info=None):
- """ Create a new VM and start it."""
+ """Create a new VM and start it."""
vm = self._vmutils.lookup(self._conn, instance['name'])
if vm is not None:
raise exception.InstanceExists(name=instance['name'])
@@ -271,7 +271,7 @@ class VMOps(baseops.BaseOps):
LOG.debug(_('Set vcpus for vm %s...'), instance["name"])
def _create_scsi_controller(self, vm_name):
- """ Create an iscsi controller ready to mount volumes """
+ """Create an iscsi controller ready to mount volumes """
LOG.debug(_('Creating a scsi controller for %(vm_name)s for volume '
'attaching') % locals())
vms = self._conn.MSVM_ComputerSystem(ElementName=vm_name)
diff --git a/nova/virt/hyperv/volumeutils.py b/nova/virt/hyperv/volumeutils.py
index 8ae437cf9..31c05b9ad 100644
--- a/nova/virt/hyperv/volumeutils.py
+++ b/nova/virt/hyperv/volumeutils.py
@@ -68,7 +68,7 @@ class VolumeUtils(basevolumeutils.BaseVolumeUtils):
time.sleep(CONF.hyperv_wait_between_attach_retry)
def logout_storage_target(self, target_iqn):
- """ Logs out storage target through its session id """
+ """Logs out storage target through its session id """
sessions = self._conn_wmi.query(
"SELECT * FROM MSiSCSIInitiator_SessionClass \
@@ -77,5 +77,5 @@ class VolumeUtils(basevolumeutils.BaseVolumeUtils):
self.execute_log_out(session.SessionId)
def execute_log_out(self, session_id):
- """ Executes log out of the session described by its session ID """
+ """Executes log out of the session described by its session ID """
self.execute('iscsicli.exe ' + 'logouttarget ' + session_id)
diff --git a/nova/virt/hyperv/volumeutilsV2.py b/nova/virt/hyperv/volumeutilsV2.py
index 8d7c91862..03e3002f4 100644
--- a/nova/virt/hyperv/volumeutilsV2.py
+++ b/nova/virt/hyperv/volumeutilsV2.py
@@ -53,7 +53,7 @@ class VolumeUtilsV2(basevolumeutils.BaseVolumeUtils):
time.sleep(CONF.hyperv_wait_between_attach_retry)
def logout_storage_target(self, target_iqn):
- """ Logs out storage target through its session id """
+ """Logs out storage target through its session id """
target = self._conn_storage.MSFT_iSCSITarget(
NodeAddress=target_iqn)[0]
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index e3d95c62e..f360e44bc 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2026,7 +2026,7 @@ class LibvirtDriver(driver.ComputeDriver):
return stats['total'] / (1024 ** 3)
def get_vcpu_used(self):
- """ Get vcpu usage number of physical computer.
+ """Get vcpu usage number of physical computer.
:returns: The total number of vcpu that currently used.
@@ -2581,9 +2581,7 @@ class LibvirtDriver(driver.ComputeDriver):
timer.start(interval=0.5).wait()
def _fetch_instance_kernel_ramdisk(self, context, instance):
- """ Download kernel and ramdisk for given instance in the given
- instance directory.
- """
+ """Download kernel and ramdisk for instance in instance directory."""
instance_dir = os.path.join(CONF.instances_path, instance['name'])
if instance['kernel_id']:
libvirt_utils.fetch_image(context,
@@ -3004,8 +3002,7 @@ class LibvirtDriver(driver.ComputeDriver):
def get_diagnostics(self, instance):
def get_io_devices(xml_doc):
- """ get the list of io devices from the
- xml document."""
+ """get the list of io devices from the xml document."""
result = {"volumes": [], "ifaces": []}
try:
doc = etree.fromstring(xml_doc)
diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py
index a3071e0c9..f65fa4a7e 100644
--- a/nova/virt/libvirt/vif.py
+++ b/nova/virt/libvirt/vif.py
@@ -273,7 +273,7 @@ class LibvirtOpenVswitchVirtualPortDriver(LibvirtBaseVIFDriver):
OVS virtual port XML (introduced in libvirt 0.9.11)."""
def get_config(self, instance, network, mapping):
- """ Pass data required to create OVS virtual port element"""
+ """Pass data required to create OVS virtual port element"""
conf = super(LibvirtOpenVswitchVirtualPortDriver,
self).get_config(instance,
network,
diff --git a/nova/virt/libvirt/volume_nfs.py b/nova/virt/libvirt/volume_nfs.py
index c78c4c1b2..fd01ada52 100644
--- a/nova/virt/libvirt/volume_nfs.py
+++ b/nova/virt/libvirt/volume_nfs.py
@@ -39,8 +39,8 @@ CONF.register_opts(volume_opts)
class NfsVolumeDriver(volume.LibvirtVolumeDriver):
- """ Class implements libvirt part of volume driver for NFS
- """
+ """Class implements libvirt part of volume driver for NFS."""
+
def __init__(self, *args, **kwargs):
"""Create back-end to nfs and check connection"""
super(NfsVolumeDriver, self).__init__(*args, **kwargs)
diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py
index d3047d364..a03e5eab1 100644
--- a/nova/virt/xenapi/driver.py
+++ b/nova/virt/xenapi/driver.py
@@ -189,7 +189,7 @@ class XenAPIDriver(driver.ComputeDriver):
block_device_info)
def snapshot(self, context, instance, image_id, update_task_state):
- """ Create snapshot from a running VM instance """
+ """Create snapshot from a running VM instance."""
self._vmops.snapshot(context, instance, image_id, update_task_state)
def reboot(self, instance, network_info, reboot_type,
@@ -515,24 +515,24 @@ class XenAPIDriver(driver.ComputeDriver):
return self._vmops.unfilter_instance(instance_ref, network_info)
def refresh_security_group_rules(self, security_group_id):
- """ Updates security group rules for all instances
- associated with a given security group
- Invoked when security group rules are updated
- """
+ """Updates security group rules for all instances associated with a
+ given security group.
+
+ Invoked when security group rules are updated."""
return self._vmops.refresh_security_group_rules(security_group_id)
def refresh_security_group_members(self, security_group_id):
- """ Updates security group rules for all instances
- associated with a given security group
- Invoked when instances are added/removed to a security group
- """
+ """Updates security group rules for all instances associated with a
+ given security group.
+
+ Invoked when instances are added/removed to a security group."""
return self._vmops.refresh_security_group_members(security_group_id)
def refresh_instance_security_rules(self, instance):
- """ Updates security group rules for specified instance
- Invoked when instances are added/removed to a security group
- or when a rule is added/removed to a security group
- """
+ """Updates security group rules for specified instance.
+
+ Invoked when instances are added/removed to a security group
+ or when a rule is added/removed to a security group."""
return self._vmops.refresh_instance_security_rules(instance)
def refresh_provider_fw_rules(self):
diff --git a/nova/virt/xenapi/firewall.py b/nova/virt/xenapi/firewall.py
index e30465741..9c6a60d18 100644
--- a/nova/virt/xenapi/firewall.py
+++ b/nova/virt/xenapi/firewall.py
@@ -27,12 +27,11 @@ LOG = logging.getLogger(__name__)
class Dom0IptablesFirewallDriver(firewall.IptablesFirewallDriver):
- """ Dom0IptablesFirewallDriver class
+ """Dom0IptablesFirewallDriver class
This class provides an implementation for nova.virt.Firewall
using iptables. This class is meant to be used with the xenapi
- backend and uses xenapi plugin to enforce iptables rules in dom0
-
+ backend and uses xenapi plugin to enforce iptables rules in dom0.
"""
def _plugin_execute(self, *cmd, **kwargs):
# Prepare arguments for plugin call
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index fbf3e0599..06e950f43 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1509,15 +1509,15 @@ class VMOps(object):
self._session.call_xenapi('VM.remove_from_xenstore_data', vm_ref, key)
def refresh_security_group_rules(self, security_group_id):
- """ recreates security group rules for every instance """
+ """recreates security group rules for every instance """
self.firewall_driver.refresh_security_group_rules(security_group_id)
def refresh_security_group_members(self, security_group_id):
- """ recreates security group rules for every instance """
+ """recreates security group rules for every instance """
self.firewall_driver.refresh_security_group_members(security_group_id)
def refresh_instance_security_rules(self, instance):
- """ recreates security group rules for specified instance """
+ """recreates security group rules for specified instance """
self.firewall_driver.refresh_instance_security_rules(instance)
def refresh_provider_fw_rules(self):
@@ -1600,8 +1600,8 @@ class VMOps(object):
def check_can_live_migrate_source(self, ctxt, instance_ref,
dest_check_data):
- """ Check if it is possible to execute live migration
- on the source side.
+ """Check if it's possible to execute live migration on the source side.
+
:param context: security context
:param instance_ref: nova.db.sqlalchemy.models.Instance object
:param dest_check_data: data returned by the check on the
diff --git a/run_tests.sh b/run_tests.sh
index a34cab5a0..c4a1d9efc 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -119,7 +119,7 @@ function run_pep8 {
srcfiles+=" setup.py"
# Until all these issues get fixed, ignore.
- ignore='--ignore=N4,E12,E711,E721,E712'
+ ignore='--ignore=N402,E12,E711,E721,E712'
${wrapper} python tools/hacking.py ${ignore} ${srcfiles}
diff --git a/tools/hacking.py b/tools/hacking.py
index bde4f42d4..a860aa37b 100755
--- a/tools/hacking.py
+++ b/tools/hacking.py
@@ -268,18 +268,23 @@ def nova_import_no_db_in_virt(logical_line, filename):
yield (0, "NOVA N307: nova.db import not allowed in nova/virt/*")
-def nova_docstring_start_space(physical_line):
+def nova_docstring_start_space(physical_line, previous_logical):
"""Check for docstring not start with space.
nova HACKING guide recommendation for docstring:
Docstring should not start with space
N401
"""
- pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE]) # start
- if (pos != -1 and len(physical_line) > pos + 1):
- if (physical_line[pos + 3] == ' '):
- return (pos, "NOVA N401: one line docstring should not start with"
- " a space")
+ # it's important that we determine this is actually a docstring,
+ # and not a doc block used somewhere after the first line of a
+ # function def
+ if (previous_logical.startswith("def ") or
+ previous_logical.startswith("class ")):
+ pos = max([physical_line.find(i) for i in DOCSTRING_TRIPLE])
+ if (pos != -1 and len(physical_line) > pos + 4):
+ if (physical_line[pos + 3] == ' '):
+ return (pos, "NOVA N401: docstring should not start with"
+ " a space")
def nova_docstring_one_line(physical_line):
diff --git a/tox.ini b/tox.ini
index a3e44630f..ca5e6e778 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,9 +18,9 @@ downloadcache = ~/cache/pip
[testenv:pep8]
deps=pep8==1.3.3
commands =
- python tools/hacking.py --ignore=N4,E12,E711,E721,E712 --repeat --show-source \
+ python tools/hacking.py --ignore=N402,E12,E711,E721,E712 --repeat --show-source \
--exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg .
- python tools/hacking.py --ignore=N4,E12,E711,E721,E712 --repeat --show-source \
+ python tools/hacking.py --ignore=N402,E12,E711,E721,E712 --repeat --show-source \
--filename=nova* bin
[testenv:pylint]