foreman_remote_execution 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: 9a83d62de427a930126dbdac52051e2a6ca6e0cc
4
- data.tar.gz: a304bc71914618eb42fa1648b4f6ce3f2f31fceb
3
+ metadata.gz: e5f866fe37c11fd1081d685e3715e64658354b5f
4
+ data.tar.gz: c5fddb603234b2930bc94226411a982039c5996e
5
5
  SHA512:
6
- metadata.gz: 9afcf6f187db3707ed4842ad877d8273c3bead70b25f0fb078dacc2888d0218cbed4d41c2b2e85e874cc88522946488915ff123883e12f507638c9ef1581f9ea
7
- data.tar.gz: 8a38221109dea89d1b5c91f84179727e563b2f880a948b83029adda2df3b6ffddd058dcc5e5651cb32d06bc1c6ada3bc6ddcc6b15e83fb8c3f9db71296c8d371
6
+ metadata.gz: 64da2786680750ada9d49b6459b63bc6a2440f1c0226de78a08c50b1b632c8b7583cd1d76c569dc1e7e1836318229cfbf1811671517f8aca0be0539188403961
7
+ data.tar.gz: f707c970f5b3fb9fccbe4e65d4321a449a6980b5b9f3999266ab49e4d238eb56f4644319bb12e88e691e85819570d3fc7267c62e6ec851a7f40fa58d58b6a912
@@ -0,0 +1,17 @@
1
+ module Actions
2
+ module RemoteExecution
3
+ module Helpers
4
+ module LiveOutput
5
+ def exception_to_output(context, exception, timestamp = Time.now)
6
+ format_output(context + ": #{exception.class} - #{exception.message}", 'debug', timestamp)
7
+ end
8
+
9
+ def format_output(message, type = 'debug', timestamp = Time.now)
10
+ { 'output_type' => type,
11
+ 'output' => message,
12
+ 'timestamp' => timestamp.to_f }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,6 +2,8 @@ module Actions
2
2
  module RemoteExecution
3
3
  class RunHostJob < Actions::EntryAction
4
4
 
5
+ include Actions::RemoteExecution::Helpers::LiveOutput
6
+
5
7
  def resource_locks
6
8
  :link
7
9
  end
@@ -42,7 +44,12 @@ module Actions
42
44
  end
43
45
 
44
46
  def live_output
45
- planned_actions(RunProxyCommand).first.live_output
47
+ proxy_command_action = planned_actions(RunProxyCommand).first
48
+ if proxy_command_action
49
+ proxy_command_action.live_output
50
+ else
51
+ execution_plan.errors.map { |e| exception_to_output(_('Failed to initialize command'), e) }
52
+ end
46
53
  end
47
54
 
48
55
  def humanized_name
@@ -3,6 +3,7 @@ module Actions
3
3
  class RunProxyCommand < Actions::ProxyAction
4
4
 
5
5
  include ::Dynflow::Action::Cancellable
6
+ include Actions::RemoteExecution::Helpers::LiveOutput
6
7
 
7
8
  def plan(proxy, hostname, script, options = {})
8
9
  options = { :effective_user => nil }.merge(options)
@@ -67,8 +68,9 @@ module Actions
67
68
 
68
69
  def finalized_output
69
70
  records = []
70
- if self.output[:proxy_output].present?
71
- records.concat(self.output[:proxy_output].fetch(:result, []))
71
+
72
+ if proxy_result.present?
73
+ records.concat(proxy_result)
72
74
  else
73
75
  records << format_output(_('No output'))
74
76
  end
@@ -81,14 +83,8 @@ module Actions
81
83
  return records
82
84
  end
83
85
 
84
- def exception_to_output(context, exception, timestamp = Time.now)
85
- format_output(context + ": #{exception.class} - #{exception.message}", 'debug', timestamp)
86
- end
87
-
88
- def format_output(message, type = 'debug', timestamp = Time.now)
89
- { 'output_type' => type,
90
- 'output' => message,
91
- 'timestamp' => timestamp.to_f }
86
+ def proxy_result
87
+ self.output.fetch(:proxy_output, {}).fetch(:result, []) || []
92
88
  end
93
89
  end
94
90
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanRemoteExecution
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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: 0.1.0
4
+ version: 0.1.1
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: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -148,6 +148,7 @@ files:
148
148
  - app/helpers/concerns/foreman_remote_execution/hosts_helper_extensions.rb
149
149
  - app/helpers/remote_execution_helper.rb
150
150
  - app/lib/actions/middleware/bind_job_invocation.rb
151
+ - app/lib/actions/remote_execution/helpers/live_output.rb
151
152
  - app/lib/actions/remote_execution/run_host_job.rb
152
153
  - app/lib/actions/remote_execution/run_hosts_job.rb
153
154
  - app/lib/actions/remote_execution/run_proxy_command.rb