foreman_acd 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -86
  3. data/app/controllers/foreman_acd/ansible_playbooks_controller.rb +13 -11
  4. data/app/controllers/foreman_acd/api/v2/ansible_playbooks_controller.rb +4 -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 +14 -9
  8. data/app/controllers/foreman_acd/app_instances_controller.rb +97 -25
  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_parameters.rb +1 -1
  12. data/app/controllers/foreman_acd/remote_execution_controller.rb +3 -6
  13. data/app/controllers/ui_acd_controller.rb +9 -0
  14. data/app/lib/actions/foreman_acd/deploy_all_hosts.rb +42 -0
  15. data/app/lib/actions/foreman_acd/run_configurator.rb +41 -0
  16. data/app/models/concerns/foreman_acd/host_managed_extensions.rb +51 -0
  17. data/app/models/foreman_acd/acd_provider.rb +3 -0
  18. data/app/models/foreman_acd/ansible_playbook.rb +30 -13
  19. data/app/models/foreman_acd/app_definition.rb +24 -1
  20. data/app/models/foreman_acd/app_instance.rb +40 -5
  21. data/app/models/foreman_acd/foreman_host.rb +23 -0
  22. data/app/models/foreman_acd/taxonomy_extensions.rb +17 -0
  23. data/app/services/foreman_acd/app_configurator.rb +7 -10
  24. data/app/services/foreman_acd/app_deployer.rb +59 -47
  25. data/app/services/foreman_acd/inventory_creator.rb +12 -25
  26. data/app/views/foreman_acd/ansible_playbooks/_form.html.erb +11 -2
  27. data/app/views/foreman_acd/ansible_playbooks/edit.html.erb +9 -1
  28. data/app/views/foreman_acd/ansible_playbooks/index.html.erb +3 -3
  29. data/app/views/foreman_acd/api/v2/ansible_playbooks/base.json.rabl +2 -0
  30. data/app/views/foreman_acd/api/v2/ansible_playbooks/index.json.rabl +2 -0
  31. data/app/views/foreman_acd/api/v2/ansible_playbooks/show.json.rabl +6 -0
  32. data/app/views/foreman_acd/api/v2/app_definitions/base.json.rabl +2 -0
  33. data/app/views/foreman_acd/api/v2/app_definitions/index.json.rabl +2 -0
  34. data/app/views/foreman_acd/api/v2/app_definitions/show.json.rabl +6 -0
  35. data/app/views/foreman_acd/api/v2/app_instances/base.json.rabl +3 -1
  36. data/app/views/foreman_acd/api/v2/app_instances/index.json.rabl +2 -0
  37. data/app/views/foreman_acd/api/v2/app_instances/show.json.rabl +2 -0
  38. data/app/views/foreman_acd/app_definitions/_form.html.erb +8 -0
  39. data/app/views/foreman_acd/app_definitions/edit.html.erb +10 -5
  40. data/app/views/foreman_acd/app_definitions/index.html.erb +4 -4
  41. data/app/views/foreman_acd/app_instances/_form.html.erb +3 -3
  42. data/app/views/foreman_acd/app_instances/edit.html.erb +10 -0
  43. data/app/views/foreman_acd/app_instances/index.html.erb +87 -14
  44. data/app/views/foreman_acd/app_instances/report.html.erb +5 -2
  45. data/app/views/templates/job/run_acd_ansible_playbook.erb +14 -1
  46. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  47. data/config/routes.rb +1 -2
  48. data/db/migrate/20200917120220_add_ansible_playbook_id.rb +1 -1
  49. data/db/migrate/20201016002819_add_ansible_vars_all_to_app_definitions.rb +3 -0
  50. data/db/migrate/20201016104338_add_ansible_vars_all_to_app_instances.rb +3 -0
  51. data/db/migrate/20210112111548_add_organization_to_app_instance.rb +22 -0
  52. data/db/migrate/20210112113853_add_location_to_app_instance.rb +8 -0
  53. data/db/migrate/20210202141658_create_foreman_hosts.rb +24 -0
  54. data/db/migrate/20210204111306_remove_hosts_from_app_instances.rb +8 -0
  55. data/db/migrate/20210209091014_rename_acd_tables.rb +16 -0
  56. data/db/migrate/20210216083522_add_last_progress_report.rb +8 -0
  57. data/db/migrate/20210216091529_add_last_deploy_task.rb +8 -0
  58. data/db/seeds.d/62_acd_proxy_feature.rb +1 -3
  59. data/db/seeds.d/75-job_templates.rb +6 -1
  60. data/lib/foreman_acd/engine.rb +14 -3
  61. data/lib/foreman_acd/plugin.rb +49 -28
  62. data/lib/foreman_acd/version.rb +1 -1
  63. data/locale/en/foreman_acd.edit.po +326 -0
  64. data/locale/en/foreman_acd.po +232 -2
  65. data/{app/controllers/foreman_acd/api/v2/app_playbooks_controller.rb → locale/en/foreman_acd.po.time_stamp} +0 -0
  66. data/locale/foreman_acd.pot +343 -8
  67. data/test/controllers/ansible_playbooks_controller_test.rb +27 -0
  68. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +31 -18
  69. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +8 -0
  70. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +1 -0
  71. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +26 -0
  72. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +1 -0
  73. data/webpack/components/ApplicationDefinition/index.js +2 -0
  74. data/webpack/components/ApplicationInstance/ApplicationInstance.js +67 -30
  75. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +8 -0
  76. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +1 -0
  77. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +16 -2
  78. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +1 -0
  79. data/webpack/components/ApplicationInstance/components/Service.js +1 -1
  80. data/webpack/components/ApplicationInstance/index.js +2 -0
  81. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +53 -60
  82. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +17 -0
  83. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +7 -51
  84. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +2 -4
  85. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +4 -18
  86. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +0 -1
  87. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +1 -1
  88. data/webpack/components/ApplicationInstanceReport/index.js +0 -2
  89. data/webpack/components/ParameterSelection/ParameterSelection.js +10 -0
  90. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +8 -7
  91. data/webpack/components/common/DeleteTableEntry.js +3 -2
  92. data/webpack/components/common/EditTableEntry.js +2 -1
  93. data/webpack/components/common/LockTableEntry.js +2 -1
  94. metadata +48 -6
  95. data/app/views/foreman_acd/app_instances/deploy.html.erb +0 -19
@@ -3,7 +3,6 @@
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)
@@ -11,51 +10,64 @@ module ForemanAcd
11
10
  end
12
11
 
13
12
  def 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
+ @app_instance.foreman_hosts.each do |foreman_host|
18
+ service_data = services.select { |k| k['id'] == foreman_host.service.to_i }.first
19
+ host_params = set_host_params(foreman_host, service_data)
20
+
21
+ host = foreman_host.host.presence
22
+
23
+ is_rebuild = false
24
+
25
+ if host.blank?
26
+ params = host_attributes(host_params)
27
+ log_params = params.dup
28
+ log_params['root_pass'] = '****' if log_params.key?('root_pass')
29
+ msg = "Host creation parameters for #{foreman_host.hostname}:\n#{log_params}\n"
30
+ logger.info(msg)
31
+ output << msg
32
+ host = Host.new(params)
33
+ else
34
+ msg = "Update parameters and re-deploy host #{foreman_host.hostname}"
35
+ logger.info(msg)
36
+ output << msg
37
+ host.attributes = host_attributes(host_params, host)
38
+ is_rebuild = true
55
39
  end
40
+
41
+ # REMOVE ME (but very nice for testing)
42
+ # host.mac = "00:11:22:33:44:55"
43
+
44
+ apply_compute_profile(host)
45
+ host.suggest_default_pxe_loader
46
+
47
+ all_hosts << OpenStruct.new(:foreman_host => foreman_host, :host => host, :rebuild => is_rebuild)
56
48
  end
57
49
 
58
- return app_hosts
50
+ # do this in a second step, so that we get the progress report for all
51
+ all_hosts.each do |os_host|
52
+ # Save the host -> will initiate the deployment
53
+ os_host.host.save!
54
+ msg = "Saved and initiated/updated host #{os_host.foreman_host.hostname}"
55
+ logger.info(msg)
56
+ output << msg
57
+
58
+ os_host.host.power.reset if os_host.rebuild
59
+
60
+ # save the foreman host id
61
+ os_host.foreman_host.update!(:host_id => os_host.host.id)
62
+
63
+ progress_report = Rails.cache.fetch(os_host.host.progress_report_id)
64
+ os_host.foreman_host.update!(:last_progress_report => progress_report)
65
+ if progress_report.empty?
66
+ msg = "Progress report for #{os_host.foreman_host.hostname} is empty!"
67
+ output << msg
68
+ end
69
+ end
70
+ output
59
71
  end
60
72
 
61
73
  private
@@ -91,20 +103,20 @@ module ForemanAcd
91
103
 
92
104
  def hardcoded_params
93
105
  result = {}
