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_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, 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
# File 'lib/vagrant-vcloud/action.rb', line 12

def self.action_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use PowerOn
    b.use HandleNATPortCollisions
    b.use ForwardPorts
    b.use Provision
    b.use SyncFolders
  end
end

.action_destroyObject



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

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
          if env2[:result]
           b3.use action_halt
          end
          b3.use Destroy
        end 
      else
        b2.use MessageWillNotDestroy
      end
    end
  end
end

.action_haltObject



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/vagrant-vcloud/action.rb', line 60

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

.action_provisionObject



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

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.



131
132
133
134
135
136
137
# File 'lib/vagrant-vcloud/action.rb', line 131

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.



142
143
144
145
146
147
148
# File 'lib/vagrant-vcloud/action.rb', line 142

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vagrant-vcloud/action.rb', line 22

def self.action_reload
  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 action_halt
      b2.use action_start
      b2.use DisconnectVCloud
    end
  end
end

.action_resumeObject



87
88
89
90
91
92
# File 'lib/vagrant-vcloud/action.rb', line 87

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

.action_sshObject



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/vagrant-vcloud/action.rb', line 150

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
      # 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



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

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 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.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/vagrant-vcloud/action.rb', line 39

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



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/vagrant-vcloud/action.rb', line 73

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



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

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