foreman_hooks 0.3.2 → 0.3.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc10f54a3ede56411fb9702eacd35b19a340a49f
4
+ data.tar.gz: 33853d25749e467ae70a156c1ef59980874f6c93
5
+ SHA512:
6
+ metadata.gz: 498e8466d6626c622351b7f0047f36e9ce8836caf9bdd04af6428c2b0e47782ffab6507bf44f66338310179565fd5c349d34ae8359fb7eb70860a5ba0a5fbe8c
7
+ data.tar.gz: 96e4a89cf183390aefe482250a29c9cf604f7ea26c57aa86d1496878e6a28dbee8733e5c1d19a41f7d84d3ec4a36dc1b47347bdd19a2b276964ddda467143574
data/README.md CHANGED
@@ -10,7 +10,10 @@ Foreman object, all with shell scripts.
10
10
 
11
11
  # Installation:
12
12
 
13
- Include in your `~foreman/bundler.d/foreman_hooks.rb`
13
+ If you're using an RPM based installation, please use the packages provided in
14
+ the plugin repos at http://yum.theforeman.org/plugins.
15
+
16
+ For other setups, include in your `~foreman/bundler.d/foreman_hooks.rb`
14
17
 
15
18
  gem 'foreman_hooks'
16
19
 
@@ -18,11 +21,7 @@ Or from git:
18
21
 
19
22
  gem 'foreman_hooks', :git => "https://github.com/domcleal/foreman_hooks.git"
20
23
 
21
- Regenerate Gemfile.lock:
22
-
23
- cd ~foreman && sudo -u foreman bundle install
24
-
25
- To upgrade to newest version of the plugin:
24
+ Regenerate Gemfile.lock or upgrade to the latest version of the plugin:
26
25
 
27
26
  cd ~foreman && sudo -u foreman bundle update foreman_hooks
28
27
 
@@ -47,7 +46,7 @@ become `host/managed` instead.
47
46
  Every object (or model in Rails terms) in Foreman can have hooks. Check
48
47
  `~foreman/app/models` for the full list, but these are the interesting ones:
49
48
 
50
- * `host` (or `host/managed` in Foreman 1.2)
49
+ * `host/managed` (or `host` in Foreman 1.1)
51
50
  * `report`
52
51
 
53
52
  ## Orchestration events
@@ -98,7 +97,7 @@ to read this with jgrep is provided in `examples/hook_functions.sh` and
98
97
  sourcing this utility script will be enough for most users. Otherwise, you
99
98
  may want to ensure stdin is closed.
100
99
 
101
- echo '{"host"=>{"name"=>"foo.example.com"}}' \
100
+ echo '{"host":{"name":"foo.example.com"}}' \
102
101
  | ~foreman/config/hooks/host/create/50_register_system.sh \
103
102
  create foo.example.com
104
103
 
@@ -15,7 +15,7 @@ HOOK_EVENT=$1
15
15
  # to_s representation of the object, e.g. host's fqdn
16
16
  HOOK_OBJECT=$2
17
17
 
18
- HOOK_OBJECT_FILE=$(mktemp foreman_hooks.XXXXXXXXXX)
18
+ HOOK_OBJECT_FILE=$(mktemp -t foreman_hooks.XXXXXXXXXX)
19
19
  trap "rm -f $HOOK_OBJECT_FILE" EXIT
20
20
  cat > $HOOK_OBJECT_FILE
21
21
 
@@ -65,6 +65,13 @@ module ForemanHooks
65
65
  filtered
66
66
  end
67
67
 
68
+ def attach_hook(klass, events)
69
+ if events.keys.detect { |event| ['create', 'update', 'destroy'].include? event }
70
+ klass.send(:include, ForemanHooks::OrchestrationHook) unless klass.ancestors.include?(ForemanHooks::OrchestrationHook)
71
+ end
72
+ klass.send(:include, ForemanHooks::CallbackHooks) unless klass.ancestors.include?(ForemanHooks::CallbackHooks)
73
+ end
74
+
68
75
  def logger; Rails.logger; end
69
76
  end
70
77
  end
@@ -74,11 +81,7 @@ module ActiveSupport::Dependencies
74
81
  def load_missing_constant_with_hooks(from_mod, constant_name)
75
82
  ret = load_missing_constant_without_hooks(from_mod, constant_name)
