Module: VagrantPlugins::Vmpooler::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-vmpooler/action.rb,
lib/vagrant-vmpooler/action/is_paused.rb,
lib/vagrant-vmpooler/action/is_created.rb,
lib/vagrant-vmpooler/action/read_state.rb,
lib/vagrant-vmpooler/action/setup_rsync.rb,
lib/vagrant-vmpooler/action/is_suspended.rb,
lib/vagrant-vmpooler/action/pause_server.rb,
lib/vagrant-vmpooler/action/sync_folders.rb,
lib/vagrant-vmpooler/action/create_server.rb,
lib/vagrant-vmpooler/action/delete_server.rb,
lib/vagrant-vmpooler/action/read_ssh_info.rb,
lib/vagrant-vmpooler/action/reboot_server.rb,
lib/vagrant-vmpooler/action/resume_server.rb,
lib/vagrant-vmpooler/action/take_snapshot.rb,
lib/vagrant-vmpooler/action/suspend_server.rb,
lib/vagrant-vmpooler/action/wait_for_state.rb,
lib/vagrant-vmpooler/action/hard_reboot_server.rb,
lib/vagrant-vmpooler/action/message_not_created.rb,
lib/vagrant-vmpooler/action/message_server_running.rb,
lib/vagrant-vmpooler/action/message_already_created.rb,
lib/vagrant-vmpooler/action/message_will_not_destroy.rb

Defined Under Namespace

Classes: CreateServer, DeleteServer, HardRebootServer, IsCreated, IsPaused, IsSuspended, MessageAlreadyCreated, MessageNotCreated, MessageServerRunning, MessageWillNotDestroy, PauseServer, ReadSSHInfo, ReadState, RebootServer, ResumeServer, SetupRsync, SuspendServer, SyncFolders, TakeSnapshot, WaitForState

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called when ‘vagrant destroy` is executed.



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

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

.action_haltObject

This action is called when ‘vagrant halt` is executed.



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

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      # throw error?
      env[:ui].warn(I18n.t("vagrant_vmpooler.not_supported"))
    end
  end
end

.action_prepare_bootObject



74
75
76
77
78
79
80
# File 'lib/vagrant-vmpooler/action.rb', line 74

def self.action_prepare_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use Provision
    b.use SyncFolders
    b.use SetHostname
  end
end

.action_provisionObject

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



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/vagrant-vmpooler/action.rb', line 100

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

      b1.use Provision
      b1.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.



28
29
30
31
32
33
# File 'lib/vagrant-vmpooler/action.rb', line 28

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.



38
39
40
41
42
43
# File 'lib/vagrant-vmpooler/action.rb', line 38

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

.action_reloadObject

This action is called when ‘vagrant reload` is executed.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/vagrant-vmpooler/action.rb', line 116

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsPaused do |env, b1|
      unless env[:result]
        b1.use Call, IsSuspended do |env2, b2|
          env[:ui].warn(I18n.t("vagrant_vmpooler.not_supported"))
          #b2.use RebootServer
        end
      end

      b1.use Call, WaitForState, [:active], 120 do |env2, b2|
        unless env2[:result]
          env[:ui].warn(I18n.t("vagrant_vmpooler.not_supported"))
          #b2.use HardRebootServer
        end
      end
    end
  end
end

.action_resumeObject

This action is called when ‘vagrant resume` is executed.



149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/vagrant-vmpooler/action.rb', line 149

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      if env[:result]
        b1.use MessageServerRunning
        next
      end

      b1.use ResumeServer
      b1.use SyncFolders
    end
  end
end

.action_sshObject

This action is called when ‘vagrant ssh` is executed.



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vagrant-vmpooler/action.rb', line 46

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

      b1.use SSHExec
    end
  end
end

.action_ssh_runObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/vagrant-vmpooler/action.rb', line 60

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

      b1.use SSHRun
    end
  end
end

.action_suspendObject

This action is called when ‘vagrant suspend` is executed.



165
166
167
168
169
170
171
172
# File 'lib/vagrant-vmpooler/action.rb', line 165

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      env[:ui].warn(I18n.t("vagrant_vmpooler.not_supported"))
    end
  end
end

.action_take_snapshotObject



174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/vagrant-vmpooler/action.rb', line 174

def self.action_take_snapshot
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      if env[:result]
        b2.use TakeSnapshot
      else
        b1.use MessageNotCreated
      end
    end
  end
end

.action_upObject

This action is called when ‘vagrant up` is executed.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/vagrant-vmpooler/action.rb', line 83

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      unless env[:result]
        b1.use action_prepare_boot
        b1.use CreateServer
        b1.use SetupRsync
      else
        b1.use action_resume
      end
    end
  end
end