Module: VagrantPlugins::VCloud::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-vcloud/action.rb,
lib/vagrant-vcloud/action/resume.rb,
lib/vagrant-vcloud/action/destroy.rb,
lib/vagrant-vcloud/action/suspend.rb,
lib/vagrant-vcloud/action/power_on.rb,
lib/vagrant-vcloud/action/is_paused.rb,
lib/vagrant-vcloud/action/power_off.rb,
lib/vagrant-vcloud/action/build_vapp.rb,
lib/vagrant-vcloud/action/is_bridged.rb,
lib/vagrant-vcloud/action/is_created.rb,
lib/vagrant-vcloud/action/is_running.rb,
lib/vagrant-vcloud/action/read_state.rb,
lib/vagrant-vcloud/action/sync_folders.rb,
lib/vagrant-vcloud/action/forward_ports.rb,
lib/vagrant-vcloud/action/read_ssh_info.rb,
lib/vagrant-vcloud/action/connect_vcloud.rb,
lib/vagrant-vcloud/action/inventory_check.rb,
lib/vagrant-vcloud/action/announce_ssh_exec.rb,
lib/vagrant-vcloud/action/disconnect_vcloud.rb,
lib/vagrant-vcloud/action/message_not_created.rb,
lib/vagrant-vcloud/action/message_cannot_suspend.rb,
lib/vagrant-vcloud/action/unmap_port_forwardings.rb,
lib/vagrant-vcloud/action/message_already_running.rb,
lib/vagrant-vcloud/action/message_will_not_destroy.rb,
lib/vagrant-vcloud/action/handle_nat_port_collisions.rb

Defined Under Namespace

Classes: AnnounceSSHExec, BuildVApp, ConnectVCloud, Destroy, DisconnectVCloud, ForwardPorts, HandleNATPortCollisions, InventoryCheck, IsBridged, IsCreated, IsPaused, IsRunning, MessageAlreadyRunning, MessageCannotSuspend, MessageNotCreated, MessageWillNotDestroy, PowerOff, PowerOn, ReadSSHInfo, ReadState, Resume, Suspend, SyncFolders, UnmapPortForwardings

Class Method Summary collapse

Class Method Details

.action_bootObject

Vagrant commands This action boots the VM, assuming the VM is in a state that requires a bootup (i.e. not saved).



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

def self.action_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use PowerOn
    b.use Call, IsCreated do |env, b2|
      unless env[:bridged_network]
        b2.use HandleNATPortCollisions
        b2.use ForwardPorts
      end
    end
    b.use Provision
    b.use SyncFolders
  end
end

.action_destroyObject



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

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use Call, DestroyConfirm do |env, b2|
      if env[:result]
        b2.use ConfigValidate
        b2.use ConnectVCloud
        b2.use Call, IsRunning do |env2, b3|
        # If the VM is running, must power off
          b3.use action_halt if env2[:result]
          b3.use Destroy
        end
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject



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

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVCloud
    b.use Call, IsPaused do |env, b2|
      b2.use Resume if env[:result]
    end
    b.use Call, IsBridged do |env, b2|
      b2.use UnmapPortForwardings unless env[:bridged_network]
    end
    b.use PowerOff
  end
end

.action_provisionObject



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

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless 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.



135
136
137
138
139
140
141
# File 'lib/vagrant-vcloud/action.rb', line 135

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



146
147
148
149
150
151
152
# File 'lib/vagrant-vcloud/action.rb', line 146

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

.action_reloadObject



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

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

.action_resumeObject



93
94
95
96
97
98
# File 'lib/vagrant-vcloud/action.rb', line 93

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectVCloud
    b.use Resume
  end
end

.action_sshObject



154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/vagrant-vcloud/action.rb', line 154

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end
      # This calls our helper that announces the IP used to connect
      # to the VM, either directly to the vApp vShield or to the Org Edge
      b2.use AnnounceSSHExec
    end
  end
end

.action_ssh_runObject



169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/vagrant-vcloud/action.rb', line 169

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

      b2.use SSHRun
    end
  end
end

.action_startObject

This action starts a VM, assuming it is already imported and exists. A precondition of this action is that the VM exists.



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

def self.action_start
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVCloud
    b.use Call, IsRunning do |env, b2|
      # If the VM is running, then our work here is done, exit
      if env[:result]
        b2.use MessageAlreadyRunning
        next
      end
      b2.use Call, IsPaused do |env2, b3|
        if env2[:result]
          b3.use Resume
          next
        end
        b3.use action_boot
      end
    end
  end
end

.action_suspendObject



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

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectVCloud
    b.use Call, IsRunning do |env, b2|
      # If the VM is stopped, can't suspend
      if !env[:result]
        b2.use MessageCannotSuspend
      else
        b2.use Suspend
      end
    end
  end
end

.action_upObject



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/vagrant-vcloud/action.rb', line 183

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      b2.use HandleBox unless env[:result]
    end
    b.use ConnectVCloud
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use InventoryCheck
        b2.use BuildVApp
      end
    end
    b.use action_start
    b.use DisconnectVCloud
  end
end