foreman_remote_execution 6.2.0 → 7.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_ci.yml +2 -0
  3. data/app/controllers/api/v2/job_invocations_controller.rb +1 -0
  4. data/app/helpers/hosts_extensions_helper.rb +62 -0
  5. data/app/lib/actions/remote_execution/run_host_job.rb +4 -0
  6. data/app/lib/actions/remote_execution/run_hosts_job.rb +4 -0
  7. data/app/models/concerns/foreman_remote_execution/foreman_tasks_task_extensions.rb +6 -0
  8. data/app/models/host_status/execution_status.rb +2 -1
  9. data/app/models/job_invocation.rb +1 -1
  10. data/app/models/job_invocation_composer.rb +7 -3
  11. data/app/models/job_template.rb +6 -1
  12. data/app/models/remote_execution_provider.rb +4 -0
  13. data/app/models/ssh_execution_provider.rb +3 -3
  14. data/app/models/template_invocation.rb +2 -0
  15. data/app/services/remote_execution_proxy_selector.rb +1 -1
  16. data/app/views/api/v2/job_invocations/base.json.rabl +1 -1
  17. data/app/views/job_invocations/_card_target_hosts.html.erb +8 -0
  18. data/app/views/job_invocations/_form.html.erb +2 -0
  19. data/app/views/overrides/subnets/_rex_tab_pane.html.erb +1 -1
  20. data/db/migrate/20220331112719_add_ssh_user_to_job_invocation.rb +5 -0
  21. data/lib/foreman_remote_execution/engine.rb +6 -3
  22. data/lib/foreman_remote_execution/version.rb +1 -1
  23. data/locale/action_names.rb +3 -3
  24. data/locale/de/foreman_remote_execution.po +23 -23
  25. data/locale/en/foreman_remote_execution.po +23 -23
  26. data/locale/en_GB/foreman_remote_execution.po +23 -23
  27. data/locale/es/foreman_remote_execution.po +23 -23
  28. data/locale/foreman_remote_execution.pot +64 -66
  29. data/locale/fr/foreman_remote_execution.po +23 -23
  30. data/locale/ja/foreman_remote_execution.po +23 -23
  31. data/locale/ko/foreman_remote_execution.po +23 -23
  32. data/locale/pt_BR/foreman_remote_execution.po +23 -23
  33. data/locale/ru/foreman_remote_execution.po +23 -23
  34. data/locale/zh_CN/foreman_remote_execution.po +23 -23
  35. data/locale/zh_TW/foreman_remote_execution.po +23 -23
  36. data/test/unit/api_params_test.rb +33 -0
  37. data/test/unit/remote_execution_provider_test.rb +26 -0
  38. data/webpack/JobWizard/JobWizardConstants.js +2 -2
  39. data/webpack/JobWizard/__tests__/fixtures.js +8 -4
  40. data/webpack/JobWizard/steps/AdvancedFields/AdvancedFields.js +9 -0
  41. data/webpack/JobWizard/steps/AdvancedFields/Fields.js +21 -0
  42. data/webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js +7 -2
  43. data/webpack/JobWizard/steps/HostsAndInputs/SelectGQL.js +2 -1
  44. data/webpack/JobWizard/steps/HostsAndInputs/SelectedChips.js +1 -1
  45. data/webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js +1 -1
  46. data/webpack/JobWizard/steps/HostsAndInputs/hostgroups.gql +1 -0
  47. data/webpack/JobWizard/steps/HostsAndInputs/hosts.gql +1 -0
  48. data/webpack/JobWizard/steps/ReviewDetails/index.js +2 -1
  49. data/webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js +15 -15
  50. data/webpack/JobWizard/steps/form/SearchSelect.js +0 -1
  51. data/webpack/JobWizard/submit.js +2 -0
  52. data/webpack/__mocks__/foremanReact/common/globalIdHelpers.js +1 -0
  53. data/webpack/global_index.js +2 -8
  54. data/webpack/react_app/components/FeaturesDropdown/index.js +1 -1
  55. data/webpack/react_app/components/HostKebab/KebabItems.js +6 -1
  56. data/webpack/react_app/components/RecentJobsCard/RecentJobsCard.js +4 -4
  57. data/webpack/react_app/components/TargetingHosts/TargetingHostsConsts.js +1 -0
  58. data/webpack/react_app/components/TargetingHosts/TargetingHostsPage.js +8 -3
  59. data/webpack/react_app/components/TargetingHosts/__tests__/__snapshots__/TargetingHostsPage.test.js.snap +9 -1
  60. data/webpack/react_app/components/TargetingHosts/__tests__/fixtures.js +1 -4
  61. data/webpack/react_app/components/TargetingHosts/index.js +1 -0
  62. data/webpack/react_app/extend/Fills.js +48 -0
  63. metadata +9 -8
  64. data/app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb +0 -62
  65. data/webpack/react_app/extend/fillKebabItems.js +0 -11
  66. data/webpack/react_app/extend/fillRecentJobsCard.js +0 -11
  67. data/webpack/react_app/extend/fillRexFeaturesDropdown.js +0 -11
  68. data/webpack/react_app/extend/fillregistrationAdvanced.js +0 -11
