foreman_acd 0.0.6 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_acd/api/v2/app_definitions_controller.rb +1 -2
  3. data/app/controllers/foreman_acd/app_definitions_controller.rb +29 -1
  4. data/app/controllers/foreman_acd/app_instances_controller.rb +70 -21
  5. data/app/controllers/foreman_acd/concerns/app_definition_parameters.rb +1 -1
  6. data/app/controllers/foreman_acd/concerns/app_instance_parameters.rb +1 -1
  7. data/app/controllers/ui_acd_controller.rb +0 -1
  8. data/app/models/foreman_acd/app_definition.rb +0 -1
  9. data/app/views/foreman_acd/app_definitions/_form.html.erb +6 -14
  10. data/app/views/foreman_acd/app_definitions/import.html.erb +18 -0
  11. data/app/views/foreman_acd/app_definitions/index.html.erb +9 -5
  12. data/app/views/foreman_acd/app_instances/_form.html.erb +5 -5
  13. data/app/views/foreman_acd/app_instances/deploy.html.erb +19 -0
  14. data/app/views/foreman_acd/app_instances/index.html.erb +6 -5
  15. data/app/views/foreman_acd/app_instances/report.html.erb +19 -0
  16. data/app/views/ui_acd/app_definition.json.rabl +1 -1
  17. data/config/routes.rb +7 -0
  18. data/db/migrate/20190610202252_create_app_definitions.rb +1 -3
  19. data/db/migrate/20190625140305_create_app_instances.rb +1 -1
  20. data/lib/foreman_acd/plugin.rb +19 -2
  21. data/lib/foreman_acd/version.rb +1 -1
  22. data/webpack/components/ApplicationDefinition/ApplicationDefinition.js +261 -0
  23. data/webpack/components/ApplicationDefinition/ApplicationDefinition.scss +1 -0
  24. data/webpack/components/ApplicationDefinition/ApplicationDefinitionActions.js +211 -0
  25. data/webpack/components/ApplicationDefinition/ApplicationDefinitionConstants.js +9 -0
  26. data/webpack/components/ApplicationDefinition/ApplicationDefinitionReducer.js +147 -0
  27. data/webpack/components/ApplicationDefinition/ApplicationDefinitionSelectors.js +6 -0
  28. data/webpack/components/ApplicationDefinition/index.js +29 -0
  29. data/webpack/components/ApplicationInstance/ApplicationInstance.js +342 -0
  30. data/webpack/components/ApplicationInstance/ApplicationInstance.scss +11 -0
  31. data/webpack/components/ApplicationInstance/ApplicationInstanceActions.js +210 -0
  32. data/webpack/components/ApplicationInstance/ApplicationInstanceConstants.js +12 -0
  33. data/webpack/components/ApplicationInstance/ApplicationInstanceReducer.js +223 -0
  34. data/webpack/components/ApplicationInstance/ApplicationInstanceSelectors.js +8 -0
  35. data/webpack/components/ApplicationInstance/components/AppDefinitionSelector.js +49 -0
  36. data/webpack/components/ApplicationInstance/components/Service.js +30 -0
  37. data/webpack/components/ApplicationInstance/components/ServiceCounter.js +37 -0
  38. data/webpack/components/ApplicationInstance/index.js +33 -0
  39. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.js +155 -0
  40. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReport.scss +27 -0
  41. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportActions.js +86 -0
  42. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportConstants.js +4 -0
  43. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportReducer.js +52 -0
  44. data/webpack/components/ApplicationInstanceReport/ApplicationInstanceReportSelectors.js +5 -0
  45. data/webpack/components/ApplicationInstanceReport/components/ReportViewer.js +26 -0
  46. data/webpack/components/ApplicationInstanceReport/index.js +27 -0
  47. data/webpack/components/ParameterSelection/ParameterSelection.js +65 -161
  48. data/webpack/components/ParameterSelection/ParameterSelection.scss +9 -0
  49. data/webpack/components/ParameterSelection/ParameterSelectionActions.js +42 -71
  50. data/webpack/components/ParameterSelection/ParameterSelectionConstants.js +12 -19
  51. data/webpack/components/ParameterSelection/ParameterSelectionHelper.js +3 -3
  52. data/webpack/components/ParameterSelection/ParameterSelectionReducer.js +76 -75
  53. data/webpack/components/ParameterSelection/ParameterSelectionSelectors.js +2 -6
  54. data/webpack/components/ParameterSelection/__fixtures__/parameterSelection.fixtures.js +12 -21
  55. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionData_1.fixtures.js +1 -1
  56. data/webpack/components/ParameterSelection/__fixtures__/parameterSelectionReducer.fixtures.js +3 -45
  57. data/webpack/components/ParameterSelection/__tests__/ParameterSelection.test.js +20 -0
  58. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionReducer.test.js +22 -46
  59. data/webpack/components/ParameterSelection/__tests__/ParameterSelectionSelectors.test.js +6 -6
  60. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelection.test.js.snap +40 -265
  61. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionReducer.test.js.snap +11 -96
  62. data/webpack/components/ParameterSelection/__tests__/__snapshots__/ParameterSelectionSelectors.test.js.snap +3 -9
  63. data/webpack/components/ParameterSelection/index.js +4 -6
  64. data/webpack/components/common/AddTableEntry.js +30 -0
  65. data/webpack/components/common/DeleteTableEntry.js +39 -0
  66. data/webpack/components/common/ExtSelect.js +43 -0
  67. data/webpack/components/common/RailsData.js +27 -0
  68. data/webpack/components/common/__tests__/AddTableEntry.test.js +26 -0
  69. data/webpack/components/common/__tests__/DeleteTableEntry.test.js +29 -0
  70. data/webpack/components/common/__tests__/ExtSelect.test.js +38 -0
  71. data/webpack/components/common/__tests__/RailsData.test.js +16 -0
  72. data/webpack/components/common/__tests__/__snapshots__/AddParameter.test.js.snap +35 -0
  73. data/webpack/components/common/__tests__/__snapshots__/AddTableEntry.test.js.snap +35 -0
  74. data/webpack/components/common/__tests__/__snapshots__/DeleteParameter.test.js.snap +41 -0
  75. data/webpack/components/common/__tests__/__snapshots__/DeleteTableEntry.test.js.snap +41 -0
  76. data/webpack/components/common/__tests__/__snapshots__/ExtSelect.test.js.snap +18 -0
  77. data/webpack/components/common/__tests__/__snapshots__/RailsData.test.js.snap +10 -0
  78. data/webpack/helper.js +20 -0
  79. data/webpack/index.js +6 -0
  80. data/webpack/reducer.js +40 -3
  81. metadata +47 -46
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc128735b86a6df24be3490ecec2792097945edd5de653d2cdfeeb8022d259e6
4
- data.tar.gz: 47d6de7ab66f891bf07569ad795a77b2dc2db6070f4c32e198f6573c945c7305
3
+ metadata.gz: ef0b36ad161877bede4fe9a9df532a8201fc31710b1f42ab988152aeba863cac
4
+ data.tar.gz: a629384ff81f18c21883ea4a09a76828988bff02e6a709a7f2151e77fff46836
5
5
  SHA512:
