Module: VagrantPlugins::OpenStack::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-openstack-plugin/action.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/warn_networks.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/action/hard_reboot_server.rb,
lib/vagrant-openstack-plugin/action/message_not_created.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

Defined Under Namespace

Classes: ConnectOpenStack, CreateServer, DeleteServer, HardRebootServer, IsCreated, IsPaused, IsSuspended, MessageAlreadyCreated, MessageAlreadyPaused, MessageAlreadySuspended, MessageNotCreated, MessageServerRunning, MessageWillNotDestroy, PauseServer, ReadSSHInfo, ReadState, RebootServer, ResumeServer, SuspendServer, SyncFolders, WaitForState, 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
# 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
      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



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

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.



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

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.



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

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.



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

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.



121
122
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 121

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|
          b1.use action_halt unless env2[:result]
        end
      end

      b1.use Call, WaitForState, [:paused, :suspended], 120 do |env2, b2|
        if env2[:result]
          b2.use action_up
        else
          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.



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

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



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

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_upObject

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



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

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