lib/commands/prepare-plan.rb in canzea-0.1.68 vs lib/commands/prepare-plan.rb in canzea-0.1.70

- old
+ new

@@ -4,40 +4,45 @@ require 'yaml' require 'canzea/config' class PreparePlan def initialize () + @log = Logger.new(Canzea::config[:logging_root] + '/plans.log') @basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}/catalog" end # Read the blueprint instructions and prepare plan for a particular segment def do (blueprint, segment, step, test, privateKey, serverBase, serverNumber) planStep = PlanStep.new - puts "Processing configure.json for #{segment} in #{blueprint} from #{@basePath}" + log "Processing configure.json for #{segment} in #{blueprint} from #{@basePath}" instructions = YAML.load_file("#{@basePath}/blueprints/#{blueprint}/instruction.yml") segment = instructions['instructions']['segments'][segment] - puts segment['abbreviation'] + log segment['abbreviation'] index = 1 segment['image'].each { |item| if item.start_with?("step:") parts = item.split(':') if (index < Integer(step)) - puts "[#{index}] #{item} SKIPPING" + log "[#{index.to_s.rjust(2, "0")}] #{item} SKIPPING" else - puts "[#{index}] #{item}" + log "[#{index.to_s.rjust(2, "0")}] #{item}" if (test == false) publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{serverBase}-#{serverNumber}.json") - RemoteRun.new.do publicIp, privateKey, parts[1], parts[2] + RemoteRun.new.do publicIp, privateKey, parts[1], parts[2], index.to_s.rjust(2, "0") # Keep track of what we have done; parsing the response and looking at the JSON end end index = index + 1 end } end + def log (msg) + puts "-- #{msg}" + @log.info(msg) + end end \ No newline at end of file