hammer_cli_foreman_remote_execution 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82a8e161e362047b1b57912566bba871c744abf23f65b23f5425865138f281a2
4
- data.tar.gz: 3a26ec61f5fda760497bbc0bb8d9744ffa1d99bb5717f3d15a82b9750e37d949
3
+ metadata.gz: a3bdff74fb5bd32d504b13ff551678c6c3ed12aa04d73528ce2cab9f72b46665
4
+ data.tar.gz: 7ef49c8ed3a5dcaf3d668af3f8f78400eace069dde81cfc04870321ceed58b85
5
5
  SHA512:
6
- metadata.gz: f3ee7406b730f5036b5b283e35d2353f7341a007b28e10da883f5dc2fe9ab9ad801ac162765e6646b664a8cf61bd7da355eae1d10e76ca940909f9ab87a3c8ac
7
- data.tar.gz: 12bad04f757471161f6ac7e4e8cb3b5e25c4971957af6e37e9cc4fa8d7755f9257aa5c3940586696db72afe686c49ff2dcda02af30f9df2f946178ad3f12a61d
6
+ metadata.gz: fbc9ff36630e21dde97f526c37f9ecd1de65a9d7022fdd507c8fc623c6104e09d8ce6504667e68af9b5d4fff11bafa160b7ffce2506fa6bd36792e55ce76aca5
7
+ data.tar.gz: f994bee91634dce1295bb824c9fd90197e3bdd9bfa07cca8daa579a0f28110f67fd25c31b3278612a5c1be8bf70b8c1928baef8107f55abd38b270154c8c309d
@@ -9,6 +9,8 @@ module HammerCLIForemanRemoteExecution
9
9
  require 'hammer_cli_foreman_remote_execution/template_input'
10
10
  require 'hammer_cli_foreman_remote_execution/foreign_input_set'
11
11
  require 'hammer_cli_foreman_remote_execution/remote_execution_feature'
12
+ require 'hammer_cli_foreman_remote_execution/interface_extensions'
13
+ require 'hammer_cli_foreman_remote_execution/subnet_extensions'
12
14
 
13
15
  def self.exception_handler_class
14
16
  HammerCLIForeman::ExceptionHandler
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hammer_cli_foreman/interface'
4
+
5
+ module HammerCLIForemanRemoteExecution
6
+ class InterfaceExtensionsInfo < ::HammerCLI::CommandExtensions
7
+ output do |definition|
8
+ definition.append do
9
+ field :execution, _('Execution'), Fields::Boolean
10
+ end
11
+ end
12
+ end
13
+
14
+ module InterfaceExtensionsList
15
+ def format_type(nic)
16
+ type = super(nic)
17
+ if nic['execution']
18
+ if nic['primary'] || nic['provision']
19
+ type[-1] = ', '+_('execution') +')'
20
+ else
21
+ type += ' ('+_('execution') +')'
22
+ end
23
+ end
24
+ type
25
+ end
26
+ end
27
+
28
+ ::HammerCLIForeman::Interface.singleton_class.prepend InterfaceExtensionsList
29
+ ::HammerCLIForeman::Interface::InfoCommand.extend_with(InterfaceExtensionsInfo.new)
30
+ end
@@ -8,18 +8,25 @@ module HammerCLIForemanRemoteExecution
8
8
  end
9
9
  end
10
10
 
11
- class ListCommand < HammerCLIForeman::ListCommand
12
- output do
13
- field :id, _('ID')
14
- field :description, _('Description')
15
- field :status_label, _('Status')
16
- field :succeeded, _('Success')
17
- field :failed, _('Failed')
18
- field :pending, _('Pending')
19
- field :total, _('Total')
20
- field :start_at, _('Start')
21
- field :randomized_ordering, _('Randomized ordering')
11
+ module BaseOutput
12
+ def self.included(base)
13
+ base.output do
14
+ field :id, _('ID')
15
+ field :description, _('Description')
16
+ field :status_label, _('Status')
17
+ field :succeeded, _('Success')
18
+ field :failed, _('Failed')
19
+ field :pending, _('Pending')
20
+ field :total, _('Total')
21
+ field :start_at, _('Start')
22
+ field :randomized_ordering, _('Randomized ordering')
23
+ field :inputs, _('Inputs'), nil, :hide_blank => true
24
+ end
22
25
  end
26
+ end
27
+
28
+ class ListCommand < HammerCLIForeman::ListCommand
29
+ include BaseOutput
23
30
 
24
31
  def extend_data(invocation)
25
32
  JobInvocation.extend_data(invocation)
@@ -30,15 +37,43 @@ module HammerCLIForemanRemoteExecution
30
37
 
31
38
  class InfoCommand < HammerCLIForeman::InfoCommand
32
39
  extend WithoutNameOption