6
- metadata.gz: bc3220d4ccacc055d7b332f0761671ba4d82a04bdc8aeaa82cab5567e85e1bb9092edb2fa78423115b042ca7fdff3971b93a46b141f87f888e83e8fcdf42dfae
7
- data.tar.gz: 496f08b50b1014605995e80dbe2311c9ec02bbc2ab3db147ba415090d28ee2ed194376891772c79ef4986f8418312b9319949471ee5f03c94c991380a980552e
6
+ metadata.gz: 8c8843594e0cbad7c6b85398c8b4d2c8fe18703ef7dc5c2ebd4fd46ccd0690a3cf30588e13dcef66e9d568fa4c5ca97fd272ebb5f5107e3f2ad1258f9fb9d35f
7
+ data.tar.gz: 99181b0218e89485fffedfdd1374b095c1830614718332246f72238af50adb65610e03fdaa0a035f6cd68208d8f72679b141eac2b558dc1824abb30b21120b56
@@ -24,8 +24,7 @@ module ForemanAcd
24
24
  param :app_definition, Hash, :required => true, :action_aware => true do
25
25
  param :name, String, :required => true
26
26
  param :description, String, :required => true
27
- param :hostgroup_id, :number, :required => true
28
- param :parameters, String, :required => true
27
+ param :services, String, :required => true
29
28
  end
30
29
  end
31
30
 
@@ -6,7 +6,8 @@ module ForemanAcd
6
6
  include Foreman::Controller::AutoCompleteSearch
7
7
  include ::ForemanAcd::Concerns::AppDefinitionParameters
8
8
 
9
- before_action :find_resource, :only => [:edit, :update, :destroy]
9
+ before_action :find_resource, :only => [:edit, :update, :destroy, :export]
10
+ before_action :handle_file_upload, :only => [:create]
10
11
 
