foreman_rh_cloud 3.0.18.1 → 4.0.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -5
  3. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +14 -3
  4. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +8 -0
  5. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +17 -7
  6. data/app/controllers/insights_cloud/hits_controller.rb +37 -0
  7. data/app/controllers/insights_cloud/settings_controller.rb +1 -1
  8. data/app/controllers/insights_cloud/tasks_controller.rb +1 -2
  9. data/app/models/insights_client_report_status.rb +58 -0
  10. data/app/models/insights_resolution.rb +1 -1
  11. data/app/models/inventory_sync/inventory_status.rb +6 -0
  12. data/app/models/setting/rh_cloud.rb +5 -5
  13. data/app/services/foreman_rh_cloud/cloud_connector.rb +1 -1
  14. data/app/services/foreman_rh_cloud/remediations_retriever.rb +78 -0
  15. data/app/services/foreman_rh_cloud/template_renderer_helper.rb +22 -0
  16. data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +9 -0
  17. data/app/views/job_templates/rh_cloud_remediations.erb +14 -0
  18. data/config/routes.rb +2 -1
  19. data/db/migrate/20210404000001_change_resolutions.foreman_rh_cloud.rb +10 -0
  20. data/db/seeds.d/179_ui_notifications.rb +11 -0
  21. data/db/seeds.d/50_job_templates.rb +14 -0
  22. data/lib/foreman_inventory_upload.rb +9 -0
  23. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +8 -2
  24. data/lib/foreman_inventory_upload/generators/queries.rb +3 -2
  25. data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
  26. data/lib/foreman_inventory_upload/generators/tags.rb +8 -6
  27. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +5 -1
  28. data/lib/foreman_rh_cloud.rb +18 -0
  29. data/lib/foreman_rh_cloud/engine.rb +36 -2
  30. data/lib/foreman_rh_cloud/version.rb +1 -1
  31. data/lib/insights_cloud.rb +12 -0
  32. data/lib/insights_cloud/async/insights_full_sync.rb +39 -24
  33. data/lib/insights_cloud/async/insights_generate_notifications.rb +58 -0
  34. data/lib/insights_cloud/async/insights_resolutions_sync.rb +69 -0
  35. data/lib/insights_cloud/async/insights_rules_sync.rb +13 -17
  36. data/lib/insights_cloud/async/insights_scheduled_sync.rb +1 -1
  37. data/lib/inventory_sync/async/host_result.rb +11 -6
  38. data/lib/inventory_sync/async/inventory_full_sync.rb +24 -41
  39. data/lib/inventory_sync/async/inventory_hosts_sync.rb +34 -0
  40. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +17 -0
  41. data/lib/inventory_sync/async/query_inventory_job.rb +54 -0
  42. data/lib/tasks/insights.rake +4 -12
  43. data/lib/tasks/rh_cloud_inventory.rake +12 -4
  44. data/package.json +1 -1
  45. data/test/factories/insights_factories.rb +22 -0
  46. data/test/jobs/insights_full_sync_test.rb +28 -15
  47. data/test/jobs/insights_resolutions_sync_test.rb +77 -0
  48. data/test/jobs/insights_rules_sync_test.rb +8 -3
  49. data/test/jobs/inventory_full_sync_test.rb +185 -12
  50. data/test/models/insights_client_report_status_test.rb +77 -0
  51. data/test/unit/rh_cloud_http_proxy_test.rb +4 -4
  52. data/test/unit/services/foreman_rh_cloud/remediations_retriever_test.rb +49 -0
  53. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +28 -0
  54. data/test/unit/slice_generator_test.rb +11 -2
  55. data/test/unit/tags_generator_test.rb +10 -0
  56. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +1 -1
  57. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -1
  58. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +14 -16
  59. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +1 -1
  60. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +0 -1
  61. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingsConstants.js +5 -3
  62. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +15 -2
  63. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +13 -2
  64. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +81 -46
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +3 -3
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonSelectors.js +6 -12
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonFixtures.js +1 -9
  68. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonSelectors.test.js +18 -27
  69. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap +1 -16
  70. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +58 -0
  71. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js +51 -0
  72. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +2 -5
  73. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  74. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -1
  75. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +2 -2
  76. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +25 -27
  77. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +0 -2
  78. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +1 -1
  79. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +3 -0
  80. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +2 -0
  81. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +59 -0
  82. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationActions.js +12 -0
  83. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js +43 -0
  84. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +101 -0
  85. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +9 -0
  86. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModalFooter.js +43 -0
  87. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationTableConstants.js +38 -0
  88. data/webpack/InsightsCloudSync/Components/RemediationModal/Resolutions.js +55 -0
  89. data/webpack/InsightsCloudSync/Components/RemediationModal/index.js +34 -0
  90. data/webpack/InsightsCloudSync/InsightsCloudSync.js +8 -3
  91. data/webpack/InsightsCloudSync/InsightsCloudSync.scss +5 -0
  92. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +9 -6
  93. data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +4 -0
  94. data/webpack/{InsightsCloudSync/Components/InsightsTable/components → common/table}/EmptyState.js +0 -0
  95. data/webpack/common/table/helpers.js +7 -0
  96. metadata +56 -26
  97. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +0 -36
  98. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +0 -31
  99. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +0 -26
  100. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +0 -98
  101. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -18
