From: Jan Provaznik<jprovazn(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=761139
---
src/app/controllers/images_controller.rb | 23 +++++++++++++++++++----
src/app/models/template_xml.rb | 6 +++++-
src/config/locales/en.yml | 1 +
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/app/controllers/images_controller.rb
b/src/app/controllers/images_controller.rb
index a178596..123b8a2 100644
--- a/src/app/controllers/images_controller.rb
+++ b/src/app/controllers/images_controller.rb
@@ -113,12 +113,16 @@ class ImagesController< ApplicationController
begin
doc = TemplateXML.new(xml_source)
- rescue Nokogiri::XML::SyntaxError
- errors = [t('template_xml.errors.xml_parse_error')]
- else
doc.name = @name
@xml = doc.to_xml
errors = doc.validate
+ # check explicitly if rootpw is set or not,
+ # imagefactory requires this param for some
+ # target/platform combinations
+ #
https://bugzilla.redhat.com/show_bug.cgi?id=761139
+ flash.now[:warning] = I18n.t('images.flash.warning.no_rootpw') if
doc.rootpw.blank?
+ rescue Nokogiri::XML::SyntaxError
+ errors = [t('template_xml.errors.xml_parse_error')]
end
if errors.any?
@@ -134,7 +138,18 @@ class ImagesController< ApplicationController
@name = params[:name]
@xml = params[:image_xml]
- errors = TemplateXML.validate(@xml)
+ begin
+ doc = TemplateXML.new(@xml)
+ errors = doc.validate
+ # check explicitly if rootpw is set or not,
+ # imagefactory requires this param for some
+ # target/platform combinations
+ #
https://bugzilla.redhat.com/show_bug.cgi?id=761139
+ flash.now[:warning] = I18n.t('images.flash.warning.no_rootpw') if
doc.rootpw.blank?
+ rescue Nokogiri::XML::SyntaxError
+ errors = [t('template_xml.errors.xml_parse_error')]
+ end
+
if errors.any?
flash.now[:error] = errors
render :edit_xml and return
diff --git a/src/app/models/template_xml.rb b/src/app/models/template_xml.rb
index 149c9c5..8a2aa4c 100644
--- a/src/app/models/template_xml.rb
+++ b/src/app/models/template_xml.rb
@@ -57,7 +57,11 @@ class TemplateXML
end
def name
- doc.xpath('/template/name').text
+ @xml.xpath('/template/name').text
+ end
+
+ def rootpw
+ @xml.xpath('/template/os/rootpw').text
end
def to_xml
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 4dab401..602e766 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -727,6 +727,7 @@ en:
warning:
delete_failed: Unable to Delete Image
not_found: Image not found
+ no_rootpw: "Template has no rootpw parameter, build will fail for some
targets."
error:
invalid_url: Could not load the provided URL
new: