foreman_acd 0.4.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -84
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +103 -11
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +21 -3
  5. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -0
  6. data/app/controllers/foreman_acd/api/v2/app_instances_controller.rb +9 -1
  7. data/app/controllers/foreman_acd/app_definitions_controller.rb +117 -15
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +104 -30
  9. data/app/controllers/foreman_acd/concerns/ansible_playbook_parameters.rb +1 -1
  10. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  11. data/app/controllers/foreman_acd/concerns/app_instance_mixins.rb +36 -0
  12. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  13. data/app/controllers/foreman_acd/remote_execution_controller.rb +36 -23
  14. data/app/controllers/ui_acd_controller.rb +46 -0
  15. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +47 -0
  16. data/app/lib/actions/foreman_acd/run_configurator.rb +45 -0
  17. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +39 -0
  18. data/app/models/foreman_acd/acd_provider.rb +36 -0
  19. data/app/models/foreman_acd/ansible_playbook.rb +32 -14
  20. data/app/models/foreman_acd/app_definition.rb +24 -1
  21. data/app/models/foreman_acd/app_instance.rb +85 -5
  22. data/app/models/foreman_acd/foreman_host.rb +31 -0
  23. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  24. data/app/services/foreman_acd/acd_proxy_proxy_selector.rb +17 -0
  25. data/app/services/foreman_acd/app_configurator.rb +64 -36
  26. data/app/services/foreman_acd/app_deployer.rb +83 -48
  27. data/app/services/foreman_acd/inventory_creator.rb +36 -25
  28. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +50 -7
  29. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
  30. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
  32. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
  33. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
  35. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
  36. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
  38. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
  39. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
  40. data/app/views/foreman_acd/app_definitions/_form.html.erb +9 -1
  41. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
  42. data/app/views/foreman_acd/app_definitions/import.html.erb +20 -1
  43. data/app/views/foreman_acd/app_definitions/index.html.erb +5 -8
  44. data/app/views/foreman_acd/app_instances/_form.html.erb +4 -4
  45. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  46. data/app/views/foreman_acd/app_instances/index.html.erb +93 -14
  47. data/app/views/foreman_acd/app_instances/report.html.erb +12 -4
  48. data/app/views/templates/job/run_acd_ansible_playbook.erb +28 -15
  49. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  50. data/app/views/ui_acd/host_report.json.rabl +4 -0
  51. data/app/views/ui_acd/report_data.json.rabl +10 -0
  52. data/app/views/ui_acd/validate_hostname.json.rabl +6 -0
  53. data/config/routes.rb +12 -3
  54. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
  55. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
  56. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -0
  57. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  58. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  59. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  60. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  61. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  62. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  63. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  64. data/db/migrate/20210316151145_add_git_commit_to_ansible_playbooks.rb +8 -0
  65. data/db/migrate/20210503122809_add_git_url_to_ansible_playbooks.rb +8 -0
  66. data/db/migrate/20210818125913_add_is_existing_host_to_foreman_host.rb +8 -0
  67. data/db/migrate/20210902110645_add_initial_configure_task.rb +8 -0
  68. data/db/seeds.d/62_acd_proxy_feature.rb +4 -0
  69. data/db/seeds.d/75-job_templates.rb +6 -1
  70. data/lib/foreman_acd/engine.rb +40 -3
  71. data/lib/foreman_acd/plugin.rb +60 -45
  72. data/lib/foreman_acd/version.rb +1 -1
  73. data/lib/foreman_acd.rb +30 -0
  74. data/lib/tasks/foreman_acd_tasks.rake +0 -12
  75. data/locale/en/foreman_acd.edit.po +326 -0
  76. data/locale/en/foreman_acd.po +232 -2
  77. data/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
  78. data/locale/foreman_acd.pot +343 -8
  79. data/package.json +8 -8
  80. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  81. data/test/controllers/app_instances_controller_test.rb +8 -3
  82. data/test/controllers/ui_acd_controller_test.rb +22 -6
  83. data/test/factories/foreman_acd_factories.rb +18 -4
  84. data/test/models/acd_provider_test.rb +37 -0
  85. data/test/models/ansible_playbook_test.rb +11 -0
  86. data/test/models/app_definition_test.rb +1 -1
  87. data/test/models/app_instance_test.rb +2 -0
  88. data/test/models/concerns/host_extensions_test.rb +26 -0
  89. data/test/models/foreman_host_test.rb +12 -0
  90. data/webpack/__mocks__/foremanReact/API.js +2 -0
  91. data/webpack/__mocks__/foremanReact/common/I18n.js +3 -0
  92. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  93. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  94. data/webpack/__mocks__/foremanReact/components/ForemanModal.js +7 -0
  95. data/webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js +2 -0
  96. data/webpack/__mocks__/foremanReact/components/common/forms/TextInput.js +2 -0
  97. data/webpack/__mocks__/foremanReact/components/hosts/powerStatus.js +1 -0
  98. data/webpack/__snapshots__/helper.test.js.snap +14 -0
  99. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +55 -21
  100. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +14 -0
  101. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +2 -0
  102. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +48 -1
  103. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +4 -0
  104. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionConfData_1.fixtures.js +288 -0
  105. data/webpack/components/ApplicationDefinition/__fixtures__/applicationDefinitionReducer.fixtures.js +79 -0
  106. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinition.test.js +26 -0
  107. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionReducer.test.js +119 -0
  108. data/webpack/components/ApplicationDefinition/__tests__/ApplicationDefinitionSelectors.test.js +41 -0
  109. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinition.test.js.snap +225 -0
  110. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionReducer.test.js.snap +3033 -0
  111. data/webpack/components/ApplicationDefinition/__tests__/__snapshots__/ApplicationDefinitionSelectors.test.js.snap +299 -0
  112. data/webpack/components/ApplicationDefinition/components/AnsiblePlaybookSelector.js +2 -1
  113. data/webpack/components/ApplicationDefinition/components/__tests__/AnsiblePlaybookSelector.test.js +41 -0
  114. data/webpack/components/ApplicationDefinition/components/__tests__/__snapshots__/AnsiblePlaybookSelector.test.js.snap +121 -0
  115. data/webpack/components/ApplicationDefinition/index.js +8 -0
  116. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.js +214 -0
  117. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImport.scss +1 -0
  118. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportActions.js +161 -0
  119. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportConstants.js +6 -0
  120. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportReducer.js +79 -0
  121. data/webpack/components/ApplicationDefinitionImport/ApplicationDefinitionImportSelectors.js +8 -0
  122. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportConfData_1.fixtures.js +129 -0
  123. data/webpack/components/ApplicationDefinitionImport/__fixtures__/applicationDefinitionImportReducer.fixtures.js +29 -0
  124. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImport.test.js +20 -0
  125. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportReducer.test.js +43 -0
  126. data/webpack/components/ApplicationDefinitionImport/__tests__/ApplicationDefinitionImportSelectors.test.js +29 -0
  127. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImport.test.js.snap +62 -0
  128. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportReducer.test.js.snap +362 -0
  129. data/webpack/components/ApplicationDefinitionImport/__tests__/__snapshots__/ApplicationDefinitionImportSelectors.test.js.snap +130 -0
  130. data/webpack/components/ApplicationDefinitionImport/index.js +32 -0
  131. data/webpack/components/ApplicationInstance/ApplicationInstance.js +153 -45
  132. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +120 -6
  133. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +5 -0
  134. data/webpack/components/ApplicationInstance/ApplicationInstanceHelper.js +15 -0
  135. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +77 -22
  136. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +4 -0
  137. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceConfData_1.fixtures.js +263 -0
  138. data/webpack/components/ApplicationInstance/__fixtures__/applicationInstanceReducer.fixtures.js +80 -0
  139. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstance.test.js +24 -0
  140. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceReducer.test.js +131 -0
  141. data/webpack/components/ApplicationInstance/__tests__/ApplicationInstanceSelectors.test.js +44 -0
  142. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstance.test.js.snap +299 -0
  143. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceReducer.test.js.snap +2990 -0
  144. data/webpack/components/ApplicationInstance/__tests__/__snapshots__/ApplicationInstanceSelectors.test.js.snap +276 -0
  145. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +1 -0
  146. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  147. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +1 -1
  148. data/webpack/components/ApplicationInstance/helper.js +0 -0
  149. data/webpack/components/ApplicationInstance/index.js +8 -0
  150. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +128 -60
  151. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  152. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +40 -50
  153. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +5 -4
  154. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +19 -14
  155. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +4 -1
  156. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportData_1.fixtures.js +349 -0
  157. data/webpack/components/ApplicationInstanceReport/__fixtures__/applicationInstanceReportReducer.fixtures.js +20 -0
  158. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReport.test.js +47 -0
  159. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportReducer.test.js +41 -0
  160. data/webpack/components/ApplicationInstanceReport/__tests__/ApplicationInstanceReportSelectors.test.js +26 -0
  161. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReport.test.js.snap +7 -0
  162. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportReducer.test.js.snap +718 -0
  163. data/webpack/components/ApplicationInstanceReport/__tests__/__snapshots__/ApplicationInstanceReportSelectors.test.js.snap +347 -0
  164. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  165. data/webpack/components/ApplicationInstanceReport/components/__tests__/ReportViewer.test.js +24 -0
  166. data/webpack/components/ApplicationInstanceReport/components/__tests__/__snapshots__/ReportViewer.test.js.snap +24 -0
  167. data/webpack/components/ApplicationInstanceReport/index.js +8 -3
  168. data/webpack/components/ExistingHostSelection/ExistingHostSelection.js +104 -0
  169. data/webpack/components/ExistingHostSelection/ExistingHostSelection.scss +15 -0
  170. data/webpack/components/ExistingHostSelection/ExistingHostSelectionActions.js +71 -0
  171. data/webpack/components/ExistingHostSelection/ExistingHostSelectionConstants.js +4 -0
  172. data/webpack/components/ExistingHostSelection/ExistingHostSelectionHelper.js +0 -0
  173. data/webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js +90 -0
  174. data/webpack/components/ExistingHostSelection/ExistingHostSelectionSelectors.js +8 -0
  175. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionConfData_1.fixtures.js +191 -0
  176. data/webpack/components/ExistingHostSelection/__fixtures__/existingHostSelectionReducer.fixtures.js +203 -0
  177. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelection.test.js +19 -0
  178. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionReducer.test.js +59 -0
  179. data/webpack/components/ExistingHostSelection/__tests__/ExistingHostSelectionSelectors.test.js +36 -0
  180. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelection.test.js.snap +35 -0
  181. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionReducer.test.js.snap +614 -0
  182. data/webpack/components/ExistingHostSelection/__tests__/__snapshots__/ExistingHostSelectionSelectors.test.js.snap +27 -0
  183. data/webpack/components/ExistingHostSelection/components/ServiceSelector.js +48 -0
  184. data/webpack/components/ExistingHostSelection/components/__tests__/ServiceSelector.test.js +35 -0
  185. data/webpack/components/ExistingHostSelection/components/__tests__/__snapshots__/ServiceSelector.test.js.snap +77 -0
  186. data/webpack/components/ExistingHostSelection/index.js +26 -0
  187. data/webpack/components/ParameterSelection/ParameterSelection.js +138 -15
  188. data/webpack/components/ParameterSelection/ParameterSelection.scss +7 -0
  189. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +52 -9
  190. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +3 -0
  191. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +62 -25
  192. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +1 -0
  193. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +116 -84
  194. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +10 -4
  195. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +36 -46
  196. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +33 -25
  197. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  198. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +84 -112
  199. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +1488 -872
  200. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +117 -79
  201. data/webpack/components/ParameterSelection/index.js +2 -1
  202. data/webpack/components/SyncGitRepo/SyncGitRepo.js +202 -0
  203. data/webpack/components/SyncGitRepo/SyncGitRepo.scss +1 -0
  204. data/webpack/components/SyncGitRepo/SyncGitRepoActions.js +123 -0
  205. data/webpack/components/SyncGitRepo/SyncGitRepoConstants.js +8 -0
  206. data/webpack/components/SyncGitRepo/SyncGitRepoReducer.js +80 -0
  207. data/webpack/components/SyncGitRepo/SyncGitRepoSelectors.js +6 -0
  208. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoConfData_1.fixtures.js +7 -0
  209. data/webpack/components/SyncGitRepo/__fixtures__/syncGitRepoReducer.fixtures.js +44 -0
  210. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepo.test.js +27 -0
  211. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoReducer.test.js +95 -0
  212. data/webpack/components/SyncGitRepo/__tests__/SyncGitRepoSelectors.test.js +32 -0
  213. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepo.test.js.snap +31 -0
  214. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoReducer.test.js.snap +137 -0
  215. data/webpack/components/SyncGitRepo/__tests__/__snapshots__/SyncGitRepoSelectors.test.js.snap +13 -0
  216. data/webpack/components/SyncGitRepo/components/FormTextInput.js +42 -0
  217. data/webpack/components/SyncGitRepo/components/ScmTypeSelector.js +47 -0
  218. data/webpack/components/SyncGitRepo/index.js +28 -0
  219. data/webpack/components/common/DeleteTableEntry.js +18 -4
  220. data/webpack/components/common/EditTableEntry.js +50 -0
  221. data/webpack/components/common/ExtTextInput.js +43 -0
  222. data/webpack/components/common/LockTableEntry.js +60 -0
  223. data/webpack/components/common/__tests__/EditTableEntry.test.js +53 -0
  224. data/webpack/components/common/__tests__/LockTableEntry.test.js +35 -0
  225. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +40 -2
  226. data/webpack/components/common/__tests__/__snapshots__/EditTableEntry.test.js.snap +81 -0
  227. data/webpack/components/common/__tests__/__snapshots__/LockTableEntry.test.js.snap +60 -0
  228. data/webpack/helper.js +20 -1
  229. data/webpack/helper.test.js +37 -0
  230. data/webpack/index.js +7 -0
  231. data/webpack/js-yaml.js +3874 -0
  232. data/webpack/reducer.js +16 -1
  233. metadata +182 -11
  234. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
  235. data/webpack/components/common/EasyHeaderFormatter.js +0 -18
  236. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +0 -35
  237. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +0 -41
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAcd
4
+ # Extends the Host Managed
5
+ module HostManagedExtensions
6
+ extend ActiveSupport::Concern
7
+
8
+ def self.prepended(base)
9
+ base.instance_eval do
10
+ before_provision :initiate_acd_app_configurator_after_host_deployment, :if => :deployed_via_acd?
11
+ before_destroy :check_deletable, :prepend => true, :if => :deployed_via_acd?
12
+ end
13
+ end
14
+
15
+ def deployed_via_acd?
16
+ find_foreman_host
17
+ @foreman_host.present?
18
+ end
19
+
20
+ private
21
+
22
+ def check_deletable
23
+ return if @foreman_host.blank?
24
+ ::Foreman::Logging.logger('foreman_acd').warn "Could not delete host '#{name}' because it is used in Applications > App Instances '#{@foreman_host.app_instance.name}'"
25
+ raise _("Could not delete host '%{host_name}' because it is used in Applications > App Instances '%{app_instance_name}'") % {
26
+ :host_name => name, :app_instance_name => @foreman_host.app_instance.name
27
+ }
28
+ end
29
+
30
+ def find_foreman_host
31
+ @foreman_host = ForemanAcd::ForemanHost.find_by(:host_id => id)
32
+ end
33
+
34
+ def initiate_acd_app_configurator_after_host_deployment
35
+ return if @foreman_host.blank?
36
+ ForemanAcd.initiate_acd_app_configurator(@foreman_host.app_instance)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAcd
4
+ # Implement a RemoteExecutionProvider
5
+ class AcdProvider < ::RemoteExecutionProvider
6
+ class << self
7
+ def supports_effective_user?
8
+ true
9
+ end
10
+
11
+ def proxy_operation_name
12
+ 'acd'
13
+ end
14
+
15
+ def humanized_name
16
+ 'ACD'
17
+ end
18
+
19
+ def proxy_command_options(template_invocation, host)
20
+ super(template_invocation, host).merge(:name => host.name)
21
+ end
22
+
23
+ def ssh_password(_host); end
24
+
25
+ def ssh_key_passphrase(_host); end
26
+
27
+ def sudo_password(_host); end
28
+
29
+ # Workaround till infrastructure jobs on proxies are possible. See
30
+ # configure in services/foreman_acd/app_configurator.rb for more details.
31
+ # def required_proxy_selector_for(_template)
32
+ # AcdProxyProxySelector.new
33
+ # end
34
+ end
35
+ end
36
+ end
@@ -4,14 +4,36 @@ module ForemanAcd
4
4
  # Ansible playbook
