# File lib/aeolus_cli/command/build_command.rb, line 19 def initialize(opts={}, logger=nil) super(opts, logger) default = { :template_str => '', :template => '', :target => [], :image => '', :build => '', :validation => true } @options = default.merge(@options) end
# File lib/aeolus_cli/command/build_command.rb, line 84 def combo_implemented? if @options[:template].empty? || @options[:target].empty? || @options[:environment].nil? raise ArgumentError, "Error: This combination of parameters is not currently supported" end true end
# File lib/aeolus_cli/command/build_command.rb, line 75 def read_template template = read_file(@options[:template]) if template.nil? puts "Error: Cannot find specified file" quit(1) end template end
# File lib/aeolus_cli/command/build_command.rb, line 32 def run if combo_implemented? begin template = read_template validate_xml_schema(template) image = Aeolus::CLI::Image.new({ :targets => @options[:target] * ",", :tdl => "<![CDATA[#{template}]]>", :environment => @options[:environment]}) image.save! headers = ActiveSupport::OrderedHash.new headers[:image] = "Image" headers[:build] = "Build" headers[:id] = "Target Image" headers[:target] = "Target" headers[:status] = "Status" ti_array = Array(image.build.target_images.target_image) ti_array.each do |target_image| target_image.image = image.id target_image.build = image.build.id end print_collection(ti_array, headers) quit(0) rescue => e handle_exception(e) end end end
# File lib/aeolus_cli/command/build_command.rb, line 64 def validate_xml_schema(xml) errors = validate_xml_document(File.dirname(__FILE__) + "/../../../examples/tdl.rng", xml) if errors.length > 0 puts "ERROR: The given Template does not conform to the TDL Schema, see below for specific details:" errors.each do |error| puts "- Line: " + error.line.to_s + " => " + error.message end quit(1) end end