foreman_omaha 3.0.0 → 5.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 +3 -1
- data/Rakefile +4 -2
- data/app/controllers/api/v2/omaha_groups_controller.rb +2 -0
- data/app/controllers/api/v2/omaha_reports_controller.rb +2 -0
- data/app/controllers/omaha_groups_controller.rb +2 -0
- data/app/controllers/omaha_hosts_controller.rb +6 -4
- data/app/controllers/omaha_reports_controller.rb +2 -0
- 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/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb +2 -0
- data/app/helpers/foreman_omaha/application_helper.rb +2 -0
- data/app/helpers/foreman_omaha/omaha_groups_helper.rb +2 -0
- data/app/helpers/omaha_hosts_helper.rb +2 -0
- data/app/helpers/omaha_reports_helper.rb +2 -0
- data/app/models/concerns/foreman_omaha/host_extensions.rb +3 -1
- data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +2 -0
- data/app/models/foreman_omaha/fact_name.rb +2 -0
- data/app/models/foreman_omaha/omaha_facet.rb +2 -0
- data/app/models/foreman_omaha/omaha_group.rb +4 -0
- data/app/models/foreman_omaha/omaha_report.rb +4 -0
- data/app/models/host_status/omaha_status.rb +2 -0
- data/app/services/foreman_omaha/charts/oem_distribution.rb +2 -0
- data/app/services/foreman_omaha/charts/status_distribution.rb +2 -0
- data/app/services/foreman_omaha/charts/version_distribution.rb +2 -0
- data/app/services/foreman_omaha/container_linux_config_transpiler.rb +3 -0
- data/app/services/foreman_omaha/fact_importer.rb +2 -0
- data/app/services/foreman_omaha/fact_parser.rb +11 -3
- data/app/services/foreman_omaha/group_version_breakdown.rb +2 -0
- data/app/services/foreman_omaha/omaha_report_importer.rb +2 -0
- data/app/services/foreman_omaha/status_mapper.rb +2 -2
- data/app/services/foreman_omaha/template_renderer_helper.rb +9 -0
- data/app/views/api/v2/omaha_groups/base.json.rabl +2 -0
- data/app/views/api/v2/omaha_groups/index.json.rabl +2 -0
- data/app/views/api/v2/omaha_groups/main.json.rabl +2 -0
- data/app/views/api/v2/omaha_groups/show.json.rabl +2 -0
- data/app/views/api/v2/omaha_reports/base.json.rabl +2 -0
- data/app/views/api/v2/omaha_reports/create.json.rabl +2 -0
- data/app/views/api/v2/omaha_reports/index.json.rabl +2 -0
- data/app/views/api/v2/omaha_reports/main.json.rabl +2 -0
- data/app/views/api/v2/omaha_reports/show.json.rabl +2 -0
- data/app/views/api/v2/omaha_reports/update.json.rabl +2 -0
- data/app/views/foreman_omaha/api/v2/omaha_facets/base.json.rabl +2 -0
- data/app/views/foreman_omaha/api/v2/omaha_facets/base_with_root.json.rabl +2 -0
- data/app/views/foreman_omaha/api/v2/omaha_facets/show.json.rabl +2 -0
- data/app/views/omaha_reports/_list.html.erb +1 -1
- data/config/routes.rb +2 -0
- data/db/migrate/20160812083100_add_omaha_fields_to_reports.foreman_omaha.rb +2 -0
- data/db/migrate/20171101204100_create_omaha_facets.foreman_omaha.rb +2 -0
- data/db/seeds.d/200_omaha_groups.rb +2 -0
- data/db/seeds.d/60_omaha_proxy_feature.rb +2 -0
- data/lib/foreman_omaha/engine.rb +28 -14
- data/lib/foreman_omaha/version.rb +3 -1
- data/lib/foreman_omaha.rb +2 -0
- data/lib/tasks/foreman_omaha_tasks.rake +2 -0
- data/locale/gemspec.rb +2 -0
- data/test/factories/feature.rb +3 -1
- data/test/factories/foreman_omaha_factories.rb +8 -6
- data/test/factories/host.rb +19 -4
- data/test/factories/smart_proxy.rb +2 -0
- data/test/functional/api/v2/omaha_groups_controller_test.rb +2 -0
- data/test/functional/api/v2/omaha_reports_controller_test.rb +4 -2
- data/test/functional/omaha_groups_controller_test.rb +2 -0
- data/test/functional/omaha_hosts_controller_test.rb +2 -0
- data/test/functional/omaha_reports_controller_test.rb +2 -0
- data/test/graphql/queries/host_query_extensions_test.rb +41 -0
- data/test/graphql/queries/omaha_group_query_test.rb +51 -0
- data/test/graphql/queries/omaha_groups_query_test.rb +47 -0
- data/test/graphql/queries/omaha_report_query_test.rb +44 -0
- data/test/graphql/queries/omaha_reports_query_test.rb +47 -0
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/charts/oem_distribution_test.rb +2 -0
- data/test/unit/charts/status_distribution_test.rb +2 -0
- data/test/unit/charts/version_distribution_test.rb +2 -0
- data/test/unit/group_version_breakdown_test.rb +2 -0
- data/test/unit/host_status/omaha_status_test.rb +4 -2
- data/test/unit/host_test.rb +2 -0
- data/test/unit/omaha_fact_parser_test.rb +67 -23
- data/test/unit/omaha_report_test.rb +2 -0
- data/test/unit/renderer_test.rb +2 -0
- metadata +64 -9
- data/app/lib/foreman_omaha/renderer/scope/macros/omaha.rb +0 -13
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ForemanOmaha
|
|
2
2
|
|
|
3
|
-
This plug-in enables CoreOS updates using [The Foreman](https://theforeman.org/) without using the public update infrastructure.
|
|
3
|
+
This plug-in enables CoreOS and Flatcar updates using [The Foreman](https://theforeman.org/) without using the public update infrastructure.
|
|
4
4
|
To follow along with common Foreman architecture, you need this Foreman plug-in installed and a [Smart-Proxy plugin](https://github.com/theforeman/smart_proxy_omaha). The smart-proxy plug-in does all the heavy lifting. The Foreman plug-in shows facts and reports for your hosts.
|
|
5
5
|
Foreman core already supports deploying CoreOS hosts and is great for on-premise setups. This plug-in enables you to better manage your servers.
|
|
6
6
|
|
|
@@ -12,6 +12,8 @@ Foreman core already supports deploying CoreOS hosts and is great for on-premise
|
|
|
12
12
|
| >= 1.17 | ~> 1.0 |
|
|
13
13
|
| >= 1.18 | ~> 2.0 |
|
|
14
14
|
| >= 1.20 | ~> 3.0 |
|
|
15
|
+
| >= 1.24 | ~> 4.0 |
|
|
16
|
+
| >= 3.0 | ~> 5.0 |
|
|
15
17
|
|
|
16
18
|
## Installation
|
|
17
19
|
|
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
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class OmahaHostsController < ApplicationController
|
|
2
4
|
include Foreman::Controller::AutoCompleteSearch
|
|
3
5
|
include ScopesPerAction
|
|
@@ -15,10 +17,10 @@ class OmahaHostsController < ApplicationController
|
|
|
15
17
|
|
|
16
18
|
def welcome
|
|
17
19
|
has_entries = begin
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
resource_base.first.nil?
|
|
21
|
+
rescue StandardError
|
|
22
|
+
false
|
|
23
|
+
end
|
|
22
24
|
if has_entries
|
|
23
25
|
@welcome = true
|
|
24
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
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ForemanOmaha
|
|
2
4
|
module HostExtensions
|
|
3
5
|
extend ActiveSupport::Concern
|
|
@@ -14,7 +16,7 @@ module ForemanOmaha
|
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def clear_omaha_facet
|
|
17
|
-
omaha_facet
|
|
19
|
+
omaha_facet&.destroy
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def clear_omaha_facet_on_build
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ForemanOmaha
|
|
2
4
|
class OmahaGroup < ApplicationRecord
|
|
3
5
|
include Authorizable
|
|
@@ -6,6 +8,8 @@ module ForemanOmaha
|
|
|
6
8
|
N_('Omaha Channel')
|
|
7
9
|
end
|
|
8
10
|
|
|
11
|
+
graphql_type '::Types::OmahaGroup'
|
|
12
|
+
|
|
9
13
|
has_many :omaha_facets, :class_name => 'ForemanOmaha::OmahaFacet', :foreign_key => :omaha_group_id,
|
|
10
14
|
:inverse_of => :omaha_group, :dependent => :restrict_with_exception
|
|
11
15
|
has_many :hosts, :class_name => '::Host::Managed', :through => :omaha_facets,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ForemanOmaha
|
|
2
4
|
class OmahaReport < ::Report
|
|
3
5
|
enum :status => OmahaFacet::VALID_OMAHA_STATUSES
|
|
4
6
|
|
|
7
|
+
graphql_type '::Types::OmahaReport'
|
|
8
|
+
|
|
5
9
|
scoped_search :on => :omaha_version, :rename => :version, :complete_value => true
|
|
6
10
|
scoped_search :on => :status, :complete_value => statuses
|
|
7
11
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'open3'
|
|
2
4
|
|
|
3
5
|
module ForemanOmaha
|
|
4
6
|
class ContainerLinuxConfigTranspiler
|
|
5
7
|
class TranspilerNotFound < StandardError; end
|
|
8
|
+
|
|
6
9
|
class TranspileError < StandardError; end
|
|
7
10
|
|
|
8
11
|
attr_accessor :input, :output, :errors, :status
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ForemanOmaha
|
|
2
4
|
class FactParser < ::FactParser
|
|
3
5
|
def operatingsystem
|
|
4
|
-
args = { :name =>
|
|
5
|
-
description = "#{
|
|
6
|
+
args = { :name => os_name, :major => facts['osmajor'], :minor => facts['osminor'] }
|
|
7
|
+
description = "#{os_name} #{facts['version']}"
|
|
6
8
|
Coreos.where(args).first ||
|
|
7
9
|
create_coreos_version(args.merge(:description => description,
|
|
8
10
|
:release_name => facts['track']))
|
|
@@ -31,6 +33,12 @@ module ForemanOmaha
|
|
|
31
33
|
|
|
32
34
|
private
|
|
33
35
|
|
|
36
|
+
def os_name
|
|
37
|
+
return 'Flatcar' if facts['distribution']&.downcase == 'flatcar'
|
|
38
|
+
|
|
39
|
+
facts['platform']
|
|
40
|
+
end
|
|
41
|
+
|
|
34
42
|
def create_coreos_version(attrs)
|
|
35
43
|
previous_version = previous_coreos_version
|
|
36
44
|
return Coreos.create!(attrs) unless previous_coreos_version
|
|
@@ -43,7 +51,7 @@ module ForemanOmaha
|
|
|
43
51
|
end
|
|
44
52
|
|
|
45
53
|
def previous_coreos_version
|
|
46
|
-
Coreos.
|
|
54
|
+
Coreos.where(name: os_name).max_by { |os| Gem::Version.new(os.release) }
|
|
47
55
|
end
|
|
48
56
|
end
|
|
49
57
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ForemanOmaha
|
|
2
4
|
class StatusMapper
|
|
3
5
|
attr_accessor :status
|
|
@@ -25,7 +27,6 @@ module ForemanOmaha
|
|
|
25
27
|
end
|
|
26
28
|
end
|
|
27
29
|
|
|
28
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
|
29
30
|
def to_description(version = nil)
|
|
30
31
|
case status.to_sym
|
|
31
32
|
when :complete
|
|
@@ -48,6 +49,5 @@ module ForemanOmaha
|
|
|
48
49
|
_('The status of this host is unknown.')
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<td title="<%= report.to_description(report.omaha_version) %>"><span class="<%= iconclass_for_omaha_status(report.status) %>"></span> <%= report.to_label %></td>
|
|
26
26
|
<td>
|
|
27
27
|
<%= action_buttons(display_delete_if_authorized hash_for_omaha_report_path(:id => report).merge(:auth_object => report, :authorizer => authorizer),
|
|
28
|
-
|
|
28
|
+
:data => { :confirm => _("Delete report for %s?") % report.host.try(:name)}) %>
|
|
29
29
|
</td>
|
|
30
30
|
</tr>
|
|
31
31
|
<% end %>
|
data/config/routes.rb
CHANGED
data/lib/foreman_omaha/engine.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'jquery-matchheight-rails'
|
|
2
4
|
|
|
3
5
|
module ForemanOmaha
|
|
@@ -19,7 +21,7 @@ module ForemanOmaha
|
|
|
19
21
|
|
|
20
22
|
initializer 'foreman_omaha.register_plugin', :before => :finisher_hook do |_app|
|
|
21
23
|
Foreman::Plugin.register :foreman_omaha do
|
|
22
|
-
requires_foreman '>=
|
|
24
|
+
requires_foreman '>= 3.0'
|
|
23
25
|
|
|
24
26
|
apipie_documented_controllers ["#{ForemanOmaha::Engine.root}/app/controllers/api/v2/*.rb"]
|
|
25
27
|
|
|
@@ -49,9 +51,11 @@ module ForemanOmaha
|
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
role 'Omaha reports viewer',
|
|
52
|
-
[:view_omaha_reports]
|
|
54
|
+
[:view_omaha_reports],
|
|
55
|
+
'Role granting permissions to view Omaha reports.'
|
|
53
56
|
role 'Omaha reports manager',
|
|
54
|
-
[:view_omaha_reports, :destroy_omaha_reports, :upload_omaha_reports]
|
|
57
|
+
[:view_omaha_reports, :destroy_omaha_reports, :upload_omaha_reports],
|
|
58
|
+
'Role granting permissions to manage Omaha reports.'
|
|
55
59
|
|
|
56
60
|
# add menu entry
|
|
57
61
|
menu :top_menu, :omaha_reports,
|
|
@@ -87,10 +91,17 @@ module ForemanOmaha
|
|
|
87
91
|
:onlyif => proc { |host| host.omaha_facet }
|
|
88
92
|
end
|
|
89
93
|
|
|
90
|
-
add_controller_action_scope(HostsController, :index) { |base_scope| base_scope.includes(:omaha_facet) }
|
|
94
|
+
add_controller_action_scope('HostsController', :index) { |base_scope| base_scope.includes(:omaha_facet) }
|
|
91
95
|
|
|
92
96
|
# add renderer extensions
|
|
97
|
+
extend_template_helpers ForemanOmaha::TemplateRendererHelper
|
|
93
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
|
|
94
105
|
end
|
|
95
106
|
|
|
96
107
|
# Extend built in permissions
|
|
@@ -102,17 +113,20 @@ module ForemanOmaha
|
|
|
102
113
|
|
|
103
114
|
# Include concerns in this config.to_prepare block
|
|
104
115
|
config.to_prepare do
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
HostsHelper.send(:include, ForemanOmaha::HostsHelperExtensions)
|
|
112
|
-
Foreman::Renderer::Scope::Base.send(:include, ForemanOmaha::Renderer::Scope::Macros::Omaha)
|
|
113
|
-
rescue StandardError => e
|
|
114
|
-
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)
|
|
115
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})"
|
|
116
130
|
end
|
|
117
131
|
|
|
118
132
|
rake_tasks do
|
data/lib/foreman_omaha.rb
CHANGED