puppetdb_foreman 3.1.2 → 4.0.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
- SHA1:
3
- metadata.gz: 012d05bfdd197afed1c498c95114aab2a3154243
4
- data.tar.gz: ac4dcd46faa3bc80e68e6814254978b5ec58d68b
2
+ SHA256:
3
+ metadata.gz: c6a297f534df49f9b10ae4b8398bbc957b90a10156a2aaefa4344e0dc2af61a2
4
+ data.tar.gz: 2247fe908bad567d6c6d21efb7a45be0d20a4f2464d230694b802ec6b5dd00f4
5
5
  SHA512:
6
- metadata.gz: 9e90b059fff04ec699cb74f5c200ee6dbe7db6772a666b1a1a33fd0482dab34250f34f9dfa9df9a1f37575b99acdcd70e92341798360309f44fa1b0e3d31e04e
7
- data.tar.gz: 528500da760e05edfb6e238138fb1962d5d8f80db4bbae995ede84ef7014ef551c8c801987be4c2f0279b86fdd86b747dd678796837689b931a2870a19e5f960
6
+ metadata.gz: 3a4841b0a410b36c6ca57fe2f523d3ccd9f9730bace770346377e051b4565bf3162c185b009a52478eb0dbdda6e3712a8b48ea1486ffb4ab8150f00b81498450
7
+ data.tar.gz: 4aef5cba6b027aa23cfb78d54551d05406103a9ecda2c821f69bed73695e452736a427c0f303d710a709cabb5bbefa868350ec23f02909758f5d87f2cbbf3045
data/README.md CHANGED
@@ -16,6 +16,12 @@ It does the following:
16
16
 
17
17
  Feel free to raise issues, ask for features, anything, in the github repository or #theforeman IRC channel in Freenode.
18
18
 
19
+ ## Compatibility
20
+
21
+ | Foreman Version | Plugin Version |
22
+ | --------------- | -------------- |
23
+ | >= 1.17 | ~> 4.0.0 |
24
+
19
25
  # Installation:
20
26
 
21
27
  **From packages**
@@ -15,7 +15,7 @@ module PuppetdbForeman
15
15
  def destroy
16
16
  Puppetdb.client.deactivate_node(@node)
17
17
  process_success :success_msg => _('Deactivated node %s in PuppetDB') % @node, :success_redirect => puppetdb_foreman_nodes_path
18
- rescue => e
18
+ rescue StandardError => e
19
19
  process_error(:redirect => puppetdb_foreman_nodes_path, :error_msg => _('Failed to deactivate node in PuppetDB: %s') % e.message)
20
20
  end
21
21
 
@@ -23,7 +23,7 @@ module PuppetdbForeman
23
23
  facts = Puppetdb.client.facts(@node)
24
24
  host = PuppetdbHost.new(:facts => facts).to_host
25
25
  process_success :success_msg => _('Imported host %s from PuppetDB') % @node, :success_redirect => host_path(:id => host)
26
- rescue => e
26
+ rescue StandardError => e
27
27
  process_error(:redirect => puppetdb_foreman_nodes_path, :error_msg => _('Failed to import host from PuppetDB: %s') % e.message)
28
28
  end
29
29
 
@@ -17,8 +17,8 @@ module Orchestration
17
17
  def delPuppetdb
18
18
  Rails.logger.info "Deactivating node in PuppetDB: #{name}"
19
19
  ::Puppetdb.client.deactivate_node(name)
20
- rescue => e
21
- failure _("Failed to deactiate node %{name} in PuppetDB: %{message}\n ") %
20
+ rescue StandardError => e
21
+ failure _("Failed to deactivate node %{name} in PuppetDB: %{message}\n ") %
22
22
  { :name => name, :message => e.message }, e
23
23
  end
24
24
 
@@ -18,7 +18,7 @@ module PuppetdbForeman
18
18
 
19
19
  begin
20
20
  Puppetdb.client.deactivate_node(name)
21
- rescue => e
21
+ rescue StandardError => e
22
22
  errors.add(:base, _("Could not deactivate host on PuppetDB: #{e}"))
23
23
  return false
24
24
  end
@@ -22,7 +22,7 @@ module PuppetdbClient
22
22
  end
23
23
 
24
24
  def facts(nodename)
