Sha256: 8b7c0b9d8aad80da8cc80fcee567b63f5f20c5abb1242ae17c77ee3e6864aa88

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

require 'vagrant-skytap/api/vm'

module VagrantPlugins
  module Skytap
    module Action
      # This can be used with "Call" built-in to check if the environment
      # is created and branch in the middleware.
      class ExistenceCheck
        def initialize(app, env)
          @app = app
          @logger = Log4r::Logger.new("vagrant_skytap::action::existence_check")
        end

        def call(env)
          environment = env[:environment]
          env[:result] = if !environment
            :missing_environment
          elsif environment.vms.count == 0
            :no_vms
          elsif !environment.current_vm
            # Could be confusing. The *current* vm is not present. This response also implies that there are other vms.
            :missing_vm
          elsif environment.vms.count == 1
            :solitary_vm
          else
            :one_of_many_vms
          end
          @logger.debug("ExistenceCheck returning #{env[:result]}")

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.11 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.10 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.9 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.8 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.7 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.6 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.5 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.4 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.3 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.2 lib/vagrant-skytap/action/existence_check.rb
vagrant-skytap-0.1.1a lib/vagrant-skytap/action/existence_check.rb