foreman_rh_cloud 2.0.16 → 3.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -13
  3. data/app/helpers/foreman_inventory_upload_host_helper.rb +1 -8
  4. data/app/models/setting/rh_cloud.rb +5 -5
  5. data/lib/foreman_inventory_upload.rb +1 -1
  6. data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
  7. data/lib/foreman_rh_cloud/engine.rb +4 -2
  8. data/lib/foreman_rh_cloud/version.rb +1 -1
  9. data/lib/tasks/rh_cloud_inventory.rake +0 -23
  10. data/package.json +1 -1
  11. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +1 -1
  12. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +1 -1
  13. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +92 -0
  14. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
  15. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
  16. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +60 -0
  17. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +28 -0
  18. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +22 -0
  19. data/webpack/ForemanRhCloudFills.js +23 -0
  20. data/webpack/ForemanRhCloudPages.js +6 -1
  21. data/webpack/ForemanRhCloudReducers.js +10 -1
  22. data/webpack/InsightsHostDetailsTab/InsightsTab.js +5 -7
  23. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
  24. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +10 -12
  25. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -12
  26. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
  27. data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
  28. data/webpack/common/Switcher/index.js +79 -0
  29. data/webpack/global_index.js +5 -0
  30. data/webpack/index.js +4 -14
  31. metadata +25 -20
  32. data/config/Gemfile.lock.gh_test +0 -815
  33. data/config/database.yml.example +0 -17
  34. data/config/package-lock.json.gh_test +0 -36317
  35. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
  36. data/webpack/subscriptions_extension_index.js +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7230451a1045df7986bd01f42f32d66ccf3d16efc6858c7eb40bd001cc5d40a
4
- data.tar.gz: 0675fa4485a9cd91579cf35d4df110b0d1bd7aa8c422183b4c0e58ce5cf11f1a
3
+ metadata.gz: 1b0882515e038d95959e1926b002f3caebb0b38ed0bd05951208d33cea7748ae
4
+ data.tar.gz: 29d8594297d6c4ed6936d568c7c7a8547186ab7390d03b81448cc5c563f5031d
5
5
  SHA512:
6
- metadata.gz: ca8d9900c62c798990eb72dd5224b5341caf9120a3cd4e2c1c02cf53d7928d6edaca21901f0de47a604cbaa791f91accce79c70a0d00301b5f9fb221e79cec25
7
- data.tar.gz: c612e9dcc3d1662f41552c23a585148f659f2fd2d3a059a831b189f6b53c26b5189ec95d59fad7cfff97d3aa6f604cc882051d4ee694a7fffdf48903f06b34de
6
+ metadata.gz: 71d58183a48ca30f148138bb036ba0cd7bea80dd1ce087b13605e884b763035b674207f91c359f193d658211f2e742f54b2f7e4fadac3f7bc723eb10dbd85f6e
7
+ data.tar.gz: ef3740403be8ab6cc6bb2848666833b424b41cabbc7fac78b06af573db3e59cfed40b01dad2deb88d3bfcba6b8ef86a5c7fe16f8dc48d6b68e821d8f5f2c3ddf
data/README.md CHANGED
@@ -19,23 +19,10 @@ In UI: Configure -> Inventory Upload -> Restart
19
19
 
20
20
  From command-line:
21
21
 
22
- # generate and upload report for all organizations
23
- /usr/sbin/foreman-rake rh_cloud_inventory:report:generate_upload
24
-
25
- # generate and upload report for specific organization
26
- export organization_id=1
27
- /usr/sbin/foreman-rake rh_cloud_inventory:report:generate_upload
28
-
29
- # generate report for specific organization (don't upload)
30
22
  export organization_id=1
31
23
  export target=/var/lib/foreman/red_hat_inventory/generated_reports/
32
24
  /usr/sbin/foreman-rake rh_cloud_inventory:report:generate
33
25
 
34
- # upload previously generated report (needs to be named 'report_for_#{organization_id}.tar.gz')
35
- export organization_id=1
36
- export target=/var/lib/foreman/red_hat_inventory/generated_reports/
37
- /usr/sbin/foreman-rake rh_cloud_inventory:report:upload
38
-
39
26
  #### Fetch hosts remediation data