11
12
  def index
12
13
  @app_definitions = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
@@ -49,5 +50,32 @@ module ForemanAcd
49
50
  process_error
50
51
  end
51
52
  end
53
+
54
+ def action_permission
55
+ case params[:action]
56
+ when 'export'
57
+ :export
58
+ else
59
+ super
60
+ end
61
+ end
62
+
63
+ def import
64
+ read_hostgroups
65
+ @app_definition = AppDefinition.new
66
+ end
67
+
68
+ def export
69
+ filename = "#{@app_definition.name}.yaml"
70
+ data = JSON.parse(@app_definition.services).to_yaml
71
+ send_data data, :type => 'text/yaml', :disposition => 'attachment', :filename => filename
72
+ end
73
+
74
+ private
75
+
76
+ def handle_file_upload
77
+ return unless params[:foreman_acd_app_definition] && raw_file = params[:foreman_acd_app_definition][:app_definition_file]
78
+ params[:foreman_acd_app_definition][:services] = YAML.load_file(raw_file.tempfile).to_json
79
+ end
52
80
  end
53
81
  end
@@ -6,7 +6,7 @@ module ForemanAcd
6
6
  include Foreman::Controller::AutoCompleteSearch
7
7
  include ::ForemanAcd::Concerns::AppInstanceParameters
8
8
 
9
- before_action :find_resource, :only => [:edit, :update, :destroy, :deploy]
9
+ before_action :find_resource, :only => [:edit, :update, :destroy, :deploy, :report]
10
10
 
11
11
  def index
12
12
  @app_instances = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
@@ -54,26 +54,76 @@ module ForemanAcd
54
54
  case params[:action]
55
55
  when 'deploy'
56
56
  :deploy
57
+ when 'report'
58
+ :report
57
59
  else
58
60
  super
59
61
  end
60
62
  end
61
63
 
62
64
  def deploy
63
- params = host_attributes(set_host_params)
64
-
65
- # Print to log for debugging purposes
66
- logger.info("Host creation parameters:\n#{params}\n")
67
-
68
- @host = Host.new(params)
69
- apply_compute_profile(@host)
70
- @host.suggest_default_pxe_loader
71
- @host.save
72
- success _('Successfully initiated host creation')
73
- rescue StandardError => e
74
- logger.error("Failed to initiate host creation: #{e.backtrace.join($INPUT_RECORD_SEPARATOR)}")
75
- ensure
76
- redirect_to app_instances_path
65
+ services = JSON.parse(@app_instance.app_definition.services)
66
+ @deploy_hosts = []
67
+
68
+ app_hosts = JSON.parse(@app_instance.hosts)
69
+
70
+ app_hosts.each do |host_data|
71
+ begin
72
+ service_data = services.select { |k| k['id'] == host_data['service'].to_i }.first
73
+ host_params = set_host_params(host_data, service_data)
74
+
75
+ host = nil
76
+ if host_data.has_key?('foreman_host_id')
77
+ logger.debug("Try to find host with id #{host_data['foreman_host_id']}")
78
+ begin
79
+ host = Host.find(host_data['foreman_host_id'])
80
+ rescue ActiveRecord::RecordNotFound
81
+ logger.info("Host with id #{host_data['foreman_host_id']} couldn\'t be found, create a new one!")
82
+ host = nil
83
+ end
84
+ end
85
+
86
+ if host.nil?
87
+ logger.info("Host creation parameters for #{host_data['hostname']}:\n#{params}\n")
88
+ params = host_attributes(host_params)
89
+ host = Host.new(params)
90
+ else
91
+ logger.info("Update parameters and re-deploy host #{host_data['hostname']}")
92
+ host.attributes = host_attributes(host_params, host)
93
+ host.setBuild
94
+ host.power.reset
95
+ end
96
+
97
+ # REMOVE ME (but very nice for testing)
98
+ #host.mac = "00:11:22:33:44:55"
99
+
100
+ apply_compute_profile(host)
101
+ host.suggest_default_pxe_loader
102
+ host.save
103
+
104
+ # save the foreman host id
105
+ host_data['foreman_host_id'] = host.id
106
+
107
+ @deploy_hosts.push({ id: host.id, name: host_data['hostname'], hostname: host.hostname, hostUrl: host_path(h), progress_report_id: host.progress_report_id})
108
+ rescue StandardError => e
109
+ logger.error("Failed to initiate host creation: #{e.backtrace.join($INPUT_RECORD_SEPARATOR)}")
110
+ end
111
+ end
112
+
113
+ # save any change to the app_hosts json
114
+ @app_instance.hosts = app_hosts.to_json
115
+ @app_instance.save
116
+ end
117
+
118
+ def report
119
+ @report_hosts = []
120
+ app_hosts = JSON.parse(@app_instance.hosts)
121
+ app_hosts.each do |host_data|
122
+ h = Host.find(host_data['foreman_host_id'])
123
+ @report_hosts.push({id: h.id, name: host_data['hostname'], hostname: h.hostname, hostUrl: host_path(h), powerStatusUrl: power_api_host_path(h) })
124
+ end
125
+
126
+ logger.debug("deploy report hosts are: #{@report_hosts.inspect}")
77
127
  end
