Module: VagrantPlugins::VMM::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-vmm/action.rb,
lib/vagrant-vmm/action/import.rb,
lib/vagrant-vmm/action/delete_vm.rb,
lib/vagrant-vmm/action/resume_vm.rb,
lib/vagrant-vmm/action/read_state.rb,
lib/vagrant-vmm/action/suspend_vm.rb,
lib/vagrant-vmm/action/stop_instance.rb,
lib/vagrant-vmm/action/start_instance.rb,
lib/vagrant-vmm/action/wait_for_ip_address.rb,
lib/vagrant-vmm/action/message_will_not_destroy.rb

Defined Under Namespace

Classes: DeleteVM, Import, MessageWillNotDestroy, ReadState, ResumeVM, StartInstance, StopInstance, SuspendVM, WaitForIPAddress

Class Method Summary collapse

Class Method Details

.action_destroyObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vagrant-vmm/action.rb', line 26

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsState, :not_created do |env1, b1|
      if env1[:result]
        b1.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b1.use Call, DestroyConfirm do |env2, b2|
        if !env2[:result]
          b2.use MessageWillNotDestroy
          next
        end

        b2.use ConfigValidate
        b2.use StopInstance
        b2.use DeleteVM
      end
    end
  end
end

.action_haltObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vagrant-vmm/action.rb', line 48

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b2|
      if env[:result]
        b2.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b2.use Call, GracefulHalt, :off, :running do |env2, b3|
        if !env2[:result]
          b3.use StopInstance
        end
      end
    end
  end
end

.action_provisionObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/vagrant-vmm/action.rb', line 66

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b2|
      if env[:result]
        b2.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b2.use Call, IsState, :running do |env1, b3|
        if !env1[:result]
          b3.use Message, I18n.t("vagrant_VMM.message_not_running")
          next
        end


        b3.use Provision
        b3.use SyncedFolders
        b3.use WaitForIPAddress
        b3.use WaitForCommunicator, [:running]
      end
    end
  end
end

.action_read_stateObject



149
150
151
152
153
154
# File 'lib/vagrant-vmm/action.rb', line 149

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

.action_reloadObject



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

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b2|
      if env[:result]
        b2.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b2.use action_halt
      b2.use action_start
    end
  end
end

.action_resumeObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/vagrant-vmm/action.rb', line 91

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b1|
      if env[:result]
        b1.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b1.use ResumeVM
      b1.use WaitForIPAddress
      b1.use WaitForCommunicator, [:running]
    end
  end
end

.action_sshObject



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/vagrant-vmm/action.rb', line 156

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b2|
      if env[:result]
        b2.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b2.use Call, IsState, :running do |env1, b3|
        if !env1[:result]
          b3.use Message, I18n.t("vagrant_VMM.message_not_running")
          next
        end

        b3.use SSHExec
      end
    end
  end
end

.action_ssh_runObject



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/vagrant-vmm/action.rb', line 177

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b2|
      if env[:result]
        b2.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b2.use Call, IsState, :running do |env1, b3|
        if !env1[:result]
          b3.use Message, I18n.t("vagrant_VMM.message_not_running")
          next
        end

        b3.use SSHRun
      end
    end
  end
end

.action_startObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/vagrant-vmm/action.rb', line 108

def self.action_start
  Vagrant::Action::Builder.new.tap do |b|
    #
    b.use Call, IsState, :running do |env1, b1|
      if env1[:result]
        b1.use Message, I18n.t("vagrant_VMM.message_already_running")
        next
      end

      b1.use Call, IsState, :poweroff do |env2, b2|
        # if not started
        if env2[:result]
          b2.use StartInstance
          next
        end

        b2.use Call, IsState, :paused do |env3, b3|
          # if machine was paused
          if env3[:result]
            b3.use action_resume
            next
          end
        end
      end
    end
    #
  end
end

.action_suspendObject



198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/vagrant-vmm/action.rb', line 198

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env, b2|
      if env[:result]
        b2.use Message, I18n.t("vagrant_VMM.message_not_created")
        next
      end

      b2.use SuspendVM
    end
  end
end

.action_upObject



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/vagrant-vmm/action.rb', line 137

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsState, :not_created do |env1, b1|
      if env1[:result]
        b1.use Import
      end
    end
    b.use action_start
  end
end