Sha256: 57d22065500fd743e974f7f2ff71221efaf278534a4fc4933da31f6f085a2766

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

require 'log4r'
require 'vagrant-skytap/api/vm'


module VagrantPlugins
  module Skytap
    module Action
      # Adds the specified vm to this Skytap environment, assuming the vm and environment
      # both exist.
      class AddVmToEnvironment
        attr_reader :env

        def initialize(app, env)
          @app = app
          @env = env
          @logger = Log4r::Logger.new("vagrant_skytap::action::add_vm_to_environment")
        end

        def call(env)
          environment = env[:environment]
          vm = API::Vm.fetch(env, vm_url)
          environment.add_vms([vm])
          env[:machine].id = environment.vms.last.id
          environment.wait_until_ready

          @app.call(env)
        end

        def vm_url
          env[:machine].provider_config.vm_url
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/action/add_vm_to_environment.rb