78
128
 
79
129
  private
@@ -117,10 +167,12 @@ module ForemanAcd
117
167
  result
118
168
  end
119
169
 
120
- def set_host_params
170
+ def set_host_params(host_data, service_data)
121
171
  result = hardcoded_params
122
- result['hostgroup_id'] = @app_instance.app_definition.hostgroup_id
123
- JSON.parse(@app_instance.parameters).each do |param|
172
+ result['name'] = host_data['hostname']
173
+ result['hostgroup_id'] = service_data['hostgroup']
174
+
175
+ host_data['parameters'].each do |param|
124
176
  case param['type']
125
177
 
126
178
  when 'computeprofile'
@@ -129,9 +181,6 @@ module ForemanAcd
129
181
  when 'domain'
130
182
  result['domain_id'] = param['value']
131
183
 
132
- when 'hostname'
133
- result['name'] = param['value']
134
-
135
184
  when 'hostparam'
136
185
  result['host_parameters_attributes'].push(:name => param['name'], :value => param['value'])
137
186
 
@@ -9,7 +9,7 @@ module ForemanAcd
9
9
  class_methods do
10
10
  def app_definition_params_filter
11
11
  Foreman::ParameterFilter.new(::ForemanAcd::AppDefinition).tap do |filter|
12
- filter.permit(:name, :description, :hostgroup_id, :parameters)
12
+ filter.permit(:name, :description, :services)
13
13
  end
14
14
  end
15
15
  end
@@ -9,7 +9,7 @@ module ForemanAcd
9
9
  class_methods do
10
10
  def app_instance_params_filter
11
11
  Foreman::ParameterFilter.new(::ForemanAcd::AppInstance).tap do |filter|
12
- filter.permit(:name, :app_definition_id, :description, :parameters)
12
+ filter.permit(:name, :app_definition_id, :description, :hosts)
13
13
  end
14
14
  end
15
15
  end
@@ -6,7 +6,6 @@ class UiAcdController < ::Api::V2::BaseController
6
6
  @app_data = {}
7
7
  app_definition = ForemanAcd::AppDefinition.find(params[:id])
8
8
  @app_data['app_definition'] = app_definition
9
- @app_data['fdata'] = collect_fdata(app_definition.hostgroup_id)
10
9
  end
11
10
 
12
11
  def fdata
@@ -8,7 +8,6 @@ module ForemanAcd
8
8
  friendly_id :name
9
9
 
10
10
  validates :name, :presence => true, :uniqueness => true
11
- belongs_to :hostgroup, :class_name => '::Hostgroup'
12
11
  has_many :app_instances, :inverse_of => :app_definition, :dependent => :destroy
13
12
  scoped_search :on => :name
14
13
 
@@ -3,21 +3,13 @@
3
3
  "organization": current_organization,
4
4
  "location": current_location,
5
5
  "hostgroups": @hostgroups,
6
- "loadForemanDataUrl": ui_acd_fdata_path("__id__")
6
+ "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
7
+ "services": [],
7
8
  }
8
9
 
9
- if @app_definition.name.empty?
10
- json["mode"] = "newDefinition"
11
- else
12
- json["mode"] = "editDefinition"
13
- json["appDefinition"] = {
14
- "id": @app_definition.id,
15
- "name": @app_definition.name,
16
- "hostgroup_id": @app_definition.hostgroup_id,
17
- }
18
- json["parameters"] = JSON.parse(@app_definition.parameters)
10
+ if !@app_definition.name.empty?
11
+ json["services"] = JSON.parse(@app_definition.services)
19
12
  end
20
-
21
13
  %>
22
14
 
