foreman_rh_cloud 1.0.5 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -6
- data/app/controllers/foreman_rh_cloud/react_controller.rb +8 -0
- data/app/models/setting/rh_cloud.rb +1 -0
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -0
- data/app/views/{foreman_inventory_upload/layouts/react.html.erb → layouts/foreman_rh_cloud/application.html.erb} +2 -2
- data/config/routes.rb +4 -1
- data/lib/foreman_inventory_upload/async/async_helpers.rb +13 -0
- data/lib/foreman_inventory_upload/async/shell_process.rb +3 -1
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +1 -5
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +56 -0
- data/lib/foreman_inventory_upload/generators/queries.rb +6 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +14 -9
- data/lib/foreman_rh_cloud/engine.rb +17 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +20 -100
- data/test/factories/inventory_upload_factories.rb +13 -13
- data/test/unit/archived_report_generator_test.rb +1 -0
- data/test/unit/fact_helpers_test.rb +29 -0
- data/test/unit/slice_generator_test.rb +206 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +6 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +13 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +5 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +3 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +10 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/EmptyResults.js +15 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/EmptyResults.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/__tests__/__snapshots__/EmptyResults.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +1 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +12 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +8 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +2 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +4 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +13 -9
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +5 -15
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +4 -3
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +1 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +17 -5
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +4 -3
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +39 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterActions.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterSelectors.js +7 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterActions.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +35 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterSelectors.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilter.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterActions.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterSelectors.test.js.snap +9 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +31 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/integration.test.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/index.js +17 -0
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/inventoryFilter.scss +28 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +5 -2
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +1 -2
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +12 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +11 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -2
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +3 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +4 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +16 -8
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +4 -4
- data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +9 -0
- data/webpack/ForemanInventoryUpload/{ForemanInventoryUpload.test.js → __tests__/ForemanInventoryUpload.test.js} +2 -2
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +3 -0
- data/webpack/ForemanInventoryUpload/{__snapshots__ → __tests__/__snapshots__}/ForemanInventoryUpload.test.js.snap +0 -0
- data/webpack/ForemanRhCloudHelpers.js +6 -0
- data/webpack/ForemanRhCloudReducers.js +8 -0
- data/webpack/ForemanRhCloudSelectors.js +3 -0
- data/webpack/ForemanRhCloudTestHelpers.js +5 -0
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +11 -0
- data/webpack/__tests__/ForemanRhCloudSelectors.test.js +17 -0
- data/webpack/__tests__/ForemanRhCloudTestHelpers.test.js +10 -0
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +3 -0
- data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +15 -0
- data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +11 -0
- data/webpack/index.js +1 -1
- metadata +52 -14
- data/app/controllers/foreman_inventory_upload/react_controller.rb +0 -7
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +0 -4
- data/webpack/stories/ForemanInventoryUploadReducers.js +0 -3
- data/webpack/stories/configureStore.js +0 -15
- data/webpack/stories/decorators/index.js +0 -1
- data/webpack/stories/decorators/withCardsDecorator.js +0 -14
- data/webpack/stories/index.js +0 -10
- data/webpack/stories/index.scss +0 -7
- data/webpack/test_setup.js +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9b4163dafd6baf15a6b8ffc04de58d1b0316114838e06ef3c3d28f043442a6c
|
4
|
+
data.tar.gz: 9c8bf6874697a56d76e696397cfc11ed0f3f1379716d5b91bebc54fdc4be98a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d9d668982202c78267c8b3d2425a6b3f3695be21fe3bf993710990c0811438b7bf938298e5a5421a40374dbb862d48538811388d851621bb4dbba8a7dfa396
|
7
|
+
data.tar.gz: e725d4ff38d466f6c1713822108ed9d04e08946f57fbd27032977b0ef7f4278c414d7d1c418f517a6d25b27b0e2131030ae8ba376ab27ac365729b9c60737f41
|
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*
|
@@ -1,12 +1,8 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
class AccountsController < ::ApplicationController
|
3
|
-
# override default "welcome screen behavior, since we don't have a model"
|
4
|
-
def welcome
|
5
|
-
true
|
6
|
-
end
|
7
|
-
|
8
3
|
def index
|
9
|
-
|
4
|
+
organizations = User.current.my_organizations
|
5
|
+
labels = organizations.pluck(:id, :name)
|
10
6
|
|
11
7
|
accounts = Hash[
|
12
8
|
labels.map do |id, label|
|
@@ -4,6 +4,7 @@ class Setting::RhCloud < Setting
|
|
4
4
|
return unless super
|
5
5
|
[
|
6
6
|
set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), true),
|
7
|
+
set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false),
|
7
8
|
]
|
8
9
|
end
|
9
10
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= mount_react_component("ForemanInventoryUpload", '#ForemanRhCloudReactRoot') %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<%= notifications %>
|
11
11
|
<div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
|
12
12
|
<div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
|
13
|
-
<div id="
|
13
|
+
<div id="ForemanRhCloudReactRoot"></div>
|
14
|
+
<%= yield %>
|
14
15
|
<% end %>
|
15
16
|
<%= render file: "layouts/base" %>
|
16
|
-
<%= mount_react_component('ForemanInventoryUpload', '#ForemanInventoryUploadReactRoot') %>
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
namespace :foreman_inventory_upload do
|
3
|
-
get 'index', to: 'react#index'
|
4
3
|
get ':organization_id/reports/last', to: 'reports#last', constraints: { organization_id: %r{[^\/]+} }
|
5
4
|
post ':organization_id/reports', to: 'reports#generate', constraints: { organization_id: %r{[^\/]+} }
|
6
5
|
get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
|
@@ -8,4 +7,8 @@ Rails.application.routes.draw do
|
|
8
7
|
get 'accounts', to: 'accounts#index'
|
9
8
|
post 'auto_upload', to: 'uploads#auto_upload'
|
10
9
|
end
|
10
|
+
|
11
|
+
namespace :foreman_rh_cloud do
|
12
|
+
get 'inventory_upload', to: 'react#inventory_upload'
|
13
|
+
end
|
11
14
|
end
|
@@ -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 ||=
|
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
|
@@ -3,6 +3,11 @@ module ForemanInventoryUpload
|
|
3
3
|
module FactHelpers
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
CLOUD_AMAZON = 'aws'
|
7
|
+
CLOUD_GOOGLE = 'google'
|
8
|
+
CLOUD_AZURE = 'azure'
|
9
|
+
CLOUD_ALIBABA = 'alibaba'
|
10
|
+
|
6
11
|
def fact_value(host, fact_name)
|
7
12
|
value_record = host.fact_values.find do |fact_value|
|
8
13
|
fact_value.fact_name_id == ForemanInventoryUpload::Generators::Queries.fact_names[fact_name]
|
@@ -13,6 +18,57 @@ module ForemanInventoryUpload
|
|
13
18
|
def kilobytes_to_bytes(kilobytes)
|
14
19
|
kilobytes * 1024
|
15
20
|
end
|
21
|
+
|
22
|
+
def account_id(organization)
|
23
|
+
@organization_accounts ||= {}
|
24
|
+
@organization_accounts[organization.id] ||= organization.pools.where.not(account_number: nil).pluck(:account_number).first
|
25
|
+
end
|
26
|
+
|
27
|
+
def golden_ticket?(organization)
|
28
|
+
result = organization.try(:golden_ticket?)
|
29
|
+
result = organization.content_access_mode == 'org_environment' if result.nil?
|
30
|
+
|
31
|
+
@organization_golden_tickets ||= {}
|
32
|
+
@organization_golden_tickets[organization.id] ||= result
|
33
|
+
end
|
34
|
+
|
35
|
+
def cloud_provider(host)
|
36
|
+
bios_version = fact_value(host, 'dmi::bios::version')
|
37
|
+
|
38
|
+
if bios_version
|
39
|
+
return CLOUD_AMAZON if bios_version.downcase['amazon']
|
40
|
+
return CLOUD_GOOGLE if bios_version.downcase['google']
|
41
|
+
end
|
42
|
+
|
43
|
+
chassis_asset_tag = fact_value(host, 'dmi::chassis::asset_tag')
|
44
|
+
return CLOUD_AZURE if chassis_asset_tag && chassis_asset_tag['7783-7084-3265-9085-8269-3286-77']
|
45
|
+
|
46
|
+
system_manufacturer = fact_value(host, 'dmi::system::manufacturer')
|
47
|
+
return CLOUD_ALIBABA if system_manufacturer && system_manufacturer.downcase['alibaba cloud']
|
48
|
+
|
49
|
+
product_name = fact_value(host, 'dmi::system::product_name')
|
50
|
+
return CLOUD_ALIBABA if product_name && product_name.downcase['alibaba cloud ecs']
|
51
|
+
|
52
|
+
nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def obfuscate_hostname?(host)
|
56
|
+
insights_client_setting = fact_value(host, 'insights_client::obfuscate_hostname_enabled')
|
57
|
+
insights_client_setting = ActiveModel::Type::Boolean.new.cast(insights_client_setting)
|
58
|
+
return insights_client_setting unless insights_client_setting.nil?
|
59
|
+
|
60
|
+
Setting[:obfuscate_inventory_hostnames]
|
61
|
+
end
|
62
|
+
|
63
|
+
def fqdn(host)
|
64
|
+
return host.fqdn unless obfuscate_hostname?(host)
|
65
|
+
|
66
|
+
fact_value(host, 'insights_client::hostname') || obfuscate_fqdn(host.fqdn)
|
67
|
+
end
|
68
|
+
|
69
|
+
def obfuscate_fqdn(fqdn)
|
70
|
+
Base64.urlsafe_encode64(Digest::SHA1.digest(fqdn), padding: false)
|
71
|
+
end
|
16
72
|
end
|
17
73
|
end
|
18
74
|
end
|
@@ -19,6 +19,12 @@ module ForemanInventoryUpload
|
|
19
19
|
'lscpu::flags',
|
20
20
|
'distribution::version',
|
21
21
|
'distribution::id',
|
22
|
+
'virt::is_guest',
|
23
|
+
'dmi::system::manufacturer',
|
24
|
+
'dmi::system::product_name',
|
25
|
+
'dmi::chassis::asset_tag',
|
26
|
+
'insights_client::obfuscate_hostname_enabled',
|
27
|
+
'insights_client::hostname',
|
22
28
|
]).pluck(:name, :id)
|
23
29
|
]
|
24
30
|
end
|
@@ -26,7 +26,7 @@ module ForemanInventoryUpload
|
|
26
26
|
@stream.array_field('hosts', :last) do
|
27
27
|
first = true
|
28
28
|
hosts_batch.each do |host|
|
29
|
-
next unless host&.subscription_facet
|
29
|
+
next unless host&.subscription_facet
|
30
30
|
@stream.comma unless first
|
31
31
|
if report_host(host)
|
32
32
|
first = false
|
@@ -39,11 +39,10 @@ module ForemanInventoryUpload
|
|
39
39
|
|
40
40
|
def report_host(host)
|
41
41
|
@stream.object do
|
42
|
-
@stream.simple_field('
|
43
|
-
@stream.simple_field('
|
44
|
-
@stream.simple_field('
|
45
|
-
@stream.simple_field('
|
46
|
-
@stream.simple_field('satellite_id', host.subscription_facet.uuid)
|
42
|
+
@stream.simple_field('fqdn', fqdn(host))
|
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)
|
47
46
|
@stream.simple_field('bios_uuid', fact_value(host, 'dmi::system::uuid'))
|
48
47
|
@stream.simple_field('vm_uuid', fact_value(host, 'virt::uuid'))
|
49
48
|
@stream.array_field('ip_addresses') do
|
@@ -123,6 +122,11 @@ module ForemanInventoryUpload
|
|
123
122
|
@stream.simple_field('subscription_status', host.subscription_status_label)
|
124
123
|
@stream.simple_field('katello_agent_running', host.content_facet&.katello_agent_installed?)
|
125
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
|
+
)
|
129
|
+
@stream.simple_field('cloud_provider', cloud_provider(host))
|
126
130
|
unless (installed_products = host.subscription_facet&.installed_products).empty?
|
127
131
|
@stream.array_field('installed_products') do
|
128
132
|
@stream.raw(installed_products.map do |product|
|
@@ -143,15 +147,16 @@ module ForemanInventoryUpload
|
|
143
147
|
end
|
144
148
|
|
145
149
|
def report_satellite_facts(host)
|
146
|
-
@stream.simple_field('virtual_host_name', host.subscription_facet
|
147
|
-
@stream.simple_field('virtual_host_uuid', host.subscription_facet
|
150
|
+
@stream.simple_field('virtual_host_name', host.subscription_facet&.hypervisor_host&.name)
|
151
|
+
@stream.simple_field('virtual_host_uuid', host.subscription_facet&.hypervisor_host&.subscription_facet&.uuid)
|
148
152
|
if defined?(ForemanThemeSatellite)
|
149
153
|
@stream.simple_field('satellite_version', ForemanThemeSatellite::SATELLITE_VERSION)
|
150
154
|
end
|
151
155
|
@stream.simple_field('system_purpose_usage', host.subscription_facet.purpose_usage)
|
152
156
|
@stream.simple_field('system_purpose_role', host.subscription_facet.purpose_role)
|
153
157
|
@stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
|
154
|
-
@stream.simple_field('satellite_instance_id', Foreman.
|
158
|
+
@stream.simple_field('satellite_instance_id', Foreman.try(:instance_id))
|
159
|
+
@stream.simple_field('is_simple_content_access', golden_ticket?(host.organization))
|
155
160
|
@stream.simple_field('organization_id', host.organization_id, :last)
|
156
161
|
end
|
157
162
|
|
@@ -26,19 +26,31 @@ module ForemanRhCloud
|
|
26
26
|
|
27
27
|
initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
|
28
28
|
Foreman::Plugin.register :foreman_rh_cloud do
|
29
|
-
requires_foreman '
|
29
|
+
requires_foreman '> 1.24'
|
30
30
|
|
31
31
|
# Add permissions
|
32
32
|
security_block :foreman_rh_cloud do
|
33
|
-
permission
|
33
|
+
permission(:generate_foreman_rh_cloud, :'foreman_inventory_upload/reports' => [:generate])
|
34
|
+
permission(:view_foreman_rh_cloud,
|
35
|
+
'foreman_inventory_upload/accounts': [:index],
|
36
|
+
'foreman_inventory_upload/reports': [:last],
|
37
|
+
'foreman_inventory_upload/uploads': [:auto_upload, :download_file, :last],
|
38
|
+
'foreman_rh_cloud/react': [:inventory_upload]
|
39
|
+
)
|
34
40
|
end
|
35
41
|
|
36
|
-
|
37
|
-
|
42
|
+
plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud]
|
43
|
+
|
44
|
+
role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory,
|
45
|
+
generate a report, upload it to the cloud and download it locally'
|
46
|
+
|
47
|
+
add_permissions_to_default_roles Role::ORG_ADMIN => plugin_permissions,
|
48
|
+
Role::MANAGER => plugin_permissions,
|
49
|
+
Role::SYSTEM_ADMIN => plugin_permissions
|
38
50
|
|
39
51
|
# Adding a sub menu after hosts menu
|
40
52
|
sub_menu :top_menu, :foreman_rh_cloud, :caption => N_('RH Cloud'), :icon => 'fa fa-cloud-upload' do
|
41
|
-
menu :top_menu, :level1, :caption => N_('Inventory Upload'), :url_hash => { controller: :'
|
53
|
+
menu :top_menu, :level1, :caption => N_('Inventory Upload'), :url_hash => { controller: :'foreman_rh_cloud/react', :action => :inventory_upload}
|
42
54
|
end
|
43
55
|
end
|
44
56
|
end
|
data/package.json
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
"description": "Inventory Upload =============",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
|
-
"lint": "
|
8
|
-
"test": "
|
9
|
-
"test:watch": "
|
10
|
-
"test:current": "
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"
|
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
|
-
"
|
24
|
-
"
|
23
|
+
"peerDependencies": {
|
24
|
+
"@theforeman/vendor": ">= 4.0.2"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
|
-
"@
|
28
|
-
"@
|
29
|
-
"@
|
30
|
-
"
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"babel-
|
34
|
-
"
|
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
|
-
"
|
67
|
-
"
|
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
|
}
|