fencing 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 496654c6eccb23d675e9c67719f4f3ab73e033da
4
- data.tar.gz: 70534e895152e426ed8d2844b599e63820bd73e9
3
+ metadata.gz: 6914e26ea4230b97f7c5c54400baadb8a8ef06d4
4
+ data.tar.gz: ae8022b561908664f1827a465bf2246e335b2385
5
5
  SHA512:
6
- metadata.gz: 359ed4e0d4a2b10875fc229c6499df20467abcbcbd0831db075ca8e645fd62b58e9e752ea0003dcec5c7d37322de6eec234a503beda069816beae4f21e119e3f
7
- data.tar.gz: 9945c582501438bddf7a30677fe7491ea60597894608ad02475e8ad45162a0f474f322cfaf7a3d68c520ff0a502eab5424704690a6cb15720055266a5d4e1cf1
6
+ metadata.gz: 27a73da6165b566bd44d37a7ba0cb5d1ae4f4f81f308ff179bf0f9f08494a1a11481f05d4fdcb045124abbb9036ea83836b736d016e9713afbf261803de711cf
7
+ data.tar.gz: 59dd225e5b227e1a65ea1920a5ed325077c0defec9fa89c880b261c631a965db41b9fd64a06133b47011d22dc6b4c46285d1dcc14247a4f62a78ca15c593d234
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ require 'rspec/core/rake_task'
11
11
 
12
12
  spec = Gem::Specification.new do |gem|
13
13
  gem.name = "fencing"
14
- gem.version = '0.1.0'
14
+ gem.version = '0.1.1'
15
15
  gem.authors = ["George McIntosh"]
16
16
  gem.email = ["george@elevenware.com"]
17
17
  gem.summary = %q{A Puppet ENC that releases config based on configuration}
data/bin/fencing CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+ $LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '../lib' )
3
3
  require 'fencing'
4
4
 
5
5
  enc_config_location = ARGV[0]
@@ -1,3 +1,5 @@
1
+ require 'fencing/log'
2
+
1
3
  module OS
2
4
  module Puppet
3
5
  module Fencing
@@ -10,6 +12,7 @@ module OS
10
12
  end
11
13
 
12
14
  def resolve_node(host_name)
15
+ Log.log("Looking up #{host_name}")
13
16
  node_config = @config.match_node(host_name)
14
17
  assert_blocked(host_name, node_config.blocker)
15
18
  node_config.node
@@ -18,10 +21,13 @@ module OS
18
21
  def assert_blocked(host_name, blocker)
19
22
  return if !blocker
20
23
  allowed_host = blocker.blocking_host_name
24
+ Log.log("blocker not blocking #{allowed_host}")
21
25
  return if host_name.start_with?(allowed_host)
22
26
  fact_name = blocker.fact
23
27
  fact_value = @facter.lookup(allowed_host, fact_name)
28
+ Log.log("Fact #{fact_name} on node #{allowed_host} has value #{fact_value}: expecting #{blocker.expected_value}")
24
29
  raise "cannot release #{host_name}" unless fact_value == blocker.expected_value
30
+ Log.log("Fine - releasing node definition for #{host_name}")
25
31
  end
26
32
 
27
33
  end
@@ -0,0 +1,21 @@
1
+ require 'logger'
2
+
3
+ module OS
4
+ module Puppet
5
+ module Fencing
6
+
7
+ class Log
8
+
9
+ @@log = Logger.new(File.open('/etc/puppet/enc/enc-daemon.log', File::WRONLY | File::APPEND | File::CREAT))
10
+ @@log.level = Logger::DEBUG
11
+ @@log.debug "Started Fencing"
12
+
13
+ def self.log(message)
14
+ @@log.debug message
15
+ end
16
+
17
+ end
18
+
19
+ end
20
+ end
21
+ end
data/lib/fencing.rb CHANGED
@@ -2,6 +2,7 @@ require 'fencing/config'
2
2
  require 'fencing/facter_adapter'
3
3
  require 'fencing/classifier'
4
4
  require 'fencing/node_resolver'
5
+ require 'fencing/log'
5
6
  require 'json'
6
7
 
7
8
  module OS
@@ -11,11 +12,13 @@ module OS
11
12
  class FencingRunner
12
13
 
13
14
  def initialize(config_location, nodes_location)
15
+ Log.log("Fencing runner started")
14
16
  config_json = JSON.parse(File.read(config_location))
15
17
  config = OS::Puppet::Fencing::Config.new(config_json)
16
18
  facter_adapter = OS::Puppet::Fencing::FacterAdapter.new
17
19
  @classifier = OS::Puppet::Fencing::Classifier.new(config, facter_adapter)
18
20
  @resolver = OS::Puppet::Fencing::NodeResolver.new(nodes_location)
21
+
19
22
  end
20
23
 
21
24
  def lookup(host_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fencing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - George McIntosh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -97,6 +97,7 @@ files:
97
97
  - lib/fencing/classifier.rb
98
98
  - lib/fencing/config.rb
99
99
  - lib/fencing/facter_adapter.rb
100
+ - lib/fencing/log.rb
100
101
  - lib/fencing/node_resolver.rb
101
102
  - spec/enc_spec.rb
102
103
  - spec/facter_spec.rb