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
@@ -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
|
@@ -31,23 +31,25 @@ module VagrantPlugins
|
|
31
31
|
message: 'Cannot snapshot_info in this state')
|
32
32
|
else
|
33
33
|
|
34
|
-
Net::SSH
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
Net::SSH.start( config.esxi_hostname, config.esxi_username,
|
35
|
+
password: $esxi_password,
|
36
|
+
port: config.esxi_hostport,
|
37
|
+
keys: config.esxi_private_keys,
|
38
|
+
timeout: 10,
|
39
|
+
number_of_password_prompts: 0,
|
40
|
+
non_interactive: true
|
41
|
+
) do |ssh|
|
40
42
|
|
41
|
-
r = ssh
|
43
|
+
r = ssh.exec!(
|
42
44
|
"vim-cmd vmsvc/snapshot.get #{machine.id} 2>&1 | "\
|
43
45
|
"sed 's/Get Snapshot:/ /g' | "\
|
44
46
|
"grep -v "\
|
45
47
|
"-e 'Snapshot Id ' "\
|
46
48
|
"-e 'Snapshot Desciption ' "\
|
47
|
-
"-e 'Snapshot State '"
|
49
|
+
"-e 'Snapshot State '")
|
48
50
|
|
49
|
-
snapshotinfo = r
|
50
|
-
if r.
|
51
|
+
snapshotinfo = r
|
52
|
+
if r.exitstatus != 0
|
51
53
|
raise Errors::ESXiError,
|
52
54
|
message: "Unable to list snapshots:\n"\
|
53
55
|
" #{allsnapshots}\n#{r.stderr}"
|
@@ -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
|
@@ -31,19 +31,21 @@ module VagrantPlugins
|
|
31
31
|
message: 'Cannot snapshot_list in this state')
|
32
32
|
else
|
33
33
|
|
34
|
-
Net::SSH
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
Net::SSH.start( config.esxi_hostname, config.esxi_username,
|
35
|
+
password: $esxi_password,
|
36
|
+
port: config.esxi_hostport,
|
37
|
+
keys: config.esxi_private_keys,
|
38
|
+
timeout: 10,
|
39
|
+
number_of_password_prompts: 0,
|
40
|
+
non_interactive: true
|
41
|
+
) do |ssh|
|
40
42
|
|
41
|
-
r = ssh
|
43
|
+
r = ssh.exec!(
|
42
44
|
"vim-cmd vmsvc/snapshot.get #{machine.id} 2>&1 | "\
|
43
|
-
"grep 'Snapshot Name'|sed 's/.*Snapshot Name : //g'"
|
45
|
+
"grep 'Snapshot Name'|sed 's/.*Snapshot Name : //g'")
|
44
46
|
|
45
|
-
allsnapshots = r
|
46
|
-
if r.
|
47
|
+
allsnapshots = r
|
48
|
+
if r.exitstatus != 0
|
47
49
|
raise Errors::ESXiError,
|
48
50
|
message: "Unable to list snapshots:\n"\
|
49
51
|
" #{allsnapshots}\n#{r.stderr}"
|
@@ -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
|
@@ -33,24 +33,26 @@ module VagrantPlugins
|
|
33
33
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
34
34
|
message: 'Attempting to snapshot_restore')
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
password:
|
39
|
-
port:
|
40
|
-
keys:
|
41
|
-
timeout:
|
42
|
-
|
36
|
+
#
|
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
|
46
|
+
r = ssh.exec!(
|
45
47
|
"vim-cmd vmsvc/snapshot.revert #{machine.id} "\
|
46
48
|
"`vim-cmd vmsvc/snapshot.get #{machine.id} | "\
|
47
49
|
"grep -A1 '.*Snapshot Name : #{env[:snapshot_name]}$' | "\
|
48
|
-
"grep 'Snapshot Id'|awk '{print $NF}'` suppressPowerOn"
|
50
|
+
"grep 'Snapshot Id'|awk '{print $NF}'` suppressPowerOn")
|
49
51
|
|
50
|
-
if r.
|
52
|
+
if r.exitstatus != 0
|
51
53
|
raise Errors::ESXiError,
|
52
54
|
message: "Unable to restore snapshots of the VM:\n"\
|
53
|
-
" #{r
|
55
|
+
" #{r}"
|
54
56
|
end
|
55
57
|
|
56
58
|
env[:ui].info I18n.t('vagrant_vmware_esxi.snapshot_restored')
|
@@ -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
|
@@ -33,21 +33,24 @@ module VagrantPlugins
|
|
33
33
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
34
34
|
message: 'Attempting to snapshot_save')
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
password:
|
39
|
-
port:
|
40
|
-
keys:
|
41
|
-
timeout:
|
42
|
-
|
36
|
+
#
|
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: 120,
|
42
|
+
number_of_password_prompts: 0,
|
43
|
+
non_interactive: true
|
44
|
+
) do |ssh|
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
puts "machine id: #{machine.id} snapshot name: #{env[:snapshot_name]}"
|
47
|
+
r = ssh.exec!(
|
48
|
+
"vim-cmd vmsvc/snapshot.create #{machine.id} \"#{env[:snapshot_name]}\"")
|
46
49
|
|
47
|
-
if r.
|
50
|
+
if r.exitstatus != 0
|
48
51
|
raise Errors::ESXiError,
|
49
52
|
message: "Unable to save snapshots of the VM:\n"\
|
50
|
-
" #{r
|
53
|
+
" #{r}"
|
51
54
|
end
|
52
55
|
env[:ui].info I18n.t('vagrant_vmware_esxi.support')
|
53
56
|
|
@@ -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
|
@@ -36,19 +36,21 @@ module VagrantPlugins
|
|
36
36
|
env[:ui].info I18n.t('vagrant_vmware_esxi.vagrant_vmware_esxi_message',
|
37
37
|
message: 'Attempting to suspend')
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
password:
|
42
|
-
port:
|
43
|
-
keys:
|
44
|
-
timeout:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
39
|
+
#
|
40
|
+
Net::SSH.start( config.esxi_hostname, config.esxi_username,
|
41
|
+
password: $esxi_password,
|
42
|
+
port: config.esxi_hostport,
|
43
|
+
keys: config.esxi_private_keys,
|
44
|
+
timeout: 120,
|
45
|
+
number_of_password_prompts: 0,
|
46
|
+
non_interactive: true
|
47
|
+
) do |ssh|
|
48
|
+
|
49
|
+
r = ssh.exec!("vim-cmd vmsvc/power.suspend #{machine.id}")
|
50
|
+
if r.exitstatus != 0
|
49
51
|
raise Errors::ESXiError,
|
50
52
|
message: "Unable to suspend the VM:\n"\
|
51
|
-
" #{r
|
53
|
+
" #{r}"
|
52
54
|
end
|
53
55
|
env[:ui].info I18n.t('vagrant_vmware_esxi.support')
|
54
56
|
env[:ui].info I18n.t('vagrant_vmware_esxi.states.suspended.short')
|
@@ -21,7 +21,6 @@ module VagrantPlugins
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def state
|
24
|
-
#@machine.action('connect_esxi')
|
25
24
|
env = @machine.action('read_state')
|
26
25
|
state_id = env[:machine_state]
|
27
26
|
|
@@ -31,6 +30,11 @@ module VagrantPlugins
|
|
31
30
|
short = I18n.t("vagrant_vmware_esxi.states.#{state_id}.short")
|
32
31
|
long = I18n.t("vagrant_vmware_esxi.states.#{state_id}.long")
|
33
32
|
|
33
|
+
# If we're not created, then specify the special ID flag
|
34
|
+
if state_id == :not_created
|
35
|
+
state_id = Vagrant::MachineState::NOT_CREATED_ID
|
36
|
+
end
|
37
|
+
|
34
38
|
# Return the MachineState object
|
35
39
|
Vagrant::MachineState.new(state_id, short, long)
|
36
40
|
end
|
data/vagrant-vmware-esxi.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_runtime_dependency 'log4r', '~> 1.1'
|
21
21
|
s.add_runtime_dependency "iniparse", '> 1.0'
|
22
22
|
s.add_runtime_dependency "nokogiri", '> 1.5'
|
23
|
-
s.add_runtime_dependency "net-ssh
|
23
|
+
s.add_runtime_dependency "net-ssh", '> 3.0'
|
24
24
|
|
25
25
|
s.add_development_dependency "bundler"
|
26
26
|
s.add_development_dependency "rspec-core"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vmware-esxi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Senkerik
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: net-ssh
|
70
|
+
name: net-ssh
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,9 +124,9 @@ files:
|
|
124
124
|
- lib/vagrant-vmware-esxi.rb
|
125
125
|
- lib/vagrant-vmware-esxi/action.rb
|
126
126
|
- lib/vagrant-vmware-esxi/action/boot.rb
|
127
|
-
- lib/vagrant-vmware-esxi/action/connect_esxi.rb
|
128
127
|
- lib/vagrant-vmware-esxi/action/createvm.rb
|
129
128
|
- lib/vagrant-vmware-esxi/action/destroy.rb
|
129
|
+
- lib/vagrant-vmware-esxi/action/esxi_password.rb
|
130
130
|
- lib/vagrant-vmware-esxi/action/halt.rb
|
131
131
|
- lib/vagrant-vmware-esxi/action/package.rb
|
132
132
|
- lib/vagrant-vmware-esxi/action/read_ssh_info.rb
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'log4r'
|
2
|
-
require 'net/ssh/simple'
|
3
|
-
|
4
|
-
module VagrantPlugins
|
5
|
-
module ESXi
|
6
|
-
module Action
|
7
|
-
# This action connects to the ESXi, verifies credentials and
|
8
|
-
# validates if it's a ESXi host
|
9
|
-
class ConnectESXi
|
10
|
-
def initialize(app, _env)
|
11
|
-
@app = app
|
12
|
-
@logger = Log4r::Logger.new('vagrant_vmware_esxi::action::connect_esxi')
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
connect_esxi(env)
|
17
|
-
@app.call(env)
|
18
|
-
end
|
19
|
-
|
20
|
-
def connect_esxi(env)
|
21
|
-
@logger.info('vagrant-vmware-esxi, connect_esxi: start...')
|
22
|
-
|
23
|
-
# Get config.
|
24
|
-
config = env[:machine].provider_config
|
25
|
-
|
26
|
-
if config.esxi_private_keys.is_a? Array
|
27
|
-
config.esxi_private_keys = [
|
28
|
-
'~/.ssh/id_rsa',
|
29
|
-
'~/.ssh/id_dsa',
|
30
|
-
'~/.ssh/id_ecdsa',
|
31
|
-
'~/.ssh/id_ed25519'
|
32
|
-
]
|
33
|
-
end
|
34
|
-
@logger.info('vagrant-vmware-esxi, connect_esxi: esxi_private_keys: '\
|
35
|
-
"#{config.esxi_private_keys}")
|
36
|
-
|
37
|
-
Net::SSH::Simple.sync(
|
38
|
-
user: config.esxi_username,
|
39
|
-
password: config.esxi_password,
|
40
|
-
port: config.esxi_hostport,
|
41
|
-
keys: config.esxi_private_keys
|
42
|
-
) do
|
43
|
-
|
44
|
-
r = ssh config.esxi_hostname,
|
45
|
-
'esxcli system version get | grep Version:'
|
46
|
-
if (!r.stdout.include? 'Version:') || (r.exit_code != 0)
|
47
|
-
raise Errors::ESXiConfigError,
|
48
|
-
message: "Unable to access ESXi host.\n"\
|
49
|
-
'Verify esxi_hostname, esxi_hostport, '\
|
50
|
-
'esxi_username, esxi_password in your Vagrantfile.'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
@logger.info('vagrant-vmware-esxi, connect_esxi: connect success...')
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|