foreman_rh_cloud 13.0.8 → 13.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/inventory_upload/report_actions.rb +8 -1
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +82 -7
- data/app/controllers/foreman_inventory_upload/api/tasks_controller.rb +110 -0
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +41 -17
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -9
- data/config/routes.rb +4 -2
- data/db/migrate/20251209163012_drop_task_output_tables.foreman_rh_cloud.rb +24 -0
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +1 -1
- data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +39 -0
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +1 -23
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +171 -0
- data/lib/foreman_inventory_upload.rb +0 -4
- data/lib/foreman_rh_cloud/plugin.rb +1 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +0 -2
- data/lib/tasks/rh_cloud_inventory.rake +4 -2
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +10 -11
- data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +1 -2
- data/test/jobs/host_inventory_report_job_test.rb +161 -97
- data/test/jobs/queue_for_upload_job_test.rb +1 -12
- data/test/jobs/single_host_report_job_test.rb +36 -54
- data/test/jobs/upload_report_direct_job_test.rb +399 -0
- data/test/unit/rh_cloud_permissions_test.rb +2 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +49 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +4 -5
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +15 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +11 -11
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +10 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +9 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +4 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +15 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +12 -12
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +37 -130
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +60 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +1 -34
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +0 -1
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +1 -26
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +24 -17
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +178 -8
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +3 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +69 -51
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +22 -9
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +67 -4
- data/webpack/ForemanInventoryUpload/Components/TaskHistory/TaskHistory.js +140 -0
- data/webpack/ForemanInventoryUpload/Components/TaskHistory/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TaskHistory/taskHistory.scss +40 -0
- data/webpack/ForemanInventoryUpload/Components/TaskProgress/TaskProgress.js +340 -0
- data/webpack/ForemanInventoryUpload/Components/TaskProgress/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TaskProgress/taskProgress.scss +8 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +2 -2
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +0 -2
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryHelpers.test.js.snap +1 -1
- data/webpack/ForemanRhCloudPages.js +0 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +11 -19
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js +1 -2
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +2 -4
- data/webpack/InsightsVulnerabilityHostIndexExtensions/__tests__/CVECountCell.test.js +77 -22
- data/webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js +14 -0
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +5 -1
- metadata +13 -68
- data/app/models/task_output_line.rb +0 -2
- data/app/models/task_output_status.rb +0 -2
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +0 -61
- data/lib/foreman_inventory_upload/async/progress_output.rb +0 -38
- data/lib/foreman_inventory_upload/async/shell_process.rb +0 -77
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +0 -97
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +0 -55
- data/test/controllers/reports_controller_test.rb +0 -21
- data/test/controllers/uploads_controller_test.rb +0 -21
- data/test/jobs/generate_report_job_test.rb +0 -146
- data/test/jobs/upload_report_job_test.rb +0 -38
- data/test/unit/shell_process_job_test.rb +0 -29
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +0 -88
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +0 -68
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +0 -51
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +0 -64
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +0 -46
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +0 -36
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +0 -76
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +0 -44
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +0 -42
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +0 -55
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +0 -65
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +0 -20
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +0 -36
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +0 -65
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +0 -47
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +0 -46
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +0 -47
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +0 -31
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +0 -19
- data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +0 -5
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +0 -10
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +0 -110
- data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +0 -6
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +0 -34
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +0 -98
- data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +0 -32
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +0 -112
- data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +0 -3
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { screen } from '@testing-library/react';
|
|
3
|
+
import { rtlHelpers } from 'foremanReact/common/rtlTestHelpers';
|
|
3
4
|
import { API } from 'foremanReact/redux/API';
|
|
4
5
|
import { CVECountCell } from '../CVECountCell';
|
|
5
|
-
import * as ConfigHooks from '../../common/Hooks/ConfigHooks';
|
|
6
6
|
|
|
7
7
|
jest.mock('foremanReact/redux/API');
|
|
8
8
|
jest.mock('../../common/Hooks/ConfigHooks');
|
|
9
9
|
|
|
10
|
+
const { renderWithStore } = rtlHelpers;
|
|
11
|
+
|
|
10
12
|
API.get.mockImplementation(async () => ({
|
|
11
13
|
data: [
|
|
12
14
|
{
|
|
@@ -18,17 +20,13 @@ API.get.mockImplementation(async () => ({
|
|
|
18
20
|
}));
|
|
19
21
|
|
|
20
22
|
const hostDetailsMock = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
name: 'test-host.example.com',
|
|
24
|
+
subscription_facet_attributes: {
|
|
25
|
+
uuid: 'test-uuid-123',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
26
28
|
|
|
27
29
|
describe('CVECountCell', () => {
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
ConfigHooks.useIopConfig.mockReturnValue(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
30
|
afterEach(() => {
|
|
33
31
|
jest.clearAllMocks();
|
|
34
32
|
});
|
|
@@ -40,35 +38,92 @@ describe('CVECountCell', () => {
|
|
|
40
38
|
uuid: null, // no subscription
|
|
41
39
|
},
|
|
42
40
|
};
|
|
43
|
-
|
|
41
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMockIoP} />, {
|
|
42
|
+
router: {
|
|
43
|
+
location: {
|
|
44
|
+
pathname: '/',
|
|
45
|
+
search: '',
|
|
46
|
+
hash: '',
|
|
47
|
+
query: {},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
API: {
|
|
51
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
52
|
+
response: { use_iop_mode: true },
|
|
53
|
+
status: 'RESOLVED',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
});
|
|
44
57
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
45
58
|
});
|
|
46
59
|
|
|
47
60
|
it('renders UnknownIcon when IoP is not enabled', () => {
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
|
|
62
|
+
router: {
|
|
63
|
+
location: {
|
|
64
|
+
pathname: '/',
|
|
65
|
+
search: '',
|
|
66
|
+
hash: '',
|
|
67
|
+
query: {},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
API: {
|
|
71
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
72
|
+
response: { use_iop_mode: false },
|
|
73
|
+
status: 'RESOLVED',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
});
|
|
50
77
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
51
|
-
expect(ConfigHooks.useIopConfig).toHaveBeenCalled();
|
|
52
78
|
});
|
|
53
79
|
|
|
54
80
|
it('renders UnknownIcon when IoP is enabled but CVE API call fails', () => {
|
|
55
|
-
// Mock successful IoP config
|
|
56
|
-
ConfigHooks.useIopConfig.mockReturnValue(true);
|
|
57
81
|
// Mock CVE API failure - override the global mock for this test
|
|
58
82
|
API.get.mockImplementationOnce(async () => {
|
|
59
83
|
throw new Error('CVE API call failed');
|
|
60
84
|
});
|
|
61
85
|
|
|
62
|
-
|
|
86
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
|
|
87
|
+
router: {
|
|
88
|
+
location: {
|
|
89
|
+
pathname: '/',
|
|
90
|
+
search: '',
|
|
91
|
+
hash: '',
|
|
92
|
+
query: {},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
API: {
|
|
96
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
97
|
+
response: { use_iop_mode: true },
|
|
98
|
+
status: 'RESOLVED',
|
|
99
|
+
},
|
|
100
|
+
// Mock the API failure state for the CVE endpoint
|
|
101
|
+
[`HOST_CVE_COUNT_${hostDetailsMock.subscription_facet_attributes.uuid}`]: {
|
|
102
|
+
status: 'ERROR',
|
|
103
|
+
error: 'CVE API call failed',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
63
107
|
// Should render UnknownIcon when CVE API fails
|
|
64
108
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
65
|
-
expect(ConfigHooks.useIopConfig).toHaveBeenCalled();
|
|
66
109
|
});
|
|
67
110
|
|
|
68
111
|
it('renders UnknownIcon when IoP is undefined (API call pending)', () => {
|
|
69
|
-
|
|
70
|
-
|
|
112
|
+
renderWithStore(<CVECountCell hostDetails={hostDetailsMock} />, {
|
|
113
|
+
router: {
|
|
114
|
+
location: {
|
|
115
|
+
pathname: '/',
|
|
116
|
+
search: '',
|
|
117
|
+
hash: '',
|
|
118
|
+
query: {},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
API: {
|
|
122
|
+
ADVISOR_ENGINE_CONFIG: {
|
|
123
|
+
status: 'PENDING',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
71
127
|
expect(screen.getByRole('img', { hidden: true })).toBeTruthy();
|
|
72
|
-
expect(ConfigHooks.useIopConfig).toHaveBeenCalled();
|
|
73
128
|
});
|
|
74
129
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const RelativeDateTime = ({ date }) => <span>{date}</span>;
|
|
5
|
+
|
|
6
|
+
RelativeDateTime.propTypes = {
|
|
7
|
+
date: PropTypes.string,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
RelativeDateTime.defaultProps = {
|
|
11
|
+
date: '',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default RelativeDateTime;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
foremanUrl,
|
|
4
|
+
vulnerabilityDisabled,
|
|
5
|
+
hasNoInsightsFacet,
|
|
6
|
+
} from '../ForemanRhCloudHelpers';
|
|
3
7
|
|
|
4
8
|
global.URL_PREFIX = 'MY_TEST_URL_PREFIX.example.com';
|
|
5
9
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_rh_cloud
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 13.0.
|
|
4
|
+
version: 13.0.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Foreman Red Hat Cloud team
|
|
@@ -106,6 +106,7 @@ files:
|
|
|
106
106
|
- app/controllers/concerns/inventory_upload/report_actions.rb
|
|
107
107
|
- app/controllers/concerns/inventory_upload/task_actions.rb
|
|
108
108
|
- app/controllers/foreman_inventory_upload/accounts_controller.rb
|
|
109
|
+
- app/controllers/foreman_inventory_upload/api/tasks_controller.rb
|
|
109
110
|
- app/controllers/foreman_inventory_upload/cloud_status_controller.rb
|
|
110
111
|
- app/controllers/foreman_inventory_upload/missing_hosts_controller.rb
|
|
111
112
|
- app/controllers/foreman_inventory_upload/reports_controller.rb
|
|
@@ -130,8 +131,6 @@ files:
|
|
|
130
131
|
- app/models/insights_resolution.rb
|
|
131
132
|
- app/models/insights_rule.rb
|
|
132
133
|
- app/models/inventory_sync/inventory_status.rb
|
|
133
|
-
- app/models/task_output_line.rb
|
|
134
|
-
- app/models/task_output_status.rb
|
|
135
134
|
- app/overrides/layouts/base/styles.html.erb.deface
|
|
136
135
|
- app/services/foreman_rh_cloud/branch_info.rb
|
|
137
136
|
- app/services/foreman_rh_cloud/cert_auth.rb
|
|
@@ -179,6 +178,7 @@ files:
|
|
|
179
178
|
- db/migrate/20230515140211_add_missing_hosts_table.foreman_rh_cloud.rb
|
|
180
179
|
- db/migrate/20241217190624_add_unique_index_to_rule_id_and_host_id_in_insights_hits.rb
|
|
181
180
|
- db/migrate/20241220184900_change_sync_insights_recommendations_to_true.rb
|
|
181
|
+
- db/migrate/20251209163012_drop_task_output_tables.foreman_rh_cloud.rb
|
|
182
182
|
- db/seeds.d/179_ui_notifications.rb
|
|
183
183
|
- db/seeds.d/189_add_host_inventory_param.rb
|
|
184
184
|
- db/seeds.d/200_features.rb
|
|
@@ -189,14 +189,11 @@ files:
|
|
|
189
189
|
- lib/foreman_inventory_upload/async/delayed_start.rb
|
|
190
190
|
- lib/foreman_inventory_upload/async/generate_all_reports_job.rb
|
|
191
191
|
- lib/foreman_inventory_upload/async/generate_host_report.rb
|
|
192
|
-
- lib/foreman_inventory_upload/async/generate_report_job.rb
|
|
193
192
|
- lib/foreman_inventory_upload/async/host_inventory_report_job.rb
|
|
194
|
-
- lib/foreman_inventory_upload/async/progress_output.rb
|
|
195
193
|
- lib/foreman_inventory_upload/async/queue_for_upload_job.rb
|
|
196
194
|
- lib/foreman_inventory_upload/async/remove_insights_hosts_job.rb
|
|
197
|
-
- lib/foreman_inventory_upload/async/shell_process.rb
|
|
198
195
|
- lib/foreman_inventory_upload/async/single_host_report_job.rb
|
|
199
|
-
- lib/foreman_inventory_upload/async/
|
|
196
|
+
- lib/foreman_inventory_upload/async/upload_report_direct_job.rb
|
|
200
197
|
- lib/foreman_inventory_upload/generators/archived_report.rb
|
|
201
198
|
- lib/foreman_inventory_upload/generators/fact_helpers.rb
|
|
202
199
|
- lib/foreman_inventory_upload/generators/json_stream.rb
|
|
@@ -205,7 +202,6 @@ files:
|
|
|
205
202
|
- lib/foreman_inventory_upload/generators/slice.rb
|
|
206
203
|
- lib/foreman_inventory_upload/generators/tags.rb
|
|
207
204
|
- lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb
|
|
208
|
-
- lib/foreman_inventory_upload/scripts/uploader.sh.erb
|
|
209
205
|
- lib/foreman_rh_cloud.rb
|
|
210
206
|
- lib/foreman_rh_cloud/async/exponential_backoff.rb
|
|
211
207
|
- lib/foreman_rh_cloud/engine.rb
|
|
@@ -256,8 +252,6 @@ files:
|
|
|
256
252
|
- test/controllers/insights_sync/settings_controller_test.rb
|
|
257
253
|
- test/controllers/inventory_upload/api/inventory_controller_test.rb
|
|
258
254
|
- test/controllers/inventory_upload/cloud_status_controller_test.rb
|
|
259
|
-
- test/controllers/reports_controller_test.rb
|
|
260
|
-
- test/controllers/uploads_controller_test.rb
|
|
261
255
|
- test/controllers/uploads_settings_controller_test.rb
|
|
262
256
|
- test/factories/insights_factories.rb
|
|
263
257
|
- test/factories/inventory_upload_factories.rb
|
|
@@ -266,7 +260,6 @@ files:
|
|
|
266
260
|
- test/jobs/create_missing_insights_facets_test.rb
|
|
267
261
|
- test/jobs/exponential_backoff_test.rb
|
|
268
262
|
- test/jobs/generate_host_report_test.rb
|
|
269
|
-
- test/jobs/generate_report_job_test.rb
|
|
270
263
|
- test/jobs/host_inventory_report_job_test.rb
|
|
271
264
|
- test/jobs/insights_client_status_aging_test.rb
|
|
272
265
|
- test/jobs/insights_full_sync_test.rb
|
|
@@ -279,7 +272,7 @@ files:
|
|
|
279
272
|
- test/jobs/queue_for_upload_job_test.rb
|
|
280
273
|
- test/jobs/remove_insights_hosts_job_test.rb
|
|
281
274
|
- test/jobs/single_host_report_job_test.rb
|
|
282
|
-
- test/jobs/
|
|
275
|
+
- test/jobs/upload_report_direct_job_test.rb
|
|
283
276
|
- test/models/insights_client_report_status_test.rb
|
|
284
277
|
- test/test_plugin_helper.rb
|
|
285
278
|
- test/unit/archived_report_generator_test.rb
|
|
@@ -303,7 +296,6 @@ files:
|
|
|
303
296
|
- test/unit/services/foreman_rh_cloud/tags_auth_test.rb
|
|
304
297
|
- test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb
|
|
305
298
|
- test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb
|
|
306
|
-
- test/unit/shell_process_job_test.rb
|
|
307
299
|
- test/unit/slice_generator_test.rb
|
|
308
300
|
- test/unit/tags_generator_test.rb
|
|
309
301
|
- webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js
|
|
@@ -368,20 +360,8 @@ files:
|
|
|
368
360
|
- webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js
|
|
369
361
|
- webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js
|
|
370
362
|
- webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js
|
|
371
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js
|
|
372
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js
|
|
373
363
|
- webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js
|
|
374
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js
|
|
375
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js
|
|
376
364
|
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js
|
|
377
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
|
|
378
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js
|
|
379
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js
|
|
380
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js
|
|
381
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap
|
|
382
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap
|
|
383
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap
|
|
384
|
-
- webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap
|
|
385
365
|
- webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss
|
|
386
366
|
- webpack/ForemanInventoryUpload/Components/Dashboard/index.js
|
|
387
367
|
- webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js
|
|
@@ -391,13 +371,6 @@ files:
|
|
|
391
371
|
- webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap
|
|
392
372
|
- webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss
|
|
393
373
|
- webpack/ForemanInventoryUpload/Components/FileDownload/index.js
|
|
394
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js
|
|
395
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js
|
|
396
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js
|
|
397
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js
|
|
398
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap
|
|
399
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss
|
|
400
|
-
- webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js
|
|
401
374
|
- webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js
|
|
402
375
|
- webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/index.js
|
|
403
376
|
- webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js
|
|
@@ -443,7 +416,6 @@ files:
|
|
|
443
416
|
- webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js
|
|
444
417
|
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js
|
|
445
418
|
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js
|
|
446
|
-
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap
|
|
447
419
|
- webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap
|
|
448
420
|
- webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js
|
|
449
421
|
- webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
|
|
@@ -480,20 +452,6 @@ files:
|
|
|
480
452
|
- webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/index.js
|
|
481
453
|
- webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss
|
|
482
454
|
- webpack/ForemanInventoryUpload/Components/PageHeader/index.js
|
|
483
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js
|
|
484
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js
|
|
485
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js
|
|
486
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js
|
|
487
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap
|
|
488
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js
|
|
489
|
-
- webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss
|
|
490
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js
|
|
491
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js
|
|
492
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js
|
|
493
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js
|
|
494
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap
|
|
495
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/index.js
|
|
496
|
-
- webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss
|
|
497
455
|
- webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js
|
|
498
456
|
- webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js
|
|
499
457
|
- webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js
|
|
@@ -508,13 +466,6 @@ files:
|
|
|
508
466
|
- webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap
|
|
509
467
|
- webpack/ForemanInventoryUpload/Components/StatusChart/index.js
|
|
510
468
|
- webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss
|
|
511
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js
|
|
512
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js
|
|
513
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js
|
|
514
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js
|
|
515
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap
|
|
516
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/index.js
|
|
517
|
-
- webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss
|
|
518
469
|
- webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js
|
|
519
470
|
- webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js
|
|
520
471
|
- webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js
|
|
@@ -535,13 +486,12 @@ files:
|
|
|
535
486
|
- webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js
|
|
536
487
|
- webpack/ForemanInventoryUpload/Components/TabHeader/index.js
|
|
537
488
|
- webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss
|
|
538
|
-
- webpack/ForemanInventoryUpload/Components/
|
|
539
|
-
- webpack/ForemanInventoryUpload/Components/
|
|
540
|
-
- webpack/ForemanInventoryUpload/Components/
|
|
541
|
-
- webpack/ForemanInventoryUpload/Components/
|
|
542
|
-
- webpack/ForemanInventoryUpload/Components/
|
|
543
|
-
- webpack/ForemanInventoryUpload/Components/
|
|
544
|
-
- webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss
|
|
489
|
+
- webpack/ForemanInventoryUpload/Components/TaskHistory/TaskHistory.js
|
|
490
|
+
- webpack/ForemanInventoryUpload/Components/TaskHistory/index.js
|
|
491
|
+
- webpack/ForemanInventoryUpload/Components/TaskHistory/taskHistory.scss
|
|
492
|
+
- webpack/ForemanInventoryUpload/Components/TaskProgress/TaskProgress.js
|
|
493
|
+
- webpack/ForemanInventoryUpload/Components/TaskProgress/index.js
|
|
494
|
+
- webpack/ForemanInventoryUpload/Components/TaskProgress/taskProgress.scss
|
|
545
495
|
- webpack/ForemanInventoryUpload/ForemanInventoryConstants.js
|
|
546
496
|
- webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js
|
|
547
497
|
- webpack/ForemanInventoryUpload/ForemanInventoryUpload.js
|
|
@@ -588,7 +538,6 @@ files:
|
|
|
588
538
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js
|
|
589
539
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
|
|
590
540
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js
|
|
591
|
-
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap
|
|
592
541
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap
|
|
593
542
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap
|
|
594
543
|
- webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js
|
|
@@ -648,11 +597,11 @@ files:
|
|
|
648
597
|
- webpack/__mocks__/foremanReact/common/I18n.js
|
|
649
598
|
- webpack/__mocks__/foremanReact/common/MountingService.js
|
|
650
599
|
- webpack/__mocks__/foremanReact/common/helpers.js
|
|
651
|
-
- webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js
|
|
652
600
|
- webpack/__mocks__/foremanReact/components/ConfirmModal/index.js
|
|
653
601
|
- webpack/__mocks__/foremanReact/components/Head.js
|
|
654
602
|
- webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js
|
|
655
603
|
- webpack/__mocks__/foremanReact/components/ToastsList/index.js
|
|
604
|
+
- webpack/__mocks__/foremanReact/components/common/dates/RelativeDateTime.js
|
|
656
605
|
- webpack/__mocks__/foremanReact/constants.js
|
|
657
606
|
- webpack/__mocks__/foremanReact/redux/API/APISelectors.js
|
|
658
607
|
- webpack/__mocks__/foremanReact/redux/API/index.js
|
|
@@ -717,8 +666,6 @@ test_files:
|
|
|
717
666
|
- test/controllers/insights_sync/settings_controller_test.rb
|
|
718
667
|
- test/controllers/inventory_upload/api/inventory_controller_test.rb
|
|
719
668
|
- test/controllers/inventory_upload/cloud_status_controller_test.rb
|
|
720
|
-
- test/controllers/reports_controller_test.rb
|
|
721
|
-
- test/controllers/uploads_controller_test.rb
|
|
722
669
|
- test/controllers/uploads_settings_controller_test.rb
|
|
723
670
|
- test/factories/insights_factories.rb
|
|
724
671
|
- test/factories/inventory_upload_factories.rb
|
|
@@ -727,7 +674,6 @@ test_files:
|
|
|
727
674
|
- test/jobs/create_missing_insights_facets_test.rb
|
|
728
675
|
- test/jobs/exponential_backoff_test.rb
|
|
729
676
|
- test/jobs/generate_host_report_test.rb
|
|
730
|
-
- test/jobs/generate_report_job_test.rb
|
|
731
677
|
- test/jobs/host_inventory_report_job_test.rb
|
|
732
678
|
- test/jobs/insights_client_status_aging_test.rb
|
|
733
679
|
- test/jobs/insights_full_sync_test.rb
|
|
@@ -740,7 +686,7 @@ test_files:
|
|
|
740
686
|
- test/jobs/queue_for_upload_job_test.rb
|
|
741
687
|
- test/jobs/remove_insights_hosts_job_test.rb
|
|
742
688
|
- test/jobs/single_host_report_job_test.rb
|
|
743
|
-
- test/jobs/
|
|
689
|
+
- test/jobs/upload_report_direct_job_test.rb
|
|
744
690
|
- test/models/insights_client_report_status_test.rb
|
|
745
691
|
- test/test_plugin_helper.rb
|
|
746
692
|
- test/unit/archived_report_generator_test.rb
|
|
@@ -764,6 +710,5 @@ test_files:
|
|
|
764
710
|
- test/unit/services/foreman_rh_cloud/tags_auth_test.rb
|
|
765
711
|
- test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb
|
|
766
712
|
- test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb
|
|
767
|
-
- test/unit/shell_process_job_test.rb
|
|
768
713
|
- test/unit/slice_generator_test.rb
|
|
769
714
|
- test/unit/tags_generator_test.rb
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module ForemanInventoryUpload
|
|
2
|
-
module Async
|
|
3
|
-
class GenerateReportJob < ShellProcess
|
|
4
|
-
def self.output_label(label)
|
|
5
|
-
"report_for_#{label}"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def plan(base_folder, organization_id, disconnected = false, hosts_filter = nil)
|
|
9
|
-
sequence do
|
|
10
|
-
super(
|
|
11
|
-
GenerateReportJob.output_label("#{organization_id}#{hosts_filter.empty? ? nil : "[#{hosts_filter.to_s.parameterize}]"}"),
|
|
12
|
-
organization_id: organization_id,
|
|
13
|
-
base_folder: base_folder,
|
|
14
|
-
hosts_filter: hosts_filter
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
unless content_disconnected?(disconnected)
|
|
18
|
-
plan_action(
|
|
19
|
-
QueueForUploadJob,
|
|
20
|
-
base_folder,
|
|
21
|
-
ForemanInventoryUpload.facts_archive_name(organization_id, hosts_filter),
|
|
22
|
-
organization_id
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def rake_prefix
|
|
29
|
-
'foreman-' unless Rails.env.development?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def command
|
|
33
|
-
"#{rake_prefix}rake rh_cloud_inventory:report:generate"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def env
|
|
37
|
-
super.merge(
|
|
38
|
-
'target' => base_folder,
|
|
39
|
-
'organization_id' => organization_id,
|
|
40
|
-
'hosts_filter' => hosts_filter
|
|
41
|
-
)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def content_disconnected?(disconnected)
|
|
45
|
-
disconnected || !Setting[:subscription_connection_enabled]
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def base_folder
|
|
49
|
-
input[:base_folder]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def organization_id
|
|
53
|
-
input[:organization_id]
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def hosts_filter
|
|
57
|
-
input[:hosts_filter]
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module ForemanInventoryUpload
|
|
2
|
-
module Async
|
|
3
|
-
class ProgressOutput
|
|
4
|
-
def self.get(label)
|
|
5
|
-
ProgressOutput.new(label, :reader)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.register(label)
|
|
9
|
-
TaskOutputLine.where(label: @label).delete_all
|
|
10
|
-
ProgressOutput.new(label, :writer)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def initialize(label, mode)
|
|
14
|
-
@label = label
|
|
15
|
-
@mode = mode
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def full_output
|
|
19
|
-
TaskOutputLine.where(label: @label).order(:created_at).pluck(:line).join("\n")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def write_line(line)
|
|
23
|
-
TaskOutputLine.create!(label: @label, line: line)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def close
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def status
|
|
30
|
-
TaskOutputStatus.where(label: @label).pluck(:status).first || ''
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def status=(status)
|
|
34
|
-
TaskOutputStatus.upsert({ label: @label, status: status }, unique_by: :label)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
require 'open3'
|
|
2
|
-
|
|
3
|
-
module ForemanInventoryUpload
|
|
4
|
-
module Async
|
|
5
|
-
class ShellProcess < ::Actions::EntryAction
|
|
6
|
-
include AsyncHelpers
|
|
7
|
-
include ::ForemanRhCloud::Async::ExponentialBackoff
|
|
8
|
-
|
|
9
|
-
def plan(instance_label, more_inputs = {})
|
|
10
|
-
clear_task_output(instance_label)
|
|
11
|
-
inputs = more_inputs.merge(instance_label: instance_label)
|
|
12
|
-
plan_self(inputs)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def try_execute
|
|
16
|
-
klass_name = self.class.name
|
|
17
|
-
logger.debug("Starting #{klass_name} with label #{instance_label}")
|
|
18
|
-
progress_output do |progress_output|
|
|
19
|
-
Open3.popen2e(hash_to_s(env), *preprocess_command(command)) do |_stdin, stdout_stderr, wait_thread|
|
|
20
|
-
progress_output.status = "Running in pid #{wait_thread.pid}"
|
|
21
|
-
|
|
22
|
-
stdout_stderr.each do |out_line|
|
|
23
|
-
progress_output.write_line(out_line)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
progress_output.status = wait_thread.value.to_s
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
logger.debug("Finished job #{klass_name} with label #{instance_label}")
|
|
30
|
-
|
|
31
|
-
assert_task_status(ProgressOutput.get(instance_label).status)
|
|
32
|
-
done!
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def command
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def progress_output
|
|
39
|
-
progress_output = ProgressOutput.register(instance_label)
|
|
40
|
-
yield(progress_output)
|
|
41
|
-
ensure
|
|
42
|
-
progress_output.close
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def env
|
|
46
|
-
{}
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def logger
|
|
50
|
-
Foreman::Logging.logger('background')
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def rescue_strategy_for_self
|
|
54
|
-
Dynflow::Action::Rescue::Fail
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def clear_task_output(label)
|
|
58
|
-
TaskOutputLine.where(label: label).delete_all
|
|
59
|
-
TaskOutputStatus.where(label: label).delete_all
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
private
|
|
63
|
-
|
|
64
|
-
def preprocess_command(command)
|
|
65
|
-
command.kind_of?(Array) ? command : [command]
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def instance_label
|
|
69
|
-
input[:instance_label]
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def assert_task_status(status)
|
|
73
|
-
raise Foreman::Exception.new('Process exited with an unknown status: %{status}', status: status) unless status.match?(/pid \d+ exit 0/)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|