[Ovirt-devel] [PATCH server] Changed how taskomatic handles a Cobbler image record.

Darryl L. Pierce dpierce at redhat.com
Wed Dec 17 18:51:39 UTC 2008


It will now incrementally pull out the protocol, authentication details,
hostname or ip address, export path and filename for the image record.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 src/task-omatic/task_vm.rb |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/task-omatic/task_vm.rb b/src/task-omatic/task_vm.rb
index 35d78f2..c187287 100644
--- a/src/task-omatic/task_vm.rb
+++ b/src/task-omatic/task_vm.rb
@@ -367,8 +367,18 @@ def start_vm(task)
 
       raise "Image #{vm.cobbler_name} not found in Cobbler server" unless details
 
-      ignored, ip_addr, export_path, filename =
-        details.file.split(/(.*):(.*)\/(.*)/)
+      # extract the components of the image filename
+      image_uri = details.file
+      protocol = auth = ip_addr = export_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(/^(.*)\/(.+)/)
 
       found = false
 
-- 
1.6.0.4




More information about the ovirt-devel mailing list