40
27
 
41
28
  In UI: Configure -> Insights -> Sync now
@@ -6,14 +6,7 @@ module ForemanInventoryUploadHostHelper
6
6
  def hits_counts_cell(host)
7
7
  host_hits = hits_counts[host.id]
8
8
  tag.td class: ['hidden-xs', 'ellipsis', 'text-center'] do
9
- if host_hits
10
- link_to(
11
- host_hits,
12
- InsightsCloud::WebUi.system_url(InsightsCloud::WebUi::ADVISOR, host.insights.uuid),
13
- :rel => 'external noopener noreferrer',
14
- :target => '_blank'
15
- )
16
- end
9
+ link_to(host_hits, "#{host_path(host)}#insights") if host_hits
17
10
  end
18
11
  end
19
12
  end
@@ -3,12 +3,12 @@ class Setting::RhCloud < Setting
3
3
  return unless ActiveRecord::Base.connection.table_exists?('settings')
4
4
  return unless super
5
5
  [
6
- set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false, N_('Allow automatic inventory uploads')),
7
- set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false, N_('Allow recommendations synchronization')),
8
- set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false, N_('Obfuscate host names')),
9
- set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false, N_('Obfuscate IPs')),
6
+ set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false),
7
+ set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false),
8
+ set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false),
9
+ set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false),
10
10
  set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'), 'DEFAULT', N_('Red Hat Cloud token'), nil, encrypted: true),
11
- set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false, N_("Don't upload installed packages")),
11
+ set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false),
12
12
  ]
13
13
  end
14
14
 
@@ -48,7 +48,7 @@ module ForemanInventoryUpload
48
48
  end
49
49
 
50
50
  def self.facts_archive_name(organization)
51
- "report_for_#{organization}.tar.xz"
51
+ "report_for_#{organization}.tar.gz"
52
52
  end
53
53
 
54
54
  def self.upload_url
@@ -28,7 +28,7 @@ module ForemanInventoryUpload
28
28
 
29
29
  @logger.info 'Archiving generated report'
30
30
  # success = system('tar', '-zcvf', @target, '-C', tmpdir, '.')
31
- Open3.popen2e('tar', '-Jcvf', @target, '-C', tmpdir, '.') do |_in, out, wait_thr|
31
+ Open3.popen2e('tar', '-zcvf', @target, '-C', tmpdir, '.') do |_in, out, wait_thr|
32
32
  @logger.info("tar: #{out.read}")
33
33
 
34
34
  if wait_thr.value.success?
@@ -27,7 +27,7 @@ module ForemanRhCloud
27
27
 
28
28
  initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
29
29
  Foreman::Plugin.register :foreman_rh_cloud do
30
- requires_foreman '> 1.24'
30
+ requires_foreman '>= 2.3'
31
31
 
32
32
  # Add permissions
33
33
  security_block :foreman_rh_cloud do
@@ -64,7 +64,7 @@ module ForemanRhCloud
64
64
  end
65
65
  end
66
66
 
67
- register_global_js_file 'subscriptions_extension'
67
+ register_global_js_file 'global'
68
68
 
69
69
  register_custom_status(InventorySync::InventoryStatus)
70
70
 
@@ -72,6 +72,7 @@ module ForemanRhCloud
72
72
  context.add_pagelet :main_tabs,
73
73
  partial: 'hosts/insights_tab',
74
74
  name: _('Insights'),
75
+ id: 'insights',
75
76
  onlyif: proc { |host| host.insights }
76
77
  end
77
78
  end
@@ -79,6 +80,7 @@ module ForemanRhCloud
79
80
  ::Katello::UINotifications::Subscriptions::ManifestImportSuccess.include ForemanInventoryUpload::Notifications::ManifestImportSuccessNotificationOverride if defined?(Katello)
80
81
 
81
82
  ::Host::Managed.include RhCloudHost
83
+ ::Host::Base.include RhCloudHost
82
84
  end
83
85
 
