[Ovirt-devel] [PATCH server] Refines the validation for an NFS URL for Cobbler images.

Darryl L. Pierce dpierce at redhat.com
Mon Dec 22 22:03:23 UTC 2008


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




More information about the ovirt-devel mailing list