94
- result['managed'] = true
95
- result['enabled'] = true
96
106
  result['build'] = true
97
107
  result['compute_attributes'] = { 'start' => '1' }
108
+ result['enabled'] = true
98
109
  result['host_parameters_attributes'] = []
110
+ result['managed'] = true
99
111
  result
100
112
  end
101
113
 
102
- def set_host_params(host_data, service_data)
114
+ def set_host_params(foreman_host, service_data)
103
115
  result = hardcoded_params
104
- result['name'] = host_data['hostname']
116
+ result['name'] = foreman_host.hostname
105
117
  result['hostgroup_id'] = service_data['hostgroup']
106
118
 
107
- host_data['foremanParameters'].each do |param|
119
+ JSON.parse(foreman_host.foremanParameters).each do |param|
108
120
  case param['type']
109
121
 
110
122
  when 'computeprofile'
@@ -3,12 +3,11 @@
3
3
  module ForemanAcd
4
4
  # inventory creator for application instances
5
5
  class InventoryCreator
6
-
7
6
  delegate :logger, :to => :Rails
8
7
 
9
- def initialize(app_instance, host_ids)
8
+ def initialize(app_instance, foreman_hosts)
10
9
  @app_instance = app_instance
11
- @host_ids = host_ids
10
+ @foreman_hosts = foreman_hosts
12
11
  end
13
12
 
14
13
  # TODO: this might be part of the smart proxy plugin.
@@ -16,52 +15,40 @@ module ForemanAcd
16
15
  inventory = {}
17
16
  inventory['all'] = {}
18
17
 
19
- inventory['all'] = { 'vars' => inventory_all_vars } unless @app_instance.ansible_vars_all.nil? || @app_instance.ansible_vars_all.empty?
18
+ inventory['all'] = { 'vars' => inventory_all_vars } if @app_instance.ansible_vars_all.present?
20
19
 
21
20
  services = JSON.parse(@app_instance.app_definition.services)
22
- app_hosts = filtered_hosts
23
21
 
24
22
  children = {}
25
- app_hosts.each do |host_data|
26
- if host_data['foreman_host_id'].nil?
27
- logger.warn "Ignore host #{host_data['hostname']} because no foreman host id could be found. Is the host not provisioned yet?"
23
+ @foreman_hosts.each do |foreman_host|
24
+ if foreman_host.host_id.nil?
25
+ logger.warn "Ignore host #{foreman_h.hostname} because no foreman host id could be found. Is the host not provisioned yet?"
28
26
  next
29
27
  end
30
28
 
31
- service_id = host_data['service'].to_i
29
+ service_id = foreman_host.service.to_i
32
30
  host_service = services.select { |s| s['id'] == service_id }.first
33
31
  ansible_group = host_service['ansibleGroup']
34
32
 
35
- unless children.has_key?(host_service['ansibleGroup'])
36
- children[ansible_group] = { 'hosts' => {} }
37
- end
33
+ children[ansible_group] = { 'hosts' => {} } unless children.key?(host_service['ansibleGroup'])
38
34
 
39
- ansible_vars = host_data['ansibleParameters'].map { |v| { v['name'] => v['value'] } }.reduce({}, :merge!)
35
+ ansible_vars = JSON.parse(foreman_host.ansibleParameters).map { |v| { v['name'] => v['value'] } }.reduce({}, :merge!)
40
36
 
41
37
  # in case there is no ansible_user defined, set "root" as default.
42
- unless ansible_vars.has_key?('ansible_user')
43
- ansible_vars['ansible_user'] = 'root'
44
- end
38
+ ansible_vars['ansible_user'] = 'root' unless ansible_vars.key?('ansible_user')
45
39
 
46
- children[ansible_group]['hosts'][get_fqdn(host_data['foreman_host_id'])] = ansible_vars
40
+ children[ansible_group]['hosts'][foreman_host.host.name] = ansible_vars
47
41
  end
48
42
  inventory['all']['children'] = children
49
43
  inventory
50
44
  end
51
45
 
52
46
  private
47
+
53
48
  def inventory_all_vars
54
49
  JSON.parse(@app_instance.ansible_vars_all).map do |a|
55
50
  { a['name'] => a['value'] }
56
51
  end.reduce({}, :merge!)
57
52
  end
58
-
59
- def get_fqdn(host_id)
60
- Host.find(host_id)&.name
61
- end
62
-
63
- def filtered_hosts
64
- JSON.parse(@app_instance.hosts).select{ |h| h&.key?('foreman_host_id') && @host_ids.include?(h['foreman_host_id']) }
65
- end
66
53
  end
