Fix bug 2114951

This patch fixes an ambiguous regexp prevent using device_filename like
'mkwinimage-cdrom'.

The schema in Ib8857d9f725e277f27ccfab83335142b05e2cdf1 mistakenly
included r, which caused _-r to be interpreted as a range of items
from - to r.
The intent was to align the schema with what is allowed in
block_device.pyi -> validate_device_name()[1].
Since this brings the schema in line with existing validation logic, it
can be treated as a bug fix and does not require a microversion bump.

[1] 73724fef9a/nova/block_device.py (L378)

Closes-Bug: #2114951
Change-Id: Ie852e6dbd005ce46b41a486d3121d4d34d1fc1a2
Signed-off-by: René Ribaud <rribaud@redhat.com>
This commit is contained in:
René Ribaud
2025-06-19 16:01:32 +02:00
parent aa59133626
commit 1593dddfaf
2 changed files with 4 additions and 4 deletions

View File

@@ -27,11 +27,11 @@ _legacy_block_device_mapping = {
'volume_id': parameter_types.volume_id,
'snapshot_id': parameter_types.image_id,
'volume_size': parameter_types.volume_size,
# Do not allow empty device names and number values and
# containing spaces(defined in nova/block_device.py:from_api())
# Do not allow empty device names or spaces in name (defined in
# nova/block_device.py:validate_device_name())
'device_name': {
'type': 'string', 'minLength': 1, 'maxLength': 255,
'pattern': '^[a-zA-Z0-9._-r/]*$',
'pattern': '^[a-zA-Z0-9._/-]*$',
},
# Defined as boolean in nova/block_device.py:from_api()
'delete_on_termination': parameter_types.boolean,

View File

@@ -146,7 +146,7 @@ class BootFromVolumeTest(test.TestCase):
req.body = jsonutils.dump_as_bytes(body)
req.headers['content-type'] = 'application/json'
res = req.get_response(fakes.wsgi_app_v21())
self.assertEqual(400, res.status_int)
self.assertEqual(202, res.status_int)
class VolumeApiTestV21(test.NoDBTestCase):