Module: VagrantPlugins::OpenStack::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-openstack-plugin/action.rb,
lib/vagrant-openstack-plugin/plugin.rb,
lib/vagrant-openstack-plugin/command.rb,
lib/vagrant-openstack-plugin/action/is_paused.rb,
lib/vagrant-openstack-plugin/action/is_created.rb,
lib/vagrant-openstack-plugin/action/read_state.rb,
lib/vagrant-openstack-plugin/action/is_suspended.rb,
lib/vagrant-openstack-plugin/action/pause_server.rb,
lib/vagrant-openstack-plugin/action/sync_folders.rb,
lib/vagrant-openstack-plugin/action/create_server.rb,
lib/vagrant-openstack-plugin/action/delete_server.rb,
lib/vagrant-openstack-plugin/action/read_ssh_info.rb,
lib/vagrant-openstack-plugin/action/reboot_server.rb,
lib/vagrant-openstack-plugin/action/resume_server.rb,
lib/vagrant-openstack-plugin/action/take_snapshot.rb,
lib/vagrant-openstack-plugin/action/wait_for_task.rb,
lib/vagrant-openstack-plugin/action/warn_networks.rb,
lib/vagrant-openstack-plugin/action/is_snapshoting.rb,
lib/vagrant-openstack-plugin/action/suspend_server.rb,
lib/vagrant-openstack-plugin/action/wait_for_state.rb,
lib/vagrant-openstack-plugin/action/connect_openstack.rb,
lib/vagrant-openstack-plugin/command/command_snapshot.rb,
lib/vagrant-openstack-plugin/action/hard_reboot_server.rb,
lib/vagrant-openstack-plugin/action/message_not_created.rb,
lib/vagrant-openstack-plugin/action/message_snapshot_done.rb,
lib/vagrant-openstack-plugin/action/message_already_paused.rb,
lib/vagrant-openstack-plugin/action/message_server_running.rb,
lib/vagrant-openstack-plugin/action/message_already_created.rb,
lib/vagrant-openstack-plugin/action/message_will_not_destroy.rb,
lib/vagrant-openstack-plugin/action/create_network_interfaces.rb,
lib/vagrant-openstack-plugin/action/message_already_suspended.rb,
lib/vagrant-openstack-plugin/action/create_orchestration_stack.rb,
lib/vagrant-openstack-plugin/action/delete_orchestration_stack.rb,
lib/vagrant-openstack-plugin/action/message_snapshot_in_progress.rb

Defined Under Namespace

Classes: Command, CommandTakeSnapshot, ConnectOpenStack, CreateNetworkInterfaces, CreateOrchestrationStack, CreateServer, DeleteOrchestrationStack, DeleteServer, HardRebootServer, IsCreated, IsPaused, IsSnapshoting, IsSuspended, MessageAlreadyCreated, MessageAlreadyPaused, MessageAlreadySuspended, MessageNotCreated, MessageServerRunning, MessageSnapshotDone, MessageSnapshotInProgress, MessageWillNotDestroy, PauseServer, Plugin, ReadSSHInfo, ReadState, RebootServer, ResumeServer, SuspendServer, SyncFolders, TakeSnapshot, WaitForState, WaitForTask, WarnNetworks

Class Method Summary collapse

Class Method Details

.action_destroy ⇒ Object

This action is called when vagrant destroy is executed.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-openstack-plugin/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 ConnectOpenStack
        b1.use DeleteServer
        b1.use DeleteOrchestrationStack
      else
        b1.use MessageWillNotDestroy
      end
    end
  end
end

.action_halt ⇒ Object

This action is called when vagrant halt is executed.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/vagrant-openstack-plugin/action.rb', line 148

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      unless env[:result]
        b1.use Call, IsSuspended do |env2, b2|
          if env2[:result]
            b1.use MessageAlreadySuspended
            next
          end
        end
      end

      b1.use ConnectOpenStack
      b1.use PauseServer
    end
  end
end

.action_prepare_boot ⇒ Object



78
79
80
81
82
83
84
# File 'lib/vagrant-openstack-plugin/action.rb', line 78

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

.action_provision ⇒ Object

This action is called when vagrant provision is executed.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/vagrant-openstack-plugin/action.rb', line 110

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

.action_read_ssh_info ⇒ Object

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.



30
31
32
33
34
35
36
# File 'lib/vagrant-openstack-plugin/action.rb', line 30

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

.action_read_state ⇒ Object

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.



41
42
43
44
45
46
47
# File 'lib/vagrant-openstack-plugin/action.rb', line 41

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

.action_reload ⇒ Object

This action is called when vagrant reload is executed.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/vagrant-openstack-plugin/action.rb', line 127

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenStack
    b.use Call, IsPaused do |env, b1|
      unless env[:result]
        b1.use Call, IsSuspended do |env2, b2|
          b2.use RebootServer
        end
      end

      b1.use Call, WaitForState, [:active], 120 do |env2, b2|
        unless env2[:result]
          b2.use HardRebootServer
        end
      end
    end
  end
end

.action_resume ⇒ Object

This action is called when vagrant resume is executed.



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/vagrant-openstack-plugin/action.rb', line 168

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 ConnectOpenStack
      b1.use ResumeServer
      b1.use SyncFolders
    end
  end
end

.action_ssh ⇒ Object

This action is called when vagrant ssh is executed.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/vagrant-openstack-plugin/action.rb', line 50

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_run ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/vagrant-openstack-plugin/action.rb', line 64

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_suspend ⇒ Object

This action is called when vagrant suspend is executed.



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/vagrant-openstack-plugin/action.rb', line 185

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      if env[:result]
        b1.use ConnectOpenStack
        b1.use SuspendServer
      else
        b1.use Call, IsPaused do |env2, b2|
          if env2[:result]
            b2.use MessageAlreadyPaused
          else
            b2.use MessageAlreadySuspended
          end
        end
      end
    end
  end
end

.action_take_snapshot ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/vagrant-openstack-plugin/action.rb', line 205

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]
        b1.use ConnectOpenStack
        b1.use Call, IsSnapshoting do |env,b2|
          if env[:result]
            b2.use MessageSnapshotInProgress
          else
            b2.use TakeSnapshot
          end

          b2.use Call, WaitForTask, [nil], 1200 do |env3, b3|
            if env3[:result]
              b3.use MessageSnapshotDone
            end
          end


        end
      else
        b1.use MessageNotCreated
      end
    end
  end
end

.action_up ⇒ Object

This action is called when vagrant up is executed.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vagrant-openstack-plugin/action.rb', line 87

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    if Vagrant::VERSION < '1.6.0'
      b.use HandleBoxUrl
    else
      b.use HandleBox
    end
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b1|
      unless env[:result]
        b1.use action_prepare_boot
        b1.use ConnectOpenStack
        b1.use CreateOrchestrationStack
        b1.use CreateServer
        b1.use CreateNetworkInterfaces
      else
        b1.use action_resume
      end
    end
  end
end