Class: VagrantPlugins::Utm::Action::CheckAccessible

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_utm/action/check_accessible.rb

Overview

This middleware checks that the VM is accessible, and raises an exception TODO: Define what is inaccessible in UTM and set the state accordingly Currently, UTM does not report inaccessible state, So this plugin will set the state to inaccessible Hence, this action will never raise an exception

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ CheckAccessible

Returns a new instance of CheckAccessible.



15
16
17
# File 'lib/vagrant_utm/action/check_accessible.rb', line 15

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant_utm/action/check_accessible.rb', line 19

def call(env)
  if env[:machine].state.id == :inaccessible
    # The VM we are attempting to manipulate is inaccessible. This
    # is a very bad situation and can only be fixed by the user. It
    # also prohibits us from actually doing anything with the virtual
    # machine, so we raise an error.
    raise Vagrant::Errors::VMInaccessible
  end

  @app.call(env)
end