67
54
  end
@@ -3,6 +3,12 @@
3
3
 
4
4
  <ul class="nav nav-tabs" data-tabs="tabs">
5
5
  <li class="active"><a href="#primary" data-toggle="tab"><%= _('Ansible playbooks') %></a></li>
6
+ <% if show_location_tab? %>
7
+ <li><a href="#locations" data-toggle="tab"><%= _("Locations") %></a></li>
8
+ <% end %>
9
+ <% if show_organization_tab? %>
10
+ <li><a href="#organizations" data-toggle="tab"><%= _("Organizations") %></a></li>
11
+ <% end %>
6
12
  </ul>
7
13
 
8
14
  <div class="tab-content">
@@ -13,8 +19,11 @@
13
19
  <% # TODO:
14
20
  # select_f(f, :scm_type, %w[Directory GIT], :downcase, :to_s)
15
21
  %>
16
- <%= text_f f, :path %>
17
- <%= text_f f, :playfile %>
22
+ <%= text_f f, :path, :required => true %>
23
+ <%= text_f f, :playfile, :required => true %>
24
+ </div>
25
+
26
+ <%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @ansible_playbook %>
18
27
  </div>
19
28
 
20
29
  <%= submit_or_cancel f %>
@@ -1,3 +1,11 @@
1
+ <%=
2
+ breadcrumbs(:resource_url => "/acd/api/v2/ansible_playbooks",
3
+ :items => [
4
+ { :caption => _('Ansible Playbooks'),
5
+ :url => url_for(ansible_playbooks_path) },
6
+ { :caption => "Edit #{@ansible_playbook.name}",
7
+ :url => (edit_ansible_playbook_path(@ansible_playbook) if authorized_for(hash_for_edit_ansible_playbook_path(@ansible_playbook))) }
8
+ ])
9
+ %>
1
10
  <% title(_('Edit Ansible Playbook %s') % @ansible_playbook) %>
2
-
3
11
  <%= render :partial => 'form' %>
@@ -12,12 +12,12 @@
12
12
  </tr>
13
13
  <% for ansible_playbook in @ansible_playbooks %>
14
14
  <tr>
15
- <td><%=link_to_if_authorized h(ansible_playbook.name), hash_for_edit_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer) %></td>
15
+ <td><%=link_to_if_authorized h(ansible_playbook.name), hash_for_edit_ansible_playbook_path(:id => ansible_playbook) %></td>
16
16
  <td><%= ansible_playbook.description %></td>
17
17
  <td>
18
18
  <%= action_buttons(
19
- display_link_if_authorized(_("Import group variables"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer)),
20
- display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook).merge(:auth_object => ansible_playbook, :authorizer => authorizer),
19
+ display_link_if_authorized(_("Import groups"), hash_for_import_vars_ansible_playbook_path(:id => ansible_playbook)),
20
+ display_delete_if_authorized(hash_for_ansible_playbook_path(:id => ansible_playbook),
21
21
  :data => { 'confirm': _('Delete %s?') % ansible_playbook.name })
22
22
  ) %>
23
23
  </td>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @ansible_playbook
2
4
 
3
5
  attributes :id, :name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @ansible_playbooks
2
4
 
3
5
  extends 'foreman_acd/api/v2/ansible_playbooks/base'
@@ -1,3 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @ansible_playbook
2
4
 
3
5
  extends 'foreman_acd/api/v2/ansible_playbooks/base'
6
+
7
+ node do |ansible_playbook|
8
+ partial('api/v2/taxonomies/children_nodes', :object => ansible_playbook)
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @app_definition
2
4
 
3
5
  attributes :id, :name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @app_definitions
2
4
 
3
5
  extends 'foreman_acd/api/v2/app_definitions/base'
@@ -1,3 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @app_definition
2
4
 
3
5
  extends 'foreman_acd/api/v2/app_definitions/base'
6
+
7
+ node do |app_definition|
8
+ partial('api/v2/taxonomies/children_nodes', :object => app_definition)
9
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @app_instance
2
4
 
3
- attributes :id, :name
5
+ attributes :id, :name, :organization_id, :organization_name, :location_id, :location_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  collection @app_instances
2
4
 
3
5
  extends 'foreman_acd/api/v2/app_instances/base'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  object @app_instance
2
4
 
3
5
  extends 'foreman_acd/api/v2/app_instances/base'
@@ -30,6 +30,12 @@
30
30
  <%= base_errors_for @app_definition %>
