foreman_remote_execution 11.1.1 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.rubocop_todo.yml +0 -8
  4. data/.tx/config +2 -2
  5. data/app/assets/javascripts/foreman_remote_execution/locale/de/foreman_remote_execution.js +27 -21
  6. data/app/assets/javascripts/foreman_remote_execution/locale/en/foreman_remote_execution.js +24 -15
  7. data/app/assets/javascripts/foreman_remote_execution/locale/en_GB/foreman_remote_execution.js +27 -9
  8. data/app/assets/javascripts/foreman_remote_execution/locale/es/foreman_remote_execution.js +27 -24
  9. data/app/assets/javascripts/foreman_remote_execution/locale/fr/foreman_remote_execution.js +27 -24
  10. data/app/assets/javascripts/foreman_remote_execution/locale/ja/foreman_remote_execution.js +27 -24
  11. data/app/assets/javascripts/foreman_remote_execution/locale/ka/foreman_remote_execution.js +1587 -0
  12. data/app/assets/javascripts/foreman_remote_execution/locale/ko/foreman_remote_execution.js +27 -15
  13. data/app/assets/javascripts/foreman_remote_execution/locale/pt_BR/foreman_remote_execution.js +27 -24
  14. data/app/assets/javascripts/foreman_remote_execution/locale/ru/foreman_remote_execution.js +27 -15
  15. data/app/assets/javascripts/foreman_remote_execution/locale/zh_CN/foreman_remote_execution.js +27 -24
  16. data/app/assets/javascripts/foreman_remote_execution/locale/zh_TW/foreman_remote_execution.js +27 -15
  17. data/app/helpers/remote_execution_helper.rb +5 -0
  18. data/app/lib/actions/remote_execution/event_helpers.rb +42 -0
  19. data/app/lib/actions/remote_execution/run_host_job.rb +3 -16
  20. data/app/lib/actions/remote_execution/run_hosts_job.rb +7 -5
  21. data/app/models/concerns/api/v2/hosts_controller_extensions.rb +12 -0
  22. data/app/views/api/v2/job_invocations/base.json.rabl +14 -0
  23. data/config/routes.rb +2 -0
  24. data/db/migrate/20151215114631_add_host_id_to_template_invocation.rb +1 -1
  25. data/db/migrate/20151217092555_migrate_to_task_groups.rb +1 -1
  26. data/db/migrate/20160113162007_expand_all_template_invocations.rb +2 -2
  27. data/db/migrate/20160114125628_rename_job_name_to_job_category.rb +2 -2
  28. data/db/migrate/20200623073022_rename_sudo_password_to_effective_user_password.rb +2 -2
  29. data/db/migrate/20220321101835_rename_ssh_provider_to_script.rb +1 -1
  30. data/extra/cockpit/foreman-cockpit-session +1 -1
  31. data/foreman_remote_execution.gemspec +3 -1
  32. data/lib/foreman_remote_execution/engine.rb +12 -3
  33. data/lib/foreman_remote_execution/version.rb +1 -1
  34. data/locale/Makefile +3 -4
  35. data/locale/action_names.rb +0 -5
  36. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  37. data/locale/de/foreman_remote_execution.po +24 -15
  38. data/locale/en/foreman_remote_execution.po +24 -15
  39. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  40. data/locale/en_GB/foreman_remote_execution.po +24 -15
  41. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  42. data/locale/es/foreman_remote_execution.po +24 -15
  43. data/locale/foreman_remote_execution.pot +82 -69
  44. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  45. data/locale/fr/foreman_remote_execution.po +24 -15
  46. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  47. data/locale/ja/foreman_remote_execution.po +24 -15
  48. data/locale/ka/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  49. data/locale/ka/foreman_remote_execution.po +1576 -0
  50. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  51. data/locale/ko/foreman_remote_execution.po +24 -15
  52. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  53. data/locale/pt_BR/foreman_remote_execution.po +24 -15
  54. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  55. data/locale/ru/foreman_remote_execution.po +24 -15
  56. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  57. data/locale/zh_CN/foreman_remote_execution.po +24 -15
  58. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  59. data/locale/zh_TW/foreman_remote_execution.po +24 -15
  60. data/test/unit/actions/run_hosts_job_test.rb +1 -1
  61. data/test/unit/api_params_test.rb +2 -10
  62. data/webpack/JobInvocationDetail/JobInvocationActions.js +22 -0
  63. data/webpack/JobInvocationDetail/JobInvocationConstants.js +7 -0
  64. data/webpack/JobInvocationDetail/JobInvocationOverview.js +104 -0
  65. data/webpack/JobInvocationDetail/JobInvocationSelectors.js +5 -0
  66. data/webpack/JobInvocationDetail/index.js +77 -0
  67. data/webpack/JobWizard/JobWizardPageRerun.js +10 -25
  68. data/webpack/JobWizard/index.js +9 -18
  69. data/webpack/Routes/routes.js +6 -0
  70. data/webpack/react_app/components/FeaturesDropdown/actions.js +4 -2
  71. data/webpack/react_app/components/FeaturesDropdown/constants.js +5 -0
  72. data/webpack/react_app/components/FeaturesDropdown/index.js +53 -14
  73. data/webpack/react_app/components/FeaturesDropdown/index.scss +11 -0
  74. data/webpack/react_app/extend/Fills.js +6 -0
  75. metadata +24 -10
  76. data/webpack/react_app/components/FeaturesDropdown/constant.js +0 -3
  77. /data/test/graphql/mutations/job_invocations/{create.rb → create_test.rb} +0 -0
  78. /data/test/unit/{renderer_scope_input.rb → renderer_scope_input_test.rb} +0 -0
