Class: PreparePlan
- Inherits:
-
Object
- Object
- PreparePlan
- Defined in:
- lib/commands/prepare-plan.rb
Instance Method Summary collapse
-
#do(blueprint, segment, step, test, privateKey, serverBase, serverNumber) ⇒ Object
Read the blueprint instructions and prepare plan for a particular segment.
-
#initialize ⇒ PreparePlan
constructor
A new instance of PreparePlan.
- #log(msg) ⇒ Object
Constructor Details
#initialize ⇒ PreparePlan
Returns a new instance of PreparePlan.
8 9 10 11 |
# File 'lib/commands/prepare-plan.rb', line 8 def initialize () @log = Logger.new(Canzea::config[:logging_root] + '/plans.log') @basePath = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}/catalog" end |
Instance Method Details
#do(blueprint, segment, step, test, privateKey, serverBase, serverNumber) ⇒ Object
Read the blueprint instructions and prepare plan for a particular segment
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/commands/prepare-plan.rb', line 14 def do (blueprint, segment, step, 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") segment = instructions['instructions']['segments'][segment] log segment['abbreviation'] index = 1 segment['image'].each { |item| if item.start_with?("step:") parts = item.split(':') if (index < Integer(step)) log "[#{index.to_s.rjust(2, "0")}] #{item} SKIPPING" else 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], 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 |
#log(msg) ⇒ Object
44 45 46 47 |
# File 'lib/commands/prepare-plan.rb', line 44 def log (msg) puts "-- #{msg}" @log.info(msg) end |