Sha256: 26fcc68b900b27802a5e2373a2d12b4a09cadd6b4b6abe208a8bf6d6ee68cab0

Contents?: true

Size: 1.65 KB

Versions: 44

Compression:

Stored size: 1.65 KB

Contents

require 'json'
require 'commands/add-env'
require 'plan-step-class'
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}"
    end

    # Read the blueprint instructions and prepare plan for a particular segment
    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

    def log (msg)
        puts "-- #{msg}"
        @log.info(msg)
    end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
canzea-0.1.123 lib/commands/prepare-plan.rb
canzea-0.1.122 lib/commands/prepare-plan.rb
canzea-0.1.121 lib/commands/prepare-plan.rb
canzea-0.1.120 lib/commands/prepare-plan.rb
canzea-0.1.119 lib/commands/prepare-plan.rb
canzea-0.1.118 lib/commands/prepare-plan.rb
canzea-0.1.117 lib/commands/prepare-plan.rb
canzea-0.1.116 lib/commands/prepare-plan.rb
canzea-0.1.115 lib/commands/prepare-plan.rb
canzea-0.1.114 lib/commands/prepare-plan.rb
canzea-0.1.113 lib/commands/prepare-plan.rb
canzea-0.1.112 lib/commands/prepare-plan.rb
canzea-0.1.111 lib/commands/prepare-plan.rb
canzea-0.1.110 lib/commands/prepare-plan.rb
canzea-0.1.109 lib/commands/prepare-plan.rb
canzea-0.1.108 lib/commands/prepare-plan.rb
canzea-0.1.107 lib/commands/prepare-plan.rb
canzea-0.1.106 lib/commands/prepare-plan.rb
canzea-0.1.105 lib/commands/prepare-plan.rb
canzea-0.1.104 lib/commands/prepare-plan.rb