foreman_param_lookup 0.2.0 → 0.3.0

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: 89d9869be6fcfbead16041202702048dbd316153
4
- data.tar.gz: 4475619bd1d68833477317d9dc4366dedaf0aa90
3
+ metadata.gz: f466de34d3ef4091e0cccc11edd89fc6ab5bdc52
4
+ data.tar.gz: 5de1cfb7311e29e9748c63f96b6cf304858cc641
5
5
  SHA512:
6
- metadata.gz: 664b0bb1c1f345295683970fecacba3f19176f69d981a3cfc69d1db1a7e73db77a2e6c0d9c80d9797d8c165b51e5f72b9fe18a24576a654cb7ddca696687c733
7
- data.tar.gz: d8e470d73794fea5b826499515dab6d20eacee9dd6ae66c6d81536abb900c6b0e9aff823793307a2705f307f323dfc49fe8be59c0eaa3cade833d54ec7b09a2c
6
+ metadata.gz: 61c10418bfba912a73b2e283008beed4f40babf60ded47e371ae7be6ad75a24ca06cffb9b9ae7010ef35c1a06c548f407de00a4558ef062d91981401306b39cd
7
+ data.tar.gz: 6fd5058a09bae3d89258ba8ca408115230350cfc8316f45ecdcc94f03c51318d60ee3d3cccc712796d243eeb401c0ba65048d80d20cb6e2ef186fcf8911f59c1
data/README.md CHANGED
@@ -3,6 +3,9 @@
3
3
  Foreman engine plugin that exposes smart class parameter lookups for any host
4
4
  and class.
5
5
 
6
+ *Warning:* this was written as a proof of concept. It has no authentication and
7
+ should not be used in a production environment.
8
+
6
9
  The ENC YAML output that Foreman generates only provides parameters for classes
7
10
  that are included on the node through the host or hostgroup records. However
8
11
  any smart class parameter can be evaluated for a host, so this exposes an API
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,9 +1,33 @@
1
1
  class ForemanParamLookup::AnyClassification < Classification::ClassParam
2
+ include LookupKeysHelper
3
+ include HostsHelper
4
+
2
5
  def initialize args = { }
3
6
  super args
4
7
  @classes = args[:classes]
5
8
  end
6
9
 
10
+ def enc
11
+ hash = @classes.map do |puppet_class|
12
+ lookup_keys = overridable_lookup_keys(puppet_class, @host)
13
+ lookup_values = lookup_keys.map { |lookup_key|
14
+
15
+ if lookup_key.use_puppet_default
16
+ value = lookup_key.default_value
17
+ else
18
+ lookup_value = @host.lookup_values.detect { |v| v.lookup_key_id == lookup_key.id }
19
+ value = lookup_value.value unless lookup_value.nil?
20
+ end
21
+
22
+ [lookup_key.key, value]
23
+ }.compact
24
+
25
+ [puppet_class.name, Hash[lookup_values]] unless lookup_values.empty?
26
+ end
27
+
28
+ Hash[hash.compact]
29
+ end
30
+
7
31
  private
8
32
 
9
33
  def puppetclass_ids
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- match 'param_lookup', :to => 'foreman_param_lookup/classifications#lookup'
2
+ get 'param_lookup', :controller => 'foreman_param_lookup/classifications', :action => 'lookup'
3
3
  end
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: foreman_param_lookup 0.3.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "foreman_param_lookup"
8
- s.version = "0.2.0"
9
+ s.version = "0.3.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Dominic Cleal"]
12
- s.date = "2014-03-11"
14
+ s.date = "2016-04-22"
13
15
  s.description = "Exposes smart class parameters lookups as an API"
14
16
  s.email = "dcleal@redhat.com"
15
17
  s.extra_rdoc_files = [
@@ -31,8 +33,7 @@ Gem::Specification.new do |s|
31
33
  ]
32
34
  s.homepage = "http://github.com/domcleal/foreman_param_lookup"
33
35
  s.licenses = ["GPL-3"]
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = "2.0.6"
36
+ s.rubygems_version = "2.4.4"
36
37
  s.summary = "Exposes smart class parameters lookups as an API"
37
38
 
38
39
  if s.respond_to? :specification_version then
@@ -1,3 +1,3 @@
1
1
  module ForemanParamLookup
2
- require 'foreman_param_lookup/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
2
+ require 'foreman_param_lookup/engine'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_param_lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.6
80
+ rubygems_version: 2.4.4
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Exposes smart class parameters lookups as an API