vagrant-vmware-esxi 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -29
- data/Rakefile +1 -1
- data/example_box/Vagrantfile +42 -17
- data/example_box/Vagrantfile-multimachine +1 -1
- data/lib/vagrant-vmware-esxi/action.rb +17 -7
- data/lib/vagrant-vmware-esxi/action/boot.rb +12 -11
- data/lib/vagrant-vmware-esxi/action/createvm.rb +38 -51
- data/lib/vagrant-vmware-esxi/action/destroy.rb +12 -11
- data/lib/vagrant-vmware-esxi/action/esxi_password.rb +176 -0
- data/lib/vagrant-vmware-esxi/action/halt.rb +13 -11
- data/lib/vagrant-vmware-esxi/action/package.rb +2 -3
- data/lib/vagrant-vmware-esxi/action/read_ssh_info.rb +13 -11
- data/lib/vagrant-vmware-esxi/action/read_state.rb +15 -13
- data/lib/vagrant-vmware-esxi/action/resume.rb +14 -10
- data/lib/vagrant-vmware-esxi/action/snapshot_delete.rb +14 -12
- data/lib/vagrant-vmware-esxi/action/snapshot_info.rb +13 -11
- data/lib/vagrant-vmware-esxi/action/snapshot_list.rb +13 -11
- data/lib/vagrant-vmware-esxi/action/snapshot_restore.rb +14 -12
- data/lib/vagrant-vmware-esxi/action/snapshot_save.rb +15 -12
- data/lib/vagrant-vmware-esxi/action/suspend.rb +14 -12
- data/lib/vagrant-vmware-esxi/action/wait_for_state.rb +0 -1
- data/lib/vagrant-vmware-esxi/cap/snapshot_list.rb +0 -1
- data/lib/vagrant-vmware-esxi/provider.rb +5 -1
- data/lib/vagrant-vmware-esxi/version.rb +1 -1
- data/vagrant-vmware-esxi.gemspec +1 -1
- metadata +5 -5
- data/lib/vagrant-vmware-esxi/action/connect_esxi.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6c1b544be5e69be9aad5aa1d1eb7f7e47097f83
|
4
|
+
data.tar.gz: 5cfd76a90f5f9a1a5fc8989b7a32b69b214a010d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a288fc3eb3823e2763cf55d720889a87456cce474535a23233cfc0372f47aae956201df6de80fb0487fe0b09a7bbc3565704335909b96dc83a5b6861fffd3c9b
|
7
|
+
data.tar.gz: 2dedd6fbc8d32a7b5c1d7f5d20b2214fbc27dfd2a4124552e685067a5429d1e493ed3064331a631c8781eab00e9f10a062b3fdd41945f18aad236bfa8954ce3d
|
data/README.md
CHANGED
@@ -85,44 +85,69 @@ Vagrant.configure("2") do |config|
|
|
85
85
|
esxi.esxi_username = "root"
|
86
86
|
|
87
87
|
#
|
88
|
-
#
|
88
|
+
# IMPORTANT! ESXi password.
|
89
|
+
# *** NOTES about esxi_password & ssh keys!! ***
|
90
|
+
#
|
91
|
+
# 1) "prompt:"
|
92
|
+
# This will prompt you for the esxi password each time you
|
93
|
+
# run a vagrant command. This is the default.
|
94
|
+
#
|
95
|
+
# 2) "file:" or "file:my_secret_file"
|
96
|
+
# This will read a plain text file containing the esxi
|
97
|
+
# password. The default filename is ~/.esxi_password, or
|
98
|
+
# you can specify any filename after the colon ":".
|
99
|
+
#
|
100
|
+
# 3) "env:" or "env:my_secret_env_var"
|
101
|
+
# This will read the esxi password via a environment
|
102
|
+
# variable. The default is $esxi_password, but you can
|
103
|
+
# specify any environment variable after the colon ":".
|
104
|
+
#
|
105
|
+
# $ export esxi_password="my_secret_password"
|
89
106
|
#
|
90
|
-
#
|
91
|
-
#
|
107
|
+
# 4) "key:" or key:~/.ssh/some_ssh_private_key"
|
108
|
+
# Use ssh keys. The default is to use the system private keys,
|
109
|
+
# or you specify a custom private key after the colon ":".
|
92
110
|
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
# the esxi command prompt.
|
111
|
+
# To test connectivity. From your command line, you should be able to
|
112
|
+
# run following command without an error and get an esxi prompt.
|
96
113
|
#
|
97
|
-
#
|
114
|
+
# $ ssh root@ESXi_IP_ADDRESS
|
115
|
+
#
|
116
|
+
# The ssh connections to esxi will try the ssh private
|
117
|
+
# keys. However the ovftool does NOT! To make
|
118
|
+
# vagrant fully password-less, you will need to use other
|
119
|
+
# options. (set the passord, use "env:" or "file:")
|
120
|
+
#
|
121
|
+
# 5) esxi.esxi_password = "my_esxi_password"
|
122
|
+
# Enter your esxi passowrd in clear text here... This is the
|
123
|
+
# least secure method because you may share this Vagrant file without
|
124
|
+
# realizing the password is in clear text.
|
125
|
+
#
|
126
|
+
# IMPORTANT! Set the ESXi password or authentication method..
|
127
|
+
esxi.esxi_password = "prompt:"
|
98
128
|
|
99
|
-
#
|
100
|
-
# The
|
101
|
-
# keys first. However the ovftool does NOT! To make
|
102
|
-
# vagrant up fully password-less, you will need to
|
103
|
-
# enter your password here....
|
104
|
-
esxi.esxi_password = nil
|
105
|
-
|
106
|
-
# ESXi ssh keys
|
107
|
-
# The Default is to use system defaults, However
|
129
|
+
# ESXi ssh keys. (This is depreciated!!!)
|
130
|
+
# The Default is to use system default ssh keys, However
|
108
131
|
# you can specify an array of keys here...
|
132
|
+
#
|
133
|
+
# *** Depreciated, use esxi_password = "key:" instead. ***
|
109
134
|
#esxi.esxi_private_keys = []
|
110
135
|
|
111
136
|
# SSH port.
|
112
|
-
# Default port 22
|
137
|
+
# Default port 22.
|
113
138
|
#esxi.esxi_hostport = 22
|
114
139
|
|
115
140
|
# HIGHLY RECOMMENDED! Virtual Network
|
116
|
-
# You should specify a Virtual Network!
|
117
|
-
#
|
141
|
+
# You should specify a Virtual Network! If it's not specified, the
|
142
|
+
# default is to use the first found.
|
118
143
|
# You can specify up to 4 virtual networks using an array
|
119
|
-
# format. Note that Vagrant only looks at the first
|
120
|
-
# interface for
|
144
|
+
# format. Note that Vagrant only looks at the first
|
145
|
+
# interface for a valid IP address.
|
121
146
|
#esxi.virtual_network = "vmnet_example"
|
122
147
|
#esxi.virtual_network = ["vmnet1","vmnet2","vmnet3","vmnet4"]
|
123
148
|
|
124
149
|
# OPTIONAL. Specify a Disk Store
|
125
|
-
#
|
150
|
+
# If it's not specified, the Default is to use the least used Disk Store.
|
126
151
|
#esxi.vm_disk_store = "DS_001"
|
127
152
|
|
128
153
|
# OPTIONAL. Guest VM name to be created/used.
|
@@ -142,20 +167,22 @@ Vagrant.configure("2") do |config|
|
|
142
167
|
#esxi.memsize = "2048"
|
143
168
|
|
144
169
|
# OPTIONAL. Virtual CPUs override
|
145
|
-
# The default is to use the number of
|
170
|
+
# The default is to use the number of virtual cpus specified
|
146
171
|
# in the vmx file, however you can specify a new value here.
|
147
172
|
#esxi.numvcpus = "2"
|
148
173
|
|
149
174
|
# OPTIONAL. Resource Pool
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
175
|
+
# If unspecified, the default is to create VMs in the "root". You can
|
176
|
+
# specify a resource pool here to partition memory and cpu usage away
|
177
|
+
# from other systems on your esxi host. The resource pool must
|
178
|
+
# already exist and have the proper permissions set.
|
179
|
+
#
|
155
180
|
# Vagrant will NOT create a Resource pool it for you.
|
156
181
|
#esxi.resource_pool = "/Vagrant"
|
157
182
|
|
158
183
|
# DANGEROUS! Allow Overwrite
|
184
|
+
# If unspecified, the default is to produce an error if overwriting
|
185
|
+
# vm's and packages.
|
159
186
|
# Set this to 'True' will overwrite existing VMs (with the same name)
|
160
187
|
# when you run vagrant up. ie, if the vmname already exists,
|
161
188
|
# it will be destroyed, then over written... This is helpful
|
@@ -178,6 +205,7 @@ Basic usage
|
|
178
205
|
* `vagrant resume`
|
179
206
|
* `vagrant snapshot push`
|
180
207
|
* `vagrant snapshot list`
|
208
|
+
* `vagrant snapshot-info`
|
181
209
|
* `vagrant snapshot pop`
|
182
210
|
* `vagrant halt`
|
183
211
|
* `vagrant provision`
|
@@ -189,12 +217,13 @@ Known issues with vmware_esxi
|
|
189
217
|
* Cleanup doesn't always destroy a VM that has been partially built. Use the allow_overwrite = 'True' option if you need to force a rebuild.
|
190
218
|
* ovftool installer for windows doesn't put ovftool.exe in your path. You can manually set your path, or install ovftool in the \HashiCorp\Vagrant\bin directory.
|
191
219
|
* Built-in Vagrant synced folders using NFS fails if you try to re-provision.
|
192
|
-
* In general I find NFS synced folders pretty "
|
220
|
+
* In general I find NFS synced folders pretty "flaky" anyways...
|
193
221
|
* Multi machines may not provision one VM if the boxes are different.
|
194
222
|
* I found this problem with libvirt also, so I'm assuming it's a vagrant problem...
|
195
223
|
|
196
224
|
Version History
|
197
225
|
---------------
|
226
|
+
* 1.3.0 Add support to get esxi password from env, from a file or prompt.
|
198
227
|
* 1.2.1 Encode special characters in password.
|
199
228
|
* 1.2.0 Add support for up to 4 virtual networks.
|
200
229
|
* 1.7.1 Show all port groups for each virtual switch instead of just the first.
|
data/Rakefile
CHANGED
data/example_box/Vagrantfile
CHANGED
@@ -19,7 +19,7 @@ Vagrant.configure("2") do |config|
|
|
19
19
|
#config.vm.box = 'generic/alpine36'
|
20
20
|
|
21
21
|
|
22
|
-
#
|
22
|
+
# Synced folders supports type rsync and NFS.
|
23
23
|
config.vm.synced_folder('.', '/Vagrantfiles', type: 'rsync')
|
24
24
|
|
25
25
|
#
|
@@ -37,27 +37,52 @@ Vagrant.configure("2") do |config|
|
|
37
37
|
esxi.esxi_username = "root"
|
38
38
|
|
39
39
|
#
|
40
|
-
#
|
40
|
+
# IMPORTANT! ESXi password.
|
41
|
+
# *** NOTES about esxi_password & ssh keys!! ***
|
42
|
+
#
|
43
|
+
# 1) esxi.esxi_password = "my_esxi_password"
|
44
|
+
# Enter your esxi passowrd in clear text here...
|
45
|
+
#
|
46
|
+
# 2) "key:" or "" or "key:~/.ssh/some_ssh_private_key"
|
47
|
+
# Use ssh keys. The default is to use the system private keys,
|
48
|
+
# or you specify a custom private key after the colon ":".
|
49
|
+
#
|
50
|
+
# From your command line, you should be able to run
|
51
|
+
# following command without an error and be able to get to
|
52
|
+
# the esxi command prompt.
|
53
|
+
#
|
54
|
+
# $ ssh root@ESXi_IP_ADDRESS
|
55
|
+
#
|
56
|
+
# The ssh connections to esxi will try the ssh private
|
57
|
+
# keys. However the ovftool does NOT! To make
|
58
|
+
# vagrant fully password-less, you will need to use other
|
59
|
+
# options. (set the passord, use "env:" or "file:")
|
41
60
|
#
|
42
|
-
#
|
43
|
-
#
|
61
|
+
# 3) "prompt:"
|
62
|
+
# This will prompt you for the esxi password each time you
|
63
|
+
# run a vagrant command.
|
44
64
|
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
65
|
+
# 4) "file:" or "file:my_secret_file"
|
66
|
+
# This will read a plain text file containing the esxi
|
67
|
+
# password. The default filename is ~/.esxi_password, or
|
68
|
+
# you can specify any filename after the colon ":".
|
48
69
|
#
|
49
|
-
#
|
70
|
+
# 5) "env:" or "env:my_secret_env_var"
|
71
|
+
# This will read the esxi password via a environment
|
72
|
+
# variable. The default is $esxi_password, but you can
|
73
|
+
# specify any environment variable after the colon ":".
|
74
|
+
#
|
75
|
+
# $ export esxi_password="my_secret_password"
|
76
|
+
#
|
77
|
+
#
|
78
|
+
# IMPORTANT! Set the ESXi password.
|
79
|
+
esxi.esxi_password = "prompt:"
|
50
80
|
|
51
|
-
#
|
52
|
-
# The
|
53
|
-
# keys first. However the ovftool does NOT! To make
|
54
|
-
# vagrant up fully password-less, you will need to
|
55
|
-
# enter your password here....
|
56
|
-
esxi.esxi_password = nil
|
57
|
-
|
58
|
-
# ESXi ssh keys
|
59
|
-
# The Default is to use system defaults, However
|
81
|
+
# ESXi ssh keys. (This will be depreciated!!!)
|
82
|
+
# The Default is to use system default ssh keys, However
|
60
83
|
# you can specify an array of keys here...
|
84
|
+
#
|
85
|
+
# *** Depreciated, use esxi_password = "key:" instead. ***
|
61
86
|
#esxi.esxi_private_keys = []
|
62
87
|
|
63
88
|
# SSH port.
|
@@ -22,7 +22,7 @@ Vagrant.configure("2") do |config|
|
|
22
22
|
#
|
23
23
|
esxi.esxi_hostname = "esxi"
|
24
24
|
esxi.esxi_username = "root"
|
25
|
-
esxi.esxi_password =
|
25
|
+
esxi.esxi_password = "file:"
|
26
26
|
#esxi.esxi_private_keys = []
|
27
27
|
#esxi.esxi_hostport = 22
|
28
28
|
#esxi.virtual_network = "vmnet_example"
|
@@ -5,14 +5,10 @@ module VagrantPlugins
|
|
5
5
|
# actions and how to run them
|
6
6
|
module Action
|
7
7
|
include Vagrant::Action::Builtin
|
8
|
-
def self.action_connect_esxi
|
9
|
-
Vagrant::Action::Builder.new.tap do |b|
|
10
|
-
b.use ConnectESXi
|
11
|
-
end
|
12
|
-
end
|
13
8
|
|
14
9
|
def self.action_read_state
|
15
10
|
Vagrant::Action::Builder.new.tap do |b|
|
11
|
+
b.use SetESXiPassword
|
16
12
|
b.use ReadSSHInfo
|
17
13
|
b.use ReadState
|
18
14
|
end
|
@@ -20,12 +16,14 @@ module VagrantPlugins
|
|
20
16
|
|
21
17
|
def self.action_read_ssh_info
|
22
18
|
Vagrant::Action::Builder.new.tap do |b|
|
19
|
+
b.use SetESXiPassword
|
23
20
|
b.use ReadSSHInfo
|
24
21
|
end
|
25
22
|
end
|
26
23
|
|
27
24
|
def self.action_halt
|
28
25
|
Vagrant::Action::Builder.new.tap do |b|
|
26
|
+
b.use SetESXiPassword
|
29
27
|
b.use ReadState
|
30
28
|
b.use Halt
|
31
29
|
end
|
@@ -33,6 +31,7 @@ module VagrantPlugins
|
|
33
31
|
|
34
32
|
def self.action_suspend
|
35
33
|
Vagrant::Action::Builder.new.tap do |b|
|
34
|
+
b.use SetESXiPassword
|
36
35
|
b.use ReadState
|
37
36
|
b.use Suspend
|
38
37
|
end
|
@@ -40,6 +39,7 @@ module VagrantPlugins
|
|
40
39
|
|
41
40
|
def self.action_resume
|
42
41
|
Vagrant::Action::Builder.new.tap do |b|
|
42
|
+
b.use SetESXiPassword
|
43
43
|
b.use ReadState
|
44
44
|
b.use Resume
|
45
45
|
end
|
@@ -47,6 +47,7 @@ module VagrantPlugins
|
|
47
47
|
|
48
48
|
def self.action_ssh
|
49
49
|
Vagrant::Action::Builder.new.tap do |b|
|
50
|
+
b.use SetESXiPassword
|
50
51
|
b.use ReadState
|
51
52
|
b.use ReadSSHInfo
|
52
53
|
b.use SSHExec
|
@@ -56,24 +57,28 @@ module VagrantPlugins
|
|
56
57
|
|
57
58
|
def self.action_snapshot_list
|
58
59
|
Vagrant::Action::Builder.new.tap do |b|
|
60
|
+
b.use SetESXiPassword
|
59
61
|
b.use SnapshotList
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
63
65
|
def self.action_snapshot_info
|
64
66
|
Vagrant::Action::Builder.new.tap do |b|
|
67
|
+
b.use SetESXiPassword
|
65
68
|
b.use SnapshotInfo
|
66
69
|
end
|
67
70
|
end
|
68
71
|
|
69
72
|
def self.action_snapshot_save
|
70
73
|
Vagrant::Action::Builder.new.tap do |b|
|
74
|
+
b.use SetESXiPassword
|
71
75
|
b.use SnapshotSave
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
75
79
|
def self.action_snapshot_restore
|
76
80
|
Vagrant::Action::Builder.new.tap do |b|
|
81
|
+
b.use SetESXiPassword
|
77
82
|
b.use action_halt
|
78
83
|
b.use Call, WaitForState, :powered_off, 240 do |env1, b1|
|
79
84
|
if env1[:result] == 'True'
|
@@ -86,6 +91,7 @@ module VagrantPlugins
|
|
86
91
|
|
87
92
|
def self.action_snapshot_delete
|
88
93
|
Vagrant::Action::Builder.new.tap do |b|
|
94
|
+
b.use SetESXiPassword
|
89
95
|
b.use SnapshotDelete
|
90
96
|
end
|
91
97
|
end
|
@@ -93,6 +99,7 @@ module VagrantPlugins
|
|
93
99
|
|
94
100
|
def self.action_destroy
|
95
101
|
Vagrant::Action::Builder.new.tap do |b|
|
102
|
+
b.use SetESXiPassword
|
96
103
|
b.use Call, ReadState do |env1, b1|
|
97
104
|
unless env1[:machine_state] == 'powered_off'
|
98
105
|
b1.use action_halt
|
@@ -105,6 +112,7 @@ module VagrantPlugins
|
|
105
112
|
|
106
113
|
def self.action_reload
|
107
114
|
Vagrant::Action::Builder.new.tap do |b|
|
115
|
+
b.use SetESXiPassword
|
108
116
|
b.use Call, ReadState do |env1, b1|
|
109
117
|
if (env1[:machine_state].to_s == 'powered_on') ||
|
110
118
|
(env1[:machine_state].to_s == 'running') ||
|
@@ -118,8 +126,8 @@ module VagrantPlugins
|
|
118
126
|
|
119
127
|
def self.action_up
|
120
128
|
Vagrant::Action::Builder.new.tap do |b|
|
129
|
+
b.use SetESXiPassword
|
121
130
|
b.use ConfigValidate
|
122
|
-
b.use ConnectESXi
|
123
131
|
b.use HandleBox
|
124
132
|
b.use ReadState
|
125
133
|
b.use CreateVM
|
@@ -135,6 +143,7 @@ module VagrantPlugins
|
|
135
143
|
|
136
144
|
def self.action_provision
|
137
145
|
Vagrant::Action::Builder.new.tap do |b|
|
146
|
+
b.use SetESXiPassword
|
138
147
|
b.use ReadState
|
139
148
|
b.use Call, WaitForState, :running, 240 do |env1, b1|
|
140
149
|
if env1[:result] == 'True'
|
@@ -149,13 +158,14 @@ module VagrantPlugins
|
|
149
158
|
|
150
159
|
def self.action_package
|
151
160
|
Vagrant::Action::Builder.new.tap do |b|
|
161
|
+
b.use SetESXiPassword
|
152
162
|
b.use ReadState
|
153
163
|
b.use Package
|
154
164
|
end
|
155
165
|
end
|
156
166
|
|
157
167
|
action_root = Pathname.new(File.expand_path('../action', __FILE__))
|
158
|
-
autoload :
|
168
|
+
autoload :SetESXiPassword, action_root.join('esxi_password')
|
159
169
|
autoload :CreateVM, action_root.join('createvm')
|
160
170
|
autoload :ReadState, action_root.join('read_state')
|
161
171
|
autoload :ReadSSHInfo, action_root.join('read_ssh_info')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'log4r'
|
2
|
-
require 'net/ssh
|
2
|
+
require 'net/ssh'
|
3
3
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module ESXi
|
@@ -34,19 +34,20 @@ module VagrantPlugins
|
|
34
34
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
35
35
|
message: 'Cannot boot in this state')
|
36
36
|
else
|
37
|
-
Net::SSH
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
Net::SSH.start( config.esxi_hostname, config.esxi_username,
|
38
|
+
password: $esxi_password,
|
39
|
+
port: config.esxi_hostport,
|
40
|
+
keys: config.esxi_private_keys,
|
41
|
+
timeout: 10,
|
42
|
+
number_of_password_prompts: 0,
|
43
|
+
non_interactive: true
|
44
|
+
) do |ssh|
|
43
45
|
|
44
|
-
r = ssh
|
45
|
-
|
46
|
-
if r.exit_code != 0
|
46
|
+
r = ssh.exec!("vim-cmd vmsvc/power.on #{machine.id}")
|
47
|
+
if r.exitstatus != 0
|
47
48
|
raise Errors::ESXiError,
|
48
49
|
message: "Unable to power on VM:\n"\
|
49
|
-
" #{r
|
50
|
+
" #{r}"
|
50
51
|
end
|
51
52
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
52
53
|
message: 'VM has been Powered On...')
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'log4r'
|
2
|
-
require 'net/ssh
|
2
|
+
require 'net/ssh'
|
3
3
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module ESXi
|
6
6
|
module Action
|
7
|
-
# This action
|
8
|
-
#
|
7
|
+
# This action creates a new vmx file (using overwrides from config file),
|
8
|
+
# then creates a new VM guest using ovftool.
|
9
9
|
class CreateVM
|
10
10
|
def initialize(app, _env)
|
11
11
|
@app = app
|
@@ -64,27 +64,28 @@ module VagrantPlugins
|
|
64
64
|
#
|
65
65
|
# Open the network connection
|
66
66
|
#
|
67
|
-
Net::SSH
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
Net::SSH.start( config.esxi_hostname, config.esxi_username,
|
68
|
+
password: $esxi_password,
|
69
|
+
port: config.esxi_hostport,
|
70
|
+
keys: config.esxi_private_keys,
|
71
|
+
timeout: 10,
|
72
|
+
number_of_password_prompts: 0,
|
73
|
+
non_interactive: true
|
74
|
+
) do |ssh|
|
73
75
|
|
74
76
|
@logger = Log4r::Logger.new('vagrant_vmware_esxi::action::createvm-ssh')
|
75
77
|
|
76
78
|
#
|
77
79
|
# Figure out DataStore
|
78
|
-
r = ssh
|
80
|
+
r = ssh.exec!(
|
79
81
|
'df | grep "^[VMFS|NFS]" | sort -nk4 |'\
|
80
|
-
'sed "s|.*/vmfs/volumes/||g" | tail +2'
|
82
|
+
'sed "s|.*/vmfs/volumes/||g" | tail +2')
|
81
83
|
|
82
|
-
availvolumes = r.
|
83
|
-
if (config.debug =~ %r{true}i)
|
84
|
-
(config.debug =~ %r{yes}i)
|
84
|
+
availvolumes = r.split(/\n/)
|
85
|
+
if (config.debug =~ %r{true}i)
|
85
86
|
puts "Available DS Volumes: #{availvolumes}"
|
86
87
|
end
|
87
|
-
if (r == '') || (r.
|
88
|
+
if (r == '') || (r.exitstatus != 0)
|
88
89
|
raise Errors::ESXiError,
|
89
90
|
message: 'Unable to get list of Disk Stores:'
|
90
91
|
end
|
@@ -116,16 +117,15 @@ module VagrantPlugins
|
|
116
117
|
#
|
117
118
|
# Figure out network
|
118
119
|
#
|
119
|
-
r = ssh
|
120
|
+
r = ssh.exec!(
|
120
121
|
'esxcli network vswitch standard list |'\
|
121
122
|
'grep Portgroups | sed "s/^ Portgroups: //g" |'\
|
122
|
-
'sed "s/,./\n/g"'
|
123
|
-
availnetworks = r.
|
124
|
-
if (config.debug =~ %r{true}i)
|
125
|
-
(config.debug =~ %r{yes}i)
|
123
|
+
'sed "s/,./\n/g"')
|
124
|
+
availnetworks = r.split(/\n/)
|
125
|
+
if (config.debug =~ %r{true}i)
|
126
126
|
puts "Available Networks: #{availnetworks}"
|
127
127
|
end
|
128
|
-
if (availnetworks == '') || (r.
|
128
|
+
if (availnetworks == '') || (r.exitstatus != 0)
|
129
129
|
raise Errors::ESXiError,
|
130
130
|
message: "Unable to get list of Virtual Networks:\n"\
|
131
131
|
"#{r.stderr}"
|
@@ -202,14 +202,11 @@ module VagrantPlugins
|
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
|
-
#
|
206
|
-
# new_vmx_contents << "ethernet0.networkName = \"#{guestvm_network}\"\n"
|
207
|
-
#end
|
205
|
+
# Append virt network options
|
208
206
|
netOpts = ""
|
209
207
|
networkID = 0
|
210
208
|
for element in guestvm_network do
|
211
|
-
if (config.debug =~ %r{true}i)
|
212
|
-
(config.debug =~ %r{yes}i)
|
209
|
+
if (config.debug =~ %r{true}i)
|
213
210
|
puts "guestvm_network[#{networkID}]: #{element}"
|
214
211
|
end
|
215
212
|
new_vmx_contents << "ethernet#{networkID}.networkName = \"net#{networkID}\"\n"
|
@@ -222,6 +219,7 @@ module VagrantPlugins
|
|
222
219
|
end
|
223
220
|
end
|
224
221
|
|
222
|
+
# append custom_vmx_settings if exists
|
225
223
|
if config.custom_vmx_settings.is_a? Array
|
226
224
|
env[:machine].provider_config.custom_vmx_settings.each do |k, v|
|
227
225
|
new_vmx_contents << "#{k} = \"#{v}\"\n"
|
@@ -286,19 +284,6 @@ module VagrantPlugins
|
|
286
284
|
end
|
287
285
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
288
286
|
message: "Resource Pool : #{resource_pool}")
|
289
|
-
#
|
290
|
-
# Encode special characters in PW
|
291
|
-
#
|
292
|
-
encoded_esxi_password = config.esxi_password.gsub('@', '%40').gsub(\
|
293
|
-
'<', '%3c').gsub('>', '%3e').gsub(\
|
294
|
-
'[', '%5b').gsub(']', '%5d').gsub(\
|
295
|
-
'(', '%28').gsub(')', '%29').gsub(\
|
296
|
-
'%', '%25').gsub('#', '%23').gsub(\
|
297
|
-
'&', '%26').gsub(':', '%3a').gsub(\
|
298
|
-
'/', '%2f').gsub('\\','%5c').gsub(\
|
299
|
-
'"', '%22').gsub('\'','%27').gsub(\
|
300
|
-
'*', '%2a').gsub('?', '%3f')
|
301
|
-
|
302
287
|
|
303
288
|
#
|
304
289
|
# Using ovftool, import vmx in box folder, export to ESXi server
|
@@ -313,32 +298,34 @@ module VagrantPlugins
|
|
313
298
|
"#{netOpts} -dm=thin --powerOn "\
|
314
299
|
"-ds=\"#{guestvm_dsname}\" --name=\"#{guestvm_vmname}\" "\
|
315
300
|
"\"#{new_vmx_file}\" vi://#{config.esxi_username}:"\
|
316
|
-
"#{encoded_esxi_password}@#{config.esxi_hostname}"\
|
301
|
+
"#{$encoded_esxi_password}@#{config.esxi_hostname}"\
|
317
302
|
"#{resource_pool}"
|
318
303
|
|
319
304
|
# Security bug if unremarked! Password will be exposed in log file.
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
305
|
+
if (config.debug =~ %r{password}i)
|
306
|
+
@logger.info("vagrant-vmware-esxi, createvm: ovf_cmd #{ovf_cmd}")
|
307
|
+
puts "ovftool command: #{ovf_cmd}"
|
308
|
+
end
|
309
|
+
if (config.debug =~ %r{true}i)
|
310
|
+
ovf_cmd_nopw = ovf_cmd.gsub(/#{$encoded_esxi_password}/, '******')
|
311
|
+
puts "ovftool command: #{ovf_cmd_nopw}"
|
324
312
|
end
|
325
313
|
unless system "#{ovf_cmd}"
|
326
314
|
raise Errors::OVFToolError, message: ''
|
327
315
|
end
|
328
316
|
|
329
|
-
# VMX file is not needed any longer
|
330
|
-
if (config.debug =~ %r{true}i)
|
331
|
-
(config.debug =~ %r{yes}i)
|
317
|
+
# VMX file is not needed any longer. Delete it
|
318
|
+
if (config.debug =~ %r{true}i)
|
332
319
|
puts "Keeping file: #{new_vmx_file}"
|
333
320
|
else
|
334
321
|
File.delete(new_vmx_file)
|
335
322
|
end
|
336
323
|
|
337
|
-
r = ssh
|
324
|
+
r = ssh.exec!(
|
338
325
|
'vim-cmd vmsvc/getallvms |'\
|
339
|
-
"grep \" #{guestvm_vmname} \"|awk '{print $1}'"
|
340
|
-
vmid = r
|
341
|
-
if (vmid == '') || (r.
|
326
|
+
"grep \" #{guestvm_vmname} \"|awk '{print $1}'")
|
327
|
+
vmid = r
|
328
|
+
if (vmid == '') || (r.exitstatus != 0)
|
342
329
|
raise Errors::ESXiError,
|
343
330
|
message: "Unable to register / start #{guestvm_vmname}"
|
344
331
|
end
|