foreman_remote_execution 3.3.2 → 3.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d093d837d0009e477549fba4700f3e0090045ba23f8b2c50fb05439fee53e403
4
- data.tar.gz: 54dffc56caa3fa1bb72bb159b152d267d2e348b64b57322ea74cdf0ad9289cc1
3
+ metadata.gz: 7c5854e373426c0a630f0a643f88522425c6482fb88fee1888fc6f61114217c3
4
+ data.tar.gz: f333b2504dc7db6e1119d418c89fcd2cd35d5dcbd72e97d393b57a16c9d305a6
5
5
  SHA512:
6
- metadata.gz: e3524503031c73f86a0f3ed0b6c8dd39499f85df47052eca941f455552665b93ff041e5d6df9870cfb95ac1219017a561a483556306905bdc005caf252a5e088
7
- data.tar.gz: 537da427406ce7c794d5e589e7e82f8c6fbda33a3a4231129905b69171421f41e98563c0496d9c7cc748f675d200729ec52f4d9067a8f7879972922358a2a868
6
+ metadata.gz: 3df47233fbc5b7bb2628a2bb49906c284e8e7c821bb8a026659e0473f9bc8760d5ed3c19f27183f5fd32ab39d5b06cdb0e9345a1e9e4a4629a269adb3121370a
7
+ data.tar.gz: 33d40d8f6449814f23648dbe20c6a376a152135b4a4c5de583a73e1db03ab69ecb39b1a2ce3a1cabad717be898a683f3d58fe5e1aaf50438011f6ce4cfbbe2b4
@@ -34,6 +34,7 @@ jobs:
34
34
  ruby-version: [2.5, 2.6]
35
35
  node-version: [12]
36
36
  steps:
37
+ - run: sudo apt-get update
37
38
  - run: sudo apt-get install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev
38
39
  - uses: actions/checkout@v2
39
40
  with:
@@ -1,9 +1,6 @@
1
- div.infoblock {
2
- margin-bottom: 20px;
3
- line-height: 2;
4
-
1
+ .target-hosts-card {
5
2
  pre {
6
- margin-top: 5px;
3
+ white-space:pre-line;
7
4
  }
8
5
  }
9
6
 
@@ -29,3 +26,7 @@ div.infoblock {
29
26
  }
30
27
  }
31
28
  }
29
+
30
+ .text_warp{
31
+ word-wrap: break-word;
32
+ }
@@ -18,14 +18,14 @@ module Api
18
18
 
19
19
  api :GET, '/job_invocations/:id', N_('Show job invocation')
20
20
  param :id, :identifier, :required => true
21
- param :host_status, String, required: false, allow_blank: true, desc: N_('Show Job status for the hosts.')
21
+ param :host_status, :bool, required: false, desc: N_('Show Job status for the hosts')
22
22
  def show
23
23
  @hosts = @job_invocation.targeting.hosts.authorized(:view_hosts, Host)
24
24
  @template_invocations = @job_invocation.template_invocations
25
25
  .where(host: @hosts)
26
26
  .includes(:input_values)
27
27
 
28
- if params[:host_status]
28
+ if params[:host_status] == 'true'
29
29
  template_invocations = @template_invocations.includes(:run_host_job_task).to_a
30
30
  @host_statuses = Hash[template_invocations.map { |ti| [ti.host_id, template_invocation_status(ti)] }]
31
31
  end
@@ -80,6 +80,7 @@ module Api
80
80
  end
81
81
  composer.trigger!
82
82
  @job_invocation = composer.job_invocation
83
+ @hosts = @job_invocation.targeting.hosts
83
84
  process_response @job_invocation
84
85
  end
85
86
 
@@ -15,9 +15,13 @@ module ForemanRemoteExecution
15
15
  proxy = ::SmartProxy.find(proxy_id)
16
16
  begin
17
17
  proxy.drop_host_from_known_hosts(target)
18
- rescue RestClient::ResourceNotFound => e
19
- # ignore 404 when known_hosts entry is missing or the module was not enabled
20
- Foreman::Logging.exception "Proxy failed to delete SSH known_hosts for #{name}, #{ip}", e, :level => :error
18
+ rescue ::ProxyAPI::ProxyException => e
19
+ if e.wrapped_exception.is_a?(RestClient::NotFound)
20
+ # ignore 404 when known_hosts entry is missing or the module was not enabled
21
+ Foreman::Logging.exception "Proxy failed to delete SSH known_hosts for #{name}, #{ip}", e, :level => :error
22
+ else
23
+ raise e
24
+ end
21
25
  rescue => e
22
26
  Rails.logger.warn e.message
23
27
  return false
@@ -29,7 +33,10 @@ module ForemanRemoteExecution
29
33
  logger.debug "Scheduling SSH known_hosts cleanup"
30
34
 
31
35
  host, _kind, _target = host_kind_target
