Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Replace all illegal chars in disk aliases #408

Merged
merged 3 commits into from
Jun 21, 2022

Conversation

smelamud
Copy link
Member

@smelamud smelamud commented Jun 2, 2022

When importing a VM, aliases are generated for all imported disks. To
comply with oVirt naming convention for disk aliases, we need to replace
all illegal characters that may appear in imported disk names.

Change-Id: I4f54a3fd8e31799d8ca33d2f4413e82f452ebabd
Bug-Url: https://bugzilla.redhat.com/1904962
Signed-off-by: Shmuel Melamud smelamud@redhat.com

When importing a VM, aliases are generated for all imported disks. To
comply with oVirt naming convention for disk aliases, we need to replace
all illegal characters that may appear in imported disk names.

Change-Id: I4f54a3fd8e31799d8ca33d2f4413e82f452ebabd
Bug-Url: https://bugzilla.redhat.com/1904962
Signed-off-by: Shmuel Melamud <smelamud@redhat.com>
@@ -75,6 +75,7 @@

private static final Pattern VMWARE_DISK_NAME_PATTERN = Pattern.compile("\\[.*?\\] .*/(.*).vmdk");
private static final Pattern DISK_NAME_PATTERN = Pattern.compile(".*/([^.]+).*");
private static final Pattern DISK_ALIAS_ILLEGAL_CHARS_PATTERN = Pattern.compile("[^\\w.-]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you allow only word chars? numeric is impossible? can you tell what exactly is illegal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

OK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

so can we reuse the pattern that is used by the webadmin?

@@ -75,6 +75,7 @@

private static final Pattern VMWARE_DISK_NAME_PATTERN = Pattern.compile("\\[.*?\\] .*/(.*).vmdk");
private static final Pattern DISK_NAME_PATTERN = Pattern.compile(".*/([^.]+).*");
private static final Pattern DISK_ALIAS_ILLEGAL_CHARS_PATTERN = Pattern.compile("[^\\w.-]");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\w includes latin letters, digits and underscore. Also period (.) and hyphen (-) are allowed. These are characters that we allow for disk alias in WebAdmin.

so can we reuse the pattern that is used by the webadmin?

@smelamud
Copy link
Member Author

Verified.

Change-Id: I5e8a6a974b80ab29841f2a9e1158157895f3245e
Signed-off-by: Shmuel Melamud <smelamud@redhat.com>
Change-Id: Ib64f9d8228c28b1a4479d0e9ed4d27b06836a4c7
Signed-off-by: Shmuel Melamud <smelamud@redhat.com>
@ahadas
Copy link
Member

ahadas commented Jun 21, 2022

/ost

@ahadas ahadas merged commit b4dda15 into oVirt:master Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants