vmreverter 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vmreverter/cli.rb +4 -13
- data/lib/vmreverter/{config_tester.rb → configuration.rb} +23 -15
- data/lib/vmreverter/hypervisor/aws.rb +2 -2
- data/lib/vmreverter/hypervisor/vsphere.rb +2 -2
- data/lib/vmreverter/hypervisor.rb +1 -1
- data/lib/vmreverter/version.rb +1 -1
- data/lib/vmreverter/vmmanager.rb +17 -2
- data/lib/vmreverter.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1695cd3a040c7d3675650f0f5b6e7b5001f0c6e2
|
4
|
+
data.tar.gz: e203d1ea4465fddcccdcd87baa26ae4a5b21559d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d03af2f9ff51183cf0a8c3ffe0bd5f380df9d384007bd80d60653a851f71ee5b6b434d9f63e86c0de04652341c2b8fe38d27b149e4a1169f805db15f32a58d4
|
7
|
+
data.tar.gz: a1c520209b623a28412bcaf9c228b1f6a88ad1d4cde940f6f99c0852d50a2b30db8c8291e2e92b1fff6c5bb5ce8fc5b7008992b1c37cf9b9060a82c72d0487a9
|
data/lib/vmreverter/cli.rb
CHANGED
@@ -3,7 +3,7 @@ module Vmreverter
|
|
3
3
|
def initialize
|
4
4
|
@options = Vmreverter::Options.parse_args
|
5
5
|
@logger = Vmreverter::Logger.new(@options)
|
6
|
-
|
6
|
+
|
7
7
|
|
8
8
|
if @options[:lockfile]
|
9
9
|
if Pathname.new(@options[:lockfile]).exist?
|
@@ -31,7 +31,8 @@ module Vmreverter
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
Vmreverter::Configuration.build(@options, @logger)
|
35
|
+
@config = Vmreverter::Configuration.instance
|
35
36
|
|
36
37
|
end
|
37
38
|
|
@@ -43,17 +44,7 @@ module Vmreverter
|
|
43
44
|
FileUtils.rm @options[:lockfile], :force => true if @options[:lockfile]
|
44
45
|
exit(1)
|
45
46
|
end
|
46
|
-
|
47
|
-
begin
|
48
|
-
@vmmanager = Vmreverter::VMManager.new(@config)
|
49
|
-
@vmmanager.invoke
|
50
|
-
@vmmanager.close_connection
|
51
|
-
rescue => e
|
52
|
-
raise e
|
53
|
-
ensure
|
54
|
-
FileUtils.rm @options[:lockfile], :force => true if @options[:lockfile]
|
55
|
-
end
|
56
|
-
|
47
|
+
Vmreverter::VMManager.execute!(@config)
|
57
48
|
end #trap
|
58
49
|
end #execute!
|
59
50
|
|
@@ -1,13 +1,21 @@
|
|
1
|
-
|
1
|
+
require 'singleton'
|
2
2
|
|
3
3
|
module Vmreverter
|
4
4
|
# Config was taken by Ruby.
|
5
|
-
class
|
5
|
+
class Configuration
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
attr_reader :logger, :options, :config
|
9
|
+
|
10
|
+
def self.build(options, logger)
|
11
|
+
@@options = options
|
12
|
+
@@logger = logger
|
13
|
+
end
|
6
14
|
|
7
|
-
|
8
|
-
|
9
|
-
@
|
10
|
-
|
15
|
+
def initialize
|
16
|
+
@options = @@options
|
17
|
+
@logger = @@logger
|
18
|
+
config_file = @options[:config]
|
11
19
|
@config = load_file(config_file)
|
12
20
|
end
|
13
21
|
|
@@ -25,16 +33,16 @@ module Vmreverter
|
|
25
33
|
config['HOSTS'].each_key do |host|
|
26
34
|
config['HOSTS'][host]['tags'] ||= []
|
27
35
|
|
28
|
-
report_and_raise(@logger, RuntimeError.new("Missing hypervisor: (#{host})"), "
|
29
|
-
hypervisor = config['HOSTS'][host]['hypervisor'].downcase
|
30
|
-
#check to see if this host has a hypervisor
|
31
|
-
report_and_raise(@logger, RuntimeError.new("Invalid hypervisor: #{hypervisor} (#{host})"), "
|
32
|
-
|
33
|
-
#check to see if this host has a hypervisor
|
34
|
-
report_and_raise(@logger, RuntimeError.new("Missing snapshot: (#{host})"), "
|
36
|
+
report_and_raise(@logger, RuntimeError.new("Missing hypervisor: (#{host})"), "Configuration::load_file") unless config['HOSTS'][host].include? "hypervisor"
|
37
|
+
hypervisor = config['HOSTS'][host]['hypervisor'].downcase
|
38
|
+
#check to see if this host has a hypervisor
|
39
|
+
report_and_raise(@logger, RuntimeError.new("Invalid hypervisor: #{hypervisor} (#{host})"), "Configuration::load_file") unless Vmreverter::HYPERVISOR_TYPES.include? hypervisor
|
40
|
+
|
41
|
+
#check to see if this host has a hypervisor
|
42
|
+
report_and_raise(@logger, RuntimeError.new("Missing snapshot: (#{host})"), "Configuration::load_file") unless config['HOSTS'][host].include? "snapshot"
|
35
43
|
|
36
44
|
end
|
37
|
-
|
45
|
+
|
38
46
|
end
|
39
47
|
|
40
48
|
# Merge some useful date into the config hash
|
@@ -53,7 +61,7 @@ module Vmreverter
|
|
53
61
|
@logger.notify "Tags for #{host} #{tag}"
|
54
62
|
end
|
55
63
|
end
|
56
|
-
|
64
|
+
|
57
65
|
# Access @config keys/values
|
58
66
|
@config["CONFIG"].each_key do|cfg|
|
59
67
|
@logger.notify "Config Key|Val: #{cfg} #{@config["CONFIG"][cfg].inspect}"
|
@@ -6,8 +6,8 @@ module Vmreverter
|
|
6
6
|
#Blimpy will import your ~/.ssh/id_rsa.pub or ~/.ssh/id_dsa.pub into a Key Pair in every region that you use in your Blimpfiles.
|
7
7
|
def initialize(blimpy_hosts, config)
|
8
8
|
@config = config
|
9
|
-
@options = config
|
10
|
-
@logger = config
|
9
|
+
@options = config.options
|
10
|
+
@logger = config.logger
|
11
11
|
@blimpy_hosts = blimpy_hosts
|
12
12
|
require 'rubygems' unless defined?(Gem)
|
13
13
|
require 'yaml' unless defined?(YAML)
|
@@ -5,8 +5,8 @@ module Vmreverter
|
|
5
5
|
|
6
6
|
def initialize(vsphere_hosts, config)
|
7
7
|
@config = config
|
8
|
-
@options = config
|
9
|
-
@logger = config
|
8
|
+
@options = config.options
|
9
|
+
@logger = config.logger
|
10
10
|
@vsphere_hosts = vsphere_hosts
|
11
11
|
require 'yaml' unless defined?(YAML)
|
12
12
|
vsphere_credentials = VsphereHelper.load_config @options[:auth]
|
data/lib/vmreverter/version.rb
CHANGED
data/lib/vmreverter/vmmanager.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pry'
|
1
2
|
%w(hypervisor).each do |lib|
|
2
3
|
begin
|
3
4
|
require "vmreverter/#{lib}"
|
@@ -15,9 +16,23 @@ module Vmreverter
|
|
15
16
|
|
16
17
|
attr_accessor :hypervisor_collection
|
17
18
|
|
19
|
+
|
20
|
+
def self.execute!(config)
|
21
|
+
begin
|
22
|
+
@vmmanager = Vmreverter::VMManager.new(config)
|
23
|
+
@vmmanager.invoke
|
24
|
+
@vmmanager.close_connection
|
25
|
+
rescue => e
|
26
|
+
raise e
|
27
|
+
ensure
|
28
|
+
FileUtils.rm config.options[:lockfile], :force => true if config.options[:lockfile]
|
29
|
+
end
|
30
|
+
end #execute!
|
31
|
+
|
32
|
+
|
18
33
|
def initialize(config)
|
19
|
-
@logger = config
|
20
|
-
@options = config
|
34
|
+
@logger = config.logger
|
35
|
+
@options = config.options
|
21
36
|
@hosts = []
|
22
37
|
@config = config
|
23
38
|
@hypervisor_collection = {}
|
data/lib/vmreverter.rb
CHANGED
@@ -19,7 +19,7 @@ module Vmreverter
|
|
19
19
|
# hypervisor methods and helpers
|
20
20
|
require 'vmreverter/hypervisor'
|
21
21
|
|
22
|
-
%w( options vmmanager
|
22
|
+
%w( options vmmanager configuration cli ).each do |lib|
|
23
23
|
begin
|
24
24
|
require "vmreverter/#{lib}"
|
25
25
|
rescue LoadError
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmreverter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shadowbq
|
@@ -139,7 +139,7 @@ files:
|
|
139
139
|
- components.LICENSE.puppet_acceptance
|
140
140
|
- lib/vmreverter.rb
|
141
141
|
- lib/vmreverter/cli.rb
|
142
|
-
- lib/vmreverter/
|
142
|
+
- lib/vmreverter/configuration.rb
|
143
143
|
- lib/vmreverter/hypervisor.rb
|
144
144
|
- lib/vmreverter/hypervisor/aws.rb
|
145
145
|
- lib/vmreverter/hypervisor/vsphere.rb
|