@@ -383,6 +383,12 @@
383
383
  "Try to abort the job without waiting for the results from the remote hosts": [
384
384
  ""
385
385
  ],
386
+ "New UI": [
387
+ ""
388
+ ],
389
+ "Switch to the new job invocation detail UI": [
390
+ ""
391
+ ],
386
392
  "Task Details": [
387
393
  "작업 자세히"
388
394
  ],
@@ -1095,6 +1101,9 @@
1095
1101
  "Job templates": [
1096
1102
  "작업 템플릿"
1097
1103
  ],
1104
+ "Job invocations detail": [
1105
+ ""
1106
+ ],
1098
1107
  "Run Puppet Once": [
1099
1108
  ""
1100
1109
  ],
@@ -1107,6 +1116,21 @@
1107
1116
  "Run a script": [
1108
1117
  ""
1109
1118
  ],
1119
+ "Not yet": [
1120
+ ""
1121
+ ],
1122
+ "Effective user:": [
1123
+ ""
1124
+ ],
1125
+ "Started at:": [
1126
+ ""
1127
+ ],
1128
+ "SSH user:": [
1129
+ ""
1130
+ ],
1131
+ "Template:": [
1132
+ ""
1133
+ ],
1110
1134
  "Submit": [
1111
1135
  ""
1112
1136
  ],
@@ -1545,29 +1569,17 @@
1545
1569
  "Active Filters:": [
1546
1570
  ""
1547
1571
  ],
1572
+ "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1573
+ "Foreman으로 원격 실행을 가져오는 플러그인입니다. 원격 관리 기능으로 구성 관리 기능을 완료합니다."
1574
+ ],
1548
1575
  "Action with sub plans": [
1549
1576
  "하위 계획이 있는 작업"
1550
1577
  ],
1551
- "Check for long running tasks": [
1552
- ""
1553
- ],
1554
- "Deliver notifications about long running tasks": [
1555
- ""
1556
- ],
1557
1578
  "Import Puppet classes": [
1558
1579
  "Puppet 클래스 가져오기"
1559
1580
  ],
1560
1581
  "Import facts": [
1561
1582
  "팩트 불러오기"
1562
- ],
1563
- "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1564
- "Foreman으로 원격 실행을 가져오는 플러그인입니다. 원격 관리 기능으로 구성 관리 기능을 완료합니다."
1565
- ],
1566
- "Distribute tasks over N seconds": [
1567
- "N초에 걸쳐 태스크 배분"
1568
- ],
1569
- "Time span": [
1570
- "기간"
1571
1583
  ]
1572
1584
  }
1573
1585
  }
@@ -383,6 +383,12 @@
383
383
  "Try to abort the job without waiting for the results from the remote hosts": [
384
384
  "Tente anular o trabalho sem esperar os resultados dos hosts remotos"
385
385
  ],