23
15
  <%= form_for @app_definition, :url => (@app_definition.new_record? ? app_definitions_path : app_definition_path(:id => @app_definition.id)) do |f| %>
@@ -31,8 +23,8 @@
31
23
  <%= text_f f, :name %>
32
24
  <%= text_f f, :description %>
33
25
 
34
- <div id='param-selection'></div>
35
- <%= mount_react_component('ParameterSelection', "#param-selection", json.to_json) %>
26
+ <div id='app_definition'></div>
27
+ <%= mount_react_component('ApplicationDefinition', "#app_definition", json.to_json) %>
36
28
  </div>
37
29
  </div>
38
30
 
@@ -0,0 +1,18 @@
1
+ <% title _('Import Application Definition') %>
2
+
3
+ <%= form_for @app_definition, :url => (app_definitions_path), :html => { :multipart => true } do |f| %>
4
+ <%= base_errors_for @app_definition %>
5
+ <ul class="nav nav-tabs" data-tabs="tabs">
6
+ <li class="active"><a href="#primary" data-toggle="tab"><%= _('Application Definitions') %></a></li>
7
+ </ul>
8
+
9
+ <div class="tab-content">
10
+ <div class="tab-pane active" id="primary">
11
+ <%= text_f f, :name %>
12
+ <%= text_f f, :description %>
13
+ <%= file_field_f f, :app_definition_file, :label_help => _("Application Definition file") %>
14
+ </div>
15
+ </div>
16
+
17
+ <%= submit_or_cancel f %>
18
+ <% end %>
@@ -1,22 +1,26 @@
1
1
  <% title _('Application Definitions') %>
2
2
 
3
- <% title_actions button_group(new_link(_('New Application Definition'))) %>
3
+ <% title_actions button_group(
4
+ new_link(_('New Application Definition')),
5
+ display_link_if_authorized(_("Import"), hash_for_import_app_definitions_path, :class => 'btn btn-default')
6
+ ) %>
4
7
 
5
8
  <table class="table table-bordered table-striped">
6
9
  <tr>
7
10
  <th><%= sort :name, :as => s_('AppDefinition|Name') %></th>
8
11
  <th><%= _('Description') %></th>
9
- <th><%= sort :hostgroup, :as => _('Host groups'), :default => 'DESC' %></th>
10
12
  <th></th>
11
13
  </tr>
12
14
  <% for app_definition in @app_definitions %>
13
15
  <tr>
14
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>
15
17
  <td><%= app_definition.description %></td>
16
- <td><%= app_definition.hostgroup %></td>
17
18
  <td>
18
- <%= action_buttons(display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
19
- :data => { 'confirm': _('Delete %s?') % app_definition.name })) %>
19
+ <%= action_buttons(
20
+ display_delete_if_authorized(hash_for_app_definition_path(:id => app_definition).merge(:auth_object => app_definition, :authorizer => authorizer),
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))
23
+ ) %>
20
24
  </td>
21
25
  </tr>
22
26
  <% end %>
@@ -5,7 +5,7 @@
5
5
  "organization": current_organization,
6
6
  "location": current_location,
7
7
  "applications": @applications,
8
- "loadParameterSelectionUrl": ui_acd_app_path("__id__"),
8
+ "loadAppDefinitionUrl": ui_acd_app_path("__id__"),
9
9
  "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
10
10
  }
11
11
  else
@@ -13,13 +13,13 @@
13
13
  "mode": "editInstance",
14
14
  "organization": current_organization,
15
15
  "location": current_location,
16
+ "loadAppDefinitionUrl": ui_acd_app_path("__id__"),
16
17
  "loadForemanDataUrl": ui_acd_fdata_path("__id__"),
17
18
  "appDefinition": {
18
19
  "id": @app_instance.app_definition.id,
19
20
  "name": @app_instance.app_definition.name,
20
- "hostgroup_id": @app_instance.app_definition.hostgroup_id,
21
21
  },
22
- "parameters": JSON.parse(@app_instance.parameters),
22
+ "hosts": JSON.parse(@app_instance.hosts),
23
23
  }
24
24
  end
25
25
  %>
@@ -35,8 +35,8 @@
35
35
  <%= text_f f, :name %>
36
36
  <%= text_f f, :description %>
37
37
 
38
- <div id='param-selection'></div>
39
- <%= mount_react_component('ParameterSelection', "#param-selection", json.to_json) %>
38
+ <div id='app_instance'></div>
39
+ <%= mount_react_component('ApplicationInstance', "#app_instance", json.to_json) %>
40
40
  </div>
