Module: VagrantPlugins::OVirtProvider::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-ovirt4/action.rb,
lib/vagrant-ovirt4/action/halt_vm.rb,
lib/vagrant-ovirt4/action/start_vm.rb,
lib/vagrant-ovirt4/action/create_vm.rb,
lib/vagrant-ovirt4/action/destroy_vm.rb,
lib/vagrant-ovirt4/action/is_created.rb,
lib/vagrant-ovirt4/action/is_running.rb,
lib/vagrant-ovirt4/action/read_state.rb,
lib/vagrant-ovirt4/action/suspend_vm.rb,
lib/vagrant-ovirt4/action/resize_disk.rb,
lib/vagrant-ovirt4/action/sync_folders.rb,
lib/vagrant-ovirt4/action/wait_till_up.rb,
lib/vagrant-ovirt4/action/connect_ovirt.rb,
lib/vagrant-ovirt4/action/read_ssh_info.rb,
lib/vagrant-ovirt4/action/snapshot_list.rb,
lib/vagrant-ovirt4/action/snapshot_save.rb,
lib/vagrant-ovirt4/action/message_not_up.rb,
lib/vagrant-ovirt4/action/wait_till_down.rb,
lib/vagrant-ovirt4/action/snapshot_delete.rb,
lib/vagrant-ovirt4/action/message_already_up.rb,
lib/vagrant-ovirt4/action/set_name_of_domain.rb,
lib/vagrant-ovirt4/action/wait_til_suspended.rb,
lib/vagrant-ovirt4/action/message_not_created.rb,
lib/vagrant-ovirt4/action/message_powering_up.rb,
lib/vagrant-ovirt4/action/message_saving_state.rb,
lib/vagrant-ovirt4/action/message_not_suspended.rb,
lib/vagrant-ovirt4/action/message_already_created.rb,
lib/vagrant-ovirt4/action/create_network_interfaces.rb

Defined Under Namespace

Classes: ConnectOVirt, CreateNetworkInterfaces, CreateVM, DestroyVM, HaltVM, IsCreated, IsRunning, MessageAlreadyCreated, MessageAlreadyUp, MessageNotCreated, MessageNotSuspended, MessageNotUp, MessagePoweringUp, MessageSavingState, ReadSSHInfo, ReadState, ResizeDisk, SetNameOfDomain, SnapshotDelete, SnapshotList, SnapshotSave, StartVM, SuspendVM, SyncFolders, WaitTilSuspended, WaitTillDown, WaitTillUp

Class Method Summary collapse

Class Method Details

.action_destroyObject



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

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use ConnectOVirt
      b2.use ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
      b2.use HaltVM
      b2.use WaitTillDown
      b2.use DestroyVM
    end
  end
end

.action_haltObject



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vagrant-ovirt4/action.rb', line 138

def self.action_halt
  with_ovirt do |env, b|
    b.use Call, IsRunning do |env2, b2|
      if env[:machine_state_id] == :powering_up
        b2.use MessagePoweringUp
        next
      end
      if !env2[:result]
        b2.use MessageNotUp
        next
      end
      b2.use HaltVM
      b2.use WaitTillDown
    end
  end
end

.action_provisionObject



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

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      if !env[:result]
        b2.use MessageNotCreated
        next
      end
      b2.use Provision
      b2.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.



89
90
91
92
93
94
95
# File 'lib/vagrant-ovirt4/action.rb', line 89

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    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.



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

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

.action_reloadObject



155
156
157
158
159
160
# File 'lib/vagrant-ovirt4/action.rb', line 155

def self.action_reload
  with_ovirt do |env, b|
    b.use action_halt
    b.use action_up
  end
end

.action_resumeObject



179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/vagrant-ovirt4/action.rb', line 179

def self.action_resume
  with_ovirt do |env, b|
    if env[:machine_state_id] == :saving_state
      b.use MessageSavingState
      next
    end
    if env[:machine_state_id] != :suspended
      b.use MessageNotSuspended
      next
    end
    b.use action_up
  end
end

.action_snapshot_deleteObject



205
206
207
208
209
# File 'lib/vagrant-ovirt4/action.rb', line 205

def self.action_snapshot_delete
  with_ovirt do |env, b|
    b.use SnapshotDelete
  end
end

.action_snapshot_listObject



193
194
195
196
197
# File 'lib/vagrant-ovirt4/action.rb', line 193

def self.action_snapshot_list
  with_ovirt do |env, b|
    b.use SnapshotList
  end
end

.action_snapshot_saveObject



199
200
201
202
203
# File 'lib/vagrant-ovirt4/action.rb', line 199

def self.action_snapshot_save
  with_ovirt do |env, b|
    b.use SnapshotSave
  end
end

.action_sshObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/vagrant-ovirt4/action.rb', line 97

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use MessageNotCreated
        next
      end
      if env[:machine_state_id] != :up
        b2.use MessageNotUp
        next
      end

      raise Errors::NoIPError if env[:ip_address].nil?
      b2.use SSHExec
    end
  end
end

.action_ssh_runObject



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

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :not_created
        b2.use MessageNotCreated
        next
      end
      if env[:machine_state_id] != :up
        b2.use MessageNotUp
        next
      end

      raise Errors::NoIPError if env[:ip_address].nil?
      b2.use SSHRun
    end
  end
end

.action_suspendObject



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

def self.action_suspend
  with_ovirt do |env, b|
    b.use Call, IsRunning do |env2, b2|
      if env[:machine_state_id] == :powering_up
        b2.use MessagePoweringUp
        next
      end
      if !env2[:result]
        b2.use MessageNotUp
        next
      end
      b2.use SuspendVM
      b2.use WaitTilSuspended
    end
  end
end

.action_upObject

This action is called to bring the box up from nothing.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vagrant-ovirt4/action.rb', line 10

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectOVirt
    b.use Call, ReadState do |env, b2|
      if env[:machine_state_id] == :up
        b2.use SyncFolders
        b2.use MessageAlreadyUp
        next
      end

      if env[:machine_state_id] == :saving_state
        b2.use MessageSavingState
        next
      end

      if env[:machine_state_id] == :not_created
        b2.use SetNameOfDomain
        b2.use CreateVM
        #b2.use ResizeDisk

        b2.use Provision
        b2.use CreateNetworkInterfaces

        b2.use SetHostname
      end

      b2.use StartVM
      b2.use WaitTillUp
      b2.use SyncFolders
    end
  end
end