386
+ "New UI": [
387
+ ""
388
+ ],
389
+ "Switch to the new job invocation detail UI": [
390
+ ""
391
+ ],
386
392
  "Task Details": [
387
393
  "Detalhes da tarefa"
388
394
  ],
@@ -1097,6 +1103,9 @@
1097
1103
  "Job templates": [
1098
1104
  "Modelos de trabalho"
1099
1105
  ],
1106
+ "Job invocations detail": [
1107
+ ""
1108
+ ],
1100
1109
  "Run Puppet Once": [
1101
1110
  "Executar Puppet"
1102
1111
  ],
@@ -1109,6 +1118,21 @@
1109
1118
  "Run a script": [
1110
1119
  ""
1111
1120
  ],
1121
+ "Not yet": [
1122
+ ""
1123
+ ],
1124
+ "Effective user:": [
1125
+ ""
1126
+ ],
1127
+ "Started at:": [
1128
+ ""
1129
+ ],
1130
+ "SSH user:": [
1131
+ ""
1132
+ ],
1133
+ "Template:": [
1134
+ ""
1135
+ ],
1112
1136
  "Submit": [
1113
1137
  ""
1114
1138
  ],
@@ -1547,38 +1571,17 @@
1547
1571
  "Active Filters:": [
1548
1572
  ""
1549
1573
  ],
1574
+ "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1575
+ "Um plugin trazendo execução remota ao Foreman, completando a funcionalidade de gerenciamento de configuração com a funcionalidade de gerenciamento remoto. "
1576
+ ],
1550
1577
  "Action with sub plans": [
1551
1578
  "Ação com subplanos "
1552
1579
  ],
1553
- "Check for long running tasks": [
1554
- ""
1555
- ],
1556
- "Deliver notifications about long running tasks": [
1557
- ""
1558
- ],
1559
1580
  "Import Puppet classes": [
1560
1581
  "Importar classes de Puppet"
1561
1582
  ],
1562
1583
  "Import facts": [
1563
1584
  "Importar fatos"
1564
- ],
1565
- "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1566
- "Um plugin trazendo execução remota ao Foreman, completando a funcionalidade de gerenciamento de configuração com a funcionalidade de gerenciamento remoto. "
1567
- ],
1568
- "Cron line format 'a b c d e', where:": [
1569
- "Cron line format 'a b c d e', onde:"
1570
- ],
1571
- "#~ \"Distribute execution over N seconds. If this is set and proxy batch triggering\"#~ \" is enabled, then tasks are triggered on the smart proxy in batches of size 1.\"": [
1572
- "#~ \"Distribuir a execução ao longo de N segundos. Se essa opção estiver definida, \"#~ \"e o acionamento em lote de proxy estiver desabilitado, então, as tarefas serão\"#~ \" acionadas no proxy inteligente em lotes de tamanho 1.\""
1573
- ],
1574
- "Distribute tasks over N seconds": [
1575
- "Distribuir tarefas em N segundos "
1576
- ],
1577
- "Set to distribute over": [
1578
- "Definir para distribuir em"
1579
- ],
1580
- "Time span": [
1581
- "Período de tempo"
1582
1585
  ]
1583
1586
  }
1584
1587
  }
@@ -383,6 +383,12 @@
383
383
  "Try to abort the job without waiting for the results from the remote hosts": [
384
384
  ""
385
385
  ],
386
+ "New UI": [
387
+ ""
388
+ ],
389
+ "Switch to the new job invocation detail UI": [
390
+ ""
391
+ ],
386
392
  "Task Details": [
387
393
  "Описание задачи"
388
394
  ],
@@ -1098,6 +1104,9 @@
1098
1104
  "Job templates": [
1099
1105
  "Шаблоны заданий"
1100
1106
  ],
1107
+ "Job invocations detail": [
1108
+ ""
1109
+ ],
1101
1110
  "Run Puppet Once": [
1102
1111
  ""
1103
1112
  ],
@@ -1110,6 +1119,21 @@
1110
1119
  "Run a script": [
1111
1120
  ""
1112
1121
  ],
