Module: VagrantPlugins::ProviderLibvirt::Action
- Includes:
- Vagrant::Action::Builtin
- Defined in:
- lib/vagrant-libvirt/action.rb,
lib/vagrant-libvirt/action/is_created.rb,
lib/vagrant-libvirt/action/is_running.rb,
lib/vagrant-libvirt/action/read_state.rb,
lib/vagrant-libvirt/action/halt_domain.rb,
lib/vagrant-libvirt/action/is_suspended.rb,
lib/vagrant-libvirt/action/start_domain.rb,
lib/vagrant-libvirt/action/wait_till_up.rb,
lib/vagrant-libvirt/action/create_domain.rb,
lib/vagrant-libvirt/action/forward_ports.rb,
lib/vagrant-libvirt/action/forward_ports.rb,
lib/vagrant-libvirt/action/read_ssh_info.rb,
lib/vagrant-libvirt/action/resume_domain.rb,
lib/vagrant-libvirt/action/share_folders.rb,
lib/vagrant-libvirt/action/destroy_domain.rb,
lib/vagrant-libvirt/action/suspend_domain.rb,
lib/vagrant-libvirt/action/connect_libvirt.rb,
lib/vagrant-libvirt/action/create_networks.rb,
lib/vagrant-libvirt/action/destroy_networks.rb,
lib/vagrant-libvirt/action/handle_box_image.rb,
lib/vagrant-libvirt/action/prune_nfs_exports.rb,
lib/vagrant-libvirt/action/set_name_of_domain.rb,
lib/vagrant-libvirt/action/handle_storage_pool.rb,
lib/vagrant-libvirt/action/message_not_created.rb,
lib/vagrant-libvirt/action/message_not_running.rb,
lib/vagrant-libvirt/action/create_domain_volume.rb,
lib/vagrant-libvirt/action/prepare_nfs_settings.rb,
lib/vagrant-libvirt/action/message_not_suspended.rb,
lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb,
lib/vagrant-libvirt/action/message_already_created.rb,
lib/vagrant-libvirt/action/create_network_interfaces.rb
Defined Under Namespace
Classes: ClearForwardedPorts, ConnectLibvirt, CreateDomain, CreateDomainVolume, CreateNetworkInterfaces, CreateNetworks, DestroyDomain, DestroyNetworks, ForwardPorts, HaltDomain, HandleBoxImage, HandleStoragePool, IsCreated, IsRunning, IsSuspended, MessageAlreadyCreated, MessageNotCreated, MessageNotRunning, MessageNotSuspended, PrepareNFSSettings, PrepareNFSValidIds, PruneNFSExports, ReadSSHInfo, ReadState, ResumeDomain, SetNameOfDomain, ShareFolders, StartDomain, SuspendDomain, WaitTillUp
Class Method Summary collapse
-
.action_destroy ⇒ Object
This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.
-
.action_halt ⇒ Object
This is the action that is primarily responsible for halting the virtual machine.
-
.action_provision ⇒ Object
This action is called when ‘vagrant provision` is called.
-
.action_read_ssh_info ⇒ Object
This action is called to read the SSH info of the machine.
-
.action_read_state ⇒ Object
This action is called to read the state of the machine.
-
.action_reload ⇒ Object
This is the action implements the reload command It uses the halt and start actions.
-
.action_resume ⇒ Object
This is the action that is primarily responsible for resuming suspended machines.
-
.action_ssh ⇒ Object
This action is called to SSH into the machine.
-
.action_ssh_run ⇒ Object
This is the action that will run a single SSH command.
-
.action_start ⇒ Object
Assuming VM is created, just start it.
-
.action_suspend ⇒ Object
This is the action that is primarily responsible for suspending the virtual machine.
-
.action_up ⇒ Object
This action is called to bring the box up from nothing.
Class Method Details
.action_destroy ⇒ Object
This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/vagrant-libvirt/action.rb', line 150 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 ConnectLibvirt b2.use ClearForwardedPorts # b2.use PruneNFSExports b2.use DestroyDomain b2.use DestroyNetworks end end end |
.action_halt ⇒ Object
This is the action that is primarily responsible for halting the virtual machine.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/vagrant-libvirt/action.rb', line 106 def self.action_halt Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectLibvirt b.use ClearForwardedPorts b.use Call, IsCreated do |env, b2| if !env[:result] b2.use MessageNotCreated next end b2.use Call, IsSuspended do |env2, b3| b3.use ResumeDomain if env2[:result] end b2.use Call, IsRunning do |env2, b3| next if !env2[:result] # VM is running, halt it. b3.use HaltDomain end end end end |
.action_provision ⇒ Object
This action is called when ‘vagrant provision` is called.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/vagrant-libvirt/action.rb', line 192 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 ConnectLibvirt b2.use Call, IsRunning do |env2, b3| if !env2[:result] b3.use MessageNotRunning next end b3.use Provision # b3.use SyncFolders end 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.
274 275 276 277 278 279 280 |
# File 'lib/vagrant-libvirt/action.rb', line 274 def self.action_read_ssh_info Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectLibvirt 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.
263 264 265 266 267 268 269 |
# File 'lib/vagrant-libvirt/action.rb', line 263 def self.action_read_state Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectLibvirt b.use ReadState end end |
.action_reload ⇒ Object
This is the action implements the reload command It uses the halt and start actions
133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/vagrant-libvirt/action.rb', line 133 def self.action_reload Vagrant::Action::Builder.new.tap do |b| b.use Call, IsCreated do |env, b2| if !env[:result] b2.use MessageNotCreated next end b2.use ConfigValidate b2.use action_halt b2.use action_start end end end |
.action_resume ⇒ Object
This is the action that is primarily responsible for resuming suspended machines.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/vagrant-libvirt/action.rb', line 240 def self.action_resume 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 ConnectLibvirt b2.use Call, IsSuspended do |env2, b3| if !env2[:result] b3.use MessageNotSuspended next end b3.use ResumeDomain end end end end |
.action_ssh ⇒ Object
This action is called to SSH into the machine.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/vagrant-libvirt/action.rb', line 169 def self.action_ssh 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 ConnectLibvirt b2.use Call, IsRunning do |env2, b3| if !env2[:result] b3.use MessageNotRunning next end b3.use SSHExec end end end end |
.action_ssh_run ⇒ Object
This is the action that will run a single SSH command.
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/vagrant-libvirt/action.rb', line 283 def self.action_ssh_run 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 ConnectLibvirt b2.use Call, IsRunning do |env2, b3| if !env2[:result] b3.use MessageNotRunning next end b3.use SSHRun end end end end |
.action_start ⇒ Object
Assuming VM is created, just start it. This action is not called directly by any subcommand. VM can be suspended, already running or in poweroff state.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/vagrant-libvirt/action.rb', line 60 def self.action_start Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectLibvirt b.use Call, IsRunning do |env, b2| # If the VM is running, then our work here is done, exit next if env[:result] b2.use Call, IsSuspended do |env2, b3| # if vm is suspended resume it then exit if env2[:result] b3.use ResumeDomain next end # VM is not running or suspended. b3.use Provision # Ensure networks are created and active b3.use CreateNetworks b3.use PrepareNFSValidIds b3.use SyncedFolderCleanup b3.use SyncedFolders # Start it.. b3.use StartDomain # Machine should gain IP address when comming up, # so wait for dhcp lease and store IP into machines data_dir. b3.use WaitTillUp b3.use ForwardPorts b3.use PrepareNFSSettings b3.use ShareFolders end end end end |
.action_suspend ⇒ Object
This is the action that is primarily responsible for suspending the virtual machine.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/vagrant-libvirt/action.rb', line 217 def self.action_suspend 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 ConnectLibvirt b2.use Call, IsRunning do |env2, b3| if !env2[:result] b3.use MessageNotRunning next end b3.use SuspendDomain end end end end |
.action_up ⇒ Object
This action is called to bring the box up from nothing.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/vagrant-libvirt/action.rb', line 12 def self.action_up Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate b.use ConnectLibvirt b.use Call, IsCreated do |env, b2| # Create VM if not yet created. if !env[:result] b2.use SetNameOfDomain b2.use HandleStoragePool b2.use HandleBox b2.use HandleBoxImage b2.use CreateDomainVolume b2.use CreateDomain b2.use Provision b2.use CreateNetworks b2.use CreateNetworkInterfaces b2.use PrepareNFSValidIds b2.use SyncedFolderCleanup b2.use SyncedFolders b2.use StartDomain b2.use WaitTillUp b2.use StartDomain b2.use WaitTillUp b2.use ForwardPorts b2.use PrepareNFSSettings b2.use ShareFolders b2.use SetHostname # b2.use SyncFolders else b2.use action_start end end end end |