vmreverter 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vmreverter/hypervisor/vsphere.rb +5 -1
- data/lib/vmreverter/hypervisor/vsphere_helper.rb +10 -16
- data/lib/vmreverter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e8a9fe0161250b23680ca5d9ab363690bbb593
|
4
|
+
data.tar.gz: eb23f05cabfcfd968fcbc76ba3d09dcc6481092a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aab154a683e29d190f7b178672f2dc1ae0140686ce09e69444497402dc3086e0a4b57877e7d830cb42608e90224cf5529855ec1ca11141da1c853ec85ee215cb
|
7
|
+
data.tar.gz: 4c66f97aa9fb47619eed1d88b55c7cc3e9f7e6bbee3abe9422628dc26dadc24dbe5d2cd895d1f7664ecb2184675c93578e70ecd86d7e82575befbcc763ea9518
|
@@ -13,7 +13,11 @@ module Vmreverter
|
|
13
13
|
|
14
14
|
@logger.notify "Connecting to vSphere at #{vsphere_credentials[:server]}" + " with credentials for #{vsphere_credentials[:user]}"
|
15
15
|
|
16
|
-
|
16
|
+
begin
|
17
|
+
@vsphere_helper = VsphereHelper.new( vsphere_credentials, @logger )
|
18
|
+
rescue Exception => e
|
19
|
+
report_and_raise(@logger, e, "VSphere::connection")
|
20
|
+
end
|
17
21
|
|
18
22
|
#Transpose Hash for @vsphere_vms = {"test-server01" => "gold-image", "test-server02" => "silver-image"}
|
19
23
|
@vsphere_vms = {}
|
@@ -1,14 +1,8 @@
|
|
1
1
|
# Apache Licensed - (github/puppetlabs) ripped from puppet_acceptance. ** See Legal notes
|
2
2
|
# Changes include namespace swaps, and refactoring
|
3
3
|
|
4
|
-
begin
|
5
|
-
require 'Vmreverter/logger'
|
6
|
-
rescue LoadError
|
7
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'logger.rb'))
|
8
|
-
end
|
9
|
-
|
10
4
|
class VsphereHelper
|
11
|
-
|
5
|
+
|
12
6
|
#Class methods
|
13
7
|
def self.load_config authfile
|
14
8
|
vsphere_credentials = {}
|
@@ -19,7 +13,7 @@ class VsphereHelper
|
|
19
13
|
vInfo = YAML.load_file( File.join(ENV['HOME'], '.fog') )
|
20
14
|
else
|
21
15
|
report_and_raise(@logger, RuntimeError.new("Couldn't authentication for vSphere in auth file !"), "VSphereHelper::load_config")
|
22
|
-
end
|
16
|
+
end
|
23
17
|
|
24
18
|
begin
|
25
19
|
vsphere_credentials[:server] = vInfo[:default][:vsphere_server]
|
@@ -32,23 +26,24 @@ class VsphereHelper
|
|
32
26
|
return vsphere_credentials
|
33
27
|
end
|
34
28
|
|
35
|
-
def initialize
|
36
|
-
|
29
|
+
def initialize(vInfo, logger)
|
30
|
+
|
31
|
+
@logger = logger
|
37
32
|
begin
|
38
33
|
require 'rbvmomi'
|
39
34
|
rescue LoadError
|
40
35
|
raise "Unable to load RbVmomi, please ensure its installed"
|
41
36
|
end
|
42
|
-
|
43
|
-
# If you don’t have trusted SSL certificates installed on the host you’re connecting to,
|
44
|
-
#you’ll get an +OpenSSL::SSL::SSLError+ “certificate verify failed”.
|
37
|
+
|
38
|
+
# If you don’t have trusted SSL certificates installed on the host you’re connecting to,
|
39
|
+
#you’ll get an +OpenSSL::SSL::SSLError+ “certificate verify failed”.
|
45
40
|
#You can work around this by using the :insecure option to +RbVmomi::VIM.connect+.
|
46
|
-
|
41
|
+
|
47
42
|
@connection = RbVmomi::VIM.connect :host => vInfo[:server],
|
48
43
|
:user => vInfo[:user],
|
49
44
|
:password => vInfo[:pass],
|
50
45
|
:insecure => true
|
51
|
-
end
|
46
|
+
end
|
52
47
|
#Instance Methods
|
53
48
|
def find_snapshot vm, snapname
|
54
49
|
search_child_snaps vm.snapshot.rootSnapshotList, snapname
|
@@ -184,4 +179,3 @@ class VsphereHelper
|
|
184
179
|
@connection.close
|
185
180
|
end
|
186
181
|
end
|
187
|
-
|
data/lib/vmreverter/version.rb
CHANGED