Sha256: 06c6396d310fece8801cf86e95e854e1d1fbfb031b8ff3c3d488af009f51177f

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module Bosh::Bootstrap::Stages
  class StageValidateInceptionVm
    attr_reader :settings

    def initialize(settings)
      @settings = settings
    end

    def commands
      @commands ||= Bosh::Bootstrap::Commander::Commands.new do |server|
        server.validate "ubuntu", script("validate_ubuntu"), ssh_username: settings.inception.username
      end
    end

    private
    def stage_name
      "stage_validate_inception_vm"
    end

    # Loads local script
    # If +variables+, then injects KEY=VALUE environment
    # variables into bash scripts.
    def script(segment_name, variables={})
      path = File.expand_path("../#{stage_name}/#{segment_name}", __FILE__)
      if File.exist?(path)
        script = File.read(path)
        if variables.keys.size > 0
          inline_variables = "#!/usr/bin/env bash\n\n"
          variables.each { |name, value| inline_variables << "#{name}=#{value}\n" }
          script.gsub!("#!/usr/bin/env bash", inline_variables)
        end
        script
      else
        Thor::Base.shell.new.say_status "error", "Missing script lib/bosh-bootstrap/stages/#{stage_name}/#{segment_name}", :red
        exit 1
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bosh-bootstrap-0.10.2 lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb
bosh-bootstrap-0.10.1 lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb
bosh-bootstrap-0.10.0 lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb
bosh-bootstrap-0.9.0 lib/bosh-bootstrap/stages/stage_validate_inception_vm.rb