@@ -7,6 +7,7 @@ import Pagination from 'foremanReact/components/Pagination';
7
7
  import { getControllerSearchProps } from 'foremanReact/constants';
8
8
 
9
9
  import TargetingHosts from './TargetingHosts';
10
+ import { TARGETING_HOSTS_AUTOCOMPLETE } from './TargetingHostsConsts';
10
11
  import './TargetingHostsPage.scss';
11
12
 
12
13
  const TargetingHostsPage = ({
@@ -16,6 +17,7 @@ const TargetingHostsPage = ({
16
17
  items,
17
18
  totalHosts,
18
19
  handlePagination,
20
+ page,
19
21
  }) => (
20
22
  <div id="targeting_hosts">
21
23
  <Grid.Row>
@@ -23,24 +25,26 @@ const TargetingHostsPage = ({
23
25
  <SearchBar
24
26
  onSearch={query => handleSearch(query)}
25
27
  data={{
26
- ...getControllerSearchProps('hosts'),
28
+ ...getControllerSearchProps('hosts', TARGETING_HOSTS_AUTOCOMPLETE),
27
29
  autocomplete: {
28
- id: 'targeting_hosts_search',
30
+ id: TARGETING_HOSTS_AUTOCOMPLETE,
29
31
  searchQuery,
30
32
  url: '/hosts/auto_complete_search',
31
33
  useKeyShortcuts: true,
32
34
  },
33
- bookmarks: {},
34
35
  }}
36
+ onBookmarkClick={handleSearch}
35
37
  />
36
38
  </Grid.Col>
37
39
  </Grid.Row>
38
40
  <br />
39
41
  <TargetingHosts apiStatus={apiStatus} items={items} />
40
42
  <Pagination
43
+ page={page}
41
44
  itemCount={totalHosts}
42
45
  onChange={args => handlePagination(args)}
43
46
  className="targeting-hosts-pagination"
47
+ updateParamsByUrl={false}
44
48
  />
45
49
  </div>
46
50
  );
@@ -52,6 +56,7 @@ TargetingHostsPage.propTypes = {
52
56
  items: PropTypes.array.isRequired,
53
57
  totalHosts: PropTypes.number.isRequired,
54
58
  handlePagination: PropTypes.func.isRequired,
59
+ page: PropTypes.number.isRequired,
55
60
  };
56
61
 
57
62
  TargetingHostsPage.defaultProps = {
@@ -23,10 +23,16 @@ exports[`TargetingHostsPage renders 1`] = `
23
23
  "url": "/hosts/auto_complete_search",
24
24
  "useKeyShortcuts": true,
25
25
  },
26
- "bookmarks": Object {},
26
+ "bookmarks": Object {
27
+ "canCreate": true,
28
+ "documentationUrl": "4.1.5Searching",
29
+ "id": "targeting_hosts_search",
30
+ "url": "/api/bookmarks",
31
+ },
27
32
  "controller": "hosts",
28
33
  }
29
34
  }
35
+ onBookmarkClick={[Function]}
30
36
  onChange={[Function]}
31
37
  onSearch={[Function]}
32
38
  />
@@ -56,6 +62,8 @@ exports[`TargetingHostsPage renders 1`] = `
56
62
  className="targeting-hosts-pagination"
57
63
  itemCount={1}
58
64
  onChange={[Function]}
65
+ page={1}
66
+ updateParamsByUrl={false}
59
67
  />
60
68
  </div>
61
69
  `;
@@ -50,10 +50,7 @@ export const TargetingHostsPageFixtures = {
50
50
  apiStatus: 'RESOLVED',
51
51
  items,
52
52
  totalHosts: 1,
53
- pagination: {
54
- page: 1,
55
- perPage: 20,
56
- },
53
+ page: 1,
57
54
  handlePagination: () => {},
58
55
  },
59
56
  };
@@ -89,6 +89,7 @@ const WrappedTargetingHosts = () => {
89
89
  items={items}
90
90
  totalHosts={totalHosts}
91
91
  handlePagination={handlePagination}
92
+ page={pagination.page}
92
93
  />
93
94
  );
94
95
  };
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
+
4
+ import FeaturesDropdown from '../components/FeaturesDropdown';
5
+ import RexInterface from '../components/RegistrationExtension/RexInterface';
6
+ import RecentJobsCard from '../components/RecentJobsCard';
7
+ import KebabItems from '../components/HostKebab/KebabItems';
8
+
9
+ const fills = [
10
+ {
11
+ slot: 'host-details-kebab',
12
+ name: 'kebab-items',
13
+ component: props => <KebabItems {...props} />,
14
+ weight: 500,
15
+ },
16
+ {
17
+ slot: 'host-overview-cards',
18
+ name: 'latest-jobs',
19
+ component: props => <RecentJobsCard {...props} />,
20
+ weight: 500,
21
+ },
22
+ {
23
+ slot: 'registrationAdvanced',
24
+ name: 'interface',
25
+ component: props => <RexInterface {...props} />,
26
+ weight: 500,
27
+ },
28
+ {
29
+ slot: '_rex-host-features',
30
+ name: '_rex-host-features',
31
+ component: props => <FeaturesDropdown {...props} />,
32
+ weight: 1000,
33
+ },
34
+ ];
35
+
36
+ const registerFills = () => {
37
+ fills.forEach(({ slot, id, component: Component, weight, metadata }) =>
38
+ addGlobalFill(
39
+ slot,
40
+ id,
41
+ <Component key={`rex-fill-${id}`} />,
42
+ weight,
43
+ metadata
44
+ )
45
+ );
46
+ };
47
+
48
+ export default registerFills;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-19 00:00:00.000000000 Z
11
+ date: 2022-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -142,8 +142,8 @@ files:
142
142
  - app/graphql/types/recurrence_input.rb
143
143
  - app/graphql/types/scheduling_input.rb
144
144
  - app/graphql/types/targeting_enum.rb
145
- - app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
146
145
  - app/helpers/concerns/foreman_remote_execution/job_templates_extensions.rb
146
+ - app/helpers/hosts_extensions_helper.rb
147
147
  - app/helpers/job_invocation_output_helper.rb
148
148
  - app/helpers/job_invocations_chart_helper.rb
149
149
  - app/helpers/job_invocations_helper.rb
@@ -323,6 +323,7 @@ files:
323
323
  - db/migrate/2021051713291621250977_add_host_proxy_invocations.rb
324
324
  - db/migrate/20210816100932_rex_setting_category_to_dsl.rb
325
325
  - db/migrate/20220321101835_rename_ssh_provider_to_script.rb
326
+ - db/migrate/20220331112719_add_ssh_user_to_job_invocation.rb
326
327
  - db/seeds.d/100-assign_features_with_templates.rb
327
328
  - db/seeds.d/20-permissions.rb
328
329
  - db/seeds.d/50-notification_blueprints.rb
@@ -388,6 +389,7 @@ files:
388
389
  - test/test_plugin_helper.rb
389
390
  - test/unit/actions/run_host_job_test.rb
390
391
  - test/unit/actions/run_hosts_job_test.rb
392
+ - test/unit/api_params_test.rb
391
393
  - test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
392
394
  - test/unit/concerns/host_extensions_test.rb
393
395
  - test/unit/concerns/nic_extensions_test.rb
@@ -462,6 +464,7 @@ files:
462
464
  - webpack/Routes/routes.js
463
465
  - webpack/__mocks__/foremanReact/Root/Context/ForemanContext/index.js
464
466
  - webpack/__mocks__/foremanReact/common/I18n.js
467
+ - webpack/__mocks__/foremanReact/common/globalIdHelpers.js
465
468
  - webpack/__mocks__/foremanReact/common/helpers.js
466
469
  - webpack/__mocks__/foremanReact/components/AutoComplete/AutoCompleteActions.js
467
470
  - webpack/__mocks__/foremanReact/components/AutoComplete/AutoCompleteConstants.js
@@ -514,10 +517,7 @@ files:
514
517
  - webpack/react_app/components/jobInvocations/AggregateStatus/index.js
515
518
  - webpack/react_app/components/jobInvocations/AggregateStatus/index.test.js
516
519
  - webpack/react_app/components/jobInvocations/index.js
517
- - webpack/react_app/extend/fillKebabItems.js
518
- - webpack/react_app/extend/fillRecentJobsCard.js
519
- - webpack/react_app/extend/fillRexFeaturesDropdown.js
520
- - webpack/react_app/extend/fillregistrationAdvanced.js
520
+ - webpack/react_app/extend/Fills.js
521
521
  - webpack/react_app/extend/reducers.js
522
522
  - webpack/react_app/redux/actions/jobInvocations/index.js
523
523
  - webpack/react_app/redux/consts.js
@@ -545,7 +545,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
545
545
  - !ruby/object:Gem::Version
546
546
  version: '0'
547
547
  requirements: []
548
- rubygems_version: 3.1.4
548
+ rubygems_version: 3.2.26
549
549
  signing_key:
550
550
  specification_version: 4
551
551
  summary: A plugin bringing remote execution to the Foreman, completing the config
@@ -572,6 +572,7 @@ test_files:
572
572
  - test/test_plugin_helper.rb
573
573
  - test/unit/actions/run_host_job_test.rb
574
574
  - test/unit/actions/run_hosts_job_test.rb
575
+ - test/unit/api_params_test.rb
575
576
  - test/unit/concerns/foreman_tasks_cleaner_extensions_test.rb
576
577
  - test/unit/concerns/host_extensions_test.rb
577
578
  - test/unit/concerns/nic_extensions_test.rb
@@ -1,62 +0,0 @@
1
- module ForemanRemoteExecution
2
- module HostsHelperExtensions
3
- def host_overview_buttons(host)
4
- [
5
- { :button => link_to_if_authorized(_("Jobs"), hash_for_job_invocations_path(search: "host=#{host.name}"), :title => _("Job invocations"), :class => 'btn btn-default'), :priority => 200 },
6
- ]
7
- end
8
-
9
- def multiple_actions
10
- res = super
11
- res += [ [_('Schedule Remote Job'), new_job_invocation_path, false] ] if can_schedule_jobs?
12
- res
13
- end
14
-
15
- def schedule_job_multi_button(*args)
16
- host_features = rex_host_features(*args)
17
-
18
- if host_features.present?
19
- action_buttons(schedule_job_button(*args), *host_features)
20
- else
21
- schedule_job_button(*args)
22
- end
23
- end
24
-
25
- def rex_host_features(host, *_rest)
26
- return [] unless can_execute_on_host?(host)
27
- RemoteExecutionFeature.with_host_action_button.order(:label).map do |feature|
28
- link_to(_('%s') % feature.name, job_invocations_path(:host_ids => [host.id], :feature => feature.label), :method => :post)
29
- end
30
- end
31
-
32
- def schedule_job_button(host, *_rest)
33
- return unless can_execute_on_host?(host)
34
- link_to(_('Schedule Remote Job'), new_job_invocation_path(:host_ids => [host.id]), :id => :run_button, :class => 'btn btn-default')
35
- end
36
-
37
- def web_console_button(host, *args)
38
- return if !authorized_for(permission: 'cockpit_hosts', auth_object: host) || !can_execute_on_infrastructure_host?(host)
39
-
40
- url = SSHExecutionProvider.cockpit_url_for_host(host.name)
41
- url ? link_to(_('Web Console'), url, :class => 'btn btn-default', :id => :'web-console-button', :target => '_new') : nil
42
- end
43
-
44
- def host_title_actions(*args)
45
- title_actions(button_group(schedule_job_multi_button(*args)),
46
- button_group(web_console_button(*args)))
47
- super(*args)
48
- end
49
-
50
- def can_schedule_jobs?
51
- authorized_for(controller: :job_invocations, action: :create)
52
- end
53
-
54
- def can_execute_on_host?(host)
55
- can_schedule_jobs? && can_execute_on_infrastructure_host?(host)
56
- end
57
-
58
- def can_execute_on_infrastructure_host?(host)
59
- !host.infrastructure_host? || User.current.can?(:execute_jobs_on_infrastructure_hosts)
60
- end
61
- end
62
- end
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
- import KebabItems from '../components/HostKebab/KebabItems';
4
-
5
- export default () =>
6
- addGlobalFill(
7
- 'host-details-kebab',
8
- 'rex-host-details-kebab-job',
9
- <KebabItems key="rex-host-details-kebab-job" />,
10
- 100
11
- );
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
- import RecentJobsCard from '../components/RecentJobsCard';
4
-
5
- export default () =>
6
- addGlobalFill(
7
- 'details-cards',
8
- 'rex-host-details-latest-jobs',
9
- <RecentJobsCard key="rex-host-details-latest-jobs" />,
10
- 1000
11
- );
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
- import FeaturesDropdown from '../components/FeaturesDropdown';
4
-
5
- export default () =>
6
- addGlobalFill(
7
- '_rex-host-features',
8
- '_rex-host-features',
9
- <FeaturesDropdown key="_rex-host-features" />,
10
- 1000
11
- );
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
- import RexInterface from '../components/RegistrationExtension/RexInterface';
4
-
5
- export default () =>
6
- addGlobalFill(
7
- 'registrationAdvanced',
8
- 'foreman-remote-exectuion-rex-interface',
9
- <RexInterface key="registration-rex-interface" />,
10
- 100
11
- );