foreman_rh_cloud 1.0.4 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -0
  4. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +14 -7
  5. data/app/models/setting/rh_cloud.rb +13 -0
  6. data/config/routes.rb +1 -0
  7. data/lib/foreman_inventory_upload.rb +12 -0
  8. data/lib/foreman_inventory_upload/async/async_helpers.rb +13 -0
  9. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +8 -0
  10. data/lib/foreman_inventory_upload/async/shell_process.rb +3 -1
  11. data/lib/foreman_inventory_upload/async/upload_report_job.rb +1 -5
  12. data/lib/foreman_inventory_upload/generators/archived_report.rb +6 -3
  13. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +13 -0
  14. data/lib/foreman_inventory_upload/generators/queries.rb +2 -0
  15. data/lib/foreman_inventory_upload/generators/slice.rb +31 -11
  16. data/lib/foreman_rh_cloud/engine.rb +5 -1
  17. data/lib/foreman_rh_cloud/version.rb +1 -1
  18. data/package.json +20 -100
  19. data/test/controllers/accounts_controller_test.rb +8 -3
  20. data/test/controllers/uploads_controller_test.rb +13 -0
  21. data/test/factories/inventory_upload_factories.rb +13 -13
  22. data/test/unit/archived_report_generator_test.rb +1 -0
  23. data/test/unit/fact_helpers_test.rb +29 -0
  24. data/test/unit/slice_generator_test.rb +112 -15
  25. data/test/unit/slice_generator_test.rb.orig +280 -0
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +2 -0
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +5 -14
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +2 -1
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +8 -0
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +2 -0
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +1 -1
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +1 -1
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +1 -1
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +1 -1
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +1 -1
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +1 -1
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +1 -1
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +12 -1
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +10 -2
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +10 -0
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +5 -2
  42. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +1 -0
  43. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +32 -0
  44. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +27 -0
  45. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +2 -0
  46. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +14 -0
  47. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +14 -0
  48. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +38 -0
  49. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +14 -0
  50. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +3 -0
  51. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +17 -0
  52. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +13 -9
  53. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +5 -15
  54. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +1 -2
  55. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +15 -2
  56. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +3 -2
  57. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +1 -1
  58. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +1 -1
  59. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +1 -1
  60. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +1 -1
  61. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +5 -2
  62. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +1 -2
  63. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +1 -1
  64. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +21 -0
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +13 -0
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +33 -0
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/index.js +1 -0
  68. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +1 -1
  69. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +1 -1
  70. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +1 -0
  71. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +4 -2
  72. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +1 -2
  73. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +0 -2
  74. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +12 -1
  75. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +1 -1
  76. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +1 -1
  77. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +1 -1
  78. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +1 -1
  79. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +1 -1
  80. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +1 -1
  81. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  82. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -2
  83. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +5 -4
  84. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +1 -1
  85. data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +6 -5
  86. metadata +22 -9
  87. data/webpack/stories/ForemanInventoryUploadReducers.js +0 -3
  88. data/webpack/stories/configureStore.js +0 -15
  89. data/webpack/stories/decorators/index.js +0 -1
  90. data/webpack/stories/decorators/withCardsDecorator.js +0 -14
  91. data/webpack/stories/index.js +0 -10
  92. data/webpack/stories/index.scss +0 -7
  93. data/webpack/test_setup.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74f7aec361b1006ae16a1e49f3c1bbf0ce5916a48849638bebc68b3b4dacde5b
4
- data.tar.gz: 2e5f90b72fbd9759f97418d13936b8e0a49d2c9add73b0f8ad5780fb860f5dce
3
+ metadata.gz: f497849e8c31b5ca95c689315cd88222097b769c1cf41d9f3ebf89f9cd64febf
4
+ data.tar.gz: deca6935796bd48f87e1bd6820deb732dc589dd6704fbd923270847be3d46984
5
5
  SHA512:
6
- metadata.gz: feec26a018a4b92c0d9d1777d9ba4633d142c6cb8f7bf109058c222af18d06ab8ab8ce52e1998739539fb4bcece3d5fb893e872b48f2c227b0714005cb2b2ff9
7
- data.tar.gz: 4cfeacaaf11a06f0d2b15840bb1fd01738a2101b5f2d9045ae9f7d58af52a14da009edfebcfd40c77079c17daffb2955e4d548cd2c4ff3879eae1f9ca7ce1191
6
+ metadata.gz: 4c0407bf3aa9d3ce7d3abc86ed6c82182024a68f7b370ba4b406d19924697a8af5c404bf4e361e638821f98a63cc81867c46d8aa6d3af9a8da0c774c33829b14
7
+ data.tar.gz: 5f4de6af57144fa3e22f10ea1d25269fe309a268bb71b8b677cfcd606f1a507fec9b02ce744e7f184fe74f56b95ed7b6b9c5110d56f0e495d217afb573b6e3cb
data/README.md CHANGED
@@ -11,6 +11,14 @@ for how to install Foreman plugins
11
11
 
12
12
  *Usage here*
13
13
 
14
+ ### In Satellite
15
+
16
+ Normally you run it via UI in RH Cloud -> Inventory Upload -> Restart, but if you need to run from command-line for some reason:
17
+
18
+ export organization_id=1
19
+ export target=/var/lib/foreman/red_hat_inventory/generated_reports/
20
+ /usr/sbin/foreman-rake foreman_inventory_upload:report:generate
21
+
14
22
  ## TODO
15
23
 
16
24
  *Todo list here*
@@ -25,6 +25,7 @@ module ForemanInventoryUpload
25
25
  ]
26
26
 
27
27
  render json: {
28
+ autoUploadEnabled: Setting[:allow_auto_inventory_upload],
28
29
  accounts: accounts,
29
30
  }, status: :ok
30
31
  end
@@ -11,14 +11,10 @@ module ForemanInventoryUpload
11
11
 
12
12
  def download_file
13
13
  filename = ForemanInventoryUpload.facts_archive_name(params[:organization_id])
14
- path = Rails.root.join(ForemanInventoryUpload.uploads_folder, filename)
15
- unless File.exist? path
16
- return throw_flash_error(
17
- "Path doesn't exist: #{path}"
18
- )
19
- end
14
+ files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
20
15
 
21
- send_file path, disposition: 'attachment', filename: filename
16
+ return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
17
+ throw_flash_error "File doesn't exist"
22
18
  end
23
19
 
24
20
  def throw_flash_error(message)
@@ -27,5 +23,16 @@ module ForemanInventoryUpload
27
23
  :error_msg => message
28
24
  )
29
25
  end
26
+
27
+ def auto_upload
28
+ Setting[:allow_auto_inventory_upload] = auto_upload_params
29
+ render json: {
30
+ autoUploadEnabled: Setting[:allow_auto_inventory_upload],
31
+ }
32
+ end
33
+
34
+ def auto_upload_params
35
+ ActiveModel::Type::Boolean.new.cast(params.require(:value))
36
+ end
30
37
  end
31
38
  end
@@ -0,0 +1,13 @@
1
+ class Setting::RhCloud < Setting
2
+ def self.default_settings
3
+ return unless ActiveRecord::Base.connection.table_exists?('settings')
4
+ return unless super
5
+ [
6
+ set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), true),
7
+ ]
8
+ end
9
+
10
+ def self.humanized_category
11
+ N_('RH Cloud')
12
+ end
13
+ end
@@ -6,5 +6,6 @@ Rails.application.routes.draw do
6
6
  get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
7
7
  get ':organization_id/uploads/file', to: 'uploads#download_file', constraints: { organization_id: %r{[^\/]+} }
8
8
  get 'accounts', to: 'accounts#index'
9
+ post 'auto_upload', to: 'uploads#auto_upload'
9
10
  end
10
11
  end
@@ -18,6 +18,18 @@ module ForemanInventoryUpload
18
18
  )
19
19
  end
20
20
 
21
+ def self.uploads_file_path(filename)
22
+ File.join(ForemanInventoryUpload.uploads_folder, filename)
23
+ end
24
+
25
+ def self.done_folder
26
+ File.join(ForemanInventoryUpload.uploads_folder, 'done/')
27
+ end
28
+
29
+ def self.done_file_path(filename)
30
+ File.join(ForemanInventoryUpload.done_folder, filename)
31
+ end
32
+
21
33
  def self.generated_reports_folder