76
83
  ForemanHooks.hooks.each do |klass,events|
77
- next unless ret.name == klass
78
- if events.keys.detect { |event| ['create', 'update', 'destroy'].include? event }
79
- ret.send(:include, ForemanHooks::OrchestrationHook) unless ret.ancestors.include?(ForemanHooks::OrchestrationHook)
80
- end
81
- ret.send(:include, ForemanHooks::CallbackHooks) unless ret.ancestors.include?(ForemanHooks::CallbackHooks)
84
+ ForemanHooks.attach_hook(ret, events) if ret.name == klass
82
85
  end
83
86
  ret
84
87
  end
@@ -2,5 +2,8 @@ require 'foreman_hooks'
2
2
 
3
3
  module ForemanHooks
4
4
  class Engine < ::Rails::Engine
5
+ config.to_prepare do
6
+ ForemanHooks.hooks.each { |klass,events| ForemanHooks.attach_hook(klass.constantize, events) }
7
+ end
5
8
  end
6
9
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
5
- prerelease:
4
+ version: 0.3.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dominic Cleal
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-30 00:00:00.000000000 Z
11
+ date: 2013-08-29 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Plugin engine for Foreman that enables running custom hook scripts on
15
14
  Foreman events
@@ -21,16 +20,12 @@ extra_rdoc_files:
21
20
  - README.md
22
21
  - TODO
23
22
  files:
24
- - .gitignore
25
- - .travis.yml
26
- - Gemfile
27
23
  - LICENSE
28
24
  - README.md
29
25
  - Rakefile
30
26
  - TODO
31
27
  - examples/hook_functions.sh
32
28
  - examples/log.sh
33
- - foreman_hooks.gemspec
34
29
  - lib/foreman_hooks.rb
35
30
  - lib/foreman_hooks/callback_hooks.rb
36
31
  - lib/foreman_hooks/engine.rb
@@ -41,26 +36,25 @@ files:
41
36
  homepage: http://github.com/domcleal/foreman_hooks
42
37
  licenses:
43
38
  - GPL-3
39
+ metadata: {}
44
40
  post_install_message:
45
41
  rdoc_options: []
46
42
  require_paths:
47
43
  - lib
48
44
  required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ! '>='
46
+ - - '>='
52
47
  - !ruby/object:Gem::Version
53
48
  version: '0'
54
49
  required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
50
  requirements:
57
- - - ! '>='
51
+ - - '>='
58
52
  - !ruby/object:Gem::Version
59
53
  version: '0'
60
54
  requirements: []
61
55
  rubyforge_project:
62
- rubygems_version: 1.8.25
56
+ rubygems_version: 2.0.6
63
57
  signing_key:
64
- specification_version: 3
58
+ specification_version: 4
65
59
  summary: Run custom hook scripts on Foreman events
66
60
  test_files: []
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .rvmrc
2
- Gemfile.lock
3
- test/foreman_app
4
- .bundle
5
- pkg/
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "1.8.7"
4
- - "1.9.3"
5
- before_install: rake test:foreman_prepare
6
- script: rake test
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- FOREMAN_GEMFILE=File.expand_path('../test/foreman_app/Gemfile', __FILE__)
4
- unless File.exist?(FOREMAN_GEMFILE)
5
- puts <<MESSAGE
6
- Foreman source code is not present. To get the latest version, run:
7
-
8
- rake test:foreman_prepare
9
-
10
- and try again.
11
- MESSAGE
12
-
13
- else
14
- self.instance_eval(Bundler.read_file(FOREMAN_GEMFILE))
15
- end
@@ -1,22 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = "foreman_hooks"
3
-
4
- s.version = "0.3.2"
5
- s.date = "2013-05-30"
6
-
7
- s.summary = "Run custom hook scripts on Foreman events"
8
- s.description = "Plugin engine for Foreman that enables running custom hook scripts on Foreman events"
9
- s.homepage = "http://github.com/domcleal/foreman_hooks"
10
- s.licenses = ["GPL-3"]
11
- s.require_paths = ["lib"]
12
-
13
- s.authors = ["Dominic Cleal"]
14
- s.email = "dcleal@redhat.com"
15
-
16
- s.extra_rdoc_files = [
17
- "LICENSE",
18
- "README.md",
19
- "TODO"
20
- ]
21
- s.files = `git ls-files`.split("\n")
22
- end