31
31
  <ul class="nav nav-tabs" data-tabs="tabs">
32
32
  <li class="active"><a href="#primary" data-toggle="tab"><%= _('Application Definitions') %></a></li>
33
+ <% if show_location_tab? %>
34
+ <li><a href="#locations" data-toggle="tab"><%= _("Locations") %></a></li>
35
+ <% end %>
36
+ <% if show_organization_tab? %>
37
+ <li><a href="#organizations" data-toggle="tab"><%= _("Organizations") %></a></li>
38
+ <% end %>
33
39
  </ul>
34
40
 
35
41
  <div class="tab-content">
@@ -40,6 +46,8 @@
40
46
  <div id='app_definition'></div>
41
47
  <%= mount_react_component('ApplicationDefinition', "#app_definition", json.to_json) %>
42
48
  </div>
49
+
50
+ <%= render 'taxonomies/loc_org_tabs', :f => f, :obj => @app_definition %>
43
51
  </div>
44
52
 
45
53
  <%= submit_or_cancel f %>
@@ -1,10 +1,15 @@
1
- <% title(_('Edit Application Definition %s') % @app_definition) %>
2
-
3
- <%= breadcrumbs(
4
- :resource_url => acd_api_v2_app_definitions_path
5
- )
1
+ <%=
2
+ breadcrumbs(:resource_url => "/acd/api/v2/app_definitions",
3
+ :items => [
4
+ { :caption => _('App Definitions'),
5
+ :url => url_for(app_definitions_path) },
6
+ { :caption => "Edit #{@app_definition.name}",
7
+ :url => (edit_app_definition_path(@app_definition) if authorized_for(hash_for_edit_app_definition_path(@app_definition))) }
8
+ ])
6
9
  %>
7
10
 
11
+ <% title(_('Edit Application Definition %s') % @app_definition) %>
12
+
8
13
  <% content_for(:javascripts) do %>
9
14
  <%= webpacked_plugins_js_for :foreman_acd %>
10
15
  <% end %>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <% title_actions button_group(
4
4
  new_link(_('New Application Definition')),
5
- display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default')
5
+ display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default', :style => "display: none;")
6
6
  ) %>
7
7
 
8
8
  <table class="table table-bordered table-striped">
@@ -13,13 +13,13 @@
13
13
  </tr>
14
14
  <% for app_definition in @app_definitions %>
15
15
  <tr>
16
- <td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer) %></td>
16
+ <td><%=link_to_if_authorized h(app_definition.name), hash_for_edit_app_definition_path(:id => app_definition) %></td>
17
17
  <td><%= app_definition.description %></td>
18
18
  <td>
19
19
  <%= action_buttons(
20
- display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
20
+ display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition),
21
21
  :data => { 'confirm': _('Delete %s?') % app_definition.name }),
22
- display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer))
22
+ # TODO: add export feature again if app-def + ansible playbook can be exported together display_link_if_authorized(_("Export"), hash_for_export_app_definition_path(:id => app_definition))
23
23
  ) %>
24
24
  </td>
25
25
  </tr>
@@ -20,7 +20,7 @@
20
20
  "id": @app_instance.app_definition.id,
21
21
  "name": @app_instance.app_definition.name,
22
22
  },
23
- "hosts": JSON.parse(@app_instance.hosts),
23
+ "hosts": collect_hosts_data,
24
24
  "ansibleVarsAll": @app_instance.ansible_vars_all.blank? ? [] : JSON.parse(@app_instance.ansible_vars_all),
25
25
  }
26
26
  end
@@ -42,7 +42,7 @@
42
42
  </div>
43
43
  </div>
44
44
  </div>
45
-
45
+ <%= f.hidden_field :organization_id %>
46
+ <%= f.hidden_field :location_id %>
46
47
  <%= submit_or_cancel f %>
47
48
  <% end %>
48
-
@@ -1,3 +1,13 @@
1
+ <%=
2
+ breadcrumbs(:resource_url => "/acd/api/v2/app_instances?location_id=#{@location.id}&organization_id=#{@organization.id}",
3
+ :items => [
4
+ { :caption => _('App Instances'),
5
+ :url => url_for(app_instances_path) },
6
+ { :caption => "Edit #{@app_instance.name}",
7
+ :url => (edit_app_instance_path(@app_instance) if authorized_for(hash_for_edit_app_instance_path(@app_instance))) }
8
+ ])
9
+ %>
10
+
1
11
  <% title(_('Edit Application Instance %s') % @app_instance) %>
2
12
 
3
13
  <% content_for(:javascripts) do %>