Module: VagrantPlugins::ProviderZone::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-zones/action.rb,
lib/vagrant-zones/action/halt.rb,
lib/vagrant-zones/action/setup.rb,
lib/vagrant-zones/action/start.rb,
lib/vagrant-zones/action/create.rb,
lib/vagrant-zones/action/import.rb,
lib/vagrant-zones/action/destroy.rb,
lib/vagrant-zones/action/network.rb,
lib/vagrant-zones/action/package.rb,
lib/vagrant-zones/action/restart.rb,
lib/vagrant-zones/action/shutdown.rb,
lib/vagrant-zones/action/is_created.rb,
lib/vagrant-zones/action/not_created.rb,
lib/vagrant-zones/action/wait_till_up.rb,
lib/vagrant-zones/action/wait_till_boot.rb,
lib/vagrant-zones/action/network_cleanup.rb,
lib/vagrant-zones/action/prepare_nfs_valid_ids.rb

Overview

Run actions against the machine

Defined Under Namespace

Classes: Create, Destroy, Halt, Import, IsCreated, Network, NetworkingCleanup, NotCreated, Package, PrepareNFSValidIds, Restart, Setup, Shutdown, Start, WaitTillBoot, WaitTillUp

Class Method Summary collapse

Class Method Details

.action_box_outdatedObject



179
180
181
182
183
# File 'lib/vagrant-zones/action.rb', line 179

def self.action_box_outdated
  Builder.new.tap do |b|
    b.use Builtin::BoxCheckOutdated
  end
end

.action_box_removeObject

This is the action that will remove a box given a name (and optionally a provider). This middleware sequence is built-in to Vagrant. Plugins can hook into this like any other middleware sequence.



188
189
190
191
192
# File 'lib/vagrant-zones/action.rb', line 188

def self.action_box_remove
  Builder.new.tap do |b|
    b.use Builtin::BoxRemove
  end
end

.action_configure_zfs_snapshotsObject



173
174
175
176
177
# File 'lib/vagrant-zones/action.rb', line 173

def self.action_configure_zfs_snapshots
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigureSnapshots
  end
end

.action_create_zfs_snapshotsObject



160
161
162
163
164
165
# File 'lib/vagrant-zones/action.rb', line 160

def self.action_create_zfs_snapshots
  Vagrant::Action::Builder.new.tap do |b|
    # b.use ConfigValidate # is this per machine?
    b.use CreateSnapshots
  end
end

.action_delete_zfs_snapshotsObject



167
168
169
170
171
# File 'lib/vagrant-zones/action.rb', line 167

def self.action_delete_zfs_snapshots
  Vagrant::Action::Builder.new.tap do |b|
    b.use DeleteSnapshots
  end
end

.action_destroyObject

This is the action that is primarily responsible for completely freeing the resources of the underlying virtual machine.



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

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |env1, b2|
      unless env1[:result]
        b2.use NotCreated
        b2.use Call, DestroyConfirm do |env2, b3|
          b3.use Destroy if env2[:result]
        end
        next
      end
      b2.use Call, DestroyConfirm do |env2, b3|
        b3.use Destroy if env2[:result]
      end
    end
  end
end

.action_haltObject

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



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/vagrant-zones/action.rb', line 85

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use NotCreated
        next
      end
      b2.use Halt if env[:result]
    end
  end
end

.action_packageObject

This action is called when you try to package an existing virtual machine to an box image.



111
112
113
114
115
# File 'lib/vagrant-zones/action.rb', line 111

def self.action_package
  Vagrant::Action::Builder.new.tap do |b|
    b.use Package
  end
end

.action_provisionObject

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



136
137
138
139
140
141
142
143
144
# File 'lib/vagrant-zones/action.rb', line 136

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |_env, b2|
      b2.use Call, IsState, :running do |_env2, b3|
        b3.use Provision
      end
    end
  end
end

.action_reloadObject

This is the action implements the reload command It uses the halt and start actions



147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/vagrant-zones/action.rb', line 147

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use NotCreated
        next
      end
      b2.use action_halt
      b2.use action_start
    end
  end
end

.action_restartObject



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant-zones/action.rb', line 58

def self.action_restart
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |_env, b2|
      b2.use Call, IsState, :stopped do |env2, b3|
        unless env2[:result]
          b3.use WaitTillUp
          b3.use Restart
        end
      end
    end
  end
end

.action_shutdownObject



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/vagrant-zones/action.rb', line 71

def self.action_shutdown
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |_env, b2|
      b2.use Call, IsState, :stopped do |env2, b3|
        unless env2[:result]
          b3.use WaitTillUp
          b3.use Shutdown
        end
      end
    end
  end
end

.action_sshObject

This action is called to SSH into the machine.



98
99
100
101
102
# File 'lib/vagrant-zones/action.rb', line 98

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use SSHExec
  end
end

.action_ssh_runObject



104
105
106
107
108
# File 'lib/vagrant-zones/action.rb', line 104

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use SSHRun
  end
end

.action_startObject

Assuming VM is created, just start it. This action is not called directly by any subcommand.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vagrant-zones/action.rb', line 42

def self.action_start
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsState, :running do |env, b1|
      if env[:result]
        b1.use Message, I18n.t('vagrant_zones.states.is_running')
        next
      end
      b1.use Call, IsState, :uncleaned do |env2, b2|
        b2.use Cleanup if env2[:result]
      end
      b1.use Start
      b1.use WaitTillUp
    end
  end
end

.action_upObject

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



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
# File 'lib/vagrant-zones/action.rb', line 15

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        env[:halt_on_error] = true
        b2.use action_start
      elsif !env[:result]
        b2.use Import
        b2.use HandleBox
        b2.use BoxCheckOutdated
        b2.use Create
        b2.use Network
        b2.use Start
        b2.use WaitTillBoot
        b2.use Setup
        b2.use WaitTillUp
        b2.use Provision
        b2.use NetworkingCleanup
        b2.use SetHostname
        b2.use SyncedFolders
        b2.use SyncedFolderCleanup
      end
    end
  end
end