84
86
  initializer "foreman_rh_cloud.set_dynflow.config.on_init", :before => :finisher_hook do |_app|
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '2.0.16'.freeze
2
+ VERSION = '3.0.14'.freeze
3
3
  end
@@ -2,21 +2,6 @@ require 'tempfile'
2
2
 
3
3
  namespace :rh_cloud_inventory do
4
4
  namespace :report do
5
- desc 'Generate inventory report and send it to Red Hat cloud'
6
- task generate_upload: [:environment, 'dynflow:client'] do
7
- unless ENV['organization_id'].nil?
8
- organizations = [ Organization.where(:id => ENV['organization_id']).first ]
9
- else
10
- organizations = Organization.unscoped.all
11
- end
12
-
13
- User.as_anonymous_admin do
14
- organizations.each do |organization|
15
- ForemanInventoryUpload::Async::GenerateReportJob.perform_now(ForemanInventoryUpload.generated_reports_folder, organization.id)
16
- puts "Generated and uploaded inventory report for organization '#{organization.name}'"
17
- end
18
- end
19
- end
20
5
  desc 'Generate inventory report to be sent to Red Hat cloud'
21
6
  task generate: :environment do
22
7
  portal_user = ENV['portal_user']
@@ -42,14 +27,6 @@ namespace :rh_cloud_inventory do
42
27
  end
43
28
  end
44
29
  end
45
- desc 'Upload generated inventory report to Red Hat cloud'
46
- task upload: [:environment, 'dynflow:client'] do
47
- base_folder = ENV['target'] || ForemanInventoryUpload.generated_reports_folder
48
- organization_id = ENV['organization_id']
49
- report_file = ForemanInventoryUpload.facts_archive_name(organization_id)
50
- ForemanInventoryUpload::Async::QueueForUploadJob.perform_now(base_folder, report_file, organization_id)
51
- puts "Uploaded #{report_file}"
52
- end
53
30
  end
54
31
 
