api: Reject non-spawn operations for vTPM
We're going to gradually introduce support for the various instance operations when using vTPM due to the complications of having to worry about the state of the vTPM device on the host. Add in API checks to reject all manner of requests until we get to include support for each one. With this change, the upcoming patch to turn everything on will allow a user to create, delete and reboot an instance with vTPM, while evacuate, rebuild, cold migration, live migration, resize, rescue and shelve will not be supported immediately. While we're here, we rename two unit test files so that their names match the files they are testing and one doesn't have to spend time finding them. Change-Id: I3862a06ca28b383d525bcc9dcbc6fb1d4062f193 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -138,6 +138,11 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
allowed=0)
|
||||
self._test_migrate_exception(exc_info, webob.exc.HTTPForbidden)
|
||||
|
||||
def test_migrate_vtpm_not_supported(self):
|
||||
exc_info = exception.OperationNotSupportedForVTPM(
|
||||
instance_uuid=uuids.instance, operation='foo')
|
||||
self._test_migrate_exception(exc_info, webob.exc.HTTPConflict)
|
||||
|
||||
def _test_migrate_live_succeeded(self, param):
|
||||
instance = self._stub_instance_get()
|
||||
|
||||
@@ -284,6 +289,13 @@ class MigrateServerTestsV21(admin_only_action_common.CommonTests):
|
||||
expected_exc=webob.exc.HTTPConflict,
|
||||
check_response=False)
|
||||
|
||||
def test_migrate_live_vtpm_not_supported(self):
|
||||
self._test_migrate_live_failed_with_exception(
|
||||
exception.OperationNotSupportedForVTPM(
|
||||
instance_uuid=uuids.instance, operation='foo'),
|
||||
expected_exc=webob.exc.HTTPConflict,
|
||||
check_response=False)
|
||||
|
||||
def test_migrate_live_pre_check_error(self):
|
||||
self._test_migrate_live_failed_with_exception(
|
||||
exception.MigrationPreCheckError(reason=''))
|
||||
@@ -601,8 +613,10 @@ class MigrateServerTestsV268(MigrateServerTestsV256):
|
||||
|
||||
@mock.patch('nova.virt.hardware.get_mem_encryption_constraint',
|
||||
new=mock.Mock(return_value=True))
|
||||
@mock.patch.object(objects.instance.Instance, 'image_meta')
|
||||
def test_live_migrate_sev_rejected(self, mock_image):
|
||||
@mock.patch.object(
|
||||
objects.instance.Instance, 'image_meta',
|
||||
new=objects.ImageMeta.from_dict({}))
|
||||
def test_live_migrate_sev_rejected(self):
|
||||
instance = self._stub_instance_get()
|
||||
body = {'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto'}}
|
||||
|
||||
Reference in New Issue
Block a user