pep8 fixes

This commit is contained in:
Jason Kölker 2011-05-31 11:46:06 -05:00
parent 6085115bef
commit 36c9396757
11 changed files with 28 additions and 40 deletions

View File

@ -748,6 +748,7 @@ def fixed_ip_get_all_by_instance(context, instance_id):
raise exception.NoFixedIpsFoundForInstance(instance_id=instance_id)
return rv
@require_context
def fixed_ip_get_by_instance_and_network(context, instance_id,
network_id):
@ -2434,7 +2435,7 @@ def project_get_networks(context, project_id, associate=True):
result = session.query(models.Network).\
filter_by(project_id=project_id).\
filter_by(deleted=False).all()
if not result:
if not associate:
return []

View File

@ -160,8 +160,7 @@ def convert_backward(migrate_engine, old_quotas, new_quotas):
'project_id': quota.project_id,
'created_at': quota.created_at,
'updated_at': quota.updated_at,
quota.resource: quota.hard_limit
}
quota.resource: quota.hard_limit}
else:
quotas[quota.project_id]['created_at'] = earliest(
quota.created_at, quotas[quota.project_id]['created_at'])

View File

@ -222,8 +222,7 @@ class JsonFilter(HostFilter):
required_disk = instance_type['local_gb']
query = ['and',
['>=', '$compute.host_memory_free', required_ram],
['>=', '$compute.disk_available', required_disk]
]
['>=', '$compute.disk_available', required_disk]]
return (self._full_name(), json.dumps(query))
def _parse_string(self, string, host, services):

View File

@ -59,7 +59,7 @@ class skip_test(object):
"""decorator that skips a test"""
def __init__(self, msg):
self.message = msg
def __call__(self, func):
def _skipper(*args, **kw):
"""wrapped skipper function."""

View File

@ -67,6 +67,6 @@ def setup():
vlan_start=FLAGS.vlan_start)
for net in db.network_get_all(ctxt):
network.set_network_host(ctxt, net['id'])
cleandb = os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db)
shutil.copyfile(testdb, cleandb)

View File

@ -465,7 +465,8 @@ class ServersTest(test.TestCase):
def image_id_from_hash(*args, **kwargs):
return 2
self.stubs.Set(nova.db.api, 'project_get_networks', project_get_networks)
self.stubs.Set(nova.db.api, 'project_get_networks',
project_get_networks)
self.stubs.Set(nova.db.api, 'instance_create', instance_create)
self.stubs.Set(nova.rpc, 'cast', fake_method)
self.stubs.Set(nova.rpc, 'call', fake_method)

View File

@ -132,13 +132,10 @@ class HostFilterTestCase(test.TestCase):
raw = ['or',
['and',
['<', '$compute.host_memory_free', 30],
['<', '$compute.disk_available', 300]
],
['<', '$compute.disk_available', 300]],
['and',
['>', '$compute.host_memory_free', 70],
['>', '$compute.disk_available', 700]
]
]
['>', '$compute.disk_available', 700]]]
cooked = json.dumps(raw)
hosts = driver.filter_hosts(self.zone_manager, cooked)
@ -149,8 +146,7 @@ class HostFilterTestCase(test.TestCase):
self.assertEquals('host%02d' % index, host)
raw = ['not',
['=', '$compute.host_memory_free', 30],
]
['=', '$compute.host_memory_free', 30],]
cooked = json.dumps(raw)
hosts = driver.filter_hosts(self.zone_manager, cooked)
@ -182,27 +178,22 @@ class HostFilterTestCase(test.TestCase):
self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps([])))
self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps({})))
self.assertTrue(driver.filter_hosts(self.zone_manager, json.dumps(
['not', True, False, True, False]
)))
['not', True, False, True, False])))
try:
driver.filter_hosts(self.zone_manager, json.dumps(
'not', True, False, True, False
))
'not', True, False, True, False))
self.fail("Should give KeyError")
except KeyError, e:
pass
self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps(
['=', '$foo', 100]
)))
['=', '$foo', 100])))
self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps(
['=', '$.....', 100]
)))
['=', '$.....', 100])))
self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps(
['>', ['and', ['or', ['not', ['<', ['>=', ['<=', ['in', ]]]]]]]]
)))
['>', ['and', ['or', ['not', ['<', ['>=',
['<=', ['in', ]]]]]]]])))
self.assertFalse(driver.filter_hosts(self.zone_manager, json.dumps(
['=', {}, ['>', '$missing....foo']]
)))
['=', {}, ['>', '$missing....foo']])))

View File

@ -82,6 +82,7 @@ def _setup_networking(instance_id, ip='1.2.3.4'):
db.fixed_ip_update(ctxt, ip, {'allocated': True,
'instance_id': instance_id})
class CacheConcurrencyTestCase(test.TestCase):
def setUp(self):
super(CacheConcurrencyTestCase, self).setUp()
@ -173,8 +174,6 @@ class LibvirtConnTestCase(test.TestCase):
self.manager.delete_user(self.user)
super(LibvirtConnTestCase, self).tearDown()
test_ip = '10.11.12.13'
test_instance = {'memory_kb': '1024000',
'basepath': '/some/path',
@ -183,7 +182,7 @@ class LibvirtConnTestCase(test.TestCase):
'vcpus': 2,
'project_id': 'fake',
'bridge': 'br101',
'instance_type_id': '5'} # m1.small
'instance_type_id': '5'} # m1.small
def lazy_load_library_exists(self):
"""check if libvirt is available."""
@ -673,7 +672,8 @@ class LibvirtConnTestCase(test.TestCase):
conn = libvirt_conn.LibvirtConnection(False)
ip = conn.get_host_ip_addr()
self.assertEquals(ip, FLAGS.my_ip)
class IptablesFirewallTestCase(test.TestCase):
def setUp(self):
super(IptablesFirewallTestCase, self).setUp()
@ -891,7 +891,6 @@ class IptablesFirewallTestCase(test.TestCase):
self.assertEquals(ipv6_network_rules,
ipv6_rules_per_network * networks_count)
@test.skip_test("skipping libvirt tests")
def test_do_refresh_security_group_rules(self):
instance_ref = self._create_instance_ref()

View File

@ -496,8 +496,10 @@ class XenAPIVMTestCase(test.TestCase):
network_manager='nova.network.manager.VlanManager',
network_driver='nova.network.xenapi_net',
vlan_interface='fake0')
def dummy(*args, **kwargs):
pass
self.stubs.Set(VMOps, 'create_vifs', dummy)
# Reset network table
xenapi_fake.reset_table('network')

View File

@ -39,15 +39,11 @@ class FakeZoneManager(zone_manager.ZoneManager):
def __init__(self):
self.service_states = {
'host1': {
'compute': {'ram': 1000}
},
'compute': {'ram': 1000}},
'host2': {
'compute': {'ram': 2000}
},
'compute': {'ram': 2000}},
'host3': {
'compute': {'ram': 3000}
}
}
'compute': {'ram': 3000}}}
class FakeEmptyZoneManager(zone_manager.ZoneManager):

View File

@ -36,7 +36,7 @@ PY_VERSION = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
def die(message, *args):
print >>sys.stderr, message % args
print >> sys.stderr, message % args
sys.exit(1)