22
34
  @generated_reports_folder ||= ensure_folder(
23
35
  File.join(
@@ -0,0 +1,13 @@
1
+ module ForemanInventoryUpload
2
+ module Async
3
+ module AsyncHelpers
4
+ extend ActiveSupport::Concern
5
+
6
+ def hash_to_s(hash)
7
+ hash.each_with_object({}) do |(k, v), a|
8
+ a[k.to_s] = v.to_s
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,6 +2,14 @@ module ForemanInventoryUpload
2
2
  module Async
3
3
  class GenerateAllReportsJob < ::ApplicationJob
4
4
  def perform
5
+ unless Setting[:allow_auto_inventory_upload]
6
+ logger.debug(
7
+ 'The scheduled process is disabled due to the "allow_auto_inventory_upload"
8
+ setting being set to false.'
9
+ )
10
+ return
11
+ end
12
+
5
13
  organizations = Organization.unscoped.all
6
14
 
7
15
  organizations.map do |organization|
@@ -3,11 +3,13 @@ require 'open3'
3
3
  module ForemanInventoryUpload
4
4
  module Async
5
5
  class ShellProcess < ::ApplicationJob
6
+ include AsyncHelpers
7
+
6
8
  def perform(instance_label)
7
9
  klass_name = self.class.name
8
10
  logger.debug("Starting #{klass_name} with label #{instance_label}")
9
11
  progress_output = ProgressOutput.register(instance_label)
10
- Open3.popen2e(env, command) do |_stdin, stdout_stderr, wait_thread|
12
+ Open3.popen2e(hash_to_s(env), command) do |_stdin, stdout_stderr, wait_thread|
11
13
  progress_output.status = "Running in pid #{wait_thread.pid}"
12
14
 
13
15
  stdout_stderr.each do |out_line|
@@ -37,11 +37,7 @@ module ForemanInventoryUpload
37
37
  end
38
38
 
39
39
  def http_proxy_string
40
- @http_proxy_string ||= begin
41
- if Setting[:content_default_http_proxy]
42
- HttpProxy.unscoped.find_by(name: Setting[:content_default_http_proxy])&.full_url
43
- end
44
- end
40
+ @http_proxy_string ||= HttpProxy.default_global_content_proxy&.full_url
45
41
  end
46
42
 
47
43
  def rh_credentials
@@ -16,9 +16,9 @@ module ForemanInventoryUpload
16
16
  first = true
17
17
  host_batches.each do |hosts_batch|
18
18
  slice_id = Foreman.uuid
19
- hosts_count = hosts_batch.count
20
- @logger.info "Adding slice #{slice_id} with #{hosts_count} hosts"
21
- generate_slice(tmpdir, slice_id, hosts_batch)
19
+ @logger.info "Adding slice #{slice_id}"
20
+ hosts_count = generate_slice(tmpdir, slice_id, hosts_batch)
21
+ @logger.info "slice #{slice_id} was created with #{hosts_count} hosts"
22
22
  inner_generator.add_slice(slice_id, hosts_count, first)
23
23
  first = false
24
24
  end
@@ -43,10 +43,13 @@ module ForemanInventoryUpload
43
43
  private
44
44
 
45
45
  def generate_slice(tmpdir, slice_id, hosts_batch)
46
+ hosts_count = 0
46
47
  File.open(File.join(tmpdir, "#{slice_id}.json"), 'w') do |slice_out|
47
48
  slice_generator = ForemanInventoryUpload::Generators::Slice.new(hosts_batch, slice_out, slice_id)
48
49
  slice_generator.render
50
+ hosts_count = slice_generator.hosts_count
49
51
  end
52
+ hosts_count
50
53
  end
51
54
  end
52
55
  end
@@ -13,6 +13,19 @@ module ForemanInventoryUpload
13
13
  def kilobytes_to_bytes(kilobytes)
14
14
  kilobytes * 1024
15
15
  end
16
+
17
+ def account_id(organization)
18
+ @organization_accounts ||= {}
19
+ @organization_accounts[organization.id] ||= organization.pools.where.not(account_number: nil).pluck(:account_number).first
20
+ end
21
+
22
+ def golden_ticket?(organization)
23
+ result = organization.try(:golden_ticket?)
24
+ result = organization.content_access_mode == 'org_environment' if result.nil?
25
+
26
+ @organization_golden_tickets ||= {}
27
+ @organization_golden_tickets[organization.id] ||= result
28
+ end
16
29
  end
17
30
  end
18
31
  end
@@ -18,6 +18,8 @@ module ForemanInventoryUpload
18
18
  'uname::release',
19
19
  'lscpu::flags',
20
20
  'distribution::version',
21
+ 'distribution::id',
22
+ 'virt::is_guest',
21
23
  ]).pluck(:name, :id)