5
5
  class AnsiblePlaybook < ApplicationRecord
6
6
  include Authorizable
7
+ include Taxonomix
7
8
  extend FriendlyId
8
9
  friendly_id :name
10
+ include Parameterizable::ByIdName
9
11
 
10
12
  self.table_name = 'acd_ansible_playbooks'
11
- has_many :app_definitions, :inverse_of => :ansible_playbook, :foreign_key => 'acd_ansible_playbook_id', dependent: :restrict_with_error
13
+ has_many :app_definitions, :inverse_of => :ansible_playbook, :foreign_key => 'acd_ansible_playbook_id', :dependent => :restrict_with_error
12
14
  validates :name, :presence => true, :uniqueness => true
15
+ validates :scm_type, :presence => true
13
16
  scoped_search :on => :name
14
- default_scope -> { order("acd_ansible_playbooks.name") }
17
+
18
+ default_scope do
19
+ with_taxonomy_scope do
20
+ order('acd_ansible_playbooks.name')
21
+ end
22
+ end
23
+
24
+ def used_location_ids
25
+ Location.joins(:taxable_taxonomies).where(
26
+ 'taxable_taxonomies.taxable_type' => 'ForemanAcd::AnsiblePlaybook',
27
+ 'taxable_taxonomies.taxable_id' => id
28
+ ).pluck("#{Taxonomy.table_name}.id")
29
+ end
30
+
31
+ def used_organization_ids
32
+ Organization.joins(:taxable_taxonomies).where(
33
+ 'taxable_taxonomies.taxable_type' => 'ForemanAcd::AnsiblePlaybook',
34
+ 'taxable_taxonomies.taxable_id' => id
35
+ ).pluck("#{Taxonomy.table_name}.id")
36
+ end
15
37
 