55
32
  desc "Synchronize Insights hosts hits"
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "2.0.14",
3
+ "version": "3.0.14",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@ const AutoUploadSwitcher = ({ autoUploadEnabled, handleToggle }) => (
9
9
  <span>Auto upload</span>
10
10
  <FieldLevelHelp
11
11
  content={__(
12
- 'Enable automatic upload of your host inventory to the Red Hat cloud'
12
+ 'Enable automatic upload of your hosts inventory to the Red Hat cloud'
13
13
  )}
14
14
  />
15
15
  <Switch
@@ -9,7 +9,7 @@ exports[`AutoUploadSwitcher rendering render with props 1`] = `
9
9
  </span>
10
10
  <FieldLevelHelp
11
11
  buttonClass=""
12
- content="Enable automatic upload of your host inventory to the Red Hat cloud"
12
+ content="Enable automatic upload of your hosts inventory to the Red Hat cloud"
13
13
  placement="top"
14
14
  rootClose={true}
15
15
  />
@@ -0,0 +1,92 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Text, TextVariants, Popover, Button } from '@patternfly/react-core';
4
+ import { InfoAltIcon, CaretRightIcon } from '@patternfly/react-icons';
5
+ import { FormGroup, Grid } from 'patternfly-react';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+ import { foremanUrl } from '../../../ForemanRhCloudHelpers';
8
+ import Switcher from '../../../common/Switcher';
9
+ import AdvancedSettings from './components/AdvancedSettings';
10
+
11
+ const InventoryAutoUploadSwitcher = ({
12
+ autoUploadEnabled,
13
+ handleToggle,
14
+ fetchSettings,
15
+ }) => {
16
+ useEffect(() => {
17
+ fetchSettings();
18
+ }, [fetchSettings]);
19
+
20
+ return (
21
+ <FormGroup>
22
+ <Grid>
23
+ <h3>{__('Red Hat Cloud Inventory')}</h3>
24
+ <hr />
25
+ <Grid.Row>
26
+ <Switcher
27
+ id="auto-upload"
28
+ label={__('Inventory Auto Upload')}
29
+ tooltip={__(
30
+ 'Enable automatic upload of your hosts inventory to the Red Hat cloud'
31
+ )}
32
+ isChecked={autoUploadEnabled}
33
+ onChange={() => handleToggle(autoUploadEnabled)}
34
+ labelCol={5}
35
+ />
36
+
37
+ <Grid.Col sm={5}>
38
+ <Popover
39
+ headerContent={<strong>Advanced Inventory Settings</strong>}
40
+ bodyContent={
41
+ <AdvancedSettings
42
+ autoUploadEnabled={autoUploadEnabled}
43
+ handleToggle={handleToggle}
44
+ />
45
+ }
46
+ position="right"
47
+ >
48
+ <Button
49
+ variant="secondary"
50
+ style={{ fontSize: 'small', marginTop: '-4px' }}
51
+ >
52
+ {__('Show Advanced Settings')} <CaretRightIcon />
53
+ </Button>
54
+ </Popover>
55
+ </Grid.Col>
56
+ </Grid.Row>
57
+ <br />
58
+ <Grid.Row>
59
+ <Grid.Col sm={12}>
60
+ <Text component={TextVariants.p}>
61
+ <InfoAltIcon /> {__('More details can be found in')}{' '}
62
+ <Text
63
+ component={TextVariants.a}
64
+ href={foremanUrl('/foreman_rh_cloud/inventory_upload')}
65
+ target="_blank"
66
+ rel="noopener noreferrer"
67
+ >
68
+ <strong>
69
+ {__('Configure')}
70
+ {' > '}
71
+ {__('Inventory Upload')}
72
+ </strong>
73
+ </Text>
74
+ </Text>
75
+ </Grid.Col>
76
+ </Grid.Row>
77
+ </Grid>
78
+ </FormGroup>
79
+ );
80
+ };
81
+
82
+ InventoryAutoUploadSwitcher.propTypes = {
83
+ autoUploadEnabled: PropTypes.bool,
84
+ handleToggle: PropTypes.func.isRequired,
85
+ fetchSettings: PropTypes.func.isRequired,
86
+ };
87
+
88
+ InventoryAutoUploadSwitcher.defaultProps = {
89
+ autoUploadEnabled: true,
90
+ };
91
+
92
+ export default InventoryAutoUploadSwitcher;
@@ -0,0 +1,17 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import { noop } from 'patternfly-react';
3
+
4
+ import InventoryAutoUpload from '../InventoryAutoUpload';
5
+
6
+ const fixtures = {
7
+ 'render with props': {
8
+ autoUploadEnabled: true,
9
+ handleToggle: noop,
10
+ fetchSettings: noop,
11
+ },
12
+ };
13
+
14
+ describe('InventoryAutoUpload', () => {
15
+ describe('rendering', () =>
16
+ testComponentSnapshotsWithFixtures(InventoryAutoUpload, fixtures));
17
+ });
@@ -0,0 +1,106 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InventoryAutoUpload rendering render with props 1`] = `
4
+ <FormGroup
5
+ bsClass="form-group"
6
+ >
7
+ <Grid
8
+ bsClass="container"
9
+ componentClass="div"
10
+ fluid={false}
11
+ >
12
+ <h3>
13
+ Red Hat Cloud Inventory
14
+ </h3>
15
+ <hr />
16
+ <Row
17
+ bsClass="row"
18
+ componentClass="div"
19
+ >
20
+ <Switcher
21
+ SwitchCol={2}
22
+ id="auto-upload"
23
+ isChecked={true}
24
+ label="Inventory Auto Upload"
25
+ labelCol={5}
26
+ onChange={[Function]}
27
+ tooltip="Enable automatic upload of your hosts inventory to the Red Hat cloud"
28
+ />
29
+ <Col
30
+ bsClass="col"
31
+ componentClass="div"
32
+ sm={5}
33
+ >
34
+ <Popover
35
+ bodyContent={
36
+ <UNDEFINED
37
+ autoUploadEnabled={true}
38
+ handleToggle={[Function]}
39
+ />
40
+ }
41
+ headerContent={
42
+ <strong>
43
+ Advanced Inventory Settings
44
+ </strong>
45
+ }
46
+ position="right"
47
+ >
48
+ <Button
49
+ style={
50
+ Object {
51
+ "fontSize": "small",
52
+ "marginTop": "-4px",
53
+ }
54
+ }
55
+ variant="secondary"
56
+ >
57
+ Show Advanced Settings
58
+
59
+ <CaretRightIcon
60
+ color="currentColor"
61
+ noVerticalAlign={false}
62
+ size="sm"
63
+ />
64
+ </Button>
65
+ </Popover>
66
+ </Col>
67
+ </Row>
68
+ <br />
69
+ <Row
70
+ bsClass="row"
71
+ componentClass="div"
72
+ >
73
+ <Col
74
+ bsClass="col"
75
+ componentClass="div"
76
+ sm={12}
77
+ >
78
+ <Text
79
+ component="p"
80
+ >
81
+ <InfoAltIcon
82
+ color="currentColor"
83
+ noVerticalAlign={false}
84
+ size="sm"
85
+ />
86
+
87
+ More details can be found in
88
+
89
+ <Text
90
+ component="a"
91
+ href="/foreman_rh_cloud/inventory_upload"
92
+ rel="noopener noreferrer"
93
+ target="_blank"
94
+ >
95
+ <strong>
96
+ Configure
97
+ &gt;
98
+ Inventory Upload
99
+ </strong>
100
+ </Text>
101
+ </Text>
102
+ </Col>
103
+ </Row>
104
+ </Grid>
105
+ </FormGroup>
106
+ `;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Grid } from 'patternfly-react';
4
+ import { translate as __ } from 'foremanReact/common/I18n';
5
+ import Switcher from '../../../../../common/Switcher';
6
+
7
+ const AdvancedSettings = ({
8
+ hostObfuscationEnabled,
9
+ hostObfuscationToggle,
10
+ ipsObfuscationEnabled,
11
+ ipsObfuscationToggle,
12
+ excludePackagesEnabled,
13
+ excludePackagesToggle,
14
+ }) => (
15
+ <form style={{ padding: '5px' }}>
16
+ <Grid.Row>
17
+ <Switcher
18
+ id="obfuscate-hostnames"
19
+ label={__('Obfuscate host names')}
20
+ tooltip={__('Obfuscate host names sent to the Red Hat cloud')}
21
+ isChecked={hostObfuscationEnabled}
22
+ onChange={() => hostObfuscationToggle(hostObfuscationEnabled)}
23
+ labelCol={8}
24
+ />
25
+ </Grid.Row>
26
+ <Grid.Row>
27
+ <Switcher
28
+ id="obfuscate-ip"
29
+ label={__('Obfuscate IPs')}
30
+ tooltip={__('Obfuscate ipv4 addresses sent to the Red Hat cloud')}
31
+ isChecked={ipsObfuscationEnabled}
32
+ onChange={() => ipsObfuscationToggle(ipsObfuscationEnabled)}
33
+ labelCol={8}
34
+ />
35
+ </Grid.Row>
36
+ <Grid.Row>
37
+ <Switcher
38
+ id="exclude-packages"
39
+ label={__('Exclude packages')}
40
+ tooltip={__(
41
+ 'Exclude packages from being uploaded to the Red Hat cloud'
42
+ )}
43
+ isChecked={excludePackagesEnabled}
44
+ onChange={() => excludePackagesToggle(excludePackagesEnabled)}
45
+ labelCol={8}
46
+ />
47
+ </Grid.Row>
48
+ </form>
49
+ );
50
+
51
+ AdvancedSettings.propTypes = {
52
+ hostObfuscationEnabled: PropTypes.bool.isRequired,
53
+ hostObfuscationToggle: PropTypes.func.isRequired,
54
+ ipsObfuscationEnabled: PropTypes.bool.isRequired,
55
+ ipsObfuscationToggle: PropTypes.func.isRequired,
56
+ excludePackagesEnabled: PropTypes.bool.isRequired,
57
+ excludePackagesToggle: PropTypes.func.isRequired,
58
+ };
59
+
60
+ export default AdvancedSettings;