[PATCH conductor 1/2] BZ815357: api: handle template xml in CDATA in images controller

mzatko at redhat.com mzatko at redhat.com
Thu May 3 12:49:44 UTC 2012


From: Maros Zatko <mzatko at redhat.com>

---
 src/app/controllers/api/images_controller.rb |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/app/controllers/api/images_controller.rb b/src/app/controllers/api/images_controller.rb
index 2bcbeee..8b9ac99 100644
--- a/src/app/controllers/api/images_controller.rb
+++ b/src/app/controllers/api/images_controller.rb
@@ -145,10 +145,17 @@ module Api
     private
     def process_post(body)
       doc = Nokogiri::XML CGI.unescapeHTML(body)
-      if !doc.xpath("/image/targets").empty? && !doc.xpath("/image/tdl/template").empty? && !doc.xpath("/image/environment").empty?
-        { :type => :build, :params => { :template => doc.xpath("/image/tdl/template").to_s,
-                                        :targets => doc.xpath("/image/targets").text,
-                                        :environment => doc.xpath("/image/environment").text}
+
+      if !doc.xpath("/image/targets").empty? &&
+         !doc.xpath("/image/tdl").empty? &&
+         !doc.xpath("/image/environment").empty?
+
+        template = Nokogiri::XML(doc.xpath("/image/tdl").text).xpath("/template")
+
+        { :type => :build,
+          :params => { :template => template.to_s,
+                       :targets => doc.xpath("/image/targets").text,
+                       :environment => doc.xpath("/image/environment").text}
         }
       elsif !doc.xpath("/image/provider_account_name").empty? && !doc.xpath("/image/target_identifier").empty? &&
                  !doc.xpath("/image/image_descriptor").empty? && !doc.xpath("/image/environment").empty?
-- 
1.7.7.6




More information about the aeolus-devel mailing list