Description of problem: Using Horizon to instantiate VM: Instances -> Launch Instance -> Key Pair -> Create Key Pair Trying to create Key Pair name with underscore character, getting "name contains bad characters" error - see attached screenshot. If you are trying to create Security Key Pair prior to VM instantiation using Access & Security -> Create Key Pair, "underscore" character is accepted. "Underscore" character shall be accepted in Security Key Pair name also in Instances -> Launch Instance -> Key Pair -> Create Key Pair menu. Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
The underscore is now allowed from the launch instance wizard, but not allowed from the key pairs page. This seems to be to opposite situation from what the bug describes.
The code we changed here isn't used by that form ... are you able to revert that patch and confirm it doesn't change the behavior of the create_key form ?
That part of the form regex is handled by this chunk of code: *** NEW_LINES = re.compile(r"\r|\n") KEYPAIR_NAME_REGEX = re.compile(r"^\w+(?:[- ]\w+)*$", re.UNICODE) KEYPAIR_ERROR_MESSAGES = { 'invalid': _('Key pair name may only contain letters, ' 'numbers, underscores, spaces, and hyphens ' 'and may not be white space.')} class CreateKeypair(forms.SelfHandlingForm): name = forms.RegexField(max_length=255, label=_("Key Pair Name"), regex=KEYPAIR_NAME_REGEX, error_messages=KEYPAIR_ERROR_MESSAGES) *** Out of curiosity, I tested this and it worked: ### import re KEYPAIR_NAME_REGEX = re.compile(r"^\w+(?:[- ]\w+)*$", re.UNICODE) string="test_test" pattern = KEYPAIR_NAME_REGEX.match(string) if pattern: print("matched") else: print("not matched") ### [dhill@knox openstack_dashboard]$ python regex_test.py matched
Well that is strange I was just able to reproduce this issue too.
And stranger is that I was able to reproduce this issue too up until now. Now I'm no longer able to reproduce this issue with the patch on and no changes at all. Could it be a browser cache issue and QA procedure ? What I did is something like this: 1) Applied the patch 2) Restarted httpd 3) Tried creating a Key Pair from the Access & Security tab 4) Didn't work for ANY Key Pairs (not just containing an underscore, all of them would just fail) then : 1) Reverted the patch 2) Restarted httpd 3) Tried creating a Key Pair from the Access & Security tab 4) Started working back again then : 1) Applied the patch 2) Restarted httpd 3) Tried creating a Key Pair from the Access & Security tab 4) Failed back again for all Key Pairs and well, then I tried lots of things like moving the undercore elsewhere in the regex, for instance "[_A-Za-z0-9 -]" , restarted httpd, retried and it failed back again. Finally, all of a sudden, it started working for some reasons . I'm wondering if there's a temp file in horizon or the browser that could have generated this situation ?
It looks like you have to restart httpd twice when changing the files in /usr/share/openstack-dashboard/openstack_dashboard because the first time you restart it, it copies the change to /usr/share/openstack-dashboard/static and I'm not able to create any key pairs . Then, if I restart httpd, it starts working. What happens if you change the existing files in /usr/share/openstack-dashboard/static before restarting httpd ? Does it help ? Are you able to solve the problem by restarting httpd a second time ?
I can confirm that each time I modify the file located in /usr/share/openstack-dashboard/openstack_dashboard, I need to restart httpd twice or Key Pair creation isn't working at all in that section. I'd suggest you try it too to confirm it solves it for you too.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHEA-2019:0045