Module: VagrantPlugins::VSphere::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vSphere/action.rb,
lib/vSphere/action/clone.rb,
lib/vSphere/action/destroy.rb,
lib/vSphere/action/power_on.rb,
lib/vSphere/action/get_state.rb,
lib/vSphere/action/power_off.rb,
lib/vSphere/action/is_created.rb,
lib/vSphere/action/is_running.rb,
lib/vSphere/action/get_ssh_info.rb,
lib/vSphere/action/close_vsphere.rb,
lib/vSphere/action/connect_vsphere.rb,
lib/vSphere/action/message_not_created.rb,
lib/vSphere/action/message_not_running.rb,
lib/vSphere/action/message_already_created.rb

Defined Under Namespace

Classes: Clone, CloseVSphere, ConnectVSphere, Destroy, GetSshInfo, GetState, IsCreated, IsRunning, MessageAlreadyCreated, MessageNotCreated, MessageNotRunning, PowerOff, PowerOn

Class Method Summary collapse

Class Method Details

.action_destroyObject

Vagrant commands



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vSphere/action.rb', line 10

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere

    b.use Call, IsRunning do |env, b2|
      if env[:result]
        b2.use Call, GracefulHalt, :poweroff, :running do |env2, b3|
          b3.use PowerOff unless env2[:result]
        end
      end
    end
    b.use Destroy
  end
end

.action_get_ssh_infoObject



163
164
165
166
167
168
169
170
# File 'lib/vSphere/action.rb', line 163

def self.action_get_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use GetSshInfo
    b.use CloseVSphere
  end
end

.action_get_stateObject

vSphere specific actions



153
154
155
156
157
158
159
160
161
# File 'lib/vSphere/action.rb', line 153

def self.action_get_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use GetState
    b.use CloseVSphere
  end
end

.action_haltObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/vSphere/action.rb', line 113

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

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use Call, GracefulHalt, :poweroff, :running do |env3, b4|
          b4.use PowerOff unless env3[:result]
        end
      end
    end
    b.use CloseVSphere
  end
end

.action_provisionObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vSphere/action.rb', line 26

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 Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use Provision
        b3.use SyncedFolders
      end
    end
  end
end

.action_reloadObject



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/vSphere/action.rb', line 138

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

.action_sshObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/vSphere/action.rb', line 48

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

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use SSHExec
      end
    end
  end
end

.action_ssh_runObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/vSphere/action.rb', line 69

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 Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use SSHRun
      end
    end
  end
end

.action_upObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/vSphere/action.rb', line 90

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use MessageAlreadyCreated
        next
      end

      b2.use Clone
    end
    b.use Call, IsRunning do |env, b2|
      b2.use PowerOn unless env[:result]
    end
    b.use CloseVSphere
    b.use Provision
    b.use SyncedFolders
    b.use SetHostname
  end
end