1122
+ "Not yet": [
1123
+ ""
1124
+ ],
1125
+ "Effective user:": [
1126
+ ""
1127
+ ],
1128
+ "Started at:": [
1129
+ ""
1130
+ ],
1131
+ "SSH user:": [
1132
+ ""
1133
+ ],
1134
+ "Template:": [
1135
+ ""
1136
+ ],
1113
1137
  "Submit": [
1114
1138
  ""
1115
1139
  ],
@@ -1548,29 +1572,17 @@
1548
1572
  "Active Filters:": [
1549
1573
  ""
1550
1574
  ],
1575
+ "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1576
+ "Дополнительный модуль Foreman для удаленного выполнения заданий, объединяющий функции управления конфигурацией и удаленного контроля."
1577
+ ],
1551
1578
  "Action with sub plans": [
1552
1579
  "Действия с подпланами"
1553
1580
  ],
1554
- "Check for long running tasks": [
1555
- ""
1556
- ],
1557
- "Deliver notifications about long running tasks": [
1558
- ""
1559
- ],
1560
1581
  "Import Puppet classes": [
1561
1582
  "Импорт классов Puppet"
1562
1583
  ],
1563
1584
  "Import facts": [
1564
1585
  "Импорт фактов"
1565
- ],
1566
- "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1567
- "Дополнительный модуль Foreman для удаленного выполнения заданий, объединяющий функции управления конфигурацией и удаленного контроля."
1568
- ],
1569
- "Distribute tasks over N seconds": [
1570
- "Распределить задачи в пределах заданного периода времени (в секундах)"
1571
- ],
1572
- "Time span": [
1573
- "Интервал"
1574
1586
  ]
1575
1587
  }
1576
1588
  }
@@ -383,6 +383,12 @@
383
383
  "Try to abort the job without waiting for the results from the remote hosts": [
384
384
  "尝试在不等待远程主机的结果情况下终止作业"
385
385
  ],
386
+ "New UI": [
387
+ ""
388
+ ],
389
+ "Switch to the new job invocation detail UI": [
390
+ ""
391
+ ],
386
392
  "Task Details": [
387
393
  "任务详情"
388
394
  ],
@@ -1094,6 +1100,9 @@
1094
1100
  "Job templates": [
1095
1101
  "作业模板"
1096
1102
  ],
1103
+ "Job invocations detail": [
1104
+ ""
1105
+ ],
1097
1106
  "Run Puppet Once": [
1098
1107
  "运行 Puppet 一次"
1099
1108
  ],
@@ -1106,6 +1115,21 @@
1106
1115
  "Run a script": [
1107
1116
  ""
1108
1117
  ],
1118
+ "Not yet": [
1119
+ ""
1120
+ ],
1121
+ "Effective user:": [
1122
+ ""
1123
+ ],
1124
+ "Started at:": [
1125
+ ""
1126
+ ],
1127
+ "SSH user:": [
1128
+ ""
1129
+ ],
1130
+ "Template:": [
1131
+ ""
1132
+ ],
1109
1133
  "Submit": [
1110
1134
  ""
1111
1135
  ],
@@ -1544,38 +1568,17 @@
1544
1568
  "Active Filters:": [
1545
1569
  ""
1546
1570
  ],
1571
+ "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1572
+ "一个将远程执行带到 Foreman 的插件,通过远程管理功能来完成配置管理功能。"
1573
+ ],
1547
1574
  "Action with sub plans": [
1548
1575
  "有子计划的操作"
1549
1576
  ],
1550
- "Check for long running tasks": [
1551
- ""
1552
- ],
1553
- "Deliver notifications about long running tasks": [
1554
- ""
1555
- ],
1556
1577
  "Import Puppet classes": [
1557
1578
  "导入 Puppet 类"
1558
1579
  ],
1559
1580
  "Import facts": [
1560
1581
  "导入事实"
1561
- ],
1562
- "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1563
- "一个将远程执行带到 Foreman 的插件,通过远程管理功能来完成配置管理功能。"
1564
- ],
1565
- "Cron line format 'a b c d e', where:": [
1566
- "Cron 行格式 'a b c d e', 其中:"
1567
- ],
1568
- "#~ \"Distribute execution over N seconds. If this is set and proxy batch triggering\"#~ \" is enabled, then tasks are triggered on the smart proxy in batches of size 1.\"": [
1569
- "在 N 秒内分配执行。如果设置了此选项并启用了代理批处理触发,则将在智能代理上以大小为 1 的批处理触发任务。"
1570
- ],
1571
- "Distribute tasks over N seconds": [
1572
- "在 N 秒内分配任务"
1573
- ],
1574
- "Set to distribute over": [
1575
- "设置为通过...分配"
1576
- ],
1577
- "Time span": [
1578
- "时间跨度"
1579
1582
  ]