22
24
  ]
23
25
  end
@@ -4,11 +4,13 @@ module ForemanInventoryUpload
4
4
  include FactHelpers
5
5
 
6
6
  attr_accessor :slice_id
7
+ attr_reader :hosts_count
7
8
 
8
9
  def initialize(hosts, output = [], slice_id = Foreman.uuid)
9
10
  @stream = JsonStream.new(output)
10
11
  @hosts = hosts
11
12
  @slice_id = slice_id
13
+ @hosts_count = 0
12
14
  end
13
15
 
14
16
  def render
@@ -24,9 +26,12 @@ module ForemanInventoryUpload
24
26
  @stream.array_field('hosts', :last) do
25
27
  first = true
26
28
  hosts_batch.each do |host|
27
- next unless host&.subscription_facet&.pools&.first
29
+ next unless host&.subscription_facet
28
30
  @stream.comma unless first
29
- first = false if report_host(host)
31
+ if report_host(host)
32
+ first = false
33
+ @hosts_count += 1
34
+ end
30
35
  end
31
36
  end
32
37
  end
@@ -34,11 +39,10 @@ module ForemanInventoryUpload
34
39
 
35
40
  def report_host(host)
36
41
  @stream.object do
37
- @stream.simple_field('display_name', host.name)
38
42
  @stream.simple_field('fqdn', host.fqdn)
39
- @stream.simple_field('account', host.subscription_facet.pools.first.account_number.to_s)
40
- @stream.simple_field('subscription_manager_id', host.subscription_facet.uuid)
41
- @stream.simple_field('satellite_id', host.subscription_facet.uuid)
43
+ @stream.simple_field('account', account_id(host.organization).to_s)
44
+ @stream.simple_field('subscription_manager_id', host.subscription_facet&.uuid)
45
+ @stream.simple_field('satellite_id', host.subscription_facet&.uuid)
42
46
  @stream.simple_field('bios_uuid', fact_value(host, 'dmi::system::uuid'))
43
47
  @stream.simple_field('vm_uuid', fact_value(host, 'virt::uuid'))
44
48
  @stream.array_field('ip_addresses') do
@@ -65,7 +69,7 @@ module ForemanInventoryUpload
65
69
 
66
70
  @stream.array_field('tags', :last) do
67
71
  report_tag('satellite', 'satellite_instance_id', Foreman.instance_id) if Foreman.respond_to?(:instance_id)
68
- report_tag('satellite', 'organization_id', host.organization_id, :last)
72
+ report_tag('satellite', 'organization_id', host.organization_id.to_s, :last)
69
73
  end
70
74
  end
71
75
  end
@@ -105,12 +109,23 @@ module ForemanInventoryUpload
105
109
  end.join(', '))
106
110
  end
107
111
  end
108
- @stream.simple_field('os_release', fact_value(host, 'distribution::name'))
112
+ @stream.simple_field(
113
+ 'os_release',
114
+ os_release_value(
115
+ name: fact_value(host, 'distribution::name'),
116
+ version: fact_value(host, 'distribution::version'),
117
+ codename: fact_value(host, 'distribution::id')
118
+ )
119
+ )
109
120
  @stream.simple_field('os_kernel_version', fact_value(host, 'uname::release'))
110
121
  @stream.simple_field('arch', host.architecture&.name)
111
122
  @stream.simple_field('subscription_status', host.subscription_status_label)
112
123
  @stream.simple_field('katello_agent_running', host.content_facet&.katello_agent_installed?)
113
124
  @stream.simple_field('satellite_managed', true)
125
+ @stream.simple_field(
126
+ 'infrastructure_type',
127
+ ActiveModel::Type::Boolean.new.cast(fact_value(host, 'virt::is_guest')) ? 'virtual' : 'physical'
128
+ )
114
129
  unless (installed_products = host.subscription_facet&.installed_products).empty?
115
130
  @stream.array_field('installed_products') do
