Merge "Boot from image fails without a clear error message"
This commit is contained in:
commit
e7a4106b58
|
@ -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())
|
||||
|
|
|
@ -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 = (
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue