Merge "Boot from image fails without a clear error message"

This commit is contained in:
Jenkins 2017-04-28 15:00:37 +00:00 committed by Gerrit Code Review
commit e7a4106b58
3 changed files with 37 additions and 4 deletions

View File

@ -162,13 +162,38 @@ class DPMdriverInitHostTestCase(TestCase):
@mock.patch.object(vm.PartitionInstance, 'attach_hbas')
@mock.patch.object(vm.PartitionInstance, 'get_partition')
@mock.patch.object(vm.PartitionInstance, 'properties')
def test_prep_for_spawn(self, mock_properties,
mock_partition, mock_attac_hbas,
mock_create, mock_context, mock_flavor):
self.dpmdriver.prep_for_spawn(mock.Mock, mock.Mock())
def test_prep_for_spawn_volume(self, mock_properties,
mock_partition,
mock_attac_hbas,
mock_create,
mock_context,
mock_flavor):
instance = mock.Mock()
instance.image_ref = ''
self.dpmdriver.prep_for_spawn(mock.Mock, instance)
mock_create.assert_called_once()
mock_attac_hbas.assert_called_once()
@mock.patch.object(flavor_object.Flavor, 'get_by_id')
@mock.patch.object(context_object, 'get_admin_context')
@mock.patch.object(vm.PartitionInstance, 'create')
@mock.patch.object(vm.PartitionInstance, 'attach_hbas')
@mock.patch.object(vm.PartitionInstance, 'get_partition')
@mock.patch.object(vm.PartitionInstance, 'properties')
def test_prep_for_spawn_image(self, mock_properties,
mock_partition,
mock_attac_hbas,
mock_create,
mock_context,
mock_flavor):
instance = mock.Mock()
instance.image_ref = '6c77503d-4bff-4205-9e90-d75373c3c689'
self.assertRaises(
exceptions.BootFromImageNotSupported,
self.dpmdriver.prep_for_spawn,
mock.Mock(), instance)
@mock.patch.object(vm.PartitionInstance, 'get_partition')
def test_get_volume_connector(self, mock_get_partition):
self.dpmdriver.get_volume_connector(mock.Mock())

View File

@ -300,6 +300,10 @@ class DPMDriver(driver.ComputeDriver):
def prep_for_spawn(self, context, instance,
flavor=None):
if instance.image_ref != '':
raise exceptions.BootFromImageNotSupported()
if not flavor:
context = context_object.get_admin_context(read_deleted='yes')
flavor = (

View File

@ -32,6 +32,10 @@ class BootOsSpecificParametersPropertyExceededError(NovaException):
"'boot-os-specific-parameters' property.")
class BootFromImageNotSupported(NovaException):
msg_fmt = _("Boot from image is not supported in nova-dpm.")
class UnsupportedVolumeTypeException(NovaException):
msg_fmt = _("Driver volume type"
" %(vol_type)s is not supported by nova-dpm.")