foreman_openbolt 1.2.1 → 1.4.0

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -1
  3. data/app/controllers/api/v2/openbolt_jobs_controller.rb +78 -0
  4. data/app/controllers/api/v2/openbolt_tasks_controller.rb +85 -0
  5. data/app/controllers/concerns/foreman_openbolt/common.rb +121 -0
  6. data/app/controllers/concerns/foreman_openbolt/jobs.rb +85 -0
  7. data/app/controllers/concerns/foreman_openbolt/tasks.rb +143 -0
  8. data/app/controllers/foreman_openbolt/task_controller.rb +12 -291
  9. data/app/lib/actions/foreman_openbolt/cleanup_proxy_artifacts.rb +4 -2
  10. data/app/lib/actions/foreman_openbolt/poll_task_status.rb +48 -29
  11. data/app/models/foreman_openbolt/task_job.rb +11 -3
  12. data/config/routes.rb +39 -4
  13. data/db/migrate/20260824000000_remove_view_smart_proxies_openbolt_permission.rb +18 -0
  14. data/db/migrate/20261118000000_add_host_groups_to_openbolt_task_jobs.rb +7 -0
  15. data/lib/foreman_openbolt/engine.rb +15 -7
  16. data/lib/foreman_openbolt/version.rb +1 -1
  17. data/lib/proxy_api/openbolt.rb +64 -13
  18. data/package.json +1 -1
  19. data/test/acceptance/api_acceptance_helper.rb +109 -0
  20. data/test/acceptance/tests/api/authn_authz_test.rb +82 -0
  21. data/test/acceptance/tests/api/jobs_test.rb +77 -0
  22. data/test/acceptance/tests/api/launch_test.rb +79 -0
  23. data/test/acceptance/tests/api/proxy_tasks_test.rb +51 -0
  24. data/test/unit/controllers/api/v2/openbolt_jobs_controller_test.rb +251 -0
  25. data/test/unit/controllers/api/v2/openbolt_tasks_controller_test.rb +438 -0
  26. data/test/unit/controllers/task_controller_test.rb +197 -39
  27. data/test/unit/docker/Dockerfile +7 -0
  28. data/test/unit/lib/actions/poll_task_status_test.rb +112 -34
  29. data/test/unit/lib/proxy_api/openbolt_test.rb +121 -6
  30. data/test/unit/models/task_job_test.rb +13 -0
  31. data/webpack/src/Components/LaunchTask/HostSelector/index.js +31 -5
  32. data/webpack/src/Components/LaunchTask/__tests__/helpers.test.js +60 -0
  33. data/webpack/src/Components/LaunchTask/helpers.js +16 -0
  34. data/webpack/src/Components/LaunchTask/hooks/__tests__/useOpenBoltOptions.test.js +3 -0
  35. data/webpack/src/Components/LaunchTask/hooks/__tests__/useTasksData.test.js +5 -4
  36. data/webpack/src/Components/LaunchTask/hooks/useOpenBoltOptions.js +1 -1
  37. data/webpack/src/Components/LaunchTask/hooks/useTasksData.js +4 -1
  38. data/webpack/src/Components/LaunchTask/index.js +29 -13
  39. data/webpack/src/Components/TaskExecution/ExecutionDetails.js +8 -0
  40. data/webpack/src/Components/TaskExecution/ExecutionDisplay.js +4 -0
  41. data/webpack/src/Components/TaskExecution/__tests__/TaskExecution.test.js +1 -1
  42. data/webpack/src/Components/TaskExecution/hooks/__tests__/useJobPolling.test.js +8 -8
  43. data/webpack/src/Components/TaskExecution/hooks/useJobPolling.js +6 -3
  44. data/webpack/src/Components/TaskExecution/index.js +43 -7
  45. data/webpack/src/Components/TaskHistory/__tests__/TaskHistory.test.js +6 -6
  46. data/webpack/src/Components/TaskHistory/index.js +8 -3
  47. data/webpack/src/Components/common/HostGroupsPopover.js +53 -0
  48. data/webpack/src/Components/common/__tests__/HostGroupsPopover.test.js +20 -0
  49. metadata +22 -7
