correcting tests; pep8
This commit is contained in:
parent
4b0785632b
commit
ad138a5a50
@ -561,7 +561,8 @@ class Controller(common.OpenstackController):
|
||||
"""
|
||||
image_id = image_meta['id']
|
||||
if image_meta['status'] != 'active':
|
||||
raise exception.InstanceNotRunning(image_id=image_id)
|
||||
raise exception.ImageUnacceptable(image_id=image_id,
|
||||
reason=_("status is not active"))
|
||||
|
||||
if image_meta.get('container_format') != 'ami':
|
||||
return None, None
|
||||
|
@ -141,23 +141,23 @@ class Invalid(NovaException):
|
||||
|
||||
|
||||
class InstanceNotRunning(Invalid):
|
||||
message = "Instance is not 'running'."
|
||||
message = "Instance %(instance_id)s is not running."
|
||||
|
||||
|
||||
class InstanceNotSuspended(Invalid):
|
||||
message = "Instance is not 'suspended'."
|
||||
message = "Instance %(instance_id)s is not suspended."
|
||||
|
||||
|
||||
class InstanceSuspendFailure(Invalid):
|
||||
message = "Failed to suspend instance: %(reason)s."
|
||||
message = "Failed to suspend instance: %(reason)s"
|
||||
|
||||
|
||||
class InstanceResumeFailure(Invalid):
|
||||
message = "Failed to resume server: %(reson)s."
|
||||
message = "Failed to resume server: %(reason)s."
|
||||
|
||||
|
||||
class InstanceRebootFailure(Invalid):
|
||||
message = "Failed to reboot instance: %(reason)s."
|
||||
message = "Failed to reboot instance: %(reason)s"
|
||||
|
||||
|
||||
class ServiceUnavailable(Invalid):
|
||||
@ -169,7 +169,7 @@ class VolumeServiceUnavailable(ServiceUnavailable):
|
||||
|
||||
|
||||
class ComputeServiceUnavailable(ServiceUnavailable):
|
||||
message = "Compute service on %(host)s is unavailable at this time."
|
||||
message = "Compute service is unavailable at this time."
|
||||
|
||||
|
||||
class UnableToMigrateToSelf(Invalid):
|
||||
@ -182,7 +182,7 @@ class SourceHostUnavailable(Invalid):
|
||||
|
||||
|
||||
class InvalidHypervisorType(Invalid):
|
||||
message = "The supplied hypervisor type of %(type)s is invalid."
|
||||
message = "The supplied hypervisor type of is invalid."
|
||||
|
||||
|
||||
class DestinationHypervisorTooOld(Invalid):
|
||||
@ -195,7 +195,7 @@ class InvalidDevicePath(Invalid):
|
||||
|
||||
|
||||
class InvalidCPUInfo(Invalid):
|
||||
message = "Unacceptable CPU info: %(reason)s."
|
||||
message = "Unacceptable CPU info: %(reason)s"
|
||||
|
||||
|
||||
class InvalidVLANTag(Invalid):
|
||||
@ -209,3 +209,7 @@ class InvalidVLANPortGroup(Invalid):
|
||||
"not associated with the desired physical adapter. " \
|
||||
"Expected vSwitch is %(expected)s, but the one associated " \
|
||||
"is %(actual)s."
|
||||
|
||||
|
||||
class ImageUnacceptable(Invalid):
|
||||
message = "Image %(image_id)s is unacceptable: %(reason)s"
|
||||
|
@ -168,7 +168,8 @@ class Scheduler(object):
|
||||
src = instance_ref['host']
|
||||
if dest == src:
|
||||
ec2_id = instance_ref['hostname']
|
||||
raise exception.UnableToMigrateToSelf(instance_id=ec2_id, host=dest)
|
||||
raise exception.UnableToMigrateToSelf(instance_id=ec2_id,
|
||||
host=dest)
|
||||
|
||||
# Checking dst host still has enough capacities.
|
||||
self.assert_compute_node_has_enough_resources(context,
|
||||
|
@ -698,14 +698,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
'topic': 'volume', 'report_count': 0}
|
||||
s_ref = db.service_create(self.context, dic)
|
||||
|
||||
try:
|
||||
self.scheduler.driver.schedule_live_migration(self.context,
|
||||
instance_id,
|
||||
i_ref['host'])
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find('volume node is not alive') >= 0)
|
||||
self.assertRaises(exception.VolumeServiceUnavailable,
|
||||
self.scheduler.driver.schedule_live_migration,
|
||||
self.context, instance_id, i_ref['host'])
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
db.volume_destroy(self.context, v_ref['id'])
|
||||
@ -718,13 +714,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
s_ref = self._create_compute_service(created_at=t, updated_at=t,
|
||||
host=i_ref['host'])
|
||||
|
||||
try:
|
||||
self.scheduler.driver._live_migration_src_check(self.context,
|
||||
i_ref)
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find('is not alive') >= 0)
|
||||
self.assertRaises(exception.ComputeServiceUnavailable,
|
||||
self.scheduler.driver._live_migration_src_check,
|
||||
self.context, i_ref)
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
@ -749,14 +742,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
s_ref = self._create_compute_service(created_at=t, updated_at=t,
|
||||
host=i_ref['host'])
|
||||
|
||||
try:
|
||||
self.scheduler.driver._live_migration_dest_check(self.context,
|
||||
i_ref,
|
||||
i_ref['host'])
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find('is not alive') >= 0)
|
||||
self.assertRaises(exception.ComputeServiceUnavailable,
|
||||
self.scheduler.driver._live_migration_dest_check,
|
||||
self.context, i_ref, i_ref['host'])
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
@ -766,14 +755,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
i_ref = db.instance_get(self.context, instance_id)
|
||||
s_ref = self._create_compute_service(host=i_ref['host'])
|
||||
|
||||
try:
|
||||
self.scheduler.driver._live_migration_dest_check(self.context,
|
||||
i_ref,
|
||||
i_ref['host'])
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find('choose other host') >= 0)
|
||||
self.assertRaises(exception.UnableToMigrateToSelf,
|
||||
self.scheduler.driver._live_migration_dest_check,
|
||||
self.context, i_ref, i_ref['host'])
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
@ -837,14 +822,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
"args": {'filename': fpath}})
|
||||
|
||||
self.mox.ReplayAll()
|
||||
try:
|
||||
self.scheduler.driver._live_migration_common_check(self.context,
|
||||
i_ref,
|
||||
dest)
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find('does not exist') >= 0)
|
||||
self.assertRaises(exception.SourceHostUnavailable,
|
||||
self.scheduler.driver._live_migration_common_check,
|
||||
self.context, i_ref, dest)
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
|
||||
@ -865,14 +846,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
try:
|
||||
self.scheduler.driver._live_migration_common_check(self.context,
|
||||
i_ref,
|
||||
dest)
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find(_('Different hypervisor type')) >= 0)
|
||||
self.assertRaises(exception.InvalidHypervisorType,
|
||||
self.scheduler.driver._live_migration_common_check,
|
||||
self.context, i_ref, dest)
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
db.service_destroy(self.context, s_ref2['id'])
|
||||
@ -895,14 +872,10 @@ class SimpleDriverTestCase(test.TestCase):
|
||||
driver.mounted_on_same_shared_storage(mox.IgnoreArg(), i_ref, dest)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
try:
|
||||
self.scheduler.driver._live_migration_common_check(self.context,
|
||||
i_ref,
|
||||
dest)
|
||||
except exception.Invalid, e:
|
||||
c = (e.message.find(_('Older hypervisor version')) >= 0)
|
||||
self.assertRaises(exception.DestinationHypervisorTooOld,
|
||||
self.scheduler.driver._live_migration_common_check,
|
||||
self.context, i_ref, dest)
|
||||
|
||||
self.assertTrue(c)
|
||||
db.instance_destroy(self.context, instance_id)
|
||||
db.service_destroy(self.context, s_ref['id'])
|
||||
db.service_destroy(self.context, s_ref2['id'])
|
||||
|
@ -451,7 +451,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
|
||||
self.mox.ReplayAll()
|
||||
conn = libvirt_conn.LibvirtConnection(False)
|
||||
self.assertRaises(exception.Invalid,
|
||||
self.assertRaises(exception.ComputeServiceUnavailable,
|
||||
conn.update_available_resource,
|
||||
self.context, 'dummy')
|
||||
|
||||
|
@ -1389,7 +1389,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
||||
try:
|
||||
service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
|
||||
except exception.NotFound:
|
||||
raise exception.ComputeServiceUnavailable()
|
||||
raise exception.ComputeServiceUnavailable(host=host)
|
||||
|
||||
# Updating host information
|
||||
dic = {'vcpus': self.get_vcpu_total(),
|
||||
|
Loading…
Reference in New Issue
Block a user