116
131
  @stream.raw(installed_products.map do |product|
@@ -131,17 +146,22 @@ module ForemanInventoryUpload
131
146
  end
132
147
 
133
148
  def report_satellite_facts(host)
134
- @stream.simple_field('virtual_host_name', host.subscription_facet.hypervisor_host&.name)
135
- @stream.simple_field('virtual_host_uuid', host.subscription_facet.hypervisor_host&.subscription_facet&.uuid)
149
+ @stream.simple_field('virtual_host_name', host.subscription_facet&.hypervisor_host&.name)
150
+ @stream.simple_field('virtual_host_uuid', host.subscription_facet&.hypervisor_host&.subscription_facet&.uuid)
136
151
  if defined?(ForemanThemeSatellite)
137
152
  @stream.simple_field('satellite_version', ForemanThemeSatellite::SATELLITE_VERSION)
138
153
  end
139
154
  @stream.simple_field('system_purpose_usage', host.subscription_facet.purpose_usage)
140
155
  @stream.simple_field('system_purpose_role', host.subscription_facet.purpose_role)
141
156
  @stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
142
- @stream.simple_field('satellite_instance_id', Foreman.respond_to?(:instance_id) ? Foreman.instance_id : nil)
157
+ @stream.simple_field('satellite_instance_id', Foreman.try(:instance_id))
158
+ @stream.simple_field('is_simple_content_access', golden_ticket?(host.organization))
143
159
  @stream.simple_field('organization_id', host.organization_id, :last)
144
160
  end
161
+
162
+ def os_release_value(name:, version:, codename:)
163
+ "#{name} #{version} (#{codename})"
164
+ end
145
165
  end
146
166
  end
147
167
  end
@@ -5,6 +5,10 @@ module ForemanRhCloud
5
5
  class Engine < ::Rails::Engine
6
6
  engine_name 'foreman_rh_cloud'
7
7
 
8
+ initializer 'foreman_rh_cloud.load_default_settings', :before => :load_config_initializers do
9
+ require_dependency File.expand_path('../../app/models/setting/rh_cloud.rb', __dir__)
10
+ end
11
+
8
12
  config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
9
13
  config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
10
14
  config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
@@ -22,7 +26,7 @@ module ForemanRhCloud
22
26
 
23
27
  initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
24
28
  Foreman::Plugin.register :foreman_rh_cloud do
25
- requires_foreman '~> 1.24.0'
29
+ requires_foreman '> 1.24'
26
30
 
27
31
  # Add permissions
28
32
  security_block :foreman_rh_cloud do
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '2.0.6'.freeze
3
3
  end
@@ -4,14 +4,14 @@
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "lint": "./node_modules/.bin/eslint -c .eslintrc webpack/",
8
- "test": "node node_modules/.bin/jest --no-cache",
9
- "test:watch": "node node_modules/.bin/jest --watchAll",
10
- "test:current": "node node_modules/.bin/jest --watch",
11
- "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
12
- "storybook": "start-storybook -p 6006",
13
- "storybook:build": "node --max_old_space_size=2048 ./node_modules/.bin/build-storybook --config-dir .storybook --output-dir .storybook-dist",
14
- "storybook:deploy": "surge --project .storybook-dist"
7
+ "lint": "tfm-lint --plugin -d /webpack",
8
+ "test": "tfm-test --plugin",
9
+ "test:watch": "tfm-test --plugin --watchAll",
10
+ "test:current": "tfm-test --plugin --watch",
11
+ "publish-coverage": "tfm-publish-coverage",
12
+ "stories": "tfm-stories --plugin",
13
+ "stories:build": "tfm-build-stories --plugin",
14
+ "stories:deploy": "surge --project .storybook-dist"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -20,106 +20,26 @@
20
20
  "bugs": {
21
21
  "url": "http://projects.theforeman.org/projects/foreman_rh_cloud/issues"
22
22
  },
23
- "optionalDependencies": {
24
- "babel-plugin-module-resolver": "^3.2.0"
23
+ "peerDependencies": {
24
+ "@theforeman/vendor": ">= 4.0.2"
25
25
  },
26
26
  "devDependencies": {
27
- "@storybook/addon-actions": "^5.0.1",
28
- "@storybook/addon-knobs": "^5.0.1",
29
- "@storybook/react": "^5.0.1",
30
- "babel-cli": "^6.10.1",
31
- "babel-core": "^6.26.3",
32
- "babel-eslint": "^8.2.3",
33
- "babel-jest": "^23.6.0",
34
- "babel-loader": "^7.1.1",
35
- "babel-plugin-dynamic-import-node": "^2.0.0",
36
- "babel-plugin-lodash": "^3.3.4",
37
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
38
- "babel-plugin-transform-class-properties": "^6.24.1",
39
- "babel-plugin-transform-object-assign": "^6.8.0",
40
- "babel-plugin-transform-object-rest-spread": "^6.8.0",
41
- "babel-preset-env": "^1.7.0",
42
- "babel-preset-react": "^6.5.0",
43
- "coveralls": "^3.0.0",
44
- "enzyme": "^3.4.0",
45
- "enzyme-adapter-react-16": "^1.4.0",
46
- "enzyme-to-json": "^3.2.1",
47
- "eslint": "^4.10.0",
48
- "eslint-import-resolver-babel-module": "^4.0.0",
49
- "eslint-plugin-patternfly-react": "0.2.0",
50
- "identity-obj-proxy": "^3.0.0",
51
- "jed": "^1.1.1",
52
- "jest-cli": "^23.6.0",
53
- "jest-prop-type-error": "^1.1.0",
54
- "node-sass": "^4.5.0",
55
- "patternfly": "^3.58.0",
27
+ "@babel/core": "^7.7.0",
28
+ "@theforeman/builder": "^4.0.2",
29
+ "@theforeman/stories": "^4.0.2",
30
+ "@theforeman/test": "^4.0.2",
31
+ "@theforeman/vendor-dev": "^4.0.2",
32
+ "@theforeman/eslint-plugin-foreman": "^4.0.2",
33
+ "babel-eslint": "^10.0.0",
34
+ "eslint": "^6.7.2",
56
35
  "prettier": "^1.13.5",
57
36
  "raf": "^3.4.0",
58
- "react-redux-test-utils": "^0.1.1",
59
- "react-remarkable": "^1.1.3",
60
- "sass-loader": "^6.0.7",
61
37
  "stylelint": "^9.3.0",
62
38
  "stylelint-config-standard": "^18.0.0",
63
39
  "surge": "^0.20.3"
64
40
  },
65
41
  "dependencies": {
66
- "babel-polyfill": "^6.26.0",
67
- "classnames": "^2.2.5",
68
- "lodash": "^4.17.10",
69
- "patternfly-react": "^2.19.1",
70
- "prop-types": "^15.6.0",
71
- "react": "^16.4.0",
72
- "react-dom": "^16.4.0",
73
- "react-intl": "^2.8.0",
74
- "react-redux": "^5.0.6",
75
- "redux": "^3.6.0",
76
- "redux-thunk": "^2.2.0",
77
- "reselect": "^3.0.1",
78
- "seamless-immutable": "^7.1.2",
79
- "urijs": "^1.18.10",
80
- "uuid": "^3.0.1"
81
- },
82
- "jest": {
83
- "automock": true,
84
- "verbose": true,
85
- "testMatch": [
86
- "**/*.test.js"
87
- ],
88
- "testURL": "http://localhost/",
89
- "collectCoverage": true,
90
- "collectCoverageFrom": [
91
- "webpack/**/*.js",
92
- "!webpack/index.js",
93
- "!webpack/test_setup.js",
94
- "!webpack/**/bundle*",
95
- "!webpack/stories/**",
96
- "!webpack/**/*stories.js"
97
- ],
98
- "coverageReporters": [
99
- "lcov"
100
- ],
101
- "unmockedModulePathPatterns": [
102
- "webpack/",
103
- "react",
104
- "node_modules/"
105
- ],
106
- "moduleNameMapper": {
107
- "^.+\\.(png|gif|css|scss)$": "identity-obj-proxy"
108
- },
109
- "globals": {
110
- "__testing__": true
111
- },
112
- "transform": {
113
- "^.+\\.js$": "babel-jest"
114
- },
115
- "moduleDirectories": [
116
- "node_modules",
117
- "webpack"
118
- ],
119
- "setupFiles": [
120
- "raf/polyfill",
121
- "jest-prop-type-error",
122
- "./webpack/test_setup.js"
123
- ]
42
+ "jed": "^1.1.1",
43
+ "react-intl": "^2.8.0"
124
44
  }
125
45
  }