25
- parse(get("#{facts_url}?#{URI.escape("query=[\"=\", \"certname\", \"#{nodename}\"]")}"))
25
+ parse(get(facts_url, query: "[\"=\", \"certname\", \"#{nodename}\"]"))
26
26
  end
27
27
 
28
28
  private
@@ -42,9 +42,9 @@ module PuppetdbClient
42
42
  "#{uri.scheme}://#{uri.host}:#{uri.port}"
43
43
  end
44
44
 
45
- def get(endpoint)
46
- logger.debug "PuppetdbClient: GET request to #{endpoint}"
47
- connection(endpoint).get.body
45
+ def get(endpoint, params = {})
46
+ logger.debug "PuppetdbClient: GET request to #{endpoint} with params: #{params}"
47
+ connection(endpoint).get(params: params).body
48
48
  end
49
49
 
50
50
  def post(endpoint, payload)
@@ -1,4 +1,4 @@
1
- class MigratePuppetdbApiVersionSetting < ActiveRecord::Migration
1
+ class MigratePuppetdbApiVersionSetting < ActiveRecord::Migration[4.2]
2
2
  def up
3
3
  puppetdb_address = Setting.where(:category => 'Setting::Puppetdb', :name => 'puppetdb_address').first.try(:value)
4
4
  return unless puppetdb_address
@@ -5,7 +5,7 @@ module PuppetdbForeman
5
5
  initializer 'puppetdb_foreman.load_default_settings', :before => :load_config_initializers do |_app|
6
6
  require_dependency File.expand_path('../../../app/models/setting/puppetdb.rb', __FILE__) if begin
7
7
  Setting.table_exists?
8
- rescue
8
+ rescue StandardError
9
9
  (false)
10
10
  end
11
11
  end
@@ -18,7 +18,7 @@ module PuppetdbForeman
18
18
 
19
19
  initializer 'puppetdb_foreman.register_plugin', :before => :finisher_hook do |_app|
20
20
  Foreman::Plugin.register :puppetdb_foreman do
21
- requires_foreman '>= 1.11'
21
+ requires_foreman '>= 1.17'
22
22
 
23
23
  apipie_documented_controllers ["#{PuppetdbForeman::Engine.root}/app/controllers/api/v2/*.rb"]
24
24
 
@@ -50,7 +50,7 @@ module PuppetdbForeman
50
50
  config.to_prepare do
51
51
  begin
52
52
  Host::Managed.send :include, PuppetdbForeman::HostExtensions
53
- rescue => e
53
+ rescue StandardError => e
54
54
  Rails.logger.warn "PuppetdbForeman: skipping engine hook (#{e})"
55
55
  end
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module PuppetdbForeman
2
- VERSION = '3.1.2'.freeze
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -19,7 +19,7 @@ namespace :puppetdb_foreman do
19
19
  "#{PuppetdbForeman::Engine.root}/lib/**/*.rb",
20
20
  "#{PuppetdbForeman::Engine.root}/test/**/*.rb"]
21
21
  end
22
- rescue
22
+ rescue StandardError
23
23
  puts 'Rubocop not loaded.'
24
24
  end
25
25
 
@@ -4,13 +4,13 @@ class Api::V2::PuppetdbNodesControllerTest < ActionController::TestCase
4
4
  setup do
5
5
  setup_settings
6
6
  User.current = users(:admin)
7
- @host = FactoryGirl.create(:host, :managed)
7
+ @host = FactoryBot.create(:host, :managed)
8
8
  end
9
9
 
10
10
  context '#index' do
11
11
  test 'lists puppetdb nodes unknown to foreman' do
12
12
  ::PuppetdbClient::V4.any_instance.stubs(:query_nodes).returns(['one.example.com', 'two.example.com'])
13
- get :index, {}, set_session_user
13
+ get :index, session: set_session_user
14
14
  assert_response :success
15
15
  response = ActiveSupport::JSON.decode(@response.body)
16
16
  hosts = response['results']
@@ -21,9 +21,9 @@ class Api::V2::PuppetdbNodesControllerTest < ActionController::TestCase
21
21
 
22
22
  context '#unknown' do
23
23
  test 'lists puppetdb nodes unknown to foreman' do
24
- host = FactoryGirl.create(:host, :managed)
24
+ host = FactoryBot.create(:host, :managed)
25
25
  ::PuppetdbClient::V4.any_instance.stubs(:query_nodes).returns([host.name, 'two.example.com'])
26
- get :unknown, {}, set_session_user
26
+ get :unknown, session: set_session_user
27
27
  assert_response :success
28
28
  response = ActiveSupport::JSON.decode(@response.body)
29
29
  hosts = response['results']
@@ -41,7 +41,7 @@ class Api::V2::PuppetdbNodesControllerTest < ActionController::TestCase
41
41
  end
42
42
 
43
43
  test 'imports a host by puppetdb facts' do
44
- delete :destroy, { :id => node }, set_session_user
44
+ delete :destroy, params: { :id => node }, session: set_session_user
45
45
  assert_response :success
46
46
  response = ActiveSupport::JSON.decode(@response.body)
47
47
  expected = { 'job' => { 'uuid' => uuid } }
@@ -51,7 +51,7 @@ class Api::V2::PuppetdbNodesControllerTest < ActionController::TestCase
51
51
 
52
52
  context '#import' do
53
53
  let(:node) { 'test.example.com' }
54
- let(:host) { FactoryGirl.create(:host) }
54
+ let(:host) { FactoryBot.create(:host) }
55
55
 
56
56
  before do
57
57
  ::PuppetdbClient::V4.any_instance.expects(:facts).with(node).returns({})
@@ -59,7 +59,7 @@ class Api::V2::PuppetdbNodesControllerTest < ActionController::TestCase
59
59
  end
60
60
 
61
61
  test 'imports a host by puppetdb facts' do
