Merge "fix N401 errors, stop ignoring all N4* errors"
This commit is contained in:
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
+4
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"""
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
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."""
|
||||
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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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"""
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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. """
|
||||
|
||||
@@ -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, {})
|
||||
|
||||
@@ -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'})
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-2
@@ -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):
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
+13
-13
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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}
|
||||
|
||||
|
||||
+11
-6
@@ -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):
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user