1580
1583
  }
1581
1584
  }
@@ -383,6 +383,12 @@
383
383
  "Try to abort the job without waiting for the results from the remote hosts": [
384
384
  ""
385
385
  ],
386
+ "New UI": [
387
+ ""
388
+ ],
389
+ "Switch to the new job invocation detail UI": [
390
+ ""
391
+ ],
386
392
  "Task Details": [
387
393
  "工作詳細資料"
388
394
  ],
@@ -1096,6 +1102,9 @@
1096
1102
  "Job templates": [
1097
1103
  "工作範本"
1098
1104
  ],
1105
+ "Job invocations detail": [
1106
+ ""
1107
+ ],
1099
1108
  "Run Puppet Once": [
1100
1109
  ""
1101
1110
  ],
@@ -1108,6 +1117,21 @@
1108
1117
  "Run a script": [
1109
1118
  ""
1110
1119
  ],
1120
+ "Not yet": [
1121
+ ""
1122
+ ],
1123
+ "Effective user:": [
1124
+ ""
1125
+ ],
1126
+ "Started at:": [
1127
+ ""
1128
+ ],
1129
+ "SSH user:": [
1130
+ ""
1131
+ ],
1132
+ "Template:": [
1133
+ ""
1134
+ ],
1111
1135
  "Submit": [
1112
1136
  ""
1113
1137
  ],
@@ -1546,29 +1570,17 @@
1546
1570
  "Active Filters:": [
1547
1571
  ""
1548
1572
  ],
1573
+ "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1574
+ "將遠端執行帶入 Foreman 的外掛程式,搭配遠端管理功能來完成配置管理。"
1575
+ ],
1549
1576
  "Action with sub plans": [
1550
1577
  "有子計畫的動作"
1551
1578
  ],
1552
- "Check for long running tasks": [
1553
- ""
1554
- ],
1555
- "Deliver notifications about long running tasks": [
1556
- ""
1557
- ],
1558
1579
  "Import Puppet classes": [
1559
1580
  "匯入 Puppet 類別"
1560
1581
  ],
1561
1582
  "Import facts": [
1562
1583
  "匯入詳情"
1563
- ],
1564
- "A plugin bringing remote execution to the Foreman, completing the config management functionality with remote management functionality.": [
1565
- "將遠端執行帶入 Foreman 的外掛程式,搭配遠端管理功能來完成配置管理。"
1566
- ],
1567
- "Distribute tasks over N seconds": [
1568
- "在幾秒間散佈工作"
1569
- ],
1570
- "Time span": [
1571
- "時間跨度"
1572
1584
  ]
1573
1585
  }
1574
1586
  }
@@ -98,6 +98,11 @@ module RemoteExecutionHelper
98
98
  :disabled => !task.cancellable?,
99
99
  :method => :post)
100
100
  end
101
+ if Setting[:lab_features]
102
+ buttons << link_to(_('New UI'), new_job_invocation_detail_path(:id => job_invocation.id),
103
+ class: 'btn btn-default',
104
+ title: _('Switch to the new job invocation detail UI'))
105
+ end
101
106
  return buttons
102
107
  end
103
108
 
@@ -0,0 +1,42 @@
1
+ module Actions
2
+ module RemoteExecution
3
+ module EventHelpers
4
+ module ClassEventHelpers
5
+ def event_states
6
+ []
7
+ end
8
+
9
+ def event_names
10
+ event_states.map do |state|
11
+ event_name_base + '_' + event_name_suffix(state).to_s
12
+ end
13
+ end
14
+
15
+ def feature_job_event_names(label)
16
+ event_states.map do |state|
17
+ ::Foreman::Observable.event_name_for("#{event_name_base}_#{label}_#{event_name_suffix(state)}")
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.included(base)
23
+ base.extend ClassEventHelpers
24
+ end
25
+
26
+ def emit_event(execution_plan, hook)
27
+ return unless root_action?
28
+
29
+ payload = event_payload(execution_plan)
30
+ base = self.class.event_name_base
31
+ suffix = self.class.event_name_suffix(hook)
32
+ if input["job_features"]&.any?
33
+ input['job_features'].each do |feature|
34
+ name = "#{base}_#{feature}_#{suffix}"
35
+ trigger_hook name, payload: payload
36
+ end
37
+ end
38
+ trigger_hook("#{base}_#{suffix}", payload: payload)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -5,8 +5,7 @@ module Actions
5
5
  include ::Actions::Helpers::WithDelegatedAction
