foreman-tasks 5.2.2 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby_tests.yml +7 -18
- data/.rubocop.yml +1 -0
- data/app/lib/actions/base.rb +1 -0
- data/app/lib/actions/foreman/host/import_facts.rb +1 -1
- data/app/lib/actions/helpers/lifecycle_logging.rb +1 -1
- data/app/lib/actions/middleware/rails_executor_wrap.rb +2 -2
- data/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb +18 -11
- data/app/lib/actions/proxy_action.rb +2 -2
- data/app/lib/actions/task_synchronization.rb +65 -0
- data/app/lib/actions/trigger_proxy_batch.rb +1 -1
- data/app/models/foreman_tasks/lock.rb +1 -1
- data/app/models/foreman_tasks/remote_task.rb +10 -3
- data/app/models/foreman_tasks/task/dynflow_task.rb +20 -21
- data/app/views/foreman_tasks/api/locks/show.json.rabl +4 -0
- data/config/routes.rb +1 -1
- data/db/migrate/20210708123832_add_parent_task_id_to_remote_tasks.foreman_tasks.rb +5 -0
- data/db/migrate/20211123170430_tasks_settings_to_dsl_category.rb +5 -0
- data/foreman-tasks.gemspec +1 -1
- data/lib/foreman_tasks/dynflow/configuration.rb +1 -6
- data/lib/foreman_tasks/dynflow.rb +1 -1
- data/lib/foreman_tasks/engine.rb +56 -9
- data/lib/foreman_tasks/test_helpers.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +2 -3
- data/locale/en/foreman_tasks.po +27 -3
- data/locale/foreman_tasks.pot +230 -176
- data/locale/fr/foreman_tasks.po +27 -3
- data/locale/ja/foreman_tasks.po +27 -3
- data/locale/zh_CN/foreman_tasks.po +27 -3
- data/test/controllers/api/tasks_controller_test.rb +1 -2
- data/test/factories/task_factory.rb +1 -1
- data/test/lib/actions/middleware/keep_current_taxonomies_test.rb +9 -1
- data/test/support/dummy_dynflow_action.rb +1 -1
- data/test/support/dummy_proxy_action.rb +1 -1
- data/test/unit/actions/proxy_action_test.rb +19 -13
- data/test/unit/actions/trigger_proxy_batch_test.rb +0 -1
- data/test/unit/troubleshooting_help_generator_test.rb +0 -1
- data/test/unit/ui_notifications_test.rb +0 -1
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +1 -1
- data/webpack/ForemanTasks/Components/TaskActions/index.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Locks.js +28 -14
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Locks.test.js.snap +50 -42
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +2 -28
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +5 -9
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +1 -5
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +2 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +1 -4
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +1 -6
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +1 -6
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTable.test.js.snap +2 -22
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +2 -12
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +1 -4
- data/webpack/ForemanTasks/Components/TasksTable/index.js +2 -2
- data/webpack/__mocks__/foremanReact/components/Pagination/index.js +2 -0
- data/webpack/__mocks__/foremanReact/{redux/actions/toasts.js → components/ToastsList/index.js} +0 -0
- metadata +8 -7
- data/app/models/setting/foreman_tasks.rb +0 -29
- data/lib/foreman_tasks/dynflow/persistence.rb +0 -46
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +0 -2
@@ -4,7 +4,7 @@ import { Table } from 'foremanReact/components/common/table';
|
|
4
4
|
import { STATUS } from 'foremanReact/constants';
|
5
5
|
import MessageBox from 'foremanReact/components/common/MessageBox';
|
6
6
|
import { translate as __ } from 'foremanReact/common/I18n';
|
7
|
-
import Pagination from 'foremanReact/components/Pagination
|
7
|
+
import Pagination from 'foremanReact/components/Pagination';
|
8
8
|
import { getURIQuery } from 'foremanReact/common/helpers';
|
9
9
|
import createTasksTableSchema from './TasksTableSchema';
|
10
10
|
import { updateURlQuery } from './TasksTableHelpers';
|
@@ -18,7 +18,6 @@ const TasksTable = ({
|
|
18
18
|
results,
|
19
19
|
history,
|
20
20
|
itemCount,
|
21
|
-
pagination,
|
22
21
|
selectedRows,
|
23
22
|
selectPage,
|
24
23
|
unselectAllRows,
|
@@ -82,16 +81,6 @@ const TasksTable = ({
|
|
82
81
|
return <span>{__('No Tasks')}</span>;
|
83
82
|
}
|
84
83
|
|
85
|
-
const changeTablePage = ({ page, perPage }) => {
|
86
|
-
updateURlQuery(
|
87
|
-
{
|
88
|
-
page,
|
89
|
-
per_page: perPage,
|
90
|
-
},
|
91
|
-
history
|
92
|
-
);
|
93
|
-
};
|
94
|
-
|
95
84
|
const setSortHistory = (by, order) => {
|
96
85
|
updateURlQuery({ sort_by: by, sort_order: order }, history);
|
97
86
|
};
|
@@ -133,14 +122,7 @@ const TasksTable = ({
|
|
133
122
|
)}
|
134
123
|
rows={results}
|
135
124
|
/>
|
136
|
-
<Pagination
|
137
|
-
className="tasks-pagination"
|
138
|
-
viewType="table"
|
139
|
-
itemCount={itemCount}
|
140
|
-
pagination={pagination}
|
141
|
-
onChange={changeTablePage}
|
142
|
-
dropdownButtonId="tasks-table-dropdown"
|
143
|
-
/>
|
125
|
+
<Pagination itemCount={itemCount} />
|
144
126
|
</div>
|
145
127
|
);
|
146
128
|
};
|
@@ -151,10 +133,6 @@ TasksTable.propTypes = {
|
|
151
133
|
status: PropTypes.oneOf(Object.keys(STATUS)),
|
152
134
|
error: PropTypes.instanceOf(Error),
|
153
135
|
itemCount: PropTypes.number.isRequired,
|
154
|
-
pagination: PropTypes.shape({
|
155
|
-
page: PropTypes.number,
|
156
|
-
perPage: PropTypes.number,
|
157
|
-
}),
|
158
136
|
history: PropTypes.object.isRequired,
|
159
137
|
openClickedModal: PropTypes.func.isRequired,
|
160
138
|
selectedRows: PropTypes.array,
|
@@ -172,10 +150,6 @@ TasksTable.propTypes = {
|
|
172
150
|
TasksTable.defaultProps = {
|
173
151
|
status: STATUS.PENDING,
|
174
152
|
error: null,
|
175
|
-
pagination: {
|
176
|
-
page: 1,
|
177
|
-
perPage: 20,
|
178
|
-
},
|
179
153
|
selectedRows: [],
|
180
154
|
allRowsSelected: false,
|
181
155
|
permissions: {
|
@@ -99,10 +99,10 @@ const TasksTablePage = ({
|
|
99
99
|
<React.Fragment>
|
100
100
|
{props.permissions.edit &&
|
101
101
|
showSelectAll &&
|
102
|
-
props.itemCount >= props.
|
102
|
+
props.itemCount >= props.perPage && (
|
103
103
|
<SelectAllAlert
|
104
104
|
itemCount={props.itemCount}
|
105
|
-
perPage={props.
|
105
|
+
perPage={props.perPage}
|
106
106
|
selectAllRows={selectAllRows}
|
107
107
|
unselectAllRows={props.unselectAllRows}
|
108
108
|
allRowsSelected={props.allRowsSelected}
|
@@ -118,9 +118,8 @@ const TasksTablePage = ({
|
|
118
118
|
TasksTablePage.propTypes = {
|
119
119
|
allRowsSelected: PropTypes.bool,
|
120
120
|
itemCount: PropTypes.number.isRequired,
|
121
|
-
|
122
|
-
|
123
|
-
}),
|
121
|
+
perPage: PropTypes.number,
|
122
|
+
|
124
123
|
selectAllRows: PropTypes.func.isRequired,
|
125
124
|
results: PropTypes.array.isRequired,
|
126
125
|
getTableItems: PropTypes.func.isRequired,
|
@@ -142,10 +141,7 @@ TasksTablePage.propTypes = {
|
|
142
141
|
};
|
143
142
|
|
144
143
|
TasksTablePage.defaultProps = {
|
145
|
-
|
146
|
-
page: 1,
|
147
|
-
perPage: 20,
|
148
|
-
},
|
144
|
+
perPage: 20,
|
149
145
|
allRowsSelected: false,
|
150
146
|
actionName: '',
|
151
147
|
status: STATUS.PENDING,
|
@@ -21,7 +21,6 @@ export const TasksTableQueryReducer = (state = initialState, action) => {
|
|
21
21
|
const { type, payload, response } = action;
|
22
22
|
const {
|
23
23
|
subtotal,
|
24
|
-
page,
|
25
24
|
per_page: perPageString,
|
26
25
|
action_name: actionName,
|
27
26
|
can_edit: canEdit,
|
@@ -34,10 +33,7 @@ export const TasksTableQueryReducer = (state = initialState, action) => {
|
|
34
33
|
return Immutable.merge(state, {
|
35
34
|
itemCount: subtotal,
|
36
35
|
actionName,
|
37
|
-
|
38
|
-
page: Number(page),
|
39
|
-
perPage: Number(perPageString),
|
40
|
-
},
|
36
|
+
perPage: Number(perPageString),
|
41
37
|
selectedRows: [],
|
42
38
|
permissions: {
|
43
39
|
edit: canEdit,
|
@@ -12,8 +12,8 @@ export const selectTasksTableContent = state =>
|
|
12
12
|
export const selectTasksTableQuery = state =>
|
13
13
|
selectTasksTable(state).tasksTableQuery || {};
|
14
14
|
|
15
|
-
export const
|
16
|
-
selectTasksTableQuery(state).
|
15
|
+
export const selectPerPage = state =>
|
16
|
+
selectTasksTableQuery(state).perPage || 20;
|
17
17
|
|
18
18
|
export const selectItemCount = state =>
|
19
19
|
selectTasksTableQuery(state).itemCount || 0;
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap
CHANGED
@@ -23,13 +23,8 @@ exports[`SubTasksPage rendering render with minimal props 1`] = `
|
|
23
23
|
openClickedModal={[MockFunction]}
|
24
24
|
openModal={[MockFunction]}
|
25
25
|
openModalAction={[MockFunction]}
|
26
|
-
pagination={
|
27
|
-
Object {
|
28
|
-
"page": 1,
|
29
|
-
"perPage": 10,
|
30
|
-
}
|
31
|
-
}
|
32
26
|
parentTaskID="some-id"
|
27
|
+
perPage={10}
|
33
28
|
reloadPage={[MockFunction]}
|
34
29
|
results={
|
35
30
|
Array [
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap
CHANGED
@@ -15,12 +15,7 @@ exports[`TasksIndexPage rendering render with minimal props 1`] = `
|
|
15
15
|
openClickedModal={[MockFunction]}
|
16
16
|
openModal={[MockFunction]}
|
17
17
|
openModalAction={[MockFunction]}
|
18
|
-
|
19
|
-
Object {
|
20
|
-
"page": 1,
|
21
|
-
"perPage": 10,
|
22
|
-
}
|
23
|
-
}
|
18
|
+
perPage={10}
|
24
19
|
reloadPage={[MockFunction]}
|
25
20
|
results={
|
26
21
|
Array [
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTable.test.js.snap
CHANGED
@@ -20,18 +20,8 @@ exports[`TasksTable rendering render with loading Props 1`] = `
|
|
20
20
|
]
|
21
21
|
}
|
22
22
|
/>
|
23
|
-
<
|
24
|
-
className="tasks-pagination"
|
25
|
-
dropdownButtonId="tasks-table-dropdown"
|
23
|
+
<Pagination
|
26
24
|
itemCount={2}
|
27
|
-
onChange={[Function]}
|
28
|
-
pagination={
|
29
|
-
Object {
|
30
|
-
"page": 1,
|
31
|
-
"perPage": 10,
|
32
|
-
}
|
33
|
-
}
|
34
|
-
viewType="table"
|
35
25
|
/>
|
36
26
|
</div>
|
37
27
|
`;
|
@@ -49,18 +39,8 @@ exports[`TasksTable rendering render with minimal Props 1`] = `
|
|
49
39
|
]
|
50
40
|
}
|
51
41
|
/>
|
52
|
-
<
|
53
|
-
className="tasks-pagination"
|
54
|
-
dropdownButtonId="tasks-table-dropdown"
|
42
|
+
<Pagination
|
55
43
|
itemCount={2}
|
56
|
-
onChange={[Function]}
|
57
|
-
pagination={
|
58
|
-
Object {
|
59
|
-
"page": 1,
|
60
|
-
"perPage": 10,
|
61
|
-
}
|
62
|
-
}
|
63
|
-
viewType="table"
|
64
44
|
/>
|
65
45
|
</div>
|
66
46
|
`;
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap
CHANGED
@@ -119,13 +119,8 @@ exports[`TasksTablePage rendering render with Breadcrubs and edit permissions 1`
|
|
119
119
|
itemCount={2}
|
120
120
|
openClickedModal={[MockFunction]}
|
121
121
|
openModal={[Function]}
|
122
|
-
pagination={
|
123
|
-
Object {
|
124
|
-
"page": 1,
|
125
|
-
"perPage": 10,
|
126
|
-
}
|
127
|
-
}
|
128
122
|
parentTaskID={null}
|
123
|
+
perPage={10}
|
129
124
|
permissions={
|
130
125
|
Object {
|
131
126
|
"edit": false,
|
@@ -259,13 +254,8 @@ exports[`TasksTablePage rendering render with minimal props 1`] = `
|
|
259
254
|
itemCount={2}
|
260
255
|
openClickedModal={[MockFunction]}
|
261
256
|
openModal={[Function]}
|
262
|
-
pagination={
|
263
|
-
Object {
|
264
|
-
"page": 1,
|
265
|
-
"perPage": 10,
|
266
|
-
}
|
267
|
-
}
|
268
257
|
parentTaskID={null}
|
258
|
+
perPage={10}
|
269
259
|
permissions={
|
270
260
|
Object {
|
271
261
|
"edit": false,
|
@@ -8,7 +8,7 @@ import {
|
|
8
8
|
selectStatus,
|
9
9
|
selectError,
|
10
10
|
selectResults,
|
11
|
-
|
11
|
+
selectPerPage,
|
12
12
|
selectItemCount,
|
13
13
|
selectSort,
|
14
14
|
selectActionName,
|
@@ -24,7 +24,7 @@ const mapStateToProps = state => ({
|
|
24
24
|
error: selectError(state),
|
25
25
|
sort: selectSort(state),
|
26
26
|
results: selectResults(state),
|
27
|
-
|
27
|
+
perPage: selectPerPage(state),
|
28
28
|
itemCount: selectItemCount(state),
|
29
29
|
actionName: selectActionName(state),
|
30
30
|
selectedRows: selectSelectedRows(state),
|
data/webpack/__mocks__/foremanReact/{redux/actions/toasts.js → components/ToastsList/index.js}
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: get_process_mem
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- app/lib/actions/proxy_action.rb
|
167
167
|
- app/lib/actions/recurring_action.rb
|
168
168
|
- app/lib/actions/serializers/active_record_serializer.rb
|
169
|
+
- app/lib/actions/task_synchronization.rb
|
169
170
|
- app/lib/actions/trigger_proxy_batch.rb
|
170
171
|
- app/lib/foreman_tasks/concerns/polling_action_extensions.rb
|
171
172
|
- app/lib/proxy_api/foreman_dynflow/dynflow_proxy.rb
|
@@ -188,7 +189,6 @@ files:
|
|
188
189
|
- app/models/foreman_tasks/task_group_member.rb
|
189
190
|
- app/models/foreman_tasks/task_groups/recurring_logic_task_group.rb
|
190
191
|
- app/models/foreman_tasks/triggering.rb
|
191
|
-
- app/models/setting/foreman_tasks.rb
|
192
192
|
- app/services/foreman_tasks/proxy_selector.rb
|
193
193
|
- app/services/foreman_tasks/troubleshooting_help_generator.rb
|
194
194
|
- app/services/ui_notifications/tasks.rb
|
@@ -250,7 +250,9 @@ files:
|
|
250
250
|
- db/migrate/20200517215015_rename_bookmarks_controller.rb
|
251
251
|
- db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb
|
252
252
|
- db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb
|
253
|
+
- db/migrate/20210708123832_add_parent_task_id_to_remote_tasks.foreman_tasks.rb
|
253
254
|
- db/migrate/20210720115251_add_purpose_to_recurring_logic.rb
|
255
|
+
- db/migrate/20211123170430_tasks_settings_to_dsl_category.rb
|
254
256
|
- db/seeds.d/20-foreman_tasks_permissions.rb
|
255
257
|
- db/seeds.d/30-notification_blueprints.rb
|
256
258
|
- db/seeds.d/60-dynflow_proxy_feature.rb
|
@@ -271,7 +273,6 @@ files:
|
|
271
273
|
- lib/foreman_tasks/dynflow.rb
|
272
274
|
- lib/foreman_tasks/dynflow/configuration.rb
|
273
275
|
- lib/foreman_tasks/dynflow/console_authorizer.rb
|
274
|
-
- lib/foreman_tasks/dynflow/persistence.rb
|
275
276
|
- lib/foreman_tasks/engine.rb
|
276
277
|
- lib/foreman_tasks/task_error.rb
|
277
278
|
- lib/foreman_tasks/tasks/cleanup.rake
|
@@ -571,7 +572,8 @@ files:
|
|
571
572
|
- webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js
|
572
573
|
- webpack/__mocks__/foremanReact/components/ForemanModal/index.js
|
573
574
|
- webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js
|
574
|
-
- webpack/__mocks__/foremanReact/components/Pagination/
|
575
|
+
- webpack/__mocks__/foremanReact/components/Pagination/index.js
|
576
|
+
- webpack/__mocks__/foremanReact/components/ToastsList/index.js
|
575
577
|
- webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js
|
576
578
|
- webpack/__mocks__/foremanReact/components/common/MessageBox.js
|
577
579
|
- webpack/__mocks__/foremanReact/components/common/dates/LongDateTime.js
|
@@ -581,7 +583,6 @@ files:
|
|
581
583
|
- webpack/__mocks__/foremanReact/constants.js
|
582
584
|
- webpack/__mocks__/foremanReact/redux/API/APISelectors.js
|
583
585
|
- webpack/__mocks__/foremanReact/redux/API/index.js
|
584
|
-
- webpack/__mocks__/foremanReact/redux/actions/toasts.js
|
585
586
|
- webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js
|
586
587
|
- webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js
|
587
588
|
- webpack/__mocks__/foremanReact/routes/common/PageLayout/components/ExportButton/ExportButton.js
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class Setting::ForemanTasks < Setting
|
2
|
-
def self.default_settings
|
3
|
-
[
|
4
|
-
set('foreman_tasks_sync_task_timeout', N_('Number of seconds to wait for synchronous task to finish.'), 120, N_('Sync task timeout')),
|
5
|
-
set('dynflow_enable_console', N_('Enable the dynflow console (/foreman_tasks/dynflow) for debugging'), true, N_('Enable dynflow console')),
|
6
|
-
set('dynflow_console_require_auth', N_('Require user to be authenticated as user with admin rights when accessing dynflow console'), true, N_('Require auth for dynflow console')),
|
7
|
-
set('foreman_tasks_proxy_action_retry_count', N_('Number of attempts to start a task on the smart proxy before failing'), 4, N_('Proxy action retry count')),
|
8
|
-
set('foreman_tasks_proxy_action_retry_interval', N_('Time in seconds between retries'), 15, N_('Proxy action retry interval')),
|
9
|
-
set('foreman_tasks_proxy_batch_trigger', N_('Allow triggering tasks on the smart proxy in batches'), true, N_('Allow proxy batch tasks')),
|
10
|
-
set('foreman_tasks_proxy_batch_size', N_('Number of tasks which should be sent to the smart proxy in one request, if foreman_tasks_proxy_batch_trigger is enabled'), 100, N_('Proxy tasks batch size')),
|
11
|
-
set('foreman_tasks_troubleshooting_url',
|
12
|
-
N_('Url pointing to the task troubleshooting documentation. '\
|
13
|
-
'It should contain %{label} placeholder, that will be replaced with normalized task label '\
|
14
|
-
'(restricted to only alphanumeric characters)). %{version} placeholder is also available.'),
|
15
|
-
nil, N_('Tasks troubleshooting URL')),
|
16
|
-
set('foreman_tasks_polling_multiplier',
|
17
|
-
N_('Polling multiplier which is used to multiply the default polling intervals. '\
|
18
|
-
'This can be used to prevent polling too frequently for long running tasks.'),
|
19
|
-
1,
|
20
|
-
N_("Polling intervals multiplier")),
|
21
|
-
]
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.load_defaults
|
25
|
-
Setting::BLANK_ATTRS.push('foreman_tasks_troubleshooting_url')
|
26
|
-
Setting::NONZERO_ATTRS.push('foreman_tasks_polling_multiplier')
|
27
|
-
super
|
28
|
-
end
|
29
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module ForemanTasks
|
2
|
-
# Wrap the Dynflow persistence to reflect the changes to execution plan
|
3
|
-
# in the Task model. This is probably a temporary solution and
|
4
|
-
# Dynflow will probably get more events-based API but it should be enought
|
5
|
-
# for start, until the requiements on the API are clear enough.
|
6
|
-
class Dynflow::Persistence < ::Dynflow::PersistenceAdapters::Sequel
|
7
|
-
def save_execution_plan(execution_plan_id, value)
|
8
|
-
# clear connection only if not running in some active record transaction already
|
9
|
-
clear_connections = ActiveRecord::Base.connection.open_transactions.zero?
|
10
|
-
super.tap do
|
11
|
-
on_execution_plan_save(execution_plan_id, value)
|
12
|
-
rescue => e
|
13
|
-
Foreman::Logging.exception('Error on on_execution_plan_save event', e,
|
14
|
-
:logger => 'dynflow')
|
15
|
-
end
|
16
|
-
ensure
|
17
|
-
::ActiveRecord::Base.clear_active_connections! if clear_connections
|
18
|
-
end
|
19
|
-
|
20
|
-
def on_execution_plan_save(execution_plan_id, data)
|
21
|
-
# We can load the data unless the execution plan was properly planned and saved
|
22
|
-
# including its steps
|
23
|
-
case data[:state]
|
24
|
-
when :pending
|
25
|
-
task = ForemanTasks::Task::DynflowTask.new_for_execution_plan(execution_plan_id, data)
|
26
|
-
task.start_at ||= Time.zone.now
|
27
|
-
task.save!
|
28
|
-
when :scheduled
|
29
|
-
delayed_plan = load_delayed_plan(execution_plan_id)
|
30
|
-
raise Foreman::Exception, 'Plan is delayed but the delay record is missing' if delayed_plan.nil?
|
31
|
-
task = ::ForemanTasks::Task::DynflowTask.find_by!(:external_id => execution_plan_id)
|
32
|
-
task.update_from_dynflow(data.merge(:start_at => delayed_plan[:start_at],
|
33
|
-
:start_before => delayed_plan[:start_before]))
|
34
|
-
when :planning
|
35
|
-
task = ::ForemanTasks::Task::DynflowTask.where(:external_id => execution_plan_id).first
|
36
|
-
task.update_from_dynflow(data)
|
37
|
-
else
|
38
|
-
if (task = ::ForemanTasks::Task::DynflowTask.where(:external_id => execution_plan_id).first)
|
39
|
-
unless task.state.to_s == data[:state].to_s
|
40
|
-
task.update_from_dynflow(data)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|