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
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 cc6b0dd..1bb1b7b 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
@@ -172,7 +174,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)