foreman_omaha 2.0.0 → 3.0.0
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 +4 -4
- data/README.md +1 -0
- data/app/controllers/omaha_hosts_controller.rb +6 -5
- data/app/lib/foreman_omaha/renderer/scope/macros/omaha.rb +13 -0
- data/app/models/concerns/foreman_omaha/host_extensions.rb +1 -0
- data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +1 -1
- data/app/models/foreman_omaha/omaha_facet.rb +2 -0
- data/app/models/foreman_omaha/omaha_report.rb +1 -0
- data/app/models/host_status/omaha_status.rb +2 -0
- data/app/services/foreman_omaha/container_linux_config_transpiler.rb +1 -0
- data/app/services/foreman_omaha/fact_parser.rb +3 -2
- data/app/services/foreman_omaha/group_version_breakdown.rb +1 -0
- data/app/services/foreman_omaha/omaha_report_importer.rb +3 -0
- data/app/views/omaha_groups/show.html.erb +11 -0
- data/lib/foreman_omaha/engine.rb +3 -2
- data/lib/foreman_omaha/version.rb +1 -1
- data/test/functional/api/v2/omaha_groups_controller_test.rb +1 -1
- data/test/functional/api/v2/omaha_reports_controller_test.rb +6 -6
- data/test/functional/omaha_reports_controller_test.rb +1 -1
- data/test/unit/host_test.rb +1 -1
- data/test/unit/omaha_fact_parser_test.rb +4 -4
- data/test/unit/renderer_test.rb +20 -10
- metadata +5 -5
- data/app/services/foreman_omaha/renderer_methods.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 421a748a9a01373e725254764e8ec0eec455da8db499a948d46de2215b9378bf
|
4
|
+
data.tar.gz: 893fd2401152eba58c412e5e87900d9d246fc6f0849f091e94172ea740f32dc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09028f73bcf73132903dfe8318befca2428178f01b9b83138fed7d431a7b51eda6b4268ca3d6cc3851871587391fabd45c7b54c35ee802c2532c970867c25cda'
|
7
|
+
data.tar.gz: 5e5cc0bb9cda50abe5bb9cec5d04ac46711403465928a9fda8e6e8b32fe0d9ab05d6bec380d9077fbf3ee16567ae3fffa3c08186f2ead2ca3e1c2d5c4d0ec2a2
|
data/README.md
CHANGED
@@ -14,11 +14,12 @@ class OmahaHostsController < ApplicationController
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def welcome
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
has_entries = begin
|
18
|
+
resource_base.first.nil?
|
19
|
+
rescue StandardError
|
20
|
+
false
|
21
|
+
end
|
22
|
+
if has_entries
|
22
23
|
@welcome = true
|
23
24
|
render :welcome
|
24
25
|
end
|
@@ -17,7 +17,7 @@ module ForemanOmaha
|
|
17
17
|
:installed => 4, :instance_hold => 5, :error => 6
|
18
18
|
}
|
19
19
|
|
20
|
-
scoped_search :on => :name, :relation => :omaha_group, :complete_value => true, :rename => :omaha_group
|
20
|
+
scoped_search :on => :name, :relation => :omaha_group, :complete_value => true, :rename => :omaha_group, :only_explicit => true
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -6,11 +6,13 @@ module HostStatus
|
|
6
6
|
|
7
7
|
def to_status(_options = {})
|
8
8
|
return ::ForemanOmaha::OmahaFacet.statuses[:unknown] unless relevant?
|
9
|
+
|
9
10
|
::ForemanOmaha::OmahaFacet.statuses[host.omaha_facet.status]
|
10
11
|
end
|
11
12
|
|
12
13
|
def to_global(_options = {})
|
13
14
|
return ::ForemanOmaha::OmahaFacet.statuses[:unknown] unless relevant?
|
15
|
+
|
14
16
|
case host.omaha_facet.status.to_sym
|
15
17
|
when :complete, :downloaded, :downloading, :installed
|
16
18
|
HostStatus::Global::OK
|
@@ -34,15 +34,16 @@ module ForemanOmaha
|
|
34
34
|
def create_coreos_version(attrs)
|
35
35
|
previous_version = previous_coreos_version
|
36
36
|
return Coreos.create!(attrs) unless previous_coreos_version
|
37
|
+
|
37
38
|
os = previous_version.deep_clone(
|
38
|
-
:include => [:ptables, :media, :os_default_templates, :architectures]
|
39
|
+
:include => [:ptables, :media, :os_default_templates, :architectures, :provisioning_templates]
|
39
40
|
)
|
40
41
|
os.update(attrs)
|
41
42
|
os
|
42
43
|
end
|
43
44
|
|
44
45
|
def previous_coreos_version
|
45
|
-
Coreos.all.
|
46
|
+
Coreos.all.max_by { |os| Gem::Version.new(os.release) }
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
@@ -19,6 +19,7 @@ module ForemanOmaha
|
|
19
19
|
def create_report_and_logs
|
20
20
|
super
|
21
21
|
return report unless report.persisted?
|
22
|
+
|
22
23
|
report.omaha_version = omaha_version
|
23
24
|
report.save
|
24
25
|
update_omaha_facet!
|
@@ -31,6 +32,7 @@ module ForemanOmaha
|
|
31
32
|
|
32
33
|
def update_omaha_facet!
|
33
34
|
return unless omaha_facet.last_report.nil? || omaha_facet.last_report.utc < time
|
35
|
+
|
34
36
|
omaha_facet.update(
|
35
37
|
:last_report => time,
|
36
38
|
:status => report_status,
|
@@ -71,6 +73,7 @@ module ForemanOmaha
|
|
71
73
|
minor = version.segments.last(2).join('.')
|
72
74
|
os = Coreos.find_by(:major => major, :minor => minor)
|
73
75
|
return unless os
|
76
|
+
|
74
77
|
ForemanOmaha::OmahaGroup.find_by(:uuid => os.release_name)
|
75
78
|
end
|
76
79
|
end
|
@@ -1,6 +1,17 @@
|
|
1
1
|
<% javascript 'foreman_omaha/application' %>
|
2
2
|
<% javascript 'charts' %>
|
3
3
|
<% title @omaha_group.name %>
|
4
|
+
<%= breadcrumbs(
|
5
|
+
items: [
|
6
|
+
{
|
7
|
+
caption: _('Omaha Groups'),
|
8
|
+
url: (url_for(hash_for_omaha_groups_path) if authorized_for(hash_for_omaha_groups_path))
|
9
|
+
},
|
10
|
+
{
|
11
|
+
caption: @omaha_group.name
|
12
|
+
}
|
13
|
+
]
|
14
|
+
) %>
|
4
15
|
<div class="container-fluid container-cards-pf">
|
5
16
|
<!-- status cards -->
|
6
17
|
<div class="row row-cards-pf">
|
data/lib/foreman_omaha/engine.rb
CHANGED
@@ -8,6 +8,7 @@ module ForemanOmaha
|
|
8
8
|
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
9
9
|
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
10
10
|
config.autoload_paths += Dir["#{config.root}/app/services"]
|
11
|
+
config.autoload_paths += Dir["#{config.root}/app/lib"]
|
11
12
|
|
12
13
|
# Add any db migrations
|
13
14
|
initializer 'foreman_omaha.load_app_instance_data' do |app|
|
@@ -18,7 +19,7 @@ module ForemanOmaha
|
|
18
19
|
|
19
20
|
initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
|
20
21
|
Foreman::Plugin.register :foreman_omaha do
|
21
|
-
requires_foreman '>= 1.
|
22
|
+
requires_foreman '>= 1.20'
|
22
23
|
|
23
24
|
apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
|
24
25
|
|
@@ -90,7 +91,6 @@ module ForemanOmaha
|
|
90
91
|
|
91
92
|
# add renderer extensions
|
92
93
|
allowed_template_helpers :transpile_container_linux_config
|
93
|
-
extend_template_helpers ForemanOmaha::RendererMethods
|
94
94
|
end
|
95
95
|
|
96
96
|
# Extend built in permissions
|
@@ -109,6 +109,7 @@ module ForemanOmaha
|
|
109
109
|
Host::Managed.send(:include, ForemanOmaha::HostExtensions)
|
110
110
|
Host::Managed.send(:include, ForemanOmaha::OmahaFacetHostExtensions)
|
111
111
|
HostsHelper.send(:include, ForemanOmaha::HostsHelperExtensions)
|
112
|
+
Foreman::Renderer::Scope::Base.send(:include, ForemanOmaha::Renderer::Scope::Macros::Omaha)
|
112
113
|
rescue StandardError => e
|
113
114
|
Rails.logger.warn "ForemanOmaha: skipping engine hook (#{e})"
|
114
115
|
end
|
@@ -23,7 +23,7 @@ class Api::V2::OmahaGroupsControllerTest < ActionController::TestCase
|
|
23
23
|
get :show, params: { :id => omaha_group.to_param }
|
24
24
|
assert_response :success
|
25
25
|
body = ActiveSupport::JSON.decode(@response.body)
|
26
|
-
|
26
|
+
assert_not_empty body
|
27
27
|
assert_equal omaha_group.id, body['id']
|
28
28
|
assert_equal omaha_group.name, body['name']
|
29
29
|
assert_equal omaha_group.uuid, body['uuid']
|
@@ -17,7 +17,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
17
17
|
assert_response :success
|
18
18
|
assert_not_nil assigns(:omaha_reports)
|
19
19
|
reports = ActiveSupport::JSON.decode(@response.body)
|
20
|
-
|
20
|
+
assert_not reports['results'].empty?
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'should show individual record' do
|
@@ -25,7 +25,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
25
25
|
get :show, params: { :id => report.to_param }
|
26
26
|
assert_response :success
|
27
27
|
show_response = ActiveSupport::JSON.decode(@response.body)
|
28
|
-
|
28
|
+
assert_not show_response.empty?
|
29
29
|
end
|
30
30
|
|
31
31
|
test 'should destroy report' do
|
@@ -34,7 +34,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
34
34
|
delete :destroy, params: { :id => report.to_param }
|
35
35
|
end
|
36
36
|
assert_response :success
|
37
|
-
|
37
|
+
assert_not Report.find_by(id: report.id)
|
38
38
|
end
|
39
39
|
|
40
40
|
test 'should get reports for given host only' do
|
@@ -43,7 +43,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
43
43
|
assert_response :success
|
44
44
|
assert_not_nil assigns(:omaha_reports)
|
45
45
|
reports = ActiveSupport::JSON.decode(@response.body)
|
46
|
-
|
46
|
+
assert_not reports['results'].empty?
|
47
47
|
assert_equal 1, reports['results'].count
|
48
48
|
end
|
49
49
|
|
@@ -63,7 +63,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
63
63
|
assert_response :success
|
64
64
|
assert_not_nil assigns(:omaha_report)
|
65
65
|
report = ActiveSupport::JSON.decode(@response.body)
|
66
|
-
|
66
|
+
assert_not report.empty?
|
67
67
|
assert_equal reports.last, ForemanOmaha::OmahaReport.find(report['id'])
|
68
68
|
end
|
69
69
|
|
@@ -74,7 +74,7 @@ class Api::V2::OmahaReportsControllerTest < ActionController::TestCase
|
|
74
74
|
assert_response :success
|
75
75
|
assert_not_nil assigns(:omaha_report)
|
76
76
|
report = ActiveSupport::JSON.decode(@response.body)
|
77
|
-
|
77
|
+
assert_not report.empty?
|
78
78
|
assert_equal main_report, ForemanOmaha::OmahaReport.find(report['id'])
|
79
79
|
end
|
80
80
|
|
@@ -49,6 +49,6 @@ class OmahaReportsControllerTest < ActionController::TestCase
|
|
49
49
|
report = FactoryBot.create(:omaha_report)
|
50
50
|
delete :destroy, params: { :id => report }, session: set_session_user
|
51
51
|
assert_redirected_to omaha_reports_url
|
52
|
-
|
52
|
+
assert_not ConfigReport.exists?(report.id)
|
53
53
|
end
|
54
54
|
end
|
data/test/unit/host_test.rb
CHANGED
@@ -51,14 +51,12 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
|
|
51
51
|
context 'with old versions' do
|
52
52
|
setup do
|
53
53
|
FactoryBot.create(:coreos,
|
54
|
-
:with_associations,
|
55
|
-
:with_os_defaults,
|
56
54
|
:major => '899',
|
57
55
|
:minor => '17.0',
|
58
56
|
:title => 'CoreOS 899.17.0')
|
59
57
|
@previous = FactoryBot.create(:coreos,
|
60
58
|
:with_associations,
|
61
|
-
:
|
59
|
+
:with_provision,
|
62
60
|
:major => '1010',
|
63
61
|
:minor => '5.0',
|
64
62
|
:title => 'CoreOS 1010.5.0')
|
@@ -70,7 +68,9 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
|
|
70
68
|
assert_equal @previous.ptables, os.ptables
|
71
69
|
assert_equal @previous.architectures, os.architectures
|
72
70
|
assert_equal @previous.media, os.media
|
73
|
-
assert_equal @previous.os_default_templates, os.os_default_templates
|
71
|
+
assert_equal @previous.os_default_templates.map(&:provisioning_template), os.os_default_templates.map(&:provisioning_template)
|
72
|
+
assert_equal @previous.os_default_templates.map(&:template_kind), os.os_default_templates.map(&:template_kind)
|
73
|
+
assert_equal @previous.provisioning_templates, os.provisioning_templates
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/test/unit/renderer_test.rb
CHANGED
@@ -2,20 +2,30 @@ require 'test_plugin_helper'
|
|
2
2
|
|
3
3
|
module ForemanOmaha
|
4
4
|
class RendererTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
|
5
|
+
let(:host) { FactoryBot.create(:host) }
|
6
|
+
let(:template) { OpenStruct.new(name: 'abc', template: "<%= transpile_container_linux_config('---') %>") }
|
7
|
+
let(:source) { Foreman::Renderer::Source::Database.new(template) }
|
8
|
+
let(:scope) { Foreman::Renderer::Scope::Base.new(host: host, source: source) }
|
9
|
+
let(:expected) { '{"ignition":{"config":{},"timeouts":{},"version":"2.1.0"},"networkd":{},"passwd":{},"storage":{},"systemd":{}}' }
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
setup do
|
12
|
+
ForemanOmaha::ContainerLinuxConfigTranspiler.any_instance.stubs(:run!).returns(expected)
|
10
13
|
end
|
11
14
|
|
12
|
-
|
15
|
+
context 'with safe mode renderer' do
|
16
|
+
let(:renderer) { Foreman::Renderer::SafeModeRenderer }
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
test 'should transpile a container linux config' do
|
19
|
+
assert_equal expected, renderer.render(source, scope)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with unsafe mode renderer' do
|
24
|
+
let(:renderer) { Foreman::Renderer::UnsafeModeRenderer }
|
25
|
+
|
26
|
+
test 'should transpile a container linux config' do
|
27
|
+
assert_equal expected, renderer.render(source, scope)
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
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: 3.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: 2018-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jquery-matchheight-rails
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.59.2
|
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.59.2
|
55
55
|
description: This plug-in adds support for the Omaha procotol to The Foreman. It allows
|
56
56
|
you to better manage and update your CoreOS servers.
|
57
57
|
email:
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- app/helpers/foreman_omaha/omaha_groups_helper.rb
|
77
77
|
- app/helpers/omaha_hosts_helper.rb
|
78
78
|
- app/helpers/omaha_reports_helper.rb
|
79
|
+
- app/lib/foreman_omaha/renderer/scope/macros/omaha.rb
|
79
80
|
- app/models/concerns/foreman_omaha/host_extensions.rb
|
80
81
|
- app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb
|
81
82
|
- app/models/foreman_omaha/fact_name.rb
|
@@ -91,7 +92,6 @@ files:
|
|
91
92
|
- app/services/foreman_omaha/fact_parser.rb
|
92
93
|
- app/services/foreman_omaha/group_version_breakdown.rb
|
93
94
|
- app/services/foreman_omaha/omaha_report_importer.rb
|
94
|
-
- app/services/foreman_omaha/renderer_methods.rb
|
95
95
|
- app/services/foreman_omaha/status_mapper.rb
|
96
96
|
- app/views/api/v2/omaha_groups/base.json.rabl
|
97
97
|
- app/views/api/v2/omaha_groups/index.json.rabl
|