Skip to content

Commit e989940

Browse files
committed
hardware: Use image_meta.id within get_mem_encryption_constraint
This change resolves bug #1928063 by replacing the use of image_meta.name with image_meta.id as I55d66c3a6cbd50da90065f4a58f77b5cd29ce9ea should ensure it is always available. The removal of other references to image_meta.name within virt.hardware is left for follow ups to keep this change small and backportable. Closes-Bug: #1928063 Change-Id: I66299e97bdb5b95e149b1780231a1c1bbdbd9865
1 parent d5ed968 commit e989940

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

nova/tests/functional/regressions/test_bug_1928063.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from nova import test
1919
from nova.tests.fixtures import libvirt as fakelibvirt
20-
from nova.tests.functional.api import client
2120
from nova.tests.functional.libvirt import base
2221
from nova.virt.libvirt.host import SEV_KERNEL_PARAM_FILE
2322

@@ -58,12 +57,5 @@ def test_hard_reboot(self):
5857
networks='none'
5958
)
6059

61-
# FIXME(lyarwood): This is bug #1928063, the instance fails to reboot
62-
# due to a NotImplementedError exception being raised when we try to
63-
# access image_meta.name as this isn't stashed in the system_metadata
64-
# of the instance and as a result is not provided in the image_meta
65-
# associated with the instance during this flow.
66-
ex = self.assertRaises(
67-
client.OpenStackApiException,
68-
self._reboot_server, server, hard=True)
69-
self.assertEqual(500, ex.response.status_code)
60+
# Hard reboot the server
61+
self._reboot_server(server, hard=True)

nova/tests/unit/virt/test_hardware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5421,7 +5421,7 @@ def test_image_requires_encrypted_memory_support_no_uefi(self):
54215421
for image_prop in ('1', 'true', 'True'):
54225422
self._test_encrypted_memory_support_no_uefi(
54235423
None, image_prop,
5424-
"hw_mem_encryption property of image %s" % self.image_name)
5424+
"hw_mem_encryption property of image %s" % self.image_id)
54255425

54265426
def test_flavor_image_require_encrypted_memory_support_no_uefi(self):
54275427
for extra_spec in ('1', 'true', 'True'):
@@ -5430,7 +5430,7 @@ def test_flavor_image_require_encrypted_memory_support_no_uefi(self):
54305430
extra_spec, image_prop,
54315431
"hw:mem_encryption extra spec in %s flavor and "
54325432
"hw_mem_encryption property of image %s"
5433-
% (self.flavor_name, self.image_name))
5433+
% (self.flavor_name, self.image_id))
54345434

54355435

54365436
class MemEncryptionRequestedWithInvalidMachineTypeTestCase(
@@ -5508,7 +5508,7 @@ def test_require_encrypted_memory_support_image_prop(self):
55085508
self._test_encrypted_memory_support_required(
55095509
{},
55105510
{'hw_mem_encryption': image_prop},
5511-
"hw_mem_encryption property of image %s" % self.image_name
5511+
"hw_mem_encryption property of image %s" % self.image_id
55125512
)
55135513

55145514
def test_require_encrypted_memory_support_both_required(self):
@@ -5519,7 +5519,7 @@ def test_require_encrypted_memory_support_both_required(self):
55195519
{'hw_mem_encryption': image_prop},
55205520
"hw:mem_encryption extra spec in %s flavor and "
55215521
"hw_mem_encryption property of image %s" %
5522-
(self.flavor_name, self.image_name)
5522+
(self.flavor_name, self.image_id)
55235523
)
55245524

55255525

nova/virt/hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ def get_mem_encryption_constraint(
13131313
flavor.name)
13141314
if image_mem_enc:
13151315
requesters.append("hw_mem_encryption property of image %s" %
1316-
image_meta.name)
1316+
image_meta.id)
13171317

13181318
_check_mem_encryption_uses_uefi_image(requesters, image_meta)
13191319
_check_mem_encryption_machine_type(image_meta, machine_type)

0 commit comments

Comments
 (0)