Darryl L. Pierce
2008-Dec-22 15:14 UTC
[Ovirt-devel] [PATCH server] Refines the validation for an NFS URL for Cobbler images.
If the URL contains a : after the hostname but no port, then it is ignored. However, if there is no protocol specified and no port supplied then an exception is raised. For now, however, we do not use the port if it's included and use the default NFS port regardless. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- src/task-omatic/task_vm.rb | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/task-omatic/task_vm.rb b/src/task-omatic/task_vm.rb index c187287..345bde5 100644 --- a/src/task-omatic/task_vm.rb +++ b/src/task-omatic/task_vm.rb @@ -369,7 +369,7 @@ def start_vm(task) # extract the components of the image filename image_uri = details.file - protocol = auth = ip_addr = export_path = filename = "" + protocol = auth = ip_addr = port = export_path = filename = "" protocol, image_uri = image_uri.split("://") if image_uri.include?("://") auth, image_uri = image_uri.split("@") if image_uri.include?("@") @@ -377,9 +377,14 @@ def start_vm(task) # result here, so we'll just ignore it ignored, ip_addr, image_uri image_uri.split(/^([^\/]+)(\/.*)/) unless image_uri =~ /^\// + # we extract the port even though we currently do not make use of it + ip_addr, port = ip_addr.split(":") if ip_addr.include?(":") + port = "" if !port ignored, export_path, filename image_uri.split(/^(.*)\/(.+)/) + raise "Invalid image URL specified" if ip_addr && port.empty? && protocol.empty? + found = false vm.storage_volumes.each do |volume| -- 1.6.0.6
Darryl L. Pierce
2008-Dec-22 22:03 UTC
[Ovirt-devel] [PATCH server] Refines the validation for an NFS URL for Cobbler images.
The image record file validation has changed. Entries are now going to be in the following allowed formats: username:password at hostname:/path/to/the/filename.ext username at hostname:/path/to/the/filename.ext hostname:/path/to/the/filename.ext /path/to/the/filename.ext Any other format, including legacy ones specifying a protocol, are quietly modified to fit the above formats. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- src/task-omatic/task_vm.rb | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/task-omatic/task_vm.rb b/src/task-omatic/task_vm.rb index c187287..f9d1617 100644 --- a/src/task-omatic/task_vm.rb +++ b/src/task-omatic/task_vm.rb @@ -369,16 +369,12 @@ def start_vm(task) # extract the components of the image filename image_uri = details.file - protocol = auth = ip_addr = export_path = filename = "" + auth = ip_addr = path = filename = "" - protocol, image_uri = image_uri.split("://") if image_uri.include?("://") auth, image_uri = image_uri.split("@") if image_uri.include?("@") - # it's ugly, but string.split returns an empty string as the first - # result here, so we'll just ignore it - ignored, ip_addr, image_uri - image_uri.split(/^([^\/]+)(\/.*)/) unless image_uri =~ /^\// - ignored, export_path, filename - image_uri.split(/^(.*)\/(.+)/) + ip_addr, image_uri = image_uri.split(":") if image_uri.include?(":") + filename = image_uri.split("/").last + export_path = filename[0...(0-filename.length)] found = false -- 1.6.0.6