32
- proxies = host.remote_execution_proxies('SSH').values
36
+ # #remote_execution_proxies may not be defined on the host object in some case
37
+ # for example Host::Discovered does not have it defined, even though these hosts
38
+ # have Nic::Managed interfaces associated with them
39
+ proxies = (host.try(:remote_execution_proxies, 'SSH') || {}).values
33
40
  proxies.flatten.uniq.each do |proxy|
34
41
  queue.create(id: queue_id(proxy.id), name: _("Remove SSH known hosts for %s") % self,
35
42
  priority: 200, action: [self, :drop_from_known_hosts, proxy.id])
@@ -10,7 +10,9 @@ class DefaultProxyProxySelector < ::RemoteExecutionProxySelector
10
10
  def available_proxies(host, provider)
11
11
  # TODO: Once we have a internal proxy marker/feature on the proxy, we can
12
12
  # swap the implementation
13
- internal_proxy = ::Katello.default_capsule
13
+ raise _('default_capsule method missing from SmartProxy') unless ::SmartProxy.respond_to?(:default_capsule)
14
+
15
+ internal_proxy = ::SmartProxy.default_capsule
14
16
  super.reduce({}) do |acc, (key, proxies)|
15
17
  acc.merge(key => proxies.select { |proxy| proxy == internal_proxy })
16
18
  end
@@ -19,10 +19,10 @@ child :targeting do
19
19
  attributes :bookmark_id, :search_query, :targeting_type, :user_id, :status, :status_label,
20
20
  :randomized_ordering
21
21
 
22
- child @hosts do
22
+ child @hosts => :hosts do
23
23
  extends 'api/v2/hosts/base'
24
24
 
25
- if params[:host_status]
25
+ if params[:host_status] == 'true'
26
26
  node :job_status do |host|
27
27
  @host_statuses[host.id]
28
28
  end
@@ -1,5 +1,5 @@
1
1
  <% template_invocations = job_invocation.pattern_template_invocations %>
2
- <div class="card-pf card-pf-accented">
2
+ <div class="card-pf card-pf-accented target-hosts-card">
3
3
  <div class="card-pf-title">
4
4
  <h2 style="height: 18px;" class="card-pf-title">
5
5
  <%= _('Target hosts') %>
@@ -1,3 +1,4 @@
1
+ <% stylesheet 'foreman_remote_execution/foreman_remote_execution' %>
1
2
  <% title _('Job invocations') %>
2
3
 
3
4
  <% title_actions(job_invocations_buttons) %>
@@ -19,7 +20,7 @@
19
20
  <tbody>
20
21
  <% @job_invocations.each do |invocation| %>
21
22
  <tr>
22
- <td><%= link_to_if_authorized invocation_description(invocation), hash_for_job_invocation_path(invocation).merge(:auth_object => invocation, :permission => :view_job_invocations, :authorizer => authorizer) %></td>
23
+ <td class="text_warp"><%= link_to_if_authorized invocation_description(invocation), hash_for_job_invocation_path(invocation).merge(:auth_object => invocation, :permission => :view_job_invocations, :authorizer => authorizer) %></td>
23
24
  <td><%= trunc_with_tooltip(invocation&.targeting&.search_query, 15) %></td>
24
25
  <td><%= link_to_invocation_task_if_authorized(invocation) %></td>
25
26
  <td><%= invocation_result(invocation, :success_count) %></td>
@@ -41,3 +41,9 @@
41
41
  <% end %>
42
42
  <%= render_tab_content_for(:main_tabs, subject: @job_invocation) %>
43
43
  </div>
