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