vmreverter 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vmreverter/cli.rb +12 -6
- data/lib/vmreverter/options.rb +16 -2
- data/lib/vmreverter/shared/error_handler.rb +4 -3
- data/lib/vmreverter/version.rb +1 -1
- data/lib/vmreverter.rb +2 -0
- data/vmreverter.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1ca2d821ebac6e2f1f46d1a843c59a444d7b6d
|
4
|
+
data.tar.gz: 821ef2696d14f8a0b29dbaf37e9f2d7f846a1a1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c50e66164b080aaeb9d37a494c0c0d7e38e91141ed6d06f20c28f34b37ebd0250989863e8502817ae0f751e6a7784a7a7ec00a230a7fec1ce99708c6382ff72
|
7
|
+
data.tar.gz: ff173f4bcb2f523bd02257d35adf3acd5b6571cca29b88c4fbff06483094b1752c778bfb215ed8e064816f8ed3afb47860f6278c7724358275a8686fec85ad17
|
data/lib/vmreverter/cli.rb
CHANGED
@@ -5,13 +5,19 @@ module Vmreverter
|
|
5
5
|
@logger = Vmreverter::Logger.new(@options)
|
6
6
|
@options[:logger] = @logger
|
7
7
|
|
8
|
-
if
|
9
|
-
|
8
|
+
if @options[:lockfile]
|
9
|
+
if Pathname.new(@options[:lockfile]).exist?
|
10
|
+
report_and_raise(@logger, ArgumentError.new("Specified lockfile path '#{@options[:lockfile].dirname}' is locked."), "Lockfile is locked")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if not @options[:config]
|
15
|
+
report_and_raise(@logger, ArgumentError.new("Missing config, specify one (-c or --config)!"), "CLI: initialize")
|
10
16
|
end
|
11
17
|
|
12
18
|
@logger.debug("Options")
|
13
19
|
@options.each do |opt, val|
|
14
|
-
if val and val != []
|
20
|
+
if val and val != []
|
15
21
|
@logger.debug("\t#{opt.to_s}:")
|
16
22
|
if val.kind_of?(Array)
|
17
23
|
val.each do |v|
|
@@ -28,20 +34,20 @@ module Vmreverter
|
|
28
34
|
end
|
29
35
|
|
30
36
|
def execute!
|
31
|
-
|
37
|
+
|
32
38
|
begin
|
33
39
|
trap(:INT) do
|
34
40
|
@logger.warn "Interrupt received; exiting..."
|
35
41
|
exit(1)
|
36
42
|
end
|
37
|
-
|
43
|
+
|
38
44
|
begin
|
39
45
|
@vmmanager = Vmreverter::VMManager.new(@config, @options, @logger)
|
40
46
|
@vmmanager.invoke
|
41
47
|
@vmmanager.close_connection
|
42
48
|
rescue => e
|
43
49
|
raise e
|
44
|
-
end
|
50
|
+
end
|
45
51
|
|
46
52
|
end #trap
|
47
53
|
end #execute!
|
data/lib/vmreverter/options.rb
CHANGED
@@ -17,7 +17,7 @@ module Vmreverter
|
|
17
17
|
|
18
18
|
optparse = OptionParser.new do|opts|
|
19
19
|
# Set a banner
|
20
|
-
opts.banner = "Usage: #{File.basename($0)} [options...]"
|
20
|
+
opts.banner = "Usage: #{File.basename($0)} #{::Vmreverter::VERSION} [options...]"
|
21
21
|
|
22
22
|
@defaults[:auth] = File.join(ENV['HOME'], '.fog')
|
23
23
|
opts.on '-a', '--auth FILE',
|
@@ -28,7 +28,7 @@ module Vmreverter
|
|
28
28
|
|
29
29
|
@defaults[:config] = nil
|
30
30
|
opts.on '-c', '--config FILE',
|
31
|
-
'Use configuration FILE',
|
31
|
+
'Use configuration FILE',
|
32
32
|
"Default: #{@defaults[:config]}" do |file|
|
33
33
|
@options[:config] = file
|
34
34
|
end
|
@@ -41,6 +41,13 @@ module Vmreverter
|
|
41
41
|
@options_from_file = parse_options_file file
|
42
42
|
end
|
43
43
|
|
44
|
+
@defaults[:lockfile] = nil
|
45
|
+
opts.on '-l', '--lockfile FILE',
|
46
|
+
'Use a lockfile to prevent concurrency',
|
47
|
+
'(default no lockfile).' do |file|
|
48
|
+
@options[:lockfile] = file
|
49
|
+
end
|
50
|
+
|
44
51
|
@defaults[:quiet] = false
|
45
52
|
opts.on '-q', '--[no-]quiet',
|
46
53
|
'Do not log output to STDOUT',
|
@@ -81,6 +88,13 @@ module Vmreverter
|
|
81
88
|
# merge in defaults
|
82
89
|
@options = @defaults.merge(@options)
|
83
90
|
|
91
|
+
if @options[:lockfile]
|
92
|
+
pn = Pathname.new(@options[:lockfile])
|
93
|
+
unless pn.dirname.writable?
|
94
|
+
raise ArgumentError, "Specified lockfile path '#{pn.dirname}' is not writable. Check permissions."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
84
98
|
@options
|
85
99
|
end
|
86
100
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Apache Licensed - (github/puppetlabs) ripped from puppet_acceptance. ** See Legal notes
|
2
2
|
# Changes include namespace swaps, method removal, method additions, and complete code refactoring
|
3
3
|
|
4
|
-
module Vmreverter
|
4
|
+
module Vmreverter
|
5
5
|
module Shared
|
6
6
|
module ErrorHandler
|
7
7
|
|
@@ -11,8 +11,9 @@ module Vmreverter
|
|
11
11
|
bt = e.backtrace
|
12
12
|
logger.pretty_backtrace(bt).each_line do |line|
|
13
13
|
logger.error(line)
|
14
|
-
end
|
15
|
-
raise e
|
14
|
+
end
|
15
|
+
#raise e
|
16
|
+
abort
|
16
17
|
end
|
17
18
|
|
18
19
|
end
|
data/lib/vmreverter/version.rb
CHANGED
data/lib/vmreverter.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'open-uri'
|
3
3
|
require 'yaml'
|
4
|
+
require 'pathname'
|
4
5
|
|
5
6
|
require 'rubygems' unless defined?(Gem)
|
6
7
|
|
7
8
|
module Vmreverter
|
8
9
|
$:.unshift(File.dirname(__FILE__))
|
10
|
+
require 'vmreverter/version'
|
9
11
|
|
10
12
|
# logger
|
11
13
|
require 'vmreverter/logger'
|
data/vmreverter.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmreverter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shadowbq
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: json
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|