6
6
  include ::Actions::ObservableAction
7
7
  include ::Actions::RemoteExecution::TemplateInvocationProgressLogging
8
-
9
- execution_plan_hooks.use :emit_feature_event, :on => :success
8
+ include ::Actions::RemoteExecution::EventHelpers
10
9
 
11
10
  middleware.do_not_use Dynflow::Middleware::Common::Transaction
12
11
  middleware.use Actions::Middleware::HideSecrets
@@ -79,20 +78,8 @@ module Actions
79
78
  end
80
79
  end
81
80
 
82
- def self.feature_job_event_name(label, suffix = :success)
83
- ::Foreman::Observable.event_name_for("#{::Actions::RemoteExecution::RunHostJob.event_name_base}_#{label}_#{::Actions::RemoteExecution::RunHostJob.event_name_suffix(suffix)}")
84
- end
85
-
86
- def emit_feature_event(execution_plan, hook = :success)
87
- return unless root_action?
88
-
89
- payload = event_payload(execution_plan)
90
- if input["job_features"]&.any?
91
- input['job_features'].each do |feature|
92
- name = "#{self.class.event_name_base}_#{feature}_#{self.class.event_name_suffix(hook)}"
93
- trigger_hook name, payload: payload
94
- end
95
- end
81
+ def self.event_states
82
+ [:success, :failure]
96
83
  end
97
84
 
98
85
  def secrets(host, job_invocation, provider)
@@ -3,6 +3,7 @@ module Actions
3
3
  class RunHostsJob < Actions::ActionWithSubPlans
4
4
  include Actions::RecurringAction
5
5
  include Actions::ObservableAction
6
+ include Actions::RemoteExecution::EventHelpers
6
7
 
7
8
  middleware.use Actions::Middleware::BindJobInvocation
8
9
  middleware.use Actions::Middleware::RecurringLogic
@@ -10,7 +11,7 @@ module Actions
10
11
 
11
12
  execution_plan_hooks.use :notify_on_success, :on => :success
12
13
  execution_plan_hooks.use :notify_on_failure, :on => :failure
13
- execution_plan_hooks.use :emit_event_running, :on => :running
14
+ execution_plan_hooks.use :emit_running_event, :on => :running
14
15
 
15
16
  class CheckOnProxyActions; end
16
17
 
@@ -28,7 +29,8 @@ module Actions
28
29
  def plan(job_invocation)
29
30
  job_invocation.task_group.save! if job_invocation.task_group.try(:new_record?)
30
31
  task.add_missing_task_groups(job_invocation.task_group) if job_invocation.task_group
31
- action_subject(job_invocation)
32
+ features = job_invocation.pattern_templates.flat_map { |t| t.remote_execution_features.pluck(:label) }.uniq
33
+ action_subject(job_invocation, job_features: features)
32
34
  job_invocation.targeting.resolve_hosts! if job_invocation.targeting.dynamic? || !job_invocation.targeting.resolved?
33
35
  set_up_concurrency_control job_invocation
34
36
  input.update(:job_category => job_invocation.job_category)
@@ -158,11 +160,11 @@ module Actions
158
160
  input[:proxy_batch_size]
159
161
  end
160
162
 
161
- def self.event_names
162
- super + [event_name_base + '_' + event_name_suffix('running')]
163
+ def self.event_states
164
+ [:success, :failure, :running]
163
165
  end
164
166
 
165
- def emit_event_running(plan)
167
+ def emit_running_event(plan)
166
168
  emit_event(plan, :running)
167
169
  end
168
170
 