41
41
  </div>
42
42
  </div>
@@ -0,0 +1,19 @@
1
+ <% title _("Deploy Application Instance #{@app_instance}") %>
2
+
3
+ <% content_for(:javascripts) do %>
4
+ <%= webpacked_plugins_js_for :foreman_acd %>
5
+ <% end %>
6
+ <% content_for(:stylesheets) do %>
7
+ <%= webpacked_plugins_css_for :foreman_acd %>
8
+ <% end %>
9
+
10
+ <%
11
+ json = {
12
+ "mode": 'liveReport',
13
+ "hosts": @deploy_hosts
14
+ }
15
+ %>
16
+
17
+ <div id='deploy'></div>
18
+ <%= mount_react_component('ApplicationInstanceReport', "#deploy", json.to_json) %>
19
+ </div
@@ -15,11 +15,12 @@
15
15
  <td><%= app_instance.app_definition %></td>
16
16
  <td><%= app_instance.description %></td>
17
17
  <td>
18
- <%= action_buttons(display_delete_if_authorized(hash_for_app_instance_path(:id => app_instance).merge(:auth_object => app_instance, :authorizer => authorizer),
19
- :data => { 'confirm': _('Delete %s?') % app_instance.name }),
20
- display_link_if_authorized(_("Deploy"), hash_for_deploy_app_instance_path(:id => app_instance), :method => :post,
21
- :title => _("Deploy the application #{app_instance}"))
22
- ) %>
18
+ <%= action_buttons(display_link_if_authorized(_("Deploy"), hash_for_deploy_app_instance_path(:id => app_instance), :method => :post,
19
+ :title => _("Deploy application #{app_instance}")),
20
+ display_link_if_authorized(_("Report"), hash_for_report_app_instance_path(:id => app_instance), :method => :get,
21
+ :title => _("Show last deployment report for application #{app_instance}")),
22
+ display_delete_if_authorized(hash_for_app_instance_path(:id => app_instance).merge(:auth_object => app_instance, :authorizer => authorizer),
23
+ :data => { 'confirm': _('Delete %s?') % app_instance.name })) %>
23
24
  </td>
24
25
  </tr>
25
26
  <% end %>
@@ -0,0 +1,19 @@
1
+ <% title _("Deployment Report for Application Instance #{@app_instance}") %>
2
+
3
+ <% content_for(:javascripts) do %>
4
+ <%= webpacked_plugins_js_for :foreman_acd %>
5
+ <% end %>
6
+ <% content_for(:stylesheets) do %>
7
+ <%= webpacked_plugins_css_for :foreman_acd %>
8
+ <% end %>
9
+
10
+ <%
11
+ json = {
12
+ "mode": 'lastReport',
13
+ "hosts": @report_hosts
14
+ }
15
+ %>
16
+
17
+ <div id='report'></div>
18
+ <%= mount_react_component('ApplicationInstanceReport', "#report", json.to_json) %>
19
+ </div
@@ -2,4 +2,4 @@
2
2
 
3
3
  object @app_definition
4
4
 
5
- attributes :id, :name, :description, :hostgroup_id, :parameters, :created_at, :updated_at
5
+ attributes :id, :name, :description, :services, :created_at, :updated_at
@@ -5,7 +5,13 @@ Rails.application.routes.draw do
5
5
  resources :app_definitions, :controller => 'foreman_acd/app_definitions' do
6
6
  collection do
7
7
  get 'auto_complete_search'
8
+ get 'import'
8
9
  end
10
+
11
+ member do
12
+ get 'export'
13
+ end
14
+
9
15
  end
10
16
 
11
17
  resources :app_instances, :controller => 'foreman_acd/app_instances' do
@@ -15,6 +21,7 @@ Rails.application.routes.draw do
15
21
 
16
22
  member do
17
23
  post 'deploy'
24
+ get 'report'
18
25
  end
19
26
  end
20
27
 
@@ -6,11 +6,9 @@ class CreateAppDefinitions < ActiveRecord::Migration[5.2]
6
6
  create_table :app_definitions do |t|
7
7
  t.string :name, :default => '', :null => false, :limit => 255, :unique => true
8
8
  t.text :description
9
- t.column :hostgroup_id, :integer
10
- t.text :parameters
9
+ t.text :services
11
10
  t.timestamps :null => true
12
11
  end
13
- add_foreign_key :app_definitions, :hostgroups
14
12
  end
15
13
 
16
14
  def down