62
- put :import, { :id => node }, set_session_user
62
+ put :import, params: { :id => node }, session: set_session_user
63
63
  assert_response :success
64
64
  response = ActiveSupport::JSON.decode(@response.body)
65
65
  assert_equal host.id, response['id']
@@ -6,14 +6,14 @@ class NodesControllerTest < ActionController::TestCase
6
6
  setup do
7
7
  setup_settings
8
8
  User.current = users(:admin)
9
- @host = FactoryGirl.create(:host, :managed)
9
+ @host = FactoryBot.create(:host, :managed)
10
10
  end
11
11
 
12
12
  context '#index' do
13
13
  test 'lists puppetdb nodes unknown to foreman' do
14
- host = FactoryGirl.create(:host, :managed)
14
+ host = FactoryBot.create(:host, :managed)
15
15
  ::PuppetdbClient::V4.any_instance.stubs(:query_nodes).returns([host.name, 'two.example.com'])
16
- get :index, {}, set_session_user
16
+ get :index, session: set_session_user
17
17
  assert_response :success
18
18
  refute response.body =~ /#{host.name}/m
19
19
  assert response.body =~ /two.example.com/m
@@ -24,7 +24,7 @@ class NodesControllerTest < ActionController::TestCase
24
24
  let(:node) { 'test.example.com' }
25
25
  test 'deactivating a node in puppetdb' do
26
26
  ::PuppetdbClient::V4.any_instance.expects(:deactivate_node).with(node).returns(true)
27
- delete :destroy, { :id => node }, set_session_user
27
+ delete :destroy, params: { :id => node }, session: set_session_user
28
28
  assert_response :found
29
29
  assert_redirected_to puppetdb_foreman_nodes_path
30
30
  assert_nil flash[:error]
@@ -35,7 +35,7 @@ class NodesControllerTest < ActionController::TestCase
35
35
 
36
36
  context '#import' do
37
37
  let(:node) { 'test.example.com' }
38
- let(:host) { FactoryGirl.create(:host) }
38
+ let(:host) { FactoryBot.create(:host) }
39
39
 
40
40
  before do
41
41
  ::PuppetdbClient::V4.any_instance.expects(:facts).with(node).returns({})
@@ -43,9 +43,7 @@ class NodesControllerTest < ActionController::TestCase
43
43
  end
44
44
 
45
45
  test 'imports a host from puppetdb facts' do
46
- put :import, {
47
- :id => node
48
- }, set_session_user
46
+ put :import, params: { :id => node }, session: set_session_user
49
47
  assert_response :found
50
48
  assert_redirected_to host_path(:id => host)
51
49
  assert_nil flash[:error]
@@ -2,13 +2,13 @@ require 'test_plugin_helper'
2
2
 
3
3
  class HostTest < ActiveSupport::TestCase
4
4
  setup do
5
- User.current = FactoryGirl.build(:user, :admin)
5
+ User.current = FactoryBot.build(:user, :admin)
6
6
  setup_settings
7
7
  disable_orchestration
8
8
  end
9
9
 
10
10
  context 'a host with puppetdb orchestration' do
11
- let(:host) { FactoryGirl.build(:host, :managed) }
11
+ let(:host) { FactoryBot.build(:host, :managed) }
12
12
 
13
13
  context 'with puppetdb enabled' do
14
14
  before do
@@ -1,8 +1,11 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
3
  class PuppetdbHostTest < ActiveSupport::TestCase
4
+ include FactImporterIsolation
5
+ allow_transactions_for_any_importer
6
+
4
7
  setup do
5
- User.current = FactoryGirl.create(:user, :admin)
8
+ User.current = FactoryBot.create(:user, :admin)
6
9
  disable_orchestration
7
10
  setup_settings
8
11
  end
@@ -32,7 +35,7 @@ class PuppetdbHostTest < ActiveSupport::TestCase
32
35
 
33
36
  test 'updates an existing host by facts' do
34
37
  Setting[:update_subnets_from_facts] = true
35
- FactoryGirl.create(:host, :managed, :hostname => 'host', :domain => FactoryGirl.create(:domain, :name => 'example.com'))
38
+ FactoryBot.create(:host, :managed, :hostname => 'host', :domain => FactoryBot.create(:domain, :name => 'example.com'))
36
39
  pdbhost.to_host
37
40
  host = Host.find_by(name: 'host.example.com')
38
41
  assert_equal 'host.example.com', host.name
@@ -2,7 +2,7 @@ require 'test_plugin_helper'
2
2
 
3
3
  class PuppetdbTest < ActiveSupport::TestCase
4
4
  setup do
5
- User.current = FactoryGirl.build(:user, :admin)
5
+ User.current = FactoryBot.build(:user, :admin)
6
6
  setup_settings
7
7
  disable_orchestration
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetdb_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-31 00:00:00.000000000 Z
11
+ date: 2018-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rubocop
28
+ name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.49.1
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.49.1
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rdoc
42
+ name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.52.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.52.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.6.12
133
+ rubygems_version: 2.7.3
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: This is a Foreman plugin to interact with PuppetDB.