16
38
  def self.humanize_class_name(_name = nil)
17
39
  _('Ansible playbook')
@@ -23,7 +45,7 @@ module ForemanAcd
23
45
 
24
46
  def content
25
47
  case scm_type
26
- when 'directory'
48
+ when 'directory' || 'git'
27
49
  File.read(File.join(path, playfile))
28
50
  else
29
51
  raise NotImplementedError.new "scm_type #{scm_type.inspect} not supported!"
@@ -31,20 +53,16 @@ module ForemanAcd
31
53
  end
32
54
 
33
55
  def as_unified_structobj
34
- groups = []
35
-
36
- JSON.load(self.vars).each do |group_name, vars|
37
- groups << OpenStruct.new(
38
- :name => group_name,
39
- :vars => vars.map { |k,v| OpenStruct.new(:name => k, :value => v) })
56
+ # FIXME: For now, we convert all values to string - even booleans and dicts
57
+ pretty_groups = JSON.parse(vars).each do |_, params|
58
+ params.transform_values!(&:to_s)
40
59
  end
41
60
 
42
- adata = OpenStruct.new(
43
- :id => self.id,
44
- :name => self.name,
45
- :groups => JSON.load(self.vars)
61
+ OpenStruct.new(
62
+ :id => id,
63
+ :name => name,
64
+ :groups => pretty_groups
46
65
  )
47
- adata
48
66
  end
49
67
  end
50
68
  end
@@ -4,14 +4,37 @@ module ForemanAcd
4
4
  # Application Definition
5
5
  class AppDefinition < ApplicationRecord
6
6
  include Authorizable
7
+ include Taxonomix
7
8
  extend FriendlyId
8
9
  friendly_id :name
10
+ include Parameterizable::ByIdName
9
11
 
12
+ self.table_name = 'acd_app_definitions'
10
13
  validates :name, :presence => true, :uniqueness => true
14
+ validates :ansible_playbook, :presence => true
11
15
  has_many :app_instances, :inverse_of => :app_definition, :dependent => :destroy
12
16
  belongs_to :ansible_playbook, :inverse_of => :app_definitions, :foreign_key => :acd_ansible_playbook_id
13
17
  scoped_search :on => :name
14
- default_scope -> { order("app_definitions.name") }
18
+
19
+ default_scope do
20
+ with_taxonomy_scope do
21
+ order('acd_app_definitions.name')
22
+ end
23
+ end
24
+
25
+ def used_location_ids
26
+ Location.joins(:taxable_taxonomies).where(
27
+ 'taxable_taxonomies.taxable_type' => 'ForemanAcd::AppDefinition',
28
+ 'taxable_taxonomies.taxable_id' => id
29
+ ).pluck("#{Taxonomy.table_name}.id")
30
+ end
31
+
32
+ def used_organization_ids
33
+ Organization.joins(:taxable_taxonomies).where(
34
+ 'taxable_taxonomies.taxable_type' => 'ForemanAcd::AppDefinition',
35
+ 'taxable_taxonomies.taxable_id' => id
36
+ ).pluck("#{Taxonomy.table_name}.id")
37
+ end
15
38
 
16
39
  def self.humanize_class_name(_name = nil)
17
40
  _('App Definition')
@@ -4,12 +4,25 @@ module ForemanAcd
4
4
  # Application Instance
5
5
  class AppInstance < ApplicationRecord
6
6
  include Authorizable
7
+ include ForemanTasks::Concerns::ActionSubject
7
8
  extend FriendlyId
8
9
  friendly_id :name
10
+ include Parameterizable::ByIdName
11
+
12
+ self.table_name = 'acd_app_instances'
13
+ belongs_to :last_deploy_task, :class_name => 'ForemanTasks::Task'
14
+ belongs_to :initial_configure_task, :class_name => 'ForemanTasks::Task'
9
15
  validates :name, :presence => true, :uniqueness => true
16
+ validates :app_definition, :presence => true
10
17
  belongs_to :app_definition, :inverse_of => :app_instances
18
+ belongs_to :organization
19
+ validates :organization, :presence => true
20
+ belongs_to :location
21
+ validates :location, :presence => true
22
+ has_many :foreman_hosts, :inverse_of => :app_instance, :dependent => :destroy
11
23
  scoped_search :on => :name
12
- default_scope -> { order("app_instances.name") }
24
+ default_scope -> { order('acd_app_instances.name') }
25
+ attr_accessor :hosts
13
26
 
14
27
  def self.humanize_class_name(_name = nil)
15
28
  _('App Instance')
@@ -19,10 +32,77 @@ module ForemanAcd
19
32
  'app_instances'
20
33
  end
21
34
 
22
- def foreman_hosts
23
- app_hosts = JSON.parse(self.hosts)
24
- host_ids = app_hosts.select{ |h| h&.key?('foreman_host_id') }.map{ |h| h['foreman_host_id'] }
25
- ::Host.find(host_ids)
35
+ def clean_all_hosts
36
+ remember_host_ids = foreman_hosts.select(&:fresh_host?).map(&:host_id)
37
+
38
+ # Clean the app instance association first
39
+ foreman_hosts.update_all(:host_id => nil)
40
+
41
+ # Remove all hosts afterwards
42
+ delete_hosts(remember_host_ids)
43
+ end
44
+
45
+ def clean_hosts_by_id(ids = [])
46
+ # Clean the app instance association first
47
+ foreman_hosts.where(:host_id => ids, :is_existing_host => false).update_all(:host_id => nil)
48
+
49
+ # Remove all hosts afterwards
50
+ delete_hosts(ids)
51
+ end
52
+
53
+ def hosts_deployment_finished?
54
+ return true if all_hosts_deployed?
55
+
56
+ ::Foreman::Logging.logger('foreman_acd').info('Another host is still in build-phase. Wait for it...')
57
+ false
58
+ end
59
+
60
+ def deployment_state
61
+ return :new if last_deploy_task.nil?
62
+ return :initiated if !last_deploy_task.nil? && last_deploy_task.ended_at.nil?
63
+
64
+ state = if all_hosts_deployed?
65
+ :finished
66
+ elsif last_deploy_task.ended_at? && last_deploy_task.result != 'success'
67
+ :failed
68
+ else
69
+ :pending
70
+ end
71
+ state
72
+ end
73
+
74
+ def initial_configure_job
75
+ return nil if initial_configure_task.nil?
76
+ return JobInvocation.find(initial_configure_task.output['configure_job_id']) if initial_configure_task.output.key?('configure_job_id') &&
77
+ !initial_configure_task.output['configure_job_id'].nil?
78
+ nil
79
+ end
80
+
81
+ def initial_configure_state
82
+ return :unconfigured if initial_configure_job.nil? && initial_configure_task.nil?
83
+ return :scheduled if initial_configure_job.nil?
84
+ return :pending unless initial_configure_job.finished?
85
+ initial_configure_job.status_label.to_sym
86
+ end
87
+
88
+ private
89
+
90
+ def all_hosts_deployed?
91
+ foreman_hosts.each do |foreman_host|
92
+ return false if foreman_host.host.nil? || foreman_host.host.build?
93
+ end
94
+ true
95
+ end
96
+
97
+ def delete_hosts(ids = [])
98
+ return if ids.empty?
99
+ ids.each do |host_id|
100
+ h = ::Host.find(host_id) unless host_id.nil?
101
+ if h
102
+ Katello::RegistrationManager.unregister_host(h, :unregistering => false) if ForemanAcd.with_katello?
103
+ h.destroy
104
+ end
105
+ end
26
106
  end
27
107
  end
28
108
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAcd
4
+ # Foreman Host
5
+ class ForemanHost < ApplicationRecord
6
+ include Authorizable
7
+
8
+ self.table_name = 'acd_foreman_hosts'
9
+ validates :hostname, :presence => true
10
+ belongs_to :app_instance, :inverse_of => :foreman_hosts
11
+ belongs_to :host, :class_name => '::Host::Managed'
12
+ scoped_search :on => :hostname
13
+ default_scope -> { order('acd_foreman_hosts.hostname') }
14
+
15
+ def self.humanize_class_name(_name = nil)
16
+ _('Foreman Host')
17
+ end
18
+
19
+ def fresh_host?
20
+ !is_existing_host
21
+ end
22
+
23
+ def existing_host?
24
+ is_existing_host
25
+ end
26
+
27
+ def self.permission_name
28
+ 'foreman_hosts'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAcd
4
+ # This is a TaxonomyExtensions
5
+ module TaxonomyExtensions
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ if SETTINGS[:version].to_s.to_f <= 1.7
10
+ def self.enabled_taxonomies
11
+ %w[locations organizations].select { |taxonomy| SETTINGS["#{taxonomy}_enabled".to_sym] }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ # To be removed after 1.7 compatibility is no longer required
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanAcd
4
+ # AcdProxy Selector implementing a RemoteExecutionProxySelector which
5
+ # only returns the Smart Proxy of the given host
6
+ class AcdProxyProxySelector < ::RemoteExecutionProxySelector
7
+ def determine_proxy(*args)
8
+ host, _provider = args
9
+
10
+ # We already did the determine_proxy in app_configurator. We want that REX
11
+ # isn't doing the determination of the proxy twice.
12
+ # Therefore, we will just return the host, which is the proxy!
13
+
14
+ ::SmartProxy.find_by(:name => host.name)
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,6 @@
3
3
  module ForemanAcd
4
4
  # application instances configurator
5
5
  class AppConfigurator
6
-
7
6
  delegate :logger, :to => :Rails
8
7
 
9
8
  def initialize(app_instance)
@@ -13,58 +12,87 @@ module ForemanAcd
13
12
  def configure
14
13
  job_input = {}
15
14
  job_input['application_name'] = @app_instance.name
16
- job_input['playbook_name'] = @app_instance.app_definition.ansible_playbook.name
17
- job_input['playbook_path'] = File.join(@app_instance.app_definition.ansible_playbook.path,
18
- @app_instance.app_definition.ansible_playbook.playfile)
19
-
20
- # TODO should or do we really need it to a file?
21
- #inventory_file = File.new("/tmp/acd_inventory_file", "w") # we can also use Tempfile.new() but a tempfile will be deleted soon (after transaction finished)
22
- #inventory_file << inventory.to_yaml
23
- #inventory_file.close
15
+ job_input['playbook_id'] = @app_instance.app_definition.ansible_playbook.id
16
+ job_input['playbook_file'] = @app_instance.app_definition.ansible_playbook.playfile
24
17
 
25
18
  logger.info("Use inventory to configure #{@app_instance.name} with ansible playbook #{@app_instance.app_definition.ansible_playbook.name}")
26
19
 
27
20
  begin
28
21
  proxy_hosts = {}
29
- jobs = []
22
+ job = nil
23
+ result = OpenStruct.new
30
24
 
31
25
  hosts = @app_instance.foreman_hosts
26
+
27
+ # Important: This uses the REX Proxy Selector and not
28
+ # the AcdProxySelection because the AcdProxySelector
29
+ # does not find the proxy but only return the given
30
+ # host. This is required because we want to run the
31
+ # ansible playbook for a group of hosts on the smart proxy.
32
+ # So the process need to be:
33
+ # 1. get the proxy which is required to connect to host a,b,c
34
+ # 2. run the job on the proxy
35
+ # In 2. we need to make sure that REX doesn't try to find the
36
+ # proxy which is necessary to connect to the proxy
32
37
  proxy_selector = RemoteExecutionProxySelector.new
33
38
  hosts.each do |h|
34
- proxy = proxy_selector.determine_proxy(h, 'SSH')
35
- unless proxy_hosts.has_key?(proxy.name)
36
- proxy_hosts[proxy.name] = Array.new
39
+ begin
40
+ unless h.host
41
+ result.success = false
42
+ result.error = 'App Instance is not deployed'
43
+ return [result, job]
44
+ end
45
+ proxy = proxy_selector.determine_proxy(h.host, 'ACD')
46
+ result.success = true
47
+ rescue NoMethodError => e
48
+ result.success = false
49
+ result.error = "#{e}, Install/Update smart-proxies for ACD"
50
+ return [result, job]
37
51
  end
38
- proxy_hosts[proxy.name] << h.id
52
+ proxy_hosts[proxy.name] = [] unless proxy_hosts.key?(proxy.name)
53
+ proxy_hosts[proxy.name] << h
39
54
  end
40
55
 
41
- # TODO just for testing...
42
- #proxy_hosts = { Host.first.name => [ Host.first.id] }
56
+ # TODO: just for testing...
57
+ # proxy_hosts = { Host.first.name => [ Host.first.id] }
43
58
 
44
- # we need to compose multiple jobs. for each proxy one job.
45
- proxy_hosts.each do |proxy_name, host_names|
46
- # create the inventory file
47
- inventory = ForemanAcd::InventoryCreator.new(@app_instance, host_names).create_inventory
48
- job_input['inventory'] = YAML.dump(inventory)
59
+ proxy_inventories = {}
60
+ proxy_host_ids = []
61
+ proxy_hosts.each do |proxy_name, foreman_hosts|
62
+ proxy_inventories[proxy_name] = ForemanAcd::InventoryCreator.new(@app_instance, foreman_hosts).create_inventory
49
63
 
50
- # Unfortunately, we can not use "JobInvocationComposer.for_feature" method
51
- # because then its not possible to the set effective_user
52
- job = JobTemplate.find(RemoteExecutionFeature.feature('run_acd_ansible_playbook').job_template_id)
53
- params = {
54
- :job_category => job.job_category,
55
- :job_template_id => job.id,
56
- :targeting_type => 'static_query',
57
- :search_query => "name = #{proxy_name}",
58
- :effective_user => 'foreman-proxy',
59
- :inputs => job_input.to_hash
60
- }
61
- composer = JobInvocationComposer.from_api_params(params)
62
- jobs << composer
64
+ # Workaround till infrastructure jobs on proxies are possible. See
65
+ # https://community.theforeman.org/t/infrastructure-roles/22001/33
66
+ #
67
+ # Why do we use 'foreman_hosts.first.host'? REX is 'host-centric'. During
68
+ # job execution, REX will try to find the proxy on which the job should be executed.
69
+ # We throw the first host at REX's feet so that the resolution of the
70
+ # proxy works (... which we have already done above).
71
+ # ACD on the smart proxy side will call the ansible-playbook for ALL hosts
72
+ # which are behind this smart proxy.
73
+ #
74
+ # Additionally, we disable that AcdProxyProxySelector is used.
75
+ # See required_proxy_selector_for in models/foreman_acd/acd_provider.rb
76
+ proxy_host_ids << foreman_hosts.first.host.id
77
+
78
+ # Actually, we want this:
79
+ # proxy_host_ids << Host.find_by(:name => proxy_name).id
63
80
  end
81
+
82
+ job_input['inventory'] = YAML.dump(proxy_inventories)
83
+ composer = JobInvocationComposer.for_feature(
84
+ :run_acd_ansible_playbook,
85
+ proxy_host_ids,
86
+ job_input.to_hash
87
+ )
88
+ job = composer
64
89
  rescue StandardError => e
65
- logger.error("Failed to configure hosts: #{e.class}: #{e.message}\n#{e.backtrace.join($INPUT_RECORD_SEPARATOR)}")
90
+ result.success = false
91
+ result.error = _('Failed to configure hosts: %{err_msg}' % { :err_msg => e.message })
92
+ logger.error('Failed to configure hosts: %{err_class}: %{err_msg}' % { :err_class => e.class, :err_msg => e.message })
93
+ job = nil
66
94
  end
67
- jobs
95
+ [result, job]
68
96
  end
69
97
  end
70
98
  end
@@ -3,59 +3,94 @@
3
3
  module ForemanAcd
4
4
  # application instances deployer
5
5
  class AppDeployer
6
-
7
6
  delegate :logger, :to => :Rails
8
7
 
9
8
  def initialize(app_instance)
10
9
  @app_instance = app_instance
11
10
  end
12
11
 
13
- def deploy
12
+ def deploy(safe_deploy)
13
+ output = []
14
14
  services = JSON.parse(@app_instance.app_definition.services)
15
- app_hosts = JSON.parse(@app_instance.hosts)
16
-
17
- app_hosts.each do |host_data|
18
- begin
19
- service_data = services.select { |k| k['id'] == host_data['service'].to_i }.first
20
- host_params = set_host_params(host_data, service_data)
21
-
22
- host = nil
23
- if host_data.has_key?('foreman_host_id')
24
- logger.debug("Try to find host with id #{host_data['foreman_host_id']}")
25
- begin
26
- host = Host.find(host_data['foreman_host_id'])
27
- rescue ActiveRecord::RecordNotFound
28
- logger.info("Host with id #{host_data['foreman_host_id']} couldn\'t be found, create a new one!")
29
- host = nil
30
- end
31
- end
32
-
33
- if host.nil?
34
- params = host_attributes(host_params)
35
- logger.info("Host creation parameters for #{host_data['hostname']}:\n#{params}\n")
36
- host = Host.new(params)
37
- else
38
- logger.info("Update parameters and re-deploy host #{host_data['hostname']}")
39
- host.attributes = host_attributes(host_params, host)
40
- host.setBuild
41
- host.power.reset
42
- end
43
-
44
- # REMOVE ME (but very nice for testing)
45
- # host.mac = "00:11:22:33:44:55"
46
-
47
- apply_compute_profile(host)
48
- host.suggest_default_pxe_loader
49
- host.save
50
-
51
- # save the foreman host id
52
- host_data['foreman_host_id'] = host.id
53
- rescue StandardError => e
54
- logger.error("Failed to initiate host creation: #{e.class}: #{e.message}\n#{e.backtrace.join($INPUT_RECORD_SEPARATOR)}")
15
+ all_hosts = []
16
+
17
+ foreman_hosts = if safe_deploy
18
+ @app_instance.foreman_hosts.find(safe_deploy)
19
+ else
20
+ @app_instance.foreman_hosts
21
+ end
22
+
23
+ foreman_hosts.each do |foreman_host|
24
+ service_data = services.select { |k| k['id'] == foreman_host.service.to_i }.first
25
+
26
+ # Handle already deployed hosts
27
+ if foreman_host.existing_host?
28
+ domain = Hostgroup.find(service_data['hostgroup']).domain.name
29
+ fqdn = "#{foreman_host.hostname}.#{domain}"
30
+ h = Host.find_by(:name => fqdn)
31
+ foreman_host.update!(:host_id => h.id)
32
+ next
33
+ end
34
+
35
+ host_params = set_host_params(foreman_host, service_data)
36
+ host = foreman_host.host.presence
37
+
38
+ is_rebuild = false
39
+
40
+ if host.blank?
41
+ params = host_attributes(host_params)
42
+ log_params = params.dup
43
+ log_params['root_pass'] = '****' if log_params.key?('root_pass')
44
+ msg = "Host creation parameters for #{foreman_host.hostname}:\n#{log_params}\n"
45
+ logger.info(msg)
46
+ output << msg
47
+ host = Host.new(params)
48
+ else
49
+ msg = "Update parameters and re-deploy host #{foreman_host.hostname}"
50
+ logger.info(msg)
51
+ output << msg
52
+ host.attributes = host_attributes(host_params, host)
53
+ is_rebuild = true
55
54
  end
55
+
56
+ # REMOVE ME (but very nice for testing)
57
+ # prng = Random.new
58
+ # x = prng.rand(100)
59
+ # y = prng.rand(100)
60
+ # host.mac = "00:11:22:33:#{x}:#{y}"
61
+
62
+ apply_compute_profile(host)
63
+ host.suggest_default_pxe_loader
64
+
65
+ all_hosts << OpenStruct.new(:foreman_host => foreman_host, :host => host, :rebuild => is_rebuild)
56
66
  end
57
67
 
58
- return app_hosts
68
+ # do this in a second step, so that we get the progress report for all
69
+ all_hosts.each do |os_host|
70
+ # Save the host -> will initiate the deployment
71
+ os_host.host.save!
72
+ msg = "Saved and initiated/updated host #{os_host.foreman_host.hostname}"
73
+ logger.info(msg)
74
+ output << msg
75
+
76
+ os_host.host.power.reset if os_host.rebuild
77
+
78
+ # save the foreman host id
79
+ os_host.foreman_host.update!(:host_id => os_host.host.id)
80
+
81
+ progress_report = Rails.cache.fetch(os_host.host.progress_report_id)
82
+ os_host.foreman_host.update!(:last_progress_report => progress_report)
83
+ if progress_report.empty?
84
+ msg = "Progress report for #{os_host.foreman_host.hostname} is empty!"
85
+ output << msg
86
+ end
87
+ end
88
+
89
+ # Try to start the configuration, too. In case of a app instance including only already deployed hosts
90
+ # this would start the configuration job then.
91
+ ForemanAcd.initiate_acd_app_configurator(@app_instance)
92
+
93
+ output
59
94
  end
60
95
 
61
96
  private
@@ -91,20 +126,20 @@ module ForemanAcd
91
126
 
92
127
  def hardcoded_params
93
128
  result = {}
94
- result['managed'] = true
95
- result['enabled'] = true
96
129
  result['build'] = true
97
130
  result['compute_attributes'] = { 'start' => '1' }
131
+ result['enabled'] = true
98
132
  result['host_parameters_attributes'] = []
133
+ result['managed'] = true
99
134
  result
100
135
  end
101
136
 
102
- def set_host_params(host_data, service_data)
137
+ def set_host_params(foreman_host, service_data)
103
138
  result = hardcoded_params
104
- result['name'] = host_data['hostname']
139
+ result['name'] = foreman_host.hostname
105
140
  result['hostgroup_id'] = service_data['hostgroup']
106
141
 
107
- host_data['foremanParameters'].each do |param|
142
+ JSON.parse(foreman_host.foremanParameters).each do |param|
108
143
  case param['type']
109
144
 
110
145
  when 'computeprofile'