@@ -0,0 +1,12 @@
1
+ module Api
2
+ module V2
3
+ module HostsControllerExtensions
4
+ extend ActiveSupport::Concern
5
+ def index_node_permissions
6
+ super.merge({
7
+ :can_create_job_invocations => authorized_for(:controller => 'job_invocations', :action => 'create'),
8
+ })
9
+ end
10
+ end
11
+ end
12
+ end
@@ -3,7 +3,11 @@ object @job_invocation
3
3
  attributes :id, :description, :job_category, :targeting_id, :status, :start_at, :status_label, :ssh_user, :time_to_pickup
4
4
 
5
5
  node do |invocation|
6
+ pattern_template = invocation.pattern_template_invocations.first
6
7
  {
8
+ :template_id => pattern_template&.template_id,
9
+ :template_name => pattern_template&.template_name,
10
+ :effective_user => pattern_template&.effective_user,
7
11
  :succeeded => invocation_count(invocation, :output_key => :success_count),
8
12
  :failed => invocation_count(invocation, :output_key => :failed_count),
9
13
  :pending => invocation_count(invocation, :output_key => :pending_count),
@@ -15,3 +19,13 @@ end
15
19
  child :task => :dynflow_task do
16
20
  attributes :id, :state
17
21
  end
22
+
23
+ if params.key?(:include_permissions)
24
+ node :permissions do |invocation|
25
+ authorizer = Authorizer.new(User.current)
26
+ edit_job_templates_permission = Permission.where(name: "edit_job_templates", resource_type: "JobTemplate").first
27
+ {
28
+ "edit_job_templates" => (edit_job_templates_permission && authorizer.can?("edit_job_templates", invocation, false)),
29
+ }
30
+ end
31
+ end
data/config/routes.rb CHANGED
@@ -22,6 +22,8 @@ Rails.application.routes.draw do
22
22
  match 'job_invocations/:id/rerun', to: 'react#index', :via => [:get], as: 'rerun_job_invocation'
23
23
  match 'old/job_invocations/new', to: 'job_invocations#new', via: [:get], as: 'form_new_job_invocation'
24
24
  match 'old/job_invocations/:id/rerun', to: 'job_invocations#rerun', via: [:get, :post], as: 'form_rerun_job_invocation'
25
+ match 'experimental/job_invocations_detail/:id', to: 'react#index', :via => [:get], as: 'new_job_invocation_detail'
26
+
25
27
  resources :job_invocations, :only => [:create, :show, :index] do
26
28
  collection do
27
29
  get 'preview_job_invocations_per_host'
@@ -9,7 +9,7 @@ class AddHostIdToTemplateInvocation < ActiveRecord::Migration[4.2]
9
9
  FakeTemplateInvocation.reset_column_information
10
10
 
11
11
  say 'Migrating existing execution locks to explicit relations, this may take a while'
12
- FakeTemplateInvocation.all.each do |template_invocation|
12
+ FakeTemplateInvocation.all.find_each do |template_invocation|
13
13
  task = ForemanTasks::Task.for_action_types('Actions::RemoteExecution::RunHostJob').joins(:locks).where(
14
14
  :'foreman_tasks_locks.resource_type' => 'TemplateInvocation',
15
15
  :'foreman_tasks_locks.resource_id' => template_invocation.id
@@ -5,7 +5,7 @@ class MigrateToTaskGroups < ActiveRecord::Migration[4.2]
5
5
 
6
6
  def up
7
7
  say 'Migrating from locks to task groups'
8
- FakeJobInvocation.where('task_group_id IS NULL AND task_id IS NOT NULL').each do |job_invocation|
8
+ FakeJobInvocation.where('task_group_id IS NULL AND task_id IS NOT NULL').find_each do |job_invocation|
9
9
  task_group = JobInvocationTaskGroup.new
10
10
  task_group.task_ids = [job_invocation.task_id]
11
11
  task_group.save!
@@ -14,7 +14,7 @@ class ExpandAllTemplateInvocations < ActiveRecord::Migration[4.2]
14
14
  FakeTemplateInvocation.update_all 'host_id = NULL'
15
15
 
16
16
  # expand all pattern template invocations and link RunHostJob
17
- JobInvocation.joins(:targeting).where("#{Targeting.table_name}.resolved_at IS NOT NULL").includes([:pattern_template_invocations, :targeting]).each do |job_invocation|
17
+ JobInvocation.joins(:targeting).where("#{Targeting.table_name}.resolved_at IS NOT NULL").includes([:pattern_template_invocations, :targeting]).find_each do |job_invocation|
18
18
  job_invocation.pattern_template_invocations.each do |pattern_template_invocation|
19
19
  job_invocation.targeting.hosts.each do |host|
20
20
  task = job_invocation.sub_tasks.find do |sub_task|
@@ -38,7 +38,7 @@ class ExpandAllTemplateInvocations < ActiveRecord::Migration[4.2]
38
38
 
39
39
  def down
40
40
  # we can't determine the last host for pattern, but keeping template invocations as pattern is safe
41
- JobInvocation.joins(:targeting).where("#{Targeting.table_name}.resolved_at IS NOT NULL").includes(:template_invocations).each do |job_invocation|
41
+ JobInvocation.joins(:targeting).where("#{Targeting.table_name}.resolved_at IS NOT NULL").includes(:template_invocations).find_each do |job_invocation|
42
42
  job_invocation.template_invocations.delete_all
43
43
  end
44
44
  end
@@ -3,13 +3,13 @@ class RenameJobNameToJobCategory < ActiveRecord::Migration[4.2]
3
3
  rename_column :templates, :job_name, :job_category
4
4
  rename_column :job_invocations, :job_name, :job_category
5
5
  JobTemplate.where(:description_format => '%{job_name} %{command}').update_all(:description_format => 'Run %{command}')
6
- JobTemplate.where("description_format LIKE '%\%{job_name}%'").each do |template|
6
+ JobTemplate.where("description_format LIKE '%\%{job_name}%'").find_each do |template|
7
7
  JobTemplate.where(:id => template.id).update_all(:description_format => template.description_format.gsub('%{job_name}', '%{job_category}'))
8
8
  end
9
9
  end
10
10
 
11
11
  def down
12
- JobTemplate.where("description_format LIKE '%\%{job_category}%'").each do |template|
12
+ JobTemplate.where("description_format LIKE '%\%{job_category}%'").find_each do |template|
13
13
  JobTemplate.where(:id => template.id).update_all(:description_format => template.description_format.gsub('%{job_category}', '%{job_name}'))
14
14
  end
15
15
  JobTemplate.where(:description_format => 'Run %{command}').update_all(:description_format => '%{job_name} %{command}')
@@ -2,7 +2,7 @@ class RenameSudoPasswordToEffectiveUserPassword < ActiveRecord::Migration[6.0]
2
2
  def up
3
3
  rename_column :job_invocations, :sudo_password, :effective_user_password
4
4
 
5
- Parameter.where(name: 'remote_execution_sudo_password').each do |parameter|
5
+ Parameter.where(name: 'remote_execution_sudo_password').find_each do |parameter|
6
6
  record = Parameter.find_by(type: parameter.type, reference_id: parameter.reference_id, name: "remote_execution_effective_user_password")
7
7
  if record.nil?
8
8
  parameter.update(name: "remote_execution_effective_user_password")
@@ -19,7 +19,7 @@ class RenameSudoPasswordToEffectiveUserPassword < ActiveRecord::Migration[6.0]
19
19
  def down
20
20
  rename_column :job_invocations, :effective_user_password, :sudo_password
21
21
 
22
- Parameter.where(name: 'remote_execution_effective_user_password').each do |parameter|
22
+ Parameter.where(name: 'remote_execution_effective_user_password').find_each do |parameter|
23
23
  record = Parameter.find_by(type: parameter.type, reference_id: parameter.reference_id, name: "remote_execution_sudo_password")
24
24
  if record.nil?
25
25
  parameter.update(name: "remote_execution_sudo_password")
@@ -6,7 +6,7 @@ class RenameSshProviderToScript < ActiveRecord::Migration[6.0]
6
6
  setting = Setting.find_by(:name => 'remote_execution_form_job_template')
7
7
  default_template = nil
8
8
 
9
- Template.where(:provider_type => from).each do |t|
9
+ Template.where(:provider_type => from).find_each do |t|
10
10
  default_template = t if t.name == setting&.value
11
11
  t.provider_type = to
12
12
  t.name = t.name.gsub(from_re, new_label)