foreman_omaha 4.0.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Rakefile +4 -2
- data/app/controllers/omaha_hosts_controller.rb +4 -4
- data/app/graphql/concerns/foreman_omaha/types/host_extensions.rb +13 -0
- data/app/graphql/foreman_omaha/types/omaha_group.rb +21 -0
- data/app/graphql/foreman_omaha/types/omaha_report.rb +21 -0
- data/app/graphql/foreman_omaha/types/omaha_report_status_enum.rb +11 -0
- data/app/services/foreman_omaha/container_linux_config_transpiler.rb +1 -0
- data/app/services/foreman_omaha/template_renderer_helper.rb +9 -0
- data/lib/foreman_omaha/engine.rb +21 -14
- data/lib/foreman_omaha/version.rb +1 -1
- data/test/functional/api/v2/omaha_reports_controller_test.rb +1 -1
- data/test/unit/omaha_fact_parser_test.rb +24 -14
- metadata +10 -12
- data/app/graphql/types/extensions/foreman_omaha/host_extensions.rb +0 -15
- data/app/graphql/types/extensions/foreman_omaha/query_extensions.rb +0 -19
- data/app/graphql/types/omaha_group.rb +0 -15
- data/app/graphql/types/omaha_report.rb +0 -15
- data/app/graphql/types/omaha_report_status_enum.rb +0 -9
- data/app/lib/foreman_omaha/renderer/scope/macros/omaha.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0ee3bbe2a41f9d5ac5ffac14c72895f5f523ba58691cdbd59c21086638d74b7
|
4
|
+
data.tar.gz: 6348671022cae92df4f7da03f665514234f325be028c523db136ab3c81244eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b97bae1c564d7745876cae86a16558f986057a63553676e8c55e6199208c810cceeca7f8a588bb637399fc32c485bfac874b61b649dd0e9252752c3226be467c
|
7
|
+
data.tar.gz: adae755d7a4e0859663bea2495c2ccce1041a7d05d478ae4eca3ca2d8910a8aff3bdcca925165e6a28101005612a5ffc980e7af2a1a0fe427a884b9f92f98ebd
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
begin
|
3
5
|
require 'bundler/setup'
|
4
6
|
rescue LoadError
|
@@ -20,7 +22,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
23
|
end
|
22
24
|
|
23
|
-
APP_RAKEFILE = File.expand_path('
|
25
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
24
26
|
|
25
27
|
Bundler::GemHelper.install_tasks
|
26
28
|
|
@@ -38,7 +40,7 @@ task default: :test
|
|
38
40
|
begin
|
39
41
|
require 'rubocop/rake_task'
|
40
42
|
RuboCop::RakeTask.new
|
41
|
-
rescue =>
|
43
|
+
rescue StandardError => _e
|
42
44
|
puts 'Rubocop not loaded.'
|
43
45
|
end
|
44
46
|
|
@@ -17,10 +17,10 @@ class OmahaHostsController < ApplicationController
|
|
17
17
|
|
18
18
|
def welcome
|
19
19
|
has_entries = begin
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
resource_base.first.nil?
|
21
|
+
rescue StandardError
|
22
|
+
false
|
23
|
+
end
|
24
24
|
if has_entries
|
25
25
|
@welcome = true
|
26
26
|
render :welcome
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanOmaha
|
4
|
+
module Types
|
5
|
+
class OmahaGroup < ::Types::BaseObject
|
6
|
+
model_class ForemanOmaha::OmahaGroup
|
7
|
+
description 'An Omaha Group'
|
8
|
+
|
9
|
+
global_id_field :id
|
10
|
+
timestamps
|
11
|
+
field :name, String
|
12
|
+
field :uuid, String
|
13
|
+
|
14
|
+
has_many :hosts, ::Types::Host
|
15
|
+
|
16
|
+
def self.graphql_definition
|
17
|
+
super.tap { |type| type.instance_variable_set(:@name, 'ForemanOmaha::OmahaGroup') }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanOmaha
|
4
|
+
module Types
|
5
|
+
class OmahaReport < ::Types::BaseObject
|
6
|
+
model_class ForemanOmaha::OmahaReport
|
7
|
+
description 'An Omaha Report'
|
8
|
+
|
9
|
+
global_id_field :id
|
10
|
+
timestamps
|
11
|
+
field :status, ForemanOmaha::Types::OmahaReportStatusEnum
|
12
|
+
field :omaha_version, String
|
13
|
+
|
14
|
+
belongs_to :host, ::Types::Host
|
15
|
+
|
16
|
+
def self.graphql_definition
|
17
|
+
super.tap { |type| type.instance_variable_set(:@name, 'ForemanOmaha::OmahaReport') }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/foreman_omaha/engine.rb
CHANGED
@@ -11,7 +11,6 @@ module ForemanOmaha
|
|
11
11
|
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
12
12
|
config.autoload_paths += Dir["#{config.root}/app/services"]
|
13
13
|
config.autoload_paths += Dir["#{config.root}/app/lib"]
|
14
|
-
config.autoload_paths += Dir["#{config.root}/app/graphql"]
|
15
14
|
|
16
15
|
# Add any db migrations
|
17
16
|
initializer 'foreman_omaha.load_app_instance_data' do |app|
|
@@ -22,7 +21,7 @@ module ForemanOmaha
|
|
22
21
|
|
23
22
|
initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
|
24
23
|
Foreman::Plugin.register :foreman_omaha do
|
25
|
-
requires_foreman '>=
|
24
|
+
requires_foreman '>= 3.0'
|
26
25
|
|
27
26
|
apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
|
28
27
|
|
@@ -95,7 +94,14 @@ module ForemanOmaha
|
|
95
94
|
add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:omaha_facet) }
|
96
95
|
|
97
96
|
# add renderer extensions
|
97
|
+
extend_template_helpers ForemanOmaha::TemplateRendererHelper
|
98
98
|
allowed_template_helpers :transpile_container_linux_config
|
99
|
+
|
100
|
+
register_graphql_query_field :omaha_group, 'ForemanOmaha::Types::OmahaGroup', :record_field
|
101
|
+
register_graphql_query_field :omaha_groups, 'ForemanOmaha::Types::OmahaGroup', :collection_field
|
102
|
+
|
103
|
+
register_graphql_query_field :omaha_report, 'ForemanOmaha::Types::OmahaReport', :record_field
|
104
|
+
register_graphql_query_field :omaha_reports, 'ForemanOmaha::Types::OmahaReport', :collection_field
|
99
105
|
end
|
100
106
|
|
101
107
|
# Extend built in permissions
|
@@ -107,19 +113,20 @@ module ForemanOmaha
|
|
107
113
|
|
108
114
|
# Include concerns in this config.to_prepare block
|
109
115
|
config.to_prepare do
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
::
|
116
|
-
::HostsHelper.include(ForemanOmaha::HostsHelperExtensions)
|
117
|
-
::Foreman::Renderer::Scope::Base.include(ForemanOmaha::Renderer::Scope::Macros::Omaha)
|
118
|
-
::Types::Query.include(Types::Extensions::ForemanOmaha::QueryExtensions)
|
119
|
-
::Types::Host.include(Types::Extensions::ForemanOmaha::HostExtensions)
|
120
|
-
rescue StandardError => e
|
121
|
-
Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
|
116
|
+
Foreman::Plugin.fact_importer_registry.register(:foreman_omaha, ForemanOmaha::FactImporter, true)
|
117
|
+
|
118
|
+
if Foreman::Plugin.respond_to?(:fact_parser_registry)
|
119
|
+
Foreman::Plugin.fact_parser_registry.register(:foreman_omaha, ForemanOmaha::FactParser, true)
|
120
|
+
else
|
121
|
+
Foreman::Plugin.fact_importer_registry.register(:foreman_omaha, ForemanOmaha::FactParser, true)
|
122
122
|
end
|
123
|
+
|
124
|
+
::Host::Managed.include(ForemanOmaha::HostExtensions)
|
125
|
+
::Host::Managed.include(ForemanOmaha::OmahaFacetHostExtensions)
|
126
|
+
::HostsHelper.include(ForemanOmaha::HostsHelperExtensions)
|
127
|
+
::Types::Host.include(ForemanOmaha::Types::HostExtensions)
|
128
|
+
rescue StandardError => e
|
129
|
+
Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
|
123
130
|
end
|
124
131
|
|
125
132
|
rake_tasks do
|
@@ -100,7 +100,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
100
100
|
|
101
101
|
test 'hosts with a registered smart proxy on should create a report successfully' do
|
102
102
|
Setting[:restrict_registered_smart_proxies] = true
|
103
|
-
Setting[:require_ssl_smart_proxies] = false
|
103
|
+
Setting[:require_ssl_smart_proxies] = false if Gem::Version.new(SETTINGS[:version].notag) < Gem::Version.new('3.1')
|
104
104
|
|
105
105
|
proxy = FactoryBot.create(:smart_proxy, :omaha)
|
106
106
|
host = URI.parse(proxy.url).host
|
@@ -38,6 +38,11 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
|
|
38
38
|
|
39
39
|
context '#operatingsystem' do
|
40
40
|
let(:os) { importer.operatingsystem }
|
41
|
+
let(:expected_os_default_templates) do
|
42
|
+
OsDefaultTemplate.joins(:provisioning_template)
|
43
|
+
.where(operatingsystem: os)
|
44
|
+
.where(templates: { name: Setting[:default_host_init_config_template] })
|
45
|
+
end
|
41
46
|
|
42
47
|
context 'without distribution fact' do
|
43
48
|
setup do
|
@@ -60,7 +65,7 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
|
|
60
65
|
assert_equal 'stable', os.release_name
|
61
66
|
assert_empty os.ptables
|
62
67
|
assert_empty os.media
|
63
|
-
|
68
|
+
assert_same_elements os.os_default_templates, expected_os_default_templates
|
64
69
|
end
|
65
70
|
end
|
66
71
|
|
@@ -78,7 +83,7 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
|
|
78
83
|
assert_equal 'stable', os.release_name
|
79
84
|
assert_empty os.ptables
|
80
85
|
assert_empty os.media
|
81
|
-
|
86
|
+
assert_same_elements os.os_default_templates, expected_os_default_templates
|
82
87
|
end
|
83
88
|
end
|
84
89
|
|
@@ -88,23 +93,28 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
|
|
88
93
|
:major => '899',
|
89
94
|
:minor => '17.0',
|
90
95
|
:title => 'CoreOS 899.17.0')
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
|
97
|
+
previous.reload
|
98
|
+
end
|
99
|
+
|
100
|
+
let(:previous) do
|
101
|
+
FactoryBot.create(:coreos,
|
102
|
+
:with_associations,
|
103
|
+
:with_provision,
|
104
|
+
:major => '1010',
|
105
|
+
:minor => '5.0',
|
106
|
+
:title => 'CoreOS 1010.5.0')
|
97
107
|
end
|
98
108
|
|
99
109
|
test 'should copy attributes from previous os version' do
|
100
110
|
assert_equal '1068', os.major
|
101
111
|
assert_equal '9.0', os.minor
|
102
|
-
assert_equal
|
103
|
-
assert_equal
|
104
|
-
assert_equal
|
105
|
-
|
106
|
-
|
107
|
-
|
112
|
+
assert_equal previous.ptables, os.ptables
|
113
|
+
assert_equal previous.architectures, os.architectures
|
114
|
+
assert_equal previous.media, os.media
|
115
|
+
assert_same_elements previous.os_default_templates.map(&:template_kind), os.os_default_templates.map(&:template_kind)
|
116
|
+
assert_same_elements previous.os_default_templates.map(&:provisioning_template), os.os_default_templates.map(&:provisioning_template)
|
117
|
+
assert_same_elements previous.provisioning_templates, os.provisioning_templates
|
108
118
|
end
|
109
119
|
end
|
110
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_omaha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-matchheight-rails
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: rubocop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.80.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
54
|
version: 0.80.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -113,17 +113,15 @@ files:
|
|
113
113
|
- app/controllers/omaha_groups_controller.rb
|
114
114
|
- app/controllers/omaha_hosts_controller.rb
|
115
115
|
- app/controllers/omaha_reports_controller.rb
|
116
|
-
- app/graphql/
|
117
|
-
- app/graphql/types/
|
118
|
-
- app/graphql/types/
|
119
|
-
- app/graphql/types/
|
120
|
-
- app/graphql/types/omaha_report_status_enum.rb
|
116
|
+
- app/graphql/concerns/foreman_omaha/types/host_extensions.rb
|
117
|
+
- app/graphql/foreman_omaha/types/omaha_group.rb
|
118
|
+
- app/graphql/foreman_omaha/types/omaha_report.rb
|
119
|
+
- app/graphql/foreman_omaha/types/omaha_report_status_enum.rb
|
121
120
|
- app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb
|
122
121
|
- app/helpers/foreman_omaha/application_helper.rb
|
123
122
|
- app/helpers/foreman_omaha/omaha_groups_helper.rb
|
124
123
|
- app/helpers/omaha_hosts_helper.rb
|
125
124
|
- app/helpers/omaha_reports_helper.rb
|
126
|
-
- app/lib/foreman_omaha/renderer/scope/macros/omaha.rb
|
127
125
|
- app/models/concerns/foreman_omaha/host_extensions.rb
|
128
126
|
- app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb
|
129
127
|
- app/models/foreman_omaha/fact_name.rb
|
@@ -140,6 +138,7 @@ files:
|
|
140
138
|
- app/services/foreman_omaha/group_version_breakdown.rb
|
141
139
|
- app/services/foreman_omaha/omaha_report_importer.rb
|
142
140
|
- app/services/foreman_omaha/status_mapper.rb
|
141
|
+
- app/services/foreman_omaha/template_renderer_helper.rb
|
143
142
|
- app/views/api/v2/omaha_groups/base.json.rabl
|
144
143
|
- app/views/api/v2/omaha_groups/index.json.rabl
|
145
144
|
- app/views/api/v2/omaha_groups/main.json.rabl
|
@@ -220,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
219
|
- !ruby/object:Gem::Version
|
221
220
|
version: '0'
|
222
221
|
requirements: []
|
223
|
-
|
224
|
-
rubygems_version: 2.7.6.2
|
222
|
+
rubygems_version: 3.1.6
|
225
223
|
signing_key:
|
226
224
|
specification_version: 4
|
227
225
|
summary: This plug-in adds support for the Omaha procotol to The Foreman.
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Types
|
4
|
-
module Extensions
|
5
|
-
module ForemanOmaha
|
6
|
-
module QueryExtensions
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
record_field :omaha_group, Types::OmahaGroup
|
11
|
-
collection_field :omaha_groups, Types::OmahaGroup
|
12
|
-
|
13
|
-
record_field :omaha_report, Types::OmahaReport
|
14
|
-
collection_field :omaha_reports, Types::OmahaReport
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Types
|
4
|
-
class OmahaGroup < BaseObject
|
5
|
-
model_class ::ForemanOmaha::OmahaGroup
|
6
|
-
description 'An Omaha Group'
|
7
|
-
|
8
|
-
global_id_field :id
|
9
|
-
timestamps
|
10
|
-
field :name, String
|
11
|
-
field :uuid, String
|
12
|
-
|
13
|
-
has_many :hosts, Types::Host
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Types
|
4
|
-
class OmahaReport < BaseObject
|
5
|
-
model_class ::ForemanOmaha::OmahaReport
|
6
|
-
description 'An Omaha Report'
|
7
|
-
|
8
|
-
global_id_field :id
|
9
|
-
timestamps
|
10
|
-
field :status, Types::OmahaReportStatusEnum
|
11
|
-
field :omaha_version, String
|
12
|
-
|
13
|
-
belongs_to :host, Types::Host
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ForemanOmaha
|
4
|
-
module Renderer
|
5
|
-
module Scope
|
6
|
-
module Macros
|
7
|
-
module Omaha
|
8
|
-
def transpile_container_linux_config(input)
|
9
|
-
ForemanOmaha::ContainerLinuxConfigTranspiler.new(input).run!
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|