@@ -21,6 +21,7 @@ const useJobPolling = jobId => {
21
21
  const [taskDescription, setTaskDescription] = useState(null);
22
22
  const [taskParameters, setTaskParameters] = useState({});
23
23
  const [targets, setTargets] = useState([]);
24
+ const [hostGroups, setHostGroups] = useState([]);
24
25
  const [smartProxy, setSmartProxy] = useState(null);
25
26
  const metadataLoaded = useRef(false);
26
27
 
@@ -55,10 +56,11 @@ const useJobPolling = jobId => {
55
56
  // Task metadata only needs to be set once since it never changes
56
57
  if (!metadataLoaded.current) {
57
58
  setSubmittedAt(statusData.submitted_at || null);
58
- setTaskName(statusData.task_name || null);
59
- setTaskDescription(statusData.task_description || null);
60
- setTaskParameters(statusData.task_parameters || {});
59
+ setTaskName(statusData.name || null);
60
+ setTaskDescription(statusData.description || null);
61
+ setTaskParameters(statusData.parameters || {});
61
62
  setTargets(statusData.targets || []);
63
+ setHostGroups(statusData.host_groups || []);
62
64
  setSmartProxy(statusData.smart_proxy || null);
63
65
  metadataLoaded.current = true;
64
66
  }
@@ -136,6 +138,7 @@ const useJobPolling = jobId => {
136
138
  taskDescription,
137
139
  taskParameters,
138
140
  targets,
141
+ hostGroups,
139
142
  smartProxy,
140
143
  };
141
144
  };
@@ -1,7 +1,14 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { useLocation, useHistory } from 'react-router-dom';
3
3
  import { translate as __ } from 'foremanReact/common/I18n';
4
- import { Alert, Button, Stack, StackItem } from '@patternfly/react-core';
4
+ import {
5
+ Alert,
6
+ Button,
7
+ Flex,
8
+ FlexItem,
9
+ Stack,
10
+ StackItem,
11
+ } from '@patternfly/react-core';
5
12
 
6
13
  import ExecutionDisplay from './ExecutionDisplay';
7
14
  import LoadingIndicator from './LoadingIndicator';
@@ -29,6 +36,7 @@ const TaskExecution = () => {
29
36
  taskDescription,
30
37
  taskParameters,
31
38
  targets,
39
+ hostGroups,
32
40
  smartProxy,
33
41
  } = useJobPolling(jobId);
34
42
 
@@ -70,13 +78,40 @@ const TaskExecution = () => {
70
78
  return (
71
79
  <Stack hasGutter>
72
80
  <StackItem>
73
- <Button
74
- variant="secondary"
75
- onClick={() => history.push(ROUTES.PAGES.LAUNCH_TASK)}
76
- className="pf-v5-u-mb-md"
81
+ <Flex
82
+ alignItems={{ default: 'alignItemsCenter' }}
83
+ justifyContent={{ default: 'justifyContent' }}
77
84
  >
78
- {__('Run Another Task')}
79
- </Button>
85
+ <FlexItem>
86
+ <Button
87
+ variant="secondary"
88
+ onClick={() => history.push(ROUTES.PAGES.LAUNCH_TASK)}
89
+ className="pf-v5-u-mb-md"
90
+ >
91
+ {__('Run Another Task')}
92
+ </Button>
93
+ </FlexItem>
94
+ <FlexItem>
95
+ <Button
96
+ variant="secondary"
97
+ onClick={() =>
98
+ history.push({
99
+ pathname: ROUTES.PAGES.LAUNCH_TASK,
100
+ state: {
101
+ smartProxy,
102
+ taskName,
103
+ taskParameters,
104
+ targets,
105
+ hostGroups,
106
+ },
107
+ })
108
+ }
109
+ className="pf-v5-u-mb-md"
110
+ >
111
+ {__('Re-Run Task')}
112
+ </Button>
113
+ </FlexItem>
114
+ </Flex>
80
115
  </StackItem>
81
116
 
82
117
  <StackItem>
@@ -86,6 +121,7 @@ const TaskExecution = () => {
86
121
  jobStatus={jobStatus}
87
122
  isPolling={isPolling}
88
123
  targets={targets}
124
+ hostGroups={hostGroups}
89
125
  submittedAt={submittedAt}
90
126
  completedAt={completedAt}
91
127
  taskName={taskName}
@@ -18,9 +18,9 @@ afterEach(() => {
18
18
  const sampleJobs = [
19
19
  {
20
20
  job_id: 'job-1',
21
- task_name: 'mymod::install',
22
- task_description: 'Install a package',
23
- task_parameters: { name: 'nginx' },
21
+ name: 'mymod::install',
22
+ description: 'Install a package',
23
+ parameters: { name: 'nginx' },
24
24
  status: 'success',
25
25
  targets: ['host1.example.com'],
26
26
  submitted_at: '2026-01-15T10:00:00Z',
@@ -29,9 +29,9 @@ const sampleJobs = [
29
29
  },
30
30
  {
31
31
  job_id: 'job-2',
32
- task_name: 'mymod::mytask',
33
- task_description: 'Restart a service',
34
- task_parameters: {},
32
+ name: 'mymod::mytask',
33
+ description: 'Restart a service',
34
+ parameters: {},
35
35
  status: 'running',
36
36
  targets: ['host2.example.com'],
37
37
  submitted_at: '2026-01-15T11:00:00Z',
@@ -29,6 +29,7 @@ import {
29
29
  formatDate,
30
30
  } from '../common/helpers';
31
31
  import HostsPopover from '../common/HostsPopover';
32
+ import HostGroupsPopover from '../common/HostGroupsPopover';
32
33
  import TaskPopover from './TaskPopover';
33
34
 
34
35
  const getStatusLabel = status => {
@@ -127,6 +128,7 @@ const TaskHistory = () => {
127
128
  <Th modifier="wrap">{__('Task Name')}</Th>
128
129
  <Th modifier="wrap">{__('Status')}</Th>
129
130
  <Th modifier="wrap">{__('Targets')}</Th>
131
+ <Th modifier="wrap">{__('Host Groups')}</Th>
130
132
  <Th modifier="wrap">{__('Submitted')}</Th>
131
133
  <Th modifier="wrap">{__('Completed')}</Th>
132
134
  <Th modifier="wrap">{__('Duration')}</Th>
@@ -138,15 +140,18 @@ const TaskHistory = () => {
138
140
  <Tr key={job.job_id}>
139
141
  <Td hasRightBorder>
140
142
  <TaskPopover
141
- taskName={job.task_name}
142
- taskDescription={job.task_description}
143
- taskParameters={job.task_parameters}
143
+ taskName={job.name}
144
+ taskDescription={job.description}
145
+ taskParameters={job.parameters}
144
146
  />
145
147
  </Td>
146
148
  <Td hasRightBorder>{getStatusLabel(job.status)}</Td>
147
149
  <Td hasRightBorder>
148
150
  <HostsPopover targets={job.targets || []} />
149
151
  </Td>
152
+ <Td hasRightBorder>
153
+ <HostGroupsPopover hostGroups={job.host_groups || []} />
154
+ </Td>
150
155
  <Td hasRightBorder>{formatDate(job.submitted_at)}</Td>
151
156
  <Td hasRightBorder>
152
157
  {job.completed_at ? formatDate(job.completed_at) : ''}
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { sprintf, translate as __ } from 'foremanReact/common/I18n';
4
+ import { Popover, Button } from '@patternfly/react-core';
5
+ import { Table, Tbody, Tr, Td } from '@patternfly/react-table';
6
+
7
+ const HostGroupsPopover = ({ hostGroups }) => {
8
+ if (!hostGroups || hostGroups.length === 0) {
9
+ return <>{__('No host groups specified')}</>;
10
+ }
11
+
12
+ const popoverContent = (
13
+ <div
14
+ style={{
15
+ maxHeight: '300px',
16
+ overflowY: 'auto',
17
+ border: '1px solid var(--pf-v5-global--BorderColor--100)',
18
+ }}
19
+ >
20
+ <Table variant="compact" borders isStriped aria-label={__('Host groups')}>
21
+ <Tbody>
22
+ {hostGroups.map((hostGroup, index) => (
23
+ <Tr key={index}>
24
+ <Td className="pf-v5-u-font-family-monospace">{hostGroup}</Td>
25
+ </Tr>
26
+ ))}
27
+ </Tbody>
28
+ </Table>
29
+ </div>
30
+ );
31
+
32
+ return (
33
+ <Popover bodyContent={popoverContent} position="right" maxWidth="600px">
34
+ <Button
35
+ variant="link"
36
+ isInline
37
+ aria-label={sprintf(__('%s host groups'), hostGroups.length)}
38
+ >
39
+ {hostGroups.length}
40
+ </Button>
41
+ </Popover>
42
+ );
43
+ };
44
+
45
+ HostGroupsPopover.propTypes = {
46
+ hostGroups: PropTypes.arrayOf(PropTypes.string),
47
+ };
48
+
49
+ HostGroupsPopover.defaultProps = {
50
+ hostGroups: [],
51
+ };
52
+
53
+ export default HostGroupsPopover;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import HostGroupsPopover from '../HostGroupsPopover';
4
+
5
+ describe('HostGroupsPopover', () => {
6
+ test('shows "No host groups specified" when hostGroups is empty', () => {
7
+ render(<HostGroupsPopover hostGroups={[]} />);
8
+ expect(screen.getByText('No host groups specified')).toBeInTheDocument();
9
+ });
10
+
11
+ test('shows "No host groups specified" when hostGroups is not provided', () => {
12
+ render(<HostGroupsPopover />);
13
+ expect(screen.getByText('No host groups specified')).toBeInTheDocument();
14
+ });
15
+
16
+ test('shows host groups count as button when hostGroups exist', () => {
17
+ render(<HostGroupsPopover hostGroups={['webserver', 'nginx', 'php']} />);
18
+ expect(screen.getByText('3')).toBeInTheDocument();
19
+ });
20
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_openbolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Overlook InfraTech
@@ -18,7 +18,7 @@ dependencies:
18
18
  version: 11.0.0
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
- version: '14'
21
+ version: '15'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +28,7 @@ dependencies:
28
28
  version: 11.0.0
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
- version: '14'
31
+ version: '15'
32
32
  description: This plugin adds OpenBolt integration into Foreman, allowing users to
33
33
  run tasks and plans present in their environment.
34
34
  email:
@@ -40,6 +40,11 @@ files:
40
40
  - LICENSE
41
41
  - README.md
42
42
  - Rakefile
43
+ - app/controllers/api/v2/openbolt_jobs_controller.rb
44
+ - app/controllers/api/v2/openbolt_tasks_controller.rb
45
+ - app/controllers/concerns/foreman_openbolt/common.rb
46
+ - app/controllers/concerns/foreman_openbolt/jobs.rb
47
+ - app/controllers/concerns/foreman_openbolt/tasks.rb
43
48
  - app/controllers/foreman_openbolt/task_controller.rb
44
49
  - app/lib/actions/foreman_openbolt/cleanup_proxy_artifacts.rb
45
50
  - app/lib/actions/foreman_openbolt/poll_task_status.rb
@@ -49,6 +54,8 @@ files:
49
54
  - db/migrate/20250819000000_create_openbolt_task_jobs.rb
50
55
  - db/migrate/20250925000000_add_command_to_openbolt_task_jobs.rb
51
56
  - db/migrate/20251001000000_add_task_description_to_task_jobs.rb
57
+ - db/migrate/20260824000000_remove_view_smart_proxies_openbolt_permission.rb
58
+ - db/migrate/20261118000000_add_host_groups_to_openbolt_task_jobs.rb
52
59
  - db/seeds.d/001_add_openbolt_feature.rb
53
60
  - lib/foreman_openbolt.rb
54
61
  - lib/foreman_openbolt/engine.rb
@@ -61,6 +68,7 @@ files:
61
68
  - locale/gemspec.rb
62
69
  - package.json
63
70
  - test/acceptance/acceptance_helper.rb
71
+ - test/acceptance/api_acceptance_helper.rb
64
72
  - test/acceptance/docker/docker-compose.yml
65
73
  - test/acceptance/docker/foreman/Dockerfile
66
74
  - test/acceptance/docker/foreman/entrypoint.sh
@@ -79,6 +87,10 @@ files:
79
87
  - test/acceptance/fixtures/modules/acceptance/tasks/target_conditional.json
80
88
  - test/acceptance/fixtures/modules/acceptance/tasks/target_conditional.sh
81
89
  - test/acceptance/fixtures/openbolt.yml
90
+ - test/acceptance/tests/api/authn_authz_test.rb
91
+ - test/acceptance/tests/api/jobs_test.rb
92
+ - test/acceptance/tests/api/launch_test.rb
93
+ - test/acceptance/tests/api/proxy_tasks_test.rb
82
94
  - test/acceptance/tests/error_handling_test.rb
83
95
  - test/acceptance/tests/host_selector_test.rb
84
96
  - test/acceptance/tests/launch_task_test.rb
@@ -89,6 +101,8 @@ files:
89
101
  - test/acceptance/tests/task_history_test.rb
90
102
  - test/acceptance/tests/transport_options_test.rb
91
103
  - test/test_plugin_helper.rb
104
+ - test/unit/controllers/api/v2/openbolt_jobs_controller_test.rb
105
+ - test/unit/controllers/api/v2/openbolt_tasks_controller_test.rb
92
106
  - test/unit/controllers/task_controller_test.rb
93
107
  - test/unit/docker/Dockerfile
94
108
  - test/unit/docker/docker-compose.yml
@@ -122,6 +136,8 @@ files:
122
136
  - webpack/src/Components/LaunchTask/__tests__/ParametersSection.test.js
123
137
  - webpack/src/Components/LaunchTask/__tests__/SmartProxySelect.test.js
124
138
  - webpack/src/Components/LaunchTask/__tests__/TaskSelect.test.js
139
+ - webpack/src/Components/LaunchTask/__tests__/helpers.test.js
140
+ - webpack/src/Components/LaunchTask/helpers.js
125
141
  - webpack/src/Components/LaunchTask/hooks/__tests__/useOpenBoltOptions.test.js
126
142
  - webpack/src/Components/LaunchTask/hooks/__tests__/useSmartProxies.test.js
127
143
  - webpack/src/Components/LaunchTask/hooks/__tests__/useTasksData.test.js
@@ -147,7 +163,9 @@ files:
147
163
  - webpack/src/Components/TaskHistory/__tests__/TaskHistory.test.js
148
164
  - webpack/src/Components/TaskHistory/__tests__/TaskPopover.test.js
149
165
  - webpack/src/Components/TaskHistory/index.js
166
+ - webpack/src/Components/common/HostGroupsPopover.js
150
167
  - webpack/src/Components/common/HostsPopover.js
168
+ - webpack/src/Components/common/__tests__/HostGroupsPopover.test.js
151
169
  - webpack/src/Components/common/__tests__/HostsPopover.test.js
152
170
  - webpack/src/Components/common/__tests__/helpers.test.js
153
171
  - webpack/src/Components/common/constants.js
@@ -171,16 +189,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
189
  - - ">="
172
190
  - !ruby/object:Gem::Version
173
191
  version: '3.0'
174
- - - "<"
175
- - !ruby/object:Gem::Version
176
- version: '5'
177
192
  required_rubygems_version: !ruby/object:Gem::Requirement
178
193
  requirements:
179
194
  - - ">="
180
195
  - !ruby/object:Gem::Version
181
196
  version: '0'
182
197
  requirements: []
183
- rubygems_version: 4.0.10
198
+ rubygems_version: 4.0.20
184
199
  specification_version: 4
185
200
  summary: Foreman OpenBolt integration
186
201
  test_files: []