Module: VagrantPlugins::TiktalikVagrant::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-tiktalik/action.rb,
lib/vagrant-tiktalik/action/power_on.rb,
lib/vagrant-tiktalik/action/power_off.rb,
lib/vagrant-tiktalik/action/is_created.rb,
lib/vagrant-tiktalik/action/read_state.rb,
lib/vagrant-tiktalik/action/run_instance.rb,
lib/vagrant-tiktalik/action/sync_folders.rb,
lib/vagrant-tiktalik/action/read_ssh_info.rb,
lib/vagrant-tiktalik/action/warn_networks.rb,
lib/vagrant-tiktalik/action/timed_provision.rb,
lib/vagrant-tiktalik/action/terminate_instance.rb,
lib/vagrant-tiktalik/action/message_not_created.rb,
lib/vagrant-tiktalik/action/message_already_created.rb,
lib/vagrant-tiktalik/action/message_will_not_destroy.rb

Defined Under Namespace

Classes: IsCreated, MessageAlreadyCreated, MessageNotCreated, MessageWillNotDestroy, PowerOff, PowerOn, ReadSSHInfo, ReadState, RunInstance, SyncFolders, TerminateInstance, TimedProvision, WarnNetworks

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vagrant-tiktalik/action.rb', line 26

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, DestroyConfirm do |env, b2|
      if env[:result]
        b2.use ConfigValidate
        b2.use TerminateInstance
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vagrant-tiktalik/action.rb', line 11

def self.action_halt
  Vagrant::Action::Builder.new.tap do |builder|
    builder.use ConfigValidate
    builder.use Call, ReadState do |env, b|
      case env[:machine_state_id]
        when :running
          b.use PowerOff
        else
          env[:ui].info I18n.t('vagrant_tiktalik.errors.instance_not_running')
      end
    end
  end
end

.action_provisionObject

This action is called when ‘vagrant provision` is called.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vagrant-tiktalik/action.rb', line 40

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Provision
      b2.use SyncFolders
    end
  end
end

.action_read_ssh_infoObject

This action is called to read the SSH info of the machine. The resulting state is expected to be put into the ‘:machine_ssh_info` key.



58
59
60
61
62
63
# File 'lib/vagrant-tiktalik/action.rb', line 58

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ReadSSHInfo
  end
end

.action_read_stateObject

This action is called to read the state of the machine. The resulting state is expected to be put into the ‘:machine_state_id` key.



68
69
70
71
72
73
# File 'lib/vagrant-tiktalik/action.rb', line 68

def self.action_read_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ReadState
  end
end

.action_sshObject

This action is called to SSH into the machine.



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vagrant-tiktalik/action.rb', line 76

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SSHExec
    end
  end
end

.action_ssh_runObject



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/vagrant-tiktalik/action.rb', line 90

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SSHRun
    end
  end
end

.action_upObject

This action is called to bring the box up from nothing.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/vagrant-tiktalik/action.rb', line 105

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate

    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :running
        env[:ui].info I18n.t('vagrant_tiktalik.active_instance')
      when :stopped
        b2.use TimedProvision
        b2.use PowerOn
        b2.use SyncFolders
      when :not_created
        b2.use TimedProvision
        b2.use SyncFolders
        #b2.use WarnNetworks
        b2.use RunInstance
      else
        env[:ui].info I18n.t('vagrant_tiktalik.unknown_state')
      end
    end
  end
end