Fix hacking N302 import only modules
* Includes some general tools/hacking cleanup * Fix several N302 cases * Disable N302 until all cases are fixed Change-Id: Iddba07ff13e10dc41a6930749044bb8c0572d279
This commit is contained in:
parent
4220e0110e
commit
4845fc2720
@ -25,7 +25,7 @@ import os
|
||||
import sys
|
||||
|
||||
from nova import config
|
||||
from nova.console import websocketproxy as ws
|
||||
from nova import console
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
|
||||
@ -77,7 +77,8 @@ if __name__ == '__main__':
|
||||
sys.exit(-1)
|
||||
|
||||
# Create and start the NovaWebSockets proxy
|
||||
server = ws.NovaWebSocketProxy(listen_host=CONF.novncproxy_host,
|
||||
server = console.websocketproxy.NovaWebSocketProxy(
|
||||
listen_host=CONF.novncproxy_host,
|
||||
listen_port=CONF.novncproxy_port,
|
||||
source_is_ipv6=CONF.source_is_ipv6,
|
||||
verbose=CONF.verbose,
|
||||
|
@ -25,7 +25,7 @@ import os
|
||||
import sys
|
||||
|
||||
from nova import config
|
||||
from nova.console import websocketproxy as ws
|
||||
from nova import console
|
||||
from nova.openstack.common import cfg
|
||||
|
||||
|
||||
@ -77,7 +77,8 @@ if __name__ == '__main__':
|
||||
sys.exit(-1)
|
||||
|
||||
# Create and start the NovaWebSockets proxy
|
||||
server = ws.NovaWebSocketProxy(listen_host=CONF.spicehtml5proxy_host,
|
||||
server = console.websocketproxy.NovaWebSocketProxy(
|
||||
listen_host=CONF.spicehtml5proxy_host,
|
||||
listen_port=CONF.spicehtml5proxy_port,
|
||||
source_is_ipv6=CONF.source_is_ipv6,
|
||||
verbose=CONF.verbose,
|
||||
|
@ -6,7 +6,7 @@ Created on 2010/12/20
|
||||
import base64
|
||||
import boto
|
||||
import boto.ec2
|
||||
from boto.ec2.securitygroup import SecurityGroup
|
||||
import boto.ec2.securitygroup as securitygroup
|
||||
from boto_v6.ec2.instance import ReservationV6
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ class EC2ConnectionV6(boto.ec2.EC2Connection):
|
||||
if security_groups:
|
||||
l = []
|
||||
for group in security_groups:
|
||||
if isinstance(group, SecurityGroup):
|
||||
if isinstance(group, securitygroup.SecurityGroup):
|
||||
l.append(group.name)
|
||||
else:
|
||||
l.append(group)
|
||||
|
@ -3,31 +3,29 @@ Created on 2010/12/20
|
||||
|
||||
@author: Nachi Ueno <ueno.nachi@lab.ntt.co.jp>
|
||||
'''
|
||||
from boto.ec2.instance import Group
|
||||
from boto.ec2.instance import Instance
|
||||
from boto.ec2.instance import Reservation
|
||||
import boto.ec2.instance
|
||||
from boto.resultset import ResultSet
|
||||
|
||||
|
||||
class ReservationV6(Reservation):
|
||||
class ReservationV6(boto.ec2.instance.Reservation):
|
||||
def startElement(self, name, attrs, connection):
|
||||
if name == 'instancesSet':
|
||||
self.instances = ResultSet([('item', InstanceV6)])
|
||||
return self.instances
|
||||
elif name == 'groupSet':
|
||||
self.groups = ResultSet([('item', Group)])
|
||||
self.groups = ResultSet([('item', boto.ec2.instance.Group)])
|
||||
return self.groups
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class InstanceV6(Instance):
|
||||
class InstanceV6(boto.ec2.instance.Instance):
|
||||
def __init__(self, connection=None):
|
||||
Instance.__init__(self, connection)
|
||||
boto.ec2.instance.Instance.__init__(self, connection)
|
||||
self.dns_name_v6 = None
|
||||
|
||||
def endElement(self, name, value, connection):
|
||||
Instance.endElement(self, name, value, connection)
|
||||
boto.ec2.instance.Instance.endElement(self, name, value, connection)
|
||||
if name == 'dnsNameV6':
|
||||
self.dns_name_v6 = value
|
||||
|
||||
|
@ -236,9 +236,7 @@ import sqlalchemy.orm
|
||||
from sqlalchemy.pool import NullPool, StaticPool
|
||||
from sqlalchemy.sql.expression import literal_column
|
||||
|
||||
from nova.exception import DBDuplicateEntry
|
||||
from nova.exception import DBError
|
||||
from nova.exception import InvalidUnicodeParameter
|
||||
import nova.exception
|
||||
from nova.openstack.common import cfg
|
||||
import nova.openstack.common.log as logging
|
||||
from nova.openstack.common import timeutils
|
||||
@ -362,7 +360,7 @@ def raise_if_duplicate_entry_error(integrity_error, engine_name):
|
||||
columns = columns.strip().split(", ")
|
||||
else:
|
||||
columns = get_columns_from_uniq_cons_or_name(columns)
|
||||
raise DBDuplicateEntry(columns, integrity_error)
|
||||
raise nova.exception.DBDuplicateEntry(columns, integrity_error)
|
||||
|
||||
|
||||
def wrap_db_error(f):
|
||||
@ -370,7 +368,7 @@ def wrap_db_error(f):
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except UnicodeEncodeError:
|
||||
raise InvalidUnicodeParameter()
|
||||
raise nova.exception.InvalidUnicodeParameter()
|
||||
# note(boris-42): We should catch unique constraint violation and
|
||||
# wrap it by our own DBDuplicateEntry exception. Unique constraint
|
||||
# violation is wrapped by IntegrityError.
|
||||
@ -381,10 +379,10 @@ def wrap_db_error(f):
|
||||
# means we should get names of columns, which values violate
|
||||
# unique constraint, from error message.
|
||||
raise_if_duplicate_entry_error(e, get_engine().name)
|
||||
raise DBError(e)
|
||||
raise nova.exception.DBError(e)
|
||||
except Exception, e:
|
||||
LOG.exception(_('DB exception wrapped.'))
|
||||
raise DBError(e)
|
||||
raise nova.exception.DBError(e)
|
||||
_wrap.func_name = f.func_name
|
||||
return _wrap
|
||||
|
||||
|
@ -23,7 +23,7 @@ from nova.openstack.common import lockutils
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import utils
|
||||
|
||||
from random import choice
|
||||
import random
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -144,4 +144,4 @@ class ServiceGroupDriver(object):
|
||||
length = len(members)
|
||||
if length == 0:
|
||||
return None
|
||||
return choice(members)
|
||||
return random.choice(members)
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
from lxml import etree
|
||||
import webob
|
||||
|
||||
@ -40,29 +40,29 @@ def fake_service_get_all(context, disabled=None):
|
||||
|
||||
if disabled:
|
||||
return [__fake_service("nova-compute", "zone-2",
|
||||
datetime(2012, 11, 14, 9, 53, 25, 0),
|
||||
datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
datetime.datetime(2012, 11, 14, 9, 53, 25, 0),
|
||||
datetime.datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
"fake_host-1", True),
|
||||
__fake_service("nova-scheduler", "internal",
|
||||
datetime(2012, 11, 14, 9, 57, 3, 0),
|
||||
datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
datetime.datetime(2012, 11, 14, 9, 57, 3, 0),
|
||||
datetime.datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
"fake_host-1", True),
|
||||
__fake_service("nova-network", "internal",
|
||||
datetime(2012, 11, 16, 7, 25, 46, 0),
|
||||
datetime(2012, 12, 26, 14, 45, 24, 0),
|
||||
datetime.datetime(2012, 11, 16, 7, 25, 46, 0),
|
||||
datetime.datetime(2012, 12, 26, 14, 45, 24, 0),
|
||||
"fake_host-2", True)]
|
||||
else:
|
||||
return [__fake_service("nova-compute", "zone-1",
|
||||
datetime(2012, 11, 14, 9, 53, 25, 0),
|
||||
datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
datetime.datetime(2012, 11, 14, 9, 53, 25, 0),
|
||||
datetime.datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
"fake_host-1", False),
|
||||
__fake_service("nova-sched", "internal",
|
||||
datetime(2012, 11, 14, 9, 57, 03, 0),
|
||||
datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
datetime.datetime(2012, 11, 14, 9, 57, 03, 0),
|
||||
datetime.datetime(2012, 12, 26, 14, 45, 25, 0),
|
||||
"fake_host-1", False),
|
||||
__fake_service("nova-network", "internal",
|
||||
datetime(2012, 11, 16, 7, 25, 46, 0),
|
||||
datetime(2012, 12, 26, 14, 45, 24, 0),
|
||||
datetime.datetime(2012, 11, 16, 7, 25, 46, 0),
|
||||
datetime.datetime(2012, 12, 26, 14, 45, 24, 0),
|
||||
"fake_host-2", False)]
|
||||
|
||||
|
||||
@ -218,18 +218,21 @@ class AvailabilityZoneSerializerTest(test.TestCase):
|
||||
'hosts': {'fake_host-1': {
|
||||
'nova-compute': {'active': True, 'available': True,
|
||||
'updated_at':
|
||||
datetime(2012, 12, 26, 14, 45, 25)}}}},
|
||||
datetime.datetime(
|
||||
2012, 12, 26, 14, 45, 25)}}}},
|
||||
{'zoneName': 'internal',
|
||||
'zoneState': {'available': True},
|
||||
'hosts': {'fake_host-1': {
|
||||
'nova-sched': {'active': True, 'available': True,
|
||||
'updated_at':
|
||||
datetime(2012, 12, 26, 14, 45, 25)}},
|
||||
datetime.datetime(
|
||||
2012, 12, 26, 14, 45, 25)}},
|
||||
'fake_host-2': {
|
||||
'nova-network': {'active': True,
|
||||
'available': False,
|
||||
'updated_at':
|
||||
datetime(2012, 12, 26, 14, 45, 24)}}}},
|
||||
datetime.datetime(
|
||||
2012, 12, 26, 14, 45, 24)}}}},
|
||||
{'zoneName': 'zone-2',
|
||||
'zoneState': {'available': False},
|
||||
'hosts': None}]
|
||||
|
@ -14,7 +14,8 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
|
||||
from nova.api.openstack.compute.contrib import services
|
||||
from nova import context
|
||||
from nova import db
|
||||
@ -24,35 +25,36 @@ from nova import test
|
||||
from nova.tests.api.openstack import fakes
|
||||
|
||||
|
||||
fake_services_list = [{'binary': 'nova-scheduler',
|
||||
'host': 'host1',
|
||||
'id': 1,
|
||||
'disabled': True,
|
||||
'topic': 'scheduler',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 2),
|
||||
'created_at': datetime(2012, 9, 18, 2, 46, 27)},
|
||||
{'binary': 'nova-compute',
|
||||
'host': 'host1',
|
||||
'id': 2,
|
||||
'disabled': True,
|
||||
'topic': 'compute',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 5),
|
||||
'created_at': datetime(2012, 9, 18, 2, 46, 27)},
|
||||
{'binary': 'nova-scheduler',
|
||||
'host': 'host2',
|
||||
'id': 3,
|
||||
'disabled': False,
|
||||
'topic': 'scheduler',
|
||||
'updated_at': datetime(2012, 9, 19, 6, 55, 34),
|
||||
'created_at': datetime(2012, 9, 18, 2, 46, 28)},
|
||||
{'binary': 'nova-compute',
|
||||
'host': 'host2',
|
||||
'id': 4,
|
||||
'disabled': True,
|
||||
'topic': 'compute',
|
||||
'updated_at': datetime(2012, 9, 18, 8, 3, 38),
|
||||
'created_at': datetime(2012, 9, 18, 2, 46, 28)},
|
||||
]
|
||||
fake_services_list = [
|
||||
{'binary': 'nova-scheduler',
|
||||
'host': 'host1',
|
||||
'id': 1,
|
||||
'disabled': True,
|
||||
'topic': 'scheduler',
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 2),
|
||||
'created_at': datetime.datetime(2012, 9, 18, 2, 46, 27)},
|
||||
{'binary': 'nova-compute',
|
||||
'host': 'host1',
|
||||
'id': 2,
|
||||
'disabled': True,
|
||||
'topic': 'compute',
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 5),
|
||||
'created_at': datetime.datetime(2012, 9, 18, 2, 46, 27)},
|
||||
{'binary': 'nova-scheduler',
|
||||
'host': 'host2',
|
||||
'id': 3,
|
||||
'disabled': False,
|
||||
'topic': 'scheduler',
|
||||
'updated_at': datetime.datetime(2012, 9, 19, 6, 55, 34),
|
||||
'created_at': datetime.datetime(2012, 9, 18, 2, 46, 28)},
|
||||
{'binary': 'nova-compute',
|
||||
'host': 'host2',
|
||||
'id': 4,
|
||||
'disabled': True,
|
||||
'topic': 'compute',
|
||||
'updated_at': datetime.datetime(2012, 9, 18, 8, 3, 38),
|
||||
'created_at': datetime.datetime(2012, 9, 18, 2, 46, 28)},
|
||||
]
|
||||
|
||||
|
||||
class FakeRequest(object):
|
||||
@ -103,7 +105,7 @@ def fake_service_update(context, service_id, values):
|
||||
|
||||
|
||||
def fake_utcnow():
|
||||
return datetime(2012, 10, 29, 13, 42, 11)
|
||||
return datetime.datetime(2012, 10, 29, 13, 42, 11)
|
||||
|
||||
|
||||
class ServicesTest(test.TestCase):
|
||||
@ -130,19 +132,19 @@ class ServicesTest(test.TestCase):
|
||||
response = {'services': [{'binary': 'nova-scheduler',
|
||||
'host': 'host1', 'zone': 'internal',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 2)},
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 2)},
|
||||
{'binary': 'nova-compute',
|
||||
'host': 'host1', 'zone': 'nova',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 5)},
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 5)},
|
||||
{'binary': 'nova-scheduler', 'host': 'host2',
|
||||
'zone': 'internal',
|
||||
'status': 'enabled', 'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 19, 6, 55, 34)},
|
||||
'updated_at': datetime.datetime(2012, 9, 19, 6, 55, 34)},
|
||||
{'binary': 'nova-compute', 'host': 'host2',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled', 'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 18, 8, 3, 38)}]}
|
||||
'updated_at': datetime.datetime(2012, 9, 18, 8, 3, 38)}]}
|
||||
self.assertEqual(res_dict, response)
|
||||
|
||||
def test_services_list_with_host(self):
|
||||
@ -152,11 +154,11 @@ class ServicesTest(test.TestCase):
|
||||
response = {'services': [{'binary': 'nova-scheduler', 'host': 'host1',
|
||||
'zone': 'internal',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 2)},
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 2)},
|
||||
{'binary': 'nova-compute', 'host': 'host1',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 5)}]}
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 5)}]}
|
||||
self.assertEqual(res_dict, response)
|
||||
|
||||
def test_services_list_with_service(self):
|
||||
@ -166,11 +168,11 @@ class ServicesTest(test.TestCase):
|
||||
response = {'services': [{'binary': 'nova-compute', 'host': 'host1',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 5)},
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 5)},
|
||||
{'binary': 'nova-compute', 'host': 'host2',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled', 'state': 'down',
|
||||
'updated_at': datetime(2012, 9, 18, 8, 3, 38)}]}
|
||||
'updated_at': datetime.datetime(2012, 9, 18, 8, 3, 38)}]}
|
||||
self.assertEqual(res_dict, response)
|
||||
|
||||
def test_services_list_with_host_service(self):
|
||||
@ -180,7 +182,7 @@ class ServicesTest(test.TestCase):
|
||||
response = {'services': [{'binary': 'nova-compute', 'host': 'host1',
|
||||
'zone': 'nova',
|
||||
'status': 'disabled', 'state': 'up',
|
||||
'updated_at': datetime(2012, 10, 29, 13, 42, 5)}]}
|
||||
'updated_at': datetime.datetime(2012, 10, 29, 13, 42, 5)}]}
|
||||
self.assertEqual(res_dict, response)
|
||||
|
||||
def test_services_enable(self):
|
||||
|
@ -22,7 +22,7 @@ from nova import config
|
||||
from nova import ipv6
|
||||
from nova.openstack.common import cfg
|
||||
from nova import paths
|
||||
from nova.tests.utils import cleanup_dns_managers
|
||||
from nova.tests import utils
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('use_ipv6', 'nova.netconf')
|
||||
@ -70,5 +70,5 @@ class ConfFixture(fixtures.Fixture):
|
||||
self.conf.set_default('vlan_interface', 'eth0')
|
||||
config.parse_args([], default_config_files=[])
|
||||
self.addCleanup(self.conf.reset)
|
||||
self.addCleanup(cleanup_dns_managers)
|
||||
self.addCleanup(utils.cleanup_dns_managers)
|
||||
self.addCleanup(ipv6.api.reset_backend)
|
||||
|
@ -26,9 +26,9 @@ from boto.ec2 import regioninfo
|
||||
from boto import exception as boto_exc
|
||||
# newer versions of boto use their own wrapper on top of httplib.HTTPResponse
|
||||
try:
|
||||
from boto.connection import HTTPResponse
|
||||
import boto.connection as httplib
|
||||
except ImportError:
|
||||
from httplib import HTTPResponse
|
||||
import httplib
|
||||
import fixtures
|
||||
import webob
|
||||
|
||||
@ -79,7 +79,7 @@ class FakeHttplibConnection(object):
|
||||
# guess that's a function the web server usually provides.
|
||||
resp = "HTTP/1.0 %s" % resp
|
||||
self.sock = FakeHttplibSocket(resp)
|
||||
self.http_response = HTTPResponse(self.sock)
|
||||
self.http_response = httplib.HTTPResponse(self.sock)
|
||||
# NOTE(vish): boto is accessing private variables for some reason
|
||||
self._HTTPConnection__response = self.http_response
|
||||
self.http_response.begin()
|
||||
|
@ -19,7 +19,7 @@
|
||||
"""Tests for metadata service."""
|
||||
|
||||
import base64
|
||||
from copy import copy
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
|
||||
@ -120,14 +120,14 @@ class MetadataTestCase(test.TestCase):
|
||||
spectacular=True)
|
||||
|
||||
def test_user_data(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
inst['user_data'] = base64.b64encode("happy")
|
||||
md = fake_InstanceMetadata(self.stubs, inst)
|
||||
self.assertEqual(
|
||||
md.get_ec2_metadata(version='2009-04-04')['user-data'], "happy")
|
||||
|
||||
def test_no_user_data(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
del inst['user_data']
|
||||
md = fake_InstanceMetadata(self.stubs, inst)
|
||||
obj = object()
|
||||
@ -136,7 +136,7 @@ class MetadataTestCase(test.TestCase):
|
||||
obj)
|
||||
|
||||
def test_security_groups(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
sgroups = [{'name': 'default'}, {'name': 'other'}]
|
||||
expected = ['default', 'other']
|
||||
|
||||
@ -145,7 +145,7 @@ class MetadataTestCase(test.TestCase):
|
||||
self.assertEqual(data['meta-data']['security-groups'], expected)
|
||||
|
||||
def test_local_hostname_fqdn(self):
|
||||
md = fake_InstanceMetadata(self.stubs, copy(self.instance))
|
||||
md = fake_InstanceMetadata(self.stubs, copy.copy(self.instance))
|
||||
data = md.get_ec2_metadata(version='2009-04-04')
|
||||
self.assertEqual(data['meta-data']['local-hostname'],
|
||||
"%s.%s" % (self.instance['hostname'], CONF.dhcp_domain))
|
||||
@ -195,7 +195,7 @@ class MetadataTestCase(test.TestCase):
|
||||
expected)
|
||||
|
||||
def test_pubkey(self):
|
||||
md = fake_InstanceMetadata(self.stubs, copy(self.instance))
|
||||
md = fake_InstanceMetadata(self.stubs, copy.copy(self.instance))
|
||||
pubkey_ent = md.lookup("/2009-04-04/meta-data/public-keys")
|
||||
|
||||
self.assertEqual(base.ec2_md_print(pubkey_ent),
|
||||
@ -204,7 +204,7 @@ class MetadataTestCase(test.TestCase):
|
||||
self.instance['key_data'])
|
||||
|
||||
def test_image_type_ramdisk(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
inst['ramdisk_id'] = 'ari-853667c0'
|
||||
md = fake_InstanceMetadata(self.stubs, inst)
|
||||
data = md.lookup("/latest/meta-data/ramdisk-id")
|
||||
@ -213,7 +213,7 @@ class MetadataTestCase(test.TestCase):
|
||||
self.assertTrue(re.match('ari-[0-9a-f]{8}', data))
|
||||
|
||||
def test_image_type_kernel(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
inst['kernel_id'] = 'aki-c2e26ff2'
|
||||
md = fake_InstanceMetadata(self.stubs, inst)
|
||||
data = md.lookup("/2009-04-04/meta-data/kernel-id")
|
||||
@ -229,7 +229,7 @@ class MetadataTestCase(test.TestCase):
|
||||
md.lookup, "/2009-04-04/meta-data/kernel-id")
|
||||
|
||||
def test_check_version(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
md = fake_InstanceMetadata(self.stubs, inst)
|
||||
|
||||
self.assertTrue(md._check_version('1.0', '2009-04-04'))
|
||||
@ -250,7 +250,7 @@ class OpenStackMetadataTestCase(test.TestCase):
|
||||
|
||||
def test_top_level_listing(self):
|
||||
# request for /openstack/<version>/ should show metadata.json
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst)
|
||||
|
||||
listing = mdinst.lookup("/openstack/")
|
||||
@ -267,14 +267,14 @@ class OpenStackMetadataTestCase(test.TestCase):
|
||||
|
||||
def test_version_content_listing(self):
|
||||
# request for /openstack/<version>/ should show metadata.json
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst)
|
||||
|
||||
listing = mdinst.lookup("/openstack/2012-08-10")
|
||||
self.assertTrue("meta_data.json" in listing)
|
||||
|
||||
def test_metadata_json(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
content = [
|
||||
('/etc/my.conf', "content of my.conf"),
|
||||
('/root/hello', "content of /root/hello"),
|
||||
@ -309,7 +309,7 @@ class OpenStackMetadataTestCase(test.TestCase):
|
||||
|
||||
def test_extra_md(self):
|
||||
# make sure extra_md makes it through to metadata
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
extra = {'foo': 'bar', 'mylist': [1, 2, 3],
|
||||
'mydict': {"one": 1, "two": 2}}
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst, extra_md=extra)
|
||||
@ -322,14 +322,14 @@ class OpenStackMetadataTestCase(test.TestCase):
|
||||
|
||||
def test_password(self):
|
||||
# make sure extra_md makes it through to metadata
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst)
|
||||
|
||||
result = mdinst.lookup("/openstack/latest/password")
|
||||
self.assertEqual(result, password.handle_password)
|
||||
|
||||
def test_userdata(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst)
|
||||
|
||||
userdata_found = mdinst.lookup("/openstack/2012-08-10/user_data")
|
||||
@ -348,7 +348,7 @@ class OpenStackMetadataTestCase(test.TestCase):
|
||||
mdinst.lookup, "/openstack/2012-08-10/user_data")
|
||||
|
||||
def test_random_seed(self):
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst)
|
||||
|
||||
# verify that 2013-04-04 has the 'random' field
|
||||
@ -364,7 +364,7 @@ class OpenStackMetadataTestCase(test.TestCase):
|
||||
|
||||
def test_no_dashes_in_metadata(self):
|
||||
# top level entries in meta_data should not contain '-' in their name
|
||||
inst = copy(self.instance)
|
||||
inst = copy.copy(self.instance)
|
||||
mdinst = fake_InstanceMetadata(self.stubs, inst)
|
||||
mdjson = json.loads(mdinst.lookup("/openstack/latest/meta_data.json"))
|
||||
|
||||
@ -522,7 +522,7 @@ class MetadataPasswordTestCase(test.TestCase):
|
||||
super(MetadataPasswordTestCase, self).setUp()
|
||||
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
||||
spectacular=True)
|
||||
self.instance = copy(INSTANCES[0])
|
||||
self.instance = copy.copy(INSTANCES[0])
|
||||
self.mdinst = fake_InstanceMetadata(self.stubs, self.instance,
|
||||
address=None, sgroups=None)
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import abc
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
@ -22,11 +23,12 @@ import uuid
|
||||
if sys.platform == 'win32':
|
||||
import wmi
|
||||
|
||||
from abc import abstractmethod
|
||||
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import log as logging
|
||||
from nova.virt.hyperv import vmutils
|
||||
|
||||
|
||||
hyperv_opts = [
|
||||
cfg.StrOpt('vswitch_name',
|
||||
default=None,
|
||||
@ -42,11 +44,11 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HyperVBaseVIFDriver(object):
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def plug(self, instance, vif):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
@abc.abstractmethod
|
||||
def unplug(self, instance, vif):
|
||||
pass
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
Handles all requests relating to volumes + cinder.
|
||||
"""
|
||||
|
||||
from copy import deepcopy
|
||||
import copy
|
||||
import sys
|
||||
|
||||
from cinderclient import exceptions as cinder_exception
|
||||
@ -139,7 +139,7 @@ def _untranslate_volume_summary_view(context, vol):
|
||||
d['volume_metadata'].append(item)
|
||||
|
||||
if hasattr(vol, 'volume_image_metadata'):
|
||||
d['volume_image_metadata'] = deepcopy(vol.volume_image_metadata)
|
||||
d['volume_image_metadata'] = copy.deepcopy(vol.volume_image_metadata)
|
||||
|
||||
return d
|
||||
|
||||
|
@ -125,7 +125,7 @@ function run_pep8 {
|
||||
srcfiles+=" setup.py"
|
||||
|
||||
# Until all these issues get fixed, ignore.
|
||||
ignore='--ignore=E12,E711,E721,E712,N403,N404'
|
||||
ignore='--ignore=E12,E711,E721,E712,N403,N404,N302'
|
||||
|
||||
# First run the hacking selftest, to make sure it's right
|
||||
echo "Running hacking.py self test"
|
||||
|
@ -17,7 +17,7 @@
|
||||
# under the License.
|
||||
|
||||
import boto
|
||||
from boto.ec2.regioninfo import RegionInfo
|
||||
from boto.ec2 import regioninfo
|
||||
import commands
|
||||
import httplib
|
||||
import os
|
||||
@ -123,7 +123,7 @@ class SmokeTestCase(unittest.TestCase):
|
||||
return boto_v6.connect_ec2(aws_access_key_id=access_key,
|
||||
aws_secret_access_key=secret_key,
|
||||
is_secure=parts['is_secure'],
|
||||
region=RegionInfo(None,
|
||||
region=regioninfo.RegionInfo(None,
|
||||
'nova',
|
||||
parts['ip']),
|
||||
port=parts['port'],
|
||||
@ -133,7 +133,7 @@ class SmokeTestCase(unittest.TestCase):
|
||||
return boto.connect_ec2(aws_access_key_id=access_key,
|
||||
aws_secret_access_key=secret_key,
|
||||
is_secure=parts['is_secure'],
|
||||
region=RegionInfo(None,
|
||||
region=regioninfo.RegionInfo(None,
|
||||
'nova',
|
||||
parts['ip']),
|
||||
port=parts['port'],
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
"""nova HACKING file compliance testing
|
||||
|
||||
built on top of pep8.py
|
||||
Built on top of pep8.py
|
||||
"""
|
||||
|
||||
import inspect
|
||||
@ -49,6 +49,8 @@ START_DOCSTRING_TRIPLE = ['u"""', 'r"""', '"""', "u'''", "r'''", "'''"]
|
||||
END_DOCSTRING_TRIPLE = ['"""', "'''"]
|
||||
VERBOSE_MISSING_IMPORT = os.getenv('HACKING_VERBOSE_MISSING_IMPORT', 'False')
|
||||
|
||||
_missingImport = set([])
|
||||
|
||||
|
||||
# Monkey patch broken excluded filter in pep8
|
||||
# See https://github.com/jcrocholl/pep8/pull/111
|
||||
@ -103,7 +105,7 @@ def import_normalize(line):
|
||||
return line
|
||||
|
||||
|
||||
def nova_todo_format(physical_line):
|
||||
def nova_todo_format(physical_line, tokens):
|
||||
"""Check for 'TODO()'.
|
||||
|
||||
nova HACKING guide recommendation for TODO:
|
||||
@ -111,14 +113,13 @@ def nova_todo_format(physical_line):
|
||||
|
||||
Okay: #TODO(sdague)
|
||||
N101: #TODO fail
|
||||
N101: #TODO (jogo) fail
|
||||
"""
|
||||
# TODO(sdague): TODO check shouldn't fail inside of space
|
||||
pos = physical_line.find('TODO')
|
||||
pos1 = physical_line.find('TODO(')
|
||||
pos2 = physical_line.find('#') # make sure it's a comment
|
||||
# TODO(sdague): should be smarter on this test
|
||||
this_test = physical_line.find('N101: #TODO fail')
|
||||
if pos != pos1 and pos2 >= 0 and pos2 < pos and this_test == -1:
|
||||
if (pos != pos1 and pos2 >= 0 and pos2 < pos and len(tokens) == 0):
|
||||
return pos, "N101: Use TODO(NAME)"
|
||||
|
||||
|
||||
@ -165,8 +166,6 @@ def nova_one_import_per_line(logical_line):
|
||||
not is_import_exception(parts[1])):
|
||||
yield pos, "N301: one import per line"
|
||||
|
||||
_missingImport = set([])
|
||||
|
||||
|
||||
def nova_import_module_only(logical_line):
|
||||
r"""Check for import module only.
|
||||
@ -175,20 +174,23 @@ def nova_import_module_only(logical_line):
|
||||
Do not import objects, only modules
|
||||
|
||||
Okay: from os import path
|
||||
N302 from os.path import mkdir as mkdir2
|
||||
N303 import bubba
|
||||
N304 import blueblue
|
||||
Okay: import os.path
|
||||
N302: from os.path import dirname as dirname2
|
||||
N303 from os.path import *
|
||||
N304 import flakes
|
||||
"""
|
||||
# N302 import only modules
|
||||
# N303 Invalid Import
|
||||
# N304 Relative Import
|
||||
|
||||
# TODO(sdague) actually get these tests working
|
||||
def importModuleCheck(mod, parent=None, added=False):
|
||||
"""Import Module helper function.
|
||||
# TODO(jogo) simplify this code
|
||||
def import_module_check(mod, parent=None, added=False):
|
||||
"""Checks for relative, modules and invalid imports.
|
||||
|
||||
If can't find module on first try, recursively check for relative
|
||||
imports
|
||||
imports.
|
||||
When parsing 'from x import y,' x is the parent.
|
||||
"""
|
||||
current_path = os.path.dirname(pep8.current_file)
|
||||
try:
|
||||
@ -196,8 +198,6 @@ def nova_import_module_only(logical_line):
|
||||
warnings.simplefilter('ignore', DeprecationWarning)
|
||||
valid = True
|
||||
if parent:
|
||||
if is_import_exception(parent):
|
||||
return
|
||||
parent_mod = __import__(parent, globals(), locals(),
|
||||
[mod], -1)
|
||||
valid = inspect.ismodule(getattr(parent_mod, mod))
|
||||
@ -209,7 +209,7 @@ def nova_import_module_only(logical_line):
|
||||
sys.path.pop()
|
||||
added = False
|
||||
return logical_line.find(mod), ("N304: No "
|
||||
"relative imports. '%s' is a relative import"
|
||||
"relative imports. '%s' is a relative import"
|
||||
% logical_line)
|
||||
return logical_line.find(mod), ("N302: import only "
|
||||
"modules. '%s' does not import a module"
|
||||
@ -219,7 +219,7 @@ def nova_import_module_only(logical_line):
|
||||
if not added:
|
||||
added = True
|
||||
sys.path.append(current_path)
|
||||
return importModuleCheck(mod, parent, added)
|
||||
return import_module_check(mod, parent, added)
|
||||
else:
|
||||
name = logical_line.split()[1]
|
||||
if name not in _missingImport:
|
||||
@ -234,23 +234,27 @@ def nova_import_module_only(logical_line):
|
||||
|
||||
except AttributeError:
|
||||
# Invalid import
|
||||
if "import *" in logical_line:
|
||||
# TODO(jogo): handle "from x import *, by checking all
|
||||
# "objects in x"
|
||||
return
|
||||
return logical_line.find(mod), ("N303: Invalid import, "
|
||||
"AttributeError raised")
|
||||
"%s" % mod)
|
||||
|
||||
# convert "from x import y" to " import x.y"
|
||||
# convert "from x import y as z" to " import x.y"
|
||||
import_normalize(logical_line)
|
||||
split_line = logical_line.split()
|
||||
|
||||
if (logical_line.startswith("import ") and "," not in logical_line and
|
||||
(len(split_line) == 2 or
|
||||
(len(split_line) == 4 and split_line[2] == "as"))):
|
||||
mod = split_line[1]
|
||||
rval = importModuleCheck(mod)
|
||||
if (", " not in logical_line and
|
||||
split_line[0] in ('import', 'from') and
|
||||
(len(split_line) in (2, 4, 6)) and
|
||||
split_line[1] != "__future__"):
|
||||
if is_import_exception(split_line[1]):
|
||||
return
|
||||
if "from" == split_line[0]:
|
||||
rval = import_module_check(split_line[3], parent=split_line[1])
|
||||
else:
|
||||
rval = import_module_check(split_line[1])
|
||||
if rval is not None:
|
||||
yield rval
|
||||
|
||||
# TODO(jogo) handle "from x import *"
|
||||
|
||||
#TODO(jogo): import template: N305
|
||||
|
||||
@ -329,6 +333,8 @@ def nova_docstring_one_line(physical_line):
|
||||
A one line docstring looks like this and ends in punctuation.
|
||||
|
||||
Okay: '''This is good.'''
|
||||
Okay: '''This is good too!'''
|
||||
Okay: '''How about this?'''
|
||||
N402: '''This is not'''
|
||||
N402: '''Bad punctuation,'''
|
||||
"""
|
||||
|
6
tox.ini
6
tox.ini
@ -18,9 +18,11 @@ downloadcache = ~/cache/pip
|
||||
deps=pep8==1.3.3
|
||||
commands =
|
||||
python tools/hacking.py --doctest
|
||||
python tools/hacking.py --ignore=E12,E711,E721,E712,N403,N404 --show-source \
|
||||
python tools/hacking.py --ignore=E12,E711,E721,E712,N403,N404,N302 \
|
||||
--show-source \
|
||||
--exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg .
|
||||
python tools/hacking.py --ignore=E12,E711,E721,E712,N403,N404 --show-source \
|
||||
python tools/hacking.py --ignore=E12,E711,E721,E712,N403,N404,N302 \
|
||||
--show-source \
|
||||
--filename=nova* bin
|
||||
|
||||
[testenv:pylint]
|
||||
|
Loading…
Reference in New Issue
Block a user