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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b1987a20c1b8d7ee9e9a6f5d7d0b3a7d3683810
4
- data.tar.gz: 9c49b36255b155c752bfa5ab940ed5fdc6ae0f00
3
+ metadata.gz: 0a1ca2d821ebac6e2f1f46d1a843c59a444d7b6d
4
+ data.tar.gz: 821ef2696d14f8a0b29dbaf37e9f2d7f846a1a1a
5
5
  SHA512:
6
- metadata.gz: '02843c053ea84f503aee0695e349bd1ced44a259dbce84edb54efc9a0849afc5b2eeff011a827f696d82d50dd023a50311cc0791298e546a942da7e5fd135183'
7
- data.tar.gz: 47441567e87c4e0256b80810df5f1079ed76f1a0b63164d48c59f95a1c0c0e36eda132896186c8fa90d91b9d7ad255f1b00edc603e57424e2d8846a52c37db12
6
+ metadata.gz: 7c50e66164b080aaeb9d37a494c0c0d7e38e91141ed6d06f20c28f34b37ebd0250989863e8502817ae0f751e6a7784a7a7ec00a230a7fec1ce99708c6382ff72
7
+ data.tar.gz: ff173f4bcb2f523bd02257d35adf3acd5b6571cca29b88c4fbff06483094b1752c778bfb215ed8e064816f8ed3afb47860f6278c7724358275a8686fec85ad17
@@ -5,13 +5,19 @@ module Vmreverter
5
5
  @logger = Vmreverter::Logger.new(@options)
6
6
  @options[:logger] = @logger
7
7
 
8
- if not @options[:config]
9
- report_and_raise(@logger, ArgumentError.new("Missing config, specify one (-c or --config)!"), "CLI: initialize")
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!
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Vmreverter
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
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
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  # Testing dependencies
26
26
  s.add_development_dependency 'rake'
27
27
  s.add_development_dependency 'bump'
28
+ s.add_development_dependency 'pry'
28
29
 
29
30
 
30
31
  # Run time dependencies
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.5
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-15 00:00:00.000000000 Z
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