33
- output ListCommand.output_definition do
34
- field :job_category, _('Job Category')
35
- field :mode, _('Mode')
36
- field :cron_line, _('Cron line')
37
- field :recurring_logic_id, _('Recurring logic ID')
38
- field :hosts, _('Hosts')
40
+ include BaseOutput
41
+ option '--show-inputs', :flag, _('Show the complete input of the job')
42
+
43
+ extend_output_definition do |definition|
44
+ definition.insert(:before, :total) do
45
+ field :missing, _('Missing')
46
+ end
47
+ definition.append do
48
+ field :job_category, _('Job Category')
49
+ field :mode, _('Mode')
50
+ field :cron_line, _('Cron line')
51
+ field :recurring_logic_id, _('Recurring logic ID')
52
+ field :hosts, _('Hosts')
53
+ end
54
+ end
55
+
56
+ def adapter
57
+ if option_id
58
+ :yaml
59
+ else
60
+ :base
61
+ end
39
62
  end
40
63
 
41
64
  def extend_data(invocation)
65
+ if option_show_inputs?
66
+ invocation['template_invocations']&.each do |template|
67
+ input_values = template['template_invocation_input_values']
68
+ values_for_host = {}
69
+ input_values&.each do |input_value|
70
+ values_for_host[input_value['template_input_name']] = input_value['value']
71
+ end
72
+ hosts = invocation.dig('targeting', 'hosts')
73
+ host_index = hosts&.index { |h| h['id'] == template['host_id'] }
74
+ invocation['targeting']['hosts'][host_index][:inputs] = values_for_host if host_index
75
+ end
76
+ end
42
77
  JobInvocation.extend_data(invocation)
43
78
  end
44
79
 
@@ -187,9 +222,11 @@ module HammerCLIForemanRemoteExecution
187
222
  def self.extend_data(invocation)
188
223
  if (targeting = invocation['targeting']) && invocation['targeting']['hosts']
189
224
  invocation['randomized_ordering'] = targeting['randomized_ordering']
190
- if (hosts = targeting['hosts'])
191
- invocation['hosts'] = "\n" + hosts.map { |host| " - #{host['name']}" }.join("\n")
225
+
226
+ hosts = targeting['hosts'].map do |host|
227
+ { 'Name' => host['name'], 'Job status' => host['job_status'], 'Inputs' => host[:inputs] }.compact
192
228
  end
229
+ invocation['hosts'] = hosts
193
230
  end
194
231
 
195
232
  if invocation['recurrence']
@@ -0,0 +1,16 @@
1
+ require 'hammer_cli_foreman/subnet'
2
+
3
+ module HammerCLIForemanRemoteExecution
4
+ class SubnetExtensions < ::HammerCLI::CommandExtensions
5
+ output do |definition|
6
+ definition.insert(:after, _("Smart Proxies"))do
7
+ collection :remote_execution_proxies, _('Remote execution proxies'), :numbered => false do
8
+ field :id, _('Id')
9
+ field :name, _('Name')
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ ::HammerCLIForeman::Subnet::InfoCommand.extend_with(SubnetExtensions.new)
16
+ end
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanRemoteExecution
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.1.2'
3
+ @version ||= Gem::Version.new '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-26 00:00:00.000000000 Z
11
+ date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -66,10 +66,12 @@ files:
66
66
  - lib/hammer_cli_foreman_remote_execution.rb
67
67
  - lib/hammer_cli_foreman_remote_execution/foreign_input_set.rb
68
68
  - lib/hammer_cli_foreman_remote_execution/i18n.rb
69
+ - lib/hammer_cli_foreman_remote_execution/interface_extensions.rb
69
70
  - lib/hammer_cli_foreman_remote_execution/job_invocation.rb
70
71
  - lib/hammer_cli_foreman_remote_execution/job_template.rb
71
72
  - lib/hammer_cli_foreman_remote_execution/options/normalizers.rb
72
73
  - lib/hammer_cli_foreman_remote_execution/remote_execution_feature.rb
74
+ - lib/hammer_cli_foreman_remote_execution/subnet_extensions.rb
73
75
  - lib/hammer_cli_foreman_remote_execution/template_input.rb
74
76
  - lib/hammer_cli_foreman_remote_execution/version.rb
75
77
  - locale/Makefile
@@ -100,7 +102,7 @@ homepage: https://github.com/theforeman/hammer_cli_foreman_remote_execution
100
102
  licenses:
101
103
  - GPL-3.0-or-later
102
104
  metadata: {}
103
- post_install_message:
105
+ post_install_message:
104
106
  rdoc_options: []
105
107
  require_paths:
106
108
  - lib
@@ -115,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
117
  - !ruby/object:Gem::Version
116
118
  version: '0'
117
119
  requirements: []
118
- rubygems_version: 3.0.3
119
- signing_key:
120
+ rubygems_version: 3.1.2
121
+ signing_key:
120
122
  specification_version: 4
121
123
  summary: CLI for the Foreman remote execution plugin
122
124
  test_files: