foreman_omaha 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/app/controllers/api/v2/omaha_groups_controller.rb +2 -0
  4. data/app/controllers/api/v2/omaha_reports_controller.rb +2 -0
  5. data/app/controllers/omaha_groups_controller.rb +2 -0
  6. data/app/controllers/omaha_hosts_controller.rb +2 -0
  7. data/app/controllers/omaha_reports_controller.rb +2 -0
  8. data/app/graphql/types/omaha_group.rb +15 -0
  9. data/app/graphql/types/omaha_report.rb +15 -0
  10. data/app/graphql/types/omaha_report_status_enum.rb +9 -0
  11. data/app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb +2 -0
  12. data/app/helpers/foreman_omaha/application_helper.rb +2 -0
  13. data/app/helpers/foreman_omaha/omaha_groups_helper.rb +2 -0
  14. data/app/helpers/omaha_hosts_helper.rb +2 -0
  15. data/app/helpers/omaha_reports_helper.rb +2 -0
  16. data/app/lib/foreman_omaha/renderer/scope/macros/omaha.rb +2 -0
  17. data/app/models/concerns/foreman_omaha/host_extensions.rb +3 -1
  18. data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +2 -0
  19. data/app/models/foreman_omaha/fact_name.rb +2 -0
  20. data/app/models/foreman_omaha/omaha_facet.rb +2 -0
  21. data/app/models/foreman_omaha/omaha_group.rb +4 -0
  22. data/app/models/foreman_omaha/omaha_report.rb +4 -0
  23. data/app/models/host_status/omaha_status.rb +2 -0
  24. data/app/services/foreman_omaha/charts/oem_distribution.rb +2 -0
  25. data/app/services/foreman_omaha/charts/status_distribution.rb +2 -0
  26. data/app/services/foreman_omaha/charts/version_distribution.rb +2 -0
  27. data/app/services/foreman_omaha/container_linux_config_transpiler.rb +2 -0
  28. data/app/services/foreman_omaha/fact_importer.rb +2 -0
  29. data/app/services/foreman_omaha/fact_parser.rb +11 -3
  30. data/app/services/foreman_omaha/group_version_breakdown.rb +2 -0
  31. data/app/services/foreman_omaha/omaha_report_importer.rb +2 -0
  32. data/app/services/foreman_omaha/status_mapper.rb +2 -2
  33. data/app/views/api/v2/omaha_groups/base.json.rabl +2 -0
  34. data/app/views/api/v2/omaha_groups/index.json.rabl +2 -0
  35. data/app/views/api/v2/omaha_groups/main.json.rabl +2 -0
  36. data/app/views/api/v2/omaha_groups/show.json.rabl +2 -0
  37. data/app/views/api/v2/omaha_reports/base.json.rabl +2 -0
  38. data/app/views/api/v2/omaha_reports/create.json.rabl +2 -0
  39. data/app/views/api/v2/omaha_reports/index.json.rabl +2 -0
  40. data/app/views/api/v2/omaha_reports/main.json.rabl +2 -0
  41. data/app/views/api/v2/omaha_reports/show.json.rabl +2 -0
  42. data/app/views/api/v2/omaha_reports/update.json.rabl +2 -0
  43. data/app/views/foreman_omaha/api/v2/omaha_facets/base.json.rabl +2 -0
  44. data/app/views/foreman_omaha/api/v2/omaha_facets/base_with_root.json.rabl +2 -0
  45. data/app/views/foreman_omaha/api/v2/omaha_facets/show.json.rabl +2 -0
  46. data/app/views/omaha_reports/_list.html.erb +1 -1
  47. data/config/routes.rb +2 -0
  48. data/db/migrate/20160812083100_add_omaha_fields_to_reports.foreman_omaha.rb +2 -0
  49. data/db/migrate/20171101204100_create_omaha_facets.foreman_omaha.rb +2 -0
  50. data/db/seeds.d/200_omaha_groups.rb +2 -0
  51. data/db/seeds.d/60_omaha_proxy_feature.rb +2 -0
  52. data/lib/foreman_omaha.rb +2 -0
  53. data/lib/foreman_omaha/engine.rb +24 -8
  54. data/lib/foreman_omaha/version.rb +3 -1
  55. data/lib/tasks/foreman_omaha_tasks.rake +2 -0
  56. data/locale/gemspec.rb +2 -0
  57. data/test/factories/feature.rb +3 -1
  58. data/test/factories/foreman_omaha_factories.rb +8 -6
  59. data/test/factories/host.rb +19 -4
  60. data/test/factories/smart_proxy.rb +2 -0
  61. data/test/functional/api/v2/omaha_groups_controller_test.rb +2 -0
  62. data/test/functional/api/v2/omaha_reports_controller_test.rb +3 -1
  63. data/test/functional/omaha_groups_controller_test.rb +2 -0
  64. data/test/functional/omaha_hosts_controller_test.rb +2 -0
  65. data/test/functional/omaha_reports_controller_test.rb +2 -0
  66. data/test/graphql/queries/host_query_extensions_test.rb +41 -0
  67. data/test/graphql/queries/omaha_group_query_test.rb +51 -0
  68. data/test/graphql/queries/omaha_groups_query_test.rb +47 -0
  69. data/test/graphql/queries/omaha_report_query_test.rb +44 -0
  70. data/test/graphql/queries/omaha_reports_query_test.rb +47 -0
  71. data/test/test_plugin_helper.rb +2 -0
  72. data/test/unit/charts/oem_distribution_test.rb +2 -0
  73. data/test/unit/charts/status_distribution_test.rb +2 -0
  74. data/test/unit/charts/version_distribution_test.rb +2 -0
  75. data/test/unit/group_version_breakdown_test.rb +2 -0
  76. data/test/unit/host_status/omaha_status_test.rb +4 -2
  77. data/test/unit/host_test.rb +2 -0
  78. data/test/unit/omaha_fact_parser_test.rb +45 -11
  79. data/test/unit/omaha_report_test.rb +2 -0
  80. data/test/unit/renderer_test.rb +2 -0
  81. metadata +62 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 421a748a9a01373e725254764e8ec0eec455da8db499a948d46de2215b9378bf