44
+
45
+ <script id="job_invocation_refresh" data-refresh-url="<%= job_invocation_path(@job_invocation) %>">
46
+ <% if @auto_refresh %>
47
+ delayed_refresh($('script#job_invocation_refresh').data('refresh-url'), {});
48
+ <% end %>
49
+ </script>
@@ -0,0 +1,5 @@
1
+ $('div#title_action div.btn-group').html('<%= button_group(job_invocation_task_buttons(@job_invocation.task)).html_safe %>');
2
+
3
+ <% if @auto_refresh %>
4
+ delayed_refresh($('script#job_invocation_refresh').data('refresh-url'), job_invocation_refresh_data());
5
+ <% end %>
@@ -97,6 +97,7 @@ handle_zypp_res_codes () {
97
97
  end
98
98
  end
99
99
  -%>
100
+ [ -x "$(command -v subscription-manager)" ] && subscription-manager refresh
100
101
  apt-get -y update
101
102
  apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y <%= action %> <%= input("package") %>
102
103
  <% elsif package_manager == 'zypper' -%>
@@ -13,4 +13,7 @@ template_inputs:
13
13
  provider_type: SSH
14
14
  kind: job_template
15
15
  -%>
16
+ <% if @host.operatingsystem.family == 'Debian' -%>
17
+ export PATH=/opt/puppetlabs/bin:$PATH
18
+ <% end -%>
16
19
  puppet agent --disable "<%= input("comment").present? ? input("comment") : "Disabled using Foreman Remote Execution" %> - <%= current_user %> - $(date "+%d/%m/%Y %H:%M")"
@@ -7,4 +7,7 @@ snippet: false
7
7
  provider_type: SSH
8
8
  kind: job_template
9
9
  -%>
10
+ <% if @host.operatingsystem.family == 'Debian' -%>
11
+ export PATH=/opt/puppetlabs/bin:$PATH
12
+ <% end -%>
10
13
  puppet agent --enable
@@ -33,4 +33,7 @@ template_inputs:
33
33
  provider_type: SSH
34
34
  kind: job_template
35
35
  -%>
36
+ <% if @host.operatingsystem.family == 'Debian' -%>
37
+ export PATH=/opt/puppetlabs/bin:$PATH
38
+ <% end -%>
36
39
  puppet module install <%= input('puppet_module') %> <%= "--target-dir #{input('target_dir')}" if input('target_dir').present? %> <%= "--version #{input('version')}" if input('version').present? %> <%= "--force" if input('force') == "true" %> <%= "--ignore-dependencies" if input('ignore_dependencies') == "true" %>
@@ -11,4 +11,7 @@ template_inputs:
11
11
  input_type: user
12
12
  required: false
13
13
  %>
14
+ <% if @host.operatingsystem.family == 'Debian' -%>
15
+ export PATH=/opt/puppetlabs/bin:$PATH
16
+ <% end -%>
14
17
  puppet agent --onetime --no-usecacheonfailure --no-daemonize <%= input("puppet_options") %>
@@ -32,6 +32,15 @@ module ForemanRemoteExecution
32
32
  end
33
33
  end
34
34
 
35
+ # A workaround for https://projects.theforeman.org/issues/30685
36
+ initializer 'foreman_remote_execution.rails_loading_workaround' do
37
+ # Without this, in production environment the module gets prepended too
38
+ # late and the extensions do not get applied
39
+ # TODO: Remove this and from config.to_prepare once there is an extension
40
+ # point in Foreman
41
+ ProvisioningTemplatesHelper.prepend ForemanRemoteExecution::JobTemplatesExtensions
42
+ end
43
+
35
44
  initializer 'foreman_remote_execution.apipie' do
36
45
  Apipie.configuration.checksum_path += ['/api/']
37
46
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '3.3.2'.freeze
2
+ VERSION = '3.3.7'.freeze
3
3
  end
@@ -44,7 +44,7 @@ module Api
44
44
  get :show, params: { :id => @invocation.id }, session: set_session_user(@user)
45
45
  assert_response :success
46
46
  response = ActiveSupport::JSON.decode(@response.body)
47
- assert_empty response['targeting']['hosts']
47
+ assert_equal response['targeting']['hosts'], []
48
48
  end
49
49
  end
50
50
 
@@ -30,7 +30,7 @@ class SSHOrchestrationTest < ActiveSupport::TestCase
30
30
 
31
31
  it 'does not fail on 404 from the smart proxy' do
32
32
  host.stubs(:skip_orchestration?).returns false
33
- SmartProxy.any_instance.expects(:drop_host_from_known_hosts).raises(RestClient::ResourceNotFound).twice
33
+ ::ProxyAPI::RemoteExecutionSSH.any_instance.expects(:delete).raises(RestClient::ResourceNotFound).twice
34
34
  host.build = true
35
35
  host.save!
36
36
  ids = ["ssh_remove_known_hosts_interface_#{interface.ip}_#{proxy.id}",
@@ -17,7 +17,7 @@ const TargetingHosts = ({ status, items }) => {
17
17
  }
18
18
 
19
19
  return (
20
- <LoadingState loading={!items.length}>
20
+ <LoadingState loading={!items.length && status === STATUS.PENDING}>
21
21
  <div>
22
22
  <table className="table table-bordered table-striped table-hover">
23
23
  <thead>
@@ -52,7 +52,7 @@ exports[`TargetingHosts renders with error 1`] = `
52
52
  exports[`TargetingHosts renders with loading 1`] = `
53
53
  <LoadingState
54
54
  additionalClasses=""
55
- loading={true}
55
+ loading={false}
56
56
  loadingText="Loading"
57
57
  size="lg"
58
58
  timeout={300}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2020-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -249,6 +249,7 @@ files:
249
249
  - app/views/job_invocations/new.html.erb
250
250
  - app/views/job_invocations/refresh.js.erb
251
251
  - app/views/job_invocations/show.html.erb
252
+ - app/views/job_invocations/show.js.erb
252
253
  - app/views/job_invocations/show.json.erb
253
254
  - app/views/job_invocations/welcome.html.erb
254
255
  - app/views/job_templates/_custom_tab_headers.html.erb