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/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, 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_destroyObject

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_haltObject

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



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/vagrant-openstack-plugin/action.rb', line 144

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_bootObject



78
79
80
81
82
83
84
85
# 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 WarnNetworks
    b.use SetHostname
  end
end

.action_provisionObject

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



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/vagrant-openstack-plugin/action.rb', line 106

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_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.



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_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.



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_reloadObject

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



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/vagrant-openstack-plugin/action.rb', line 123

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_resumeObject

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



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/vagrant-openstack-plugin/action.rb', line 164

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_sshObject

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_runObject



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_suspendObject

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



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/vagrant-openstack-plugin/action.rb', line 181

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_snapshotObject



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

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_upObject

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



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

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 ConnectOpenStack
        b1.use CreateOrchestrationStack
        b1.use CreateServer
      else
        b1.use action_resume
      end
    end
  end
end