4
- data.tar.gz: 893fd2401152eba58c412e5e87900d9d246fc6f0849f091e94172ea740f32dc8
3
+ metadata.gz: 2d18486e7d9ec48f38e24dc3230ac7952154b6368bb03b6200b530d40dfccb56
4
+ data.tar.gz: a35576ff4b8182f2d12364c3440d8fea31e194f1c39e4b8ed9787a5f487fdb69
5
5
  SHA512:
6
- metadata.gz: '09028f73bcf73132903dfe8318befca2428178f01b9b83138fed7d431a7b51eda6b4268ca3d6cc3851871587391fabd45c7b54c35ee802c2532c970867c25cda'
7
- data.tar.gz: 5e5cc0bb9cda50abe5bb9cec5d04ac46711403465928a9fda8e6e8b32fe0d9ab05d6bec380d9077fbf3ee16567ae3fffa3c08186f2ead2ca3e1c2d5c4d0ec2a2
6
+ metadata.gz: ea1a506216f9a64abe54920027716bfe31557db3d32b7cd867ad10c7bf6617f76413264be1b560bee338d6ece41c04b4752631cb773b27d53f664431b848fc5b
7
+ data.tar.gz: 9209885e3ca0b369d6acca9de2b59fbca45ce5d97ab163aa9d922bf6091f81453609c4fe0764f3b57b02cb162d7a5a093ed814d533f7b6d786743e47e83f8447
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,7 @@ 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 |
15
16
 
16
17
  ## Installation
17
18
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Api
2
4
  module V2
3
5
  class OmahaGroupsController < V2::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Api
2
4
  module V2
3
5
  class OmahaReportsController < V2::BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class OmahaGroupsController < ApplicationController
2
4
  include Foreman::Controller::AutoCompleteSearch
3
5
 
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class OmahaReportsController < ApplicationController
2
4
  include Foreman::Controller::AutoCompleteSearch
3
5
 
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Types
4
+ class OmahaReportStatusEnum < BaseEnum
5
+ ForemanOmaha::OmahaFacet::VALID_OMAHA_STATUSES.each do |status|
6
+ value status
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module HostsHelperExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module ApplicationHelper
3
5
  def facets_count(association, resource_name = controller.resource_name)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module OmahaGroupsHelper
3
5
  def omaha_version_breakdown_bar(omaha_group)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OmahaHostsHelper
2
4
  def last_omaha_report_column(record)
3
5
  time = record.omaha_facet.last_report? ? _('%s ago') % time_ago_in_words(record.omaha_facet.last_report) : ''
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OmahaReportsHelper
2
4
  def iconclass_for_omaha_status(status)
3
5
  case status.to_sym
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Renderer
3
5
  module Scope
@@ -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.destroy if 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
  module OmahaFacetHostExtensions
3
5
  extend ActiveSupport::Concern
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class FactName < ::FactName
3
5
  def origin
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class OmahaFacet < ApplicationRecord
3
5
  include Facets::Base
@@ -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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module HostStatus
2
4
  class OmahaStatus < HostStatus::Status
3
5
  def self.status_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Charts
3
5
  class OemDistribution
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Charts
3
5
  class StatusDistribution
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  module Charts
3
5
  class VersionDistribution
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open3'
2
4
 
3
5
  module ForemanOmaha
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class FactImporter < ::FactImporter
3
5
  def self.authorized_smart_proxy_features
@@ -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 => facts['platform'], :major => facts['osmajor'], :minor => facts['osminor'] }
5
- description = "#{facts['platform']} #{facts['version']}"
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.all.max_by { |os| Gem::Version.new(os.release) }
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 GroupVersionBreakdown
3
5
  attr_accessor :omaha_group
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ForemanOmaha
2
4
  class OmahaReportImporter < ::ReportImporter
3
5
  def report_name_class
@@ -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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_group
2
4
 
3
5
  attributes :id, :name, :uuid
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @omaha_groups
2
4
 
3
5
  extends 'api/v2/omaha_groups/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_group
2
4
 
3
5
  extends 'api/v2/omaha_groups/base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_group
2
4
 
3
5
  extends 'api/v2/omaha_groups/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  attributes :id, :host_id, :host_name, :reported_at, :status
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/show'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @omaha_reports
2
4
 
3
5
  extends 'api/v2/omaha_reports/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/main'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @omaha_report
2
4
 
3
5
  extends 'api/v2/omaha_reports/show'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  attributes :id, :last_report, :version, :machineid, :status
2
4
 
3
5
  child :omaha_group => :omaha_group do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  child :omaha_facet => :omaha_facet_attributes do |_omaha_facet|
2
4
  extends 'foreman_omaha/api/v2/omaha_facets/base'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  child :omaha_facet => :omaha_facet_attributes do
2
4
  extends 'foreman_omaha/api/v2/omaha_facets/base'
3
5
  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
- :confirm => _("Delete report for %s?") % report.host.try(:name)) %>
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Rails.application.routes.draw do
2
4
  namespace :api, :defaults => { :format => 'json' } do
3
5
  scope '(:apiv)', :module => :v2,