Module: VagrantPlugins::Openstack::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-openstack-provider/action.rb,
lib/vagrant-openstack-provider/action/resume.rb,
lib/vagrant-openstack-provider/action/message.rb,
lib/vagrant-openstack-provider/action/suspend.rb,
lib/vagrant-openstack-provider/action/wait_stop.rb,
lib/vagrant-openstack-provider/action/read_state.rb,
lib/vagrant-openstack-provider/action/stop_server.rb,
lib/vagrant-openstack-provider/action/wait_active.rb,
lib/vagrant-openstack-provider/action/start_server.rb,
lib/vagrant-openstack-provider/action/sync_folders.rb,
lib/vagrant-openstack-provider/action/create_server.rb,
lib/vagrant-openstack-provider/action/delete_server.rb,
lib/vagrant-openstack-provider/action/read_ssh_info.rb,
lib/vagrant-openstack-provider/action/connect_openstack.rb

Defined Under Namespace

Classes: ConnectOpenstack, CreateServer, DeleteServer, Message, NoSyncFolders, ReadSSHInfo, ReadState, Resume, RsyncFolders, StartServer, StopServer, Suspend, SyncFolders, WaitForServerToBeActive, WaitForServerToStop

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to destroy the remote machine.



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

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use DeleteServer
      end
    end
  end
end

.action_haltObject



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/vagrant-openstack-provider/action.rb', line 114

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use StopServer
      end
    end
  end
end

.action_provisionObject

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



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-openstack-provider/action.rb', line 27

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use Provision
        b2.use SyncFolders
      end
    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.



45
46
47
48
49
50
51
# File 'lib/vagrant-openstack-provider/action.rb', line 45

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.



56
57
58
59
60
61
62
# File 'lib/vagrant-openstack-provider/action.rb', line 56

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



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/vagrant-openstack-provider/action.rb', line 162

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      when :suspended
        b2.use Resume
        b2.use WaitForServerToBeActive
        b2.use StopServer
        b2.use WaitForServerToStop
        b2.use StartServer
      when :shutoff
        b2.use StartServer
      else
        b2.use StopServer
        b2.use WaitForServerToStop
        b2.use StartServer
      end
    end
  end
end

.action_resumeObject

This is the action that is primarily responsible for resuming suspended machines.



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

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use Resume
      end
    end
  end
end

.action_sshObject



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

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use SSHExec
      end
    end
  end
end

.action_ssh_runObject



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/vagrant-openstack-provider/action.rb', line 78

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      else
        b2.use SSHRun
      end
    end
  end
end

.action_suspendObject

This is the action that is primarily responsible for suspending the virtual machine.



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

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use Message, I18n.t('vagrant_openstack.not_created')
      elsif env[:machine_state_id] == :suspended
        b2.use Message, I18n.t('vagrant_openstack.already_suspended')
      else
        b2.use Suspend
      end
    end
  end
end

.action_upObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/vagrant-openstack-provider/action.rb', line 92

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOpenstack

    b.use Call, ReadState do |env, b2|
      case env[:machine_state_id]
      when :not_created
        b2.use Provision
        b2.use SyncFolders
        b2.use CreateServer
      when :shutoff
        b2.use StartServer
      when :suspended
        b2.use Resume
      else
        b2.use Message, I18n.t('vagrant_openstack.already_created')
      end
    end
  end
end