lib/commands/prepare-plan.rb in canzea-0.1.123 vs lib/commands/prepare-plan.rb in canzea-0.1.124
- old
+ new
@@ -1,19 +1,34 @@
require 'json'
+require 'base64'
require 'commands/add-env'
require 'plan-step-class'
require 'yaml'
require 'canzea/config'
+require 'commands/remote-run'
class PreparePlan
def initialize ()
@log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
@basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}"
end
+ def doPatch (params, test, privateKey, serverBase, serverNumber)
+
+ publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{serverBase}-#{serverNumber}.json")
+ publicIp.strip!
+
+ patches = Base64.decode64(params['patches'])
+ params['patches'] = JSON.parse(patches)
+
+ params['patches'].each do | patch |
+ RemoteRun.new.doCommand publicIp, privateKey, patch.command
+ end
+ end
+
# Read the blueprint instructions and prepare plan for a particular segment
- def do (blueprint, segment, step, test, privateKey, serverBase, serverNumber)
+ def do (blueprint, segment, step, task, test, privateKey, serverBase, serverNumber)
planStep = PlanStep.new
log "Processing configure.json for #{segment} in #{blueprint} from #{@basePath}"
instructions = YAML.load_file("#{@basePath}/blueprints/#{blueprint}/instruction.yml")
@@ -28,13 +43,20 @@
if (index < Integer(step))
log "[#{index.to_s.rjust(2, "0")}] #{item} SKIPPING"
else
log "[#{index.to_s.rjust(2, "0")}] #{item}"
+ publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{serverBase}-#{serverNumber}.json")
+ publicIp.strip!
if (test == false)
- publicIp = File.read("#{Canzea::config[:pwd]}/vps-#{serverBase}-#{serverNumber}.json")
- RemoteRun.new.do publicIp, privateKey, parts[1], parts[2], index.to_s.rjust(2, "0")
+ if (task == nil)
+ RemoteRun.new.do publicIp, privateKey, parts[1], parts[2], index.to_s.rjust(2, "0")
+ else
+ RemoteRun.new.doTask publicIp, privateKey, parts[1], parts[2], task, index.to_s.rjust(2, "0")
+ end
# Keep track of what we have done; parsing the response and looking at the JSON
+ else
+ RemoteRun.new.test publicIp, privateKey, parts[1], parts[2], index.to_s.rjust(2, "0")
end
end
index = index + 1
end
}
\ No newline at end of file