@@ -1,36 +0,0 @@
1
- import Immutable from 'seamless-immutable';
2
- import { STATUS } from 'foremanReact/constants';
3
- import {
4
- INVENTORY_SYNC_REQUEST,
5
- INVENTORY_SYNC_SUCCESS,
6
- INVENTORY_SYNC_ERROR,
7
- } from './SyncButtonConstants';
8
-
9
- export default (
10
- state = Immutable({}),
11
- { type, payload: { syncHosts, disconnectHosts, error } = {} }
12
- ) => {
13
- switch (type) {
14
- case INVENTORY_SYNC_REQUEST:
15
- return state.merge({
16
- ...state,
17
- status: STATUS.PENDING,
18
- error: null,
19
- });
20
- case INVENTORY_SYNC_SUCCESS:
21
- return state.merge({
22
- ...state,
23
- status: STATUS.RESOLVED,
24
- syncHosts,
25
- disconnectHosts,
26
- });
27
- case INVENTORY_SYNC_ERROR:
28
- return state.merge({
29
- ...state,
30
- status: STATUS.ERROR,
31
- error,
32
- });
33
- default:
34
- return state;
35
- }
36
- };
@@ -1,31 +0,0 @@
1
- import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
- import { API } from 'foremanReact/redux/API';
3
- import { handleSync } from '../SyncButtonActions';
4
- import { successResponse } from './SyncButtonFixtures';
5
-
6
- jest.mock('foremanReact/redux/API');
7
- API.post.mockImplementation(async () => successResponse);
8
-
9
- const fixtures = {
10
- 'should handleSync': () => handleSync(),
11
- 'should handleSync with error message': () => {
12
- API.post.mockImplementationOnce(() =>
13
- Promise.reject(new Error('Network error!'))
14
- );
15
-
16
- return handleSync();
17
- },
18
- 'should handleSync with custom error message': () => {
19
- API.post.mockImplementationOnce(() => {
20
- const customError = new Error('Server error!');
21
- customError.response = {
22
- data: { message: 'Custom error to display in a toast' },
23
- };
24
- return Promise.reject(customError);
25
- });
26
-
27
- return handleSync();
28
- },
29
- };
30
-
31
- describe('SyncButton actions', () => testActionSnapshotWithFixtures(fixtures));
@@ -1,26 +0,0 @@
1
- import { testReducerSnapshotWithFixtures } from '@theforeman/test';
2
- import reducer from '../SyncButtonReducer';
3
- import { syncHosts, disconnectHosts } from './SyncButtonFixtures';
4
- import {
5
- INVENTORY_SYNC_REQUEST,
6
- INVENTORY_SYNC_SUCCESS,
7
- } from '../SyncButtonConstants';
8
-
9
- const fixtures = {
10
- 'should return the initial state': {},
11
- 'should handle INVENTORY_SYNC_REQUEST': {
12
- action: {
13
- type: INVENTORY_SYNC_REQUEST,
14
- payload: {},
15
- },
16
- },
17
- 'should handle INVENTORY_SYNC_SUCCESS': {
18
- action: {
19
- type: INVENTORY_SYNC_SUCCESS,
20
- payload: { syncHosts, disconnectHosts },
21
- },
22
- },
23
- };
24
-
25
- describe('AccountList reducer', () =>
26
- testReducerSnapshotWithFixtures(reducer, fixtures));
@@ -1,98 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`SyncButton actions should handleSync 1`] = `
4
- Array [
5
- Array [
6
- Object {
7
- "payload": Object {},
8
- "type": "INVENTORY_SYNC_REQUEST",
9
- },
10
- ],
11
- Array [
12
- Object {
13
- "payload": Object {
14
- "disconnectHosts": 0,
15
- "syncHosts": 1,
16
- },
17
- "type": "INVENTORY_SYNC_SUCCESS",
18
- },
19
- ],
20
- Array [
21
- Object {
22
- "payload": Object {
23
- "message": Object {
24
- "message": <Toast
25
- disconnectHosts={0}
26
- syncHosts={1}
27
- />,
28
- "sticky": true,
29
- "type": "success",
30
- },
31
- },
32
- "type": "TOASTS_ADD",
33
- },
34
- ],
35
- ]
36
- `;
37
-
38
- exports[`SyncButton actions should handleSync with custom error message 1`] = `
39
- Array [
40
- Array [
41
- Object {
42
- "payload": Object {},
43
- "type": "INVENTORY_SYNC_REQUEST",
44
- },
45
- ],
46
- Array [
47
- Object {
48
- "payload": Object {
49
- "error": "Server error!",
50
- },
51
- "type": "INVENTORY_SYNC_ERROR",
52
- },
53
- ],
54
- Array [
55
- Object {
56
- "payload": Object {
57
- "message": Object {
58
- "message": "Custom error to display in a toast",
59
- "sticky": true,
60
- "type": "error",
61
- },
62
- },
63
- "type": "TOASTS_ADD",
64
- },
65
- ],
66
- ]
67
- `;
68
-
69
- exports[`SyncButton actions should handleSync with error message 1`] = `
70
- Array [
71
- Array [
72
- Object {
73
- "payload": Object {},
74
- "type": "INVENTORY_SYNC_REQUEST",
75
- },
76
- ],
77
- Array [
78
- Object {
79
- "payload": Object {
80
- "error": "Network error!",
81
- },
82
- "type": "INVENTORY_SYNC_ERROR",
83
- },
84
- ],
85
- Array [
86
- Object {
87
- "payload": Object {
88
- "message": Object {
89
- "message": "Network error!",
90
- "sticky": true,
91
- "type": "error",
92
- },
93
- },
94
- "type": "TOASTS_ADD",
95
- },
96
- ],
97
- ]
98
- `;
@@ -1,18 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`AccountList reducer should handle INVENTORY_SYNC_REQUEST 1`] = `
4
- Object {
5
- "error": null,
6
- "status": "PENDING",
7
- }
8
- `;
9
-
10
- exports[`AccountList reducer should handle INVENTORY_SYNC_SUCCESS 1`] = `
11
- Object {
12
- "disconnectHosts": 0,
13
- "status": "RESOLVED",
14
- "syncHosts": 1,
15
- }
16
- `;
17
-
18
- exports[`AccountList reducer should return the initial state 1`] = `Object {}`;