Substitute special characters in resource class
Everything except alphanumeric characters and an underscore needs to
be replaced by an underscore.
Closes-issue: https://mirantis.jira.com/browse/PRODX-9565
Change-Id: Icb30abb9a4f147d8aeddd99908ec29e8ccd63ac6
(cherry picked from commit b843614d884eed648212889cb70eb4154b60bb43)
(cherry picked from commit d22afcb4c9b58705ef48ec805a4eb50cad58c128)
(cherry picked from commit a3f29922668b39ccaa9f5ef5631cc232fc0308d3)
diff --git a/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py b/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
index dcfc023..b0878fc 100644
--- a/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
+++ b/ironic_tempest_plugin/tests/scenario/test_baremetal_basic_ops.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import re
+
from oslo_log import log as logging
from tempest.common import utils
from tempest.common import waiters
@@ -176,7 +178,9 @@
# The resource class in ironic may be lower case, and must omit the
# CUSTOM_ prefix. Normalise it.
node_resource_class = node['resource_class']
- node_resource_class = node_resource_class.upper()
+ # Replace non-alphanumeric characters with underscores
+ node_resource_class = re.sub(
+ '[^0-9A-Za-z]+', '_', node_resource_class).upper()
node_resource_class = 'CUSTOM_' + node_resource_class
self.assertEqual(resource_class, node_resource_class)