hammer_cli_foreman 2.3.2 → 2.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +27 -3
  3. data/lib/hammer_cli_foreman/architecture.rb +5 -5
  4. data/lib/hammer_cli_foreman/bookmark.rb +6 -6
  5. data/lib/hammer_cli_foreman/command_extensions/ping.rb +21 -2
  6. data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
  7. data/lib/hammer_cli_foreman/command_extensions/update_common.rb +14 -0
  8. data/lib/hammer_cli_foreman/command_extensions.rb +1 -0
  9. data/lib/hammer_cli_foreman/commands.rb +14 -0
  10. data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
  11. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +2 -1
  12. data/lib/hammer_cli_foreman/compute_resource.rb +22 -0
  13. data/lib/hammer_cli_foreman/config_group.rb +5 -5
  14. data/lib/hammer_cli_foreman/config_report.rb +2 -0
  15. data/lib/hammer_cli_foreman/filter.rb +2 -2
  16. data/lib/hammer_cli_foreman/host.rb +1 -12
  17. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +6 -5
  18. data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
  19. data/lib/hammer_cli_foreman/model.rb +5 -5
  20. data/lib/hammer_cli_foreman/operating_system.rb +10 -9
  21. data/lib/hammer_cli_foreman/option_builders.rb +6 -5
  22. data/lib/hammer_cli_foreman/ping.rb +6 -1
  23. data/lib/hammer_cli_foreman/registration.rb +18 -0
  24. data/lib/hammer_cli_foreman/settings.rb +3 -3
  25. data/lib/hammer_cli_foreman/usergroup.rb +5 -5
  26. data/lib/hammer_cli_foreman/version.rb +1 -1
  27. data/lib/hammer_cli_foreman.rb +4 -1
  28. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  29. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  30. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/test/data/2.4/foreman_api.json +1 -0
  42. data/test/data/2.5/foreman_api.json +1 -0
  43. data/test/functional/architecture_test.rb +79 -0
  44. data/test/functional/bookmark_test.rb +22 -1
  45. data/test/functional/compute_profile_test.rb +54 -0
  46. data/test/functional/compute_resource_test.rb +37 -0
  47. data/test/functional/config_group_test.rb +50 -0
  48. data/test/functional/filter_test.rb +115 -47
  49. data/test/functional/host_test.rb +94 -12
  50. data/test/functional/http_proxy_test.rb +12 -0
  51. data/test/functional/location_test.rb +13 -0
  52. data/test/functional/mail_notification_test.rb +20 -0
  53. data/test/functional/media_test.rb +11 -0
  54. data/test/functional/model_test.rb +50 -0
  55. data/test/functional/operating_system_test.rb +51 -0
  56. data/test/functional/ping_test.rb +33 -0
  57. data/test/functional/realm_test.rb +11 -0
  58. data/test/functional/registration_test.rb +8 -0
  59. data/test/functional/report_template_test.rb +11 -0
  60. data/test/functional/settings_test.rb +21 -0
  61. data/test/functional/status_test.rb +79 -13
  62. data/test/functional/template_test.rb +12 -0
  63. data/test/functional/user_test.rb +11 -0
  64. data/test/functional/usergroup_test.rb +51 -0
  65. data/test/test_helper.rb +1 -1
  66. data/test/unit/apipie_resource_mock.rb +21 -0
  67. data/test/unit/architecture_test.rb +10 -1
  68. data/test/unit/bookmark_test.rb +99 -0
  69. data/test/unit/compute_profile_test.rb +87 -0
  70. data/test/unit/config_group_test.rb +10 -0
  71. data/test/unit/config_report_test.rb +1 -0
  72. data/test/unit/mail_notification_test.rb +53 -0
  73. data/test/unit/model_test.rb +10 -0
  74. data/test/unit/operating_system_test.rb +14 -1
  75. data/test/unit/settings_test.rb +4 -0
  76. data/test/unit/usergroup_test.rb +10 -0
  77. metadata +81 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b30a6bc396c149912681a2a600c7dcc84fc5144b90b5b4b8cf45f57690bbaa39
4
- data.tar.gz: de18a4c812f92f1988791f404986a2e7b0c5464d401b001ddedee3c934a1f137
3
+ metadata.gz: 93d22f69396968e2647cc8efb573ec822089921f6aa70c61241a1f89dab81943
4
+ data.tar.gz: e057aef23b95de6e1c358415be115f6a9aa3c77baa5c53bf5d095ad12cfd6f4f
5
5
  SHA512:
6
- metadata.gz: 4fe825dd7cb98c62c1093d11d33e1d488b80bd55f6927089cb4a84e9214d3fbedb7add28d5436492c63f6d8b5cf8b7c3f64d6d30de9aac1fc39fdace9324c465
7
- data.tar.gz: 2d317a4070fa04020b10aa0f7c5c43a000c325ac2cde01a888c4d82fe8a6a01e746e0d4d9a66a92a239e4597f7e25daf5399e5b97d892fd84ac43e0b80052f02
6
+ metadata.gz: d5be068183ddf5f0f1f3288337fe9d7acbb8f42e441ac665ac89413ea08ea9d5728df3005153b1bb85534e6ecaeca3ae1911b34985a3a51831db32695265e96e
7
+ data.tar.gz: f8a21cba6a36e76a220c32ad9c2f1e73329773c949c9c968c921f86c13b2a20f0eec854f68ee2e0295aaa50e8f28128c93f98af48c838be2d2a2ae712a2046b2
data/doc/release_notes.md CHANGED
@@ -1,10 +1,34 @@
1
1
  Release notes
2
2
  =============
3
- ### 2.3.2 (2021-05-04)
4
- * Apply option family on searchablesoptionbuilder, [#30996](http://projects.theforeman.org/issues/30996)
3
+ ### 2.5.2 (2022-02-01)
4
+ * Fix puppet-class command description ([PR #590](https://github.com/theforeman/hammer-cli-foreman/pull/590)), [#33438](http://projects.theforeman.org/issues/33438)
5
+
6
+ ### 2.5.1 (2021-06-08)
7
+ * Show new msg for empty update commands, [#32454](http://projects.theforeman.org/issues/32454)
5
8
 
6
- ### 2.3.1 (2021-01-27)
9
+ ### 2.5.0 (2021-05-04)
10
+ * Update test data to latest foreman
11
+ * change to resource_type_label, [#11454](http://projects.theforeman.org/issues/11454)
12
+ * Display the report origin, [#32428](http://projects.theforeman.org/issues/32428)
13
+ * Apply option family on searchablesoptionbuilder, [#30996](http://projects.theforeman.org/issues/30996)
14
+ * Add associate vms command for compute resource ([PR #563](https://github.com/theforeman/hammer-cli-foreman/pull/563)), [#32271](http://projects.theforeman.org/issues/32271)
15
+ * Support unrecognized services in ping, [#32265](http://projects.theforeman.org/issues/32265)
16
+ * Change --owner_type's default to user ([PR #562](https://github.com/theforeman/hammer-cli-foreman/pull/562)), [#30814](http://projects.theforeman.org/issues/30814)
17
+ * Drop puppetrun command from hammer ([PR #561](https://github.com/theforeman/hammer-cli-foreman/pull/561)), [#31806](http://projects.theforeman.org/issues/31806)
18
+ * Global registration module ([PR #558](https://github.com/theforeman/hammer-cli-foreman/pull/558)), [#31630](http://projects.theforeman.org/issues/31630)
19
+ * Add support for vnic profile ([PR #552](https://github.com/theforeman/hammer-cli-foreman/pull/552)), [#31493](http://projects.theforeman.org/issues/31493)
20
+ * Bump to 2.5.0-develop
21
+ * Bump to 2.4.0
22
+ * Correct descriptions for resources, [#31668](http://projects.theforeman.org/issues/31668)
23
+
24
+
25
+ ### 2.4.0 (2021-02-01)
26
+ * Fix hammer list failure when defaults are set ([PR #551](https://github.com/theforeman/hammer-cli-foreman/pull/551)), [#31384](http://projects.theforeman.org/issues/31384)
7
27
  * Deprecating puppetrun command ([PR #554](https://github.com/theforeman/hammer-cli-foreman/pull/554)), [#31536](http://projects.theforeman.org/issues/31536)
28
+ * Set new owner with host update ([PR #556](https://github.com/theforeman/hammer-cli-foreman/pull/556)), [#31609](http://projects.theforeman.org/issues/31609)
29
+ * Consume structured statuses api data ([PR #553](https://github.com/theforeman/hammer-cli-foreman/pull/553)), [#31570](http://projects.theforeman.org/issues/31570)
30
+ * Added missing tests to filter ([PR #549](https://github.com/theforeman/hammer-cli-foreman/pull/549)), [#31074](http://projects.theforeman.org/issues/31074')
31
+ * Bump to 2.4.0-develop
8
32
 
9
33
  ### 2.3.0 (2020-11-03)
10
34
  * Hammer ping skip authentication ([PR #550](https://github.com/theforeman/hammer-cli-foreman/pull/550)), [#31140](http://projects.theforeman.org/issues/31140)
@@ -11,7 +11,7 @@ module HammerCLIForeman
11
11
  field :name, _("Name")
12
12
  end
13
13
 
14
- build_options
14
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
15
15
  end
16
16
 
17
17
 
@@ -23,7 +23,7 @@ module HammerCLIForeman
23
23
  HammerCLIForeman::References.timestamps(self)
24
24
  end
25
25
 
26
- build_options
26
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
27
27
  end
28
28
 
29
29
 
@@ -31,7 +31,7 @@ module HammerCLIForeman
31
31
  success_message _("Architecture created.")
32
32
  failure_message _("Could not create the architecture")
33
33
 
34
- build_options
34
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
35
35
  end
36
36
 
37
37
 
@@ -39,7 +39,7 @@ module HammerCLIForeman
39
39
  success_message _("Architecture deleted.")
40
40
  failure_message _("Could not delete the architecture")
41
41
 
42
- build_options
42
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
43
43
  end
44
44
 
45
45
 
@@ -47,7 +47,7 @@ module HammerCLIForeman
47
47
  success_message _("Architecture updated.")
48
48
  failure_message _("Could not update the architecture")
49
49
 
50
- build_options
50
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
51
51
  end
52
52
 
53
53
  HammerCLIForeman::AssociatingCommands::OperatingSystem.extend_command(self)
@@ -15,34 +15,34 @@ module HammerCLIForeman
15
15
  field :owner_type, _('Owner Type')
16
16
  end
17
17
 
18
- build_options
18
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
19
19
  end
20
20
 
21
21
  class InfoCommand < HammerCLIForeman::InfoCommand
22
22
  output ListCommand.output_definition
23
-
24
- build_options
23
+
24
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
25
25
  end
26
26
 
27
27
  class CreateCommand < HammerCLIForeman::CreateCommand
28
28
  success_message _('Bookmark %<name>s created.')
29
29
  failure_message _('Failed to create %<name>s bookmark')
30
30
 
31
- build_options
31
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
32
32
  end
33
33
 
34
34
  class UpdateCommand < HammerCLIForeman::UpdateCommand
35
35
  success_message _('Bookmark %<name>s updated successfully.')
36
36
  failure_message _('Failed to update %<name>s bookmark')
37
37
 
38
- build_options
38
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
39
39
  end
40
40
 
41
41
  class DeleteCommand < HammerCLIForeman::DeleteCommand
42
42
  success_message _('Bookmark deleted successfully.')
43
43
  failure_message _('Failed to delete bookmark')
44
44
 
45
- build_options
45
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
46
46
  end
47
47
 
48
48
  autoload_subcommands
@@ -10,9 +10,28 @@ module HammerCLIForeman
10
10
  end
11
11
  end
12
12
 
13
+ def self.check_for_unrecognized(plugins, output_definition)
14
+ failed = plugins.select { |_, data| data['services'] }
15
+ .each_with_object([]) { |(_, d), s| s << d['services'] }
16
+ .reduce({}, :merge)
17
+ .select do |name, data|
18
+ begin
19
+ output_definition.find_field(name)
20
+ false
21
+ rescue ArgumentError
22
+ data['status'] == _('FAIL')
23
+ end
24
+ end
25
+ return if failed.empty?
26
+
27
+ warn [_('%{count} more service(s) failed, but not shown:') % { count: failed.size },
28
+ failed.keys.join(', '),
29
+ ''].join("\n")
30
+ end
31
+
13
32
  def self.failed?(services)
14
- services.each_value.any? { |s| s['status'] == _('FAIL') } ||
15
- services['foreman']['database']['active'] == 'FAIL'
33
+ services['foreman']['database']['active'] == 'FAIL' ||
34
+ services.each_value.any? { |s| s['status'] == _('FAIL') }
16
35
  end
17
36
 
18
37
  request_options do |options|
@@ -4,7 +4,7 @@ module HammerCLIForeman
4
4
  before_print do |data|
5
5
  return if data['results'].nil?
6
6
 
7
- normalize_plugins(data['results']['foreman']['plugins'])
7
+ normalize_plugins(data['results']['foreman']['plugins']) if data['results']['foreman']['plugins'].any?(String)
8
8
  data['results']['foreman']['smart_proxies'].each do |proxy|
9
9
  proxy['features'] = normalize_features(proxy['features'])
10
10
  proxy['failed_features'] = normalize_failed_features(proxy['failed_features'])
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HammerCLIForeman
4
+ module CommandExtensions
5
+ class UpdateCommon < HammerCLI::CommandExtensions
6
+ inheritable true
7
+
8
+ request_params do |params, command_object|
9
+ update_params = params[command_object.resource.singular_name]
10
+ command_object.context[:action_message] = :nothing_to_do if update_params && update_params.empty?
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,4 @@
1
+ require 'hammer_cli_foreman/command_extensions/update_common'
1
2
  require 'hammer_cli_foreman/command_extensions/fields'
2
3
  require 'hammer_cli_foreman/command_extensions/puppet_environment'
3
4
  require 'hammer_cli_foreman/command_extensions/puppet_environments'
@@ -548,6 +548,19 @@ module HammerCLIForeman
548
548
  builder
549
549
  end
550
550
 
551
+ def self.inherited(child)
552
+ child.success_message_for(:nothing_to_do, _('Nothing to update.'))
553
+ end
554
+
555
+ def clean_up_context
556
+ super
557
+ context.delete(:action_message)
558
+ end
559
+
560
+ def success_message
561
+ success_message_for(context[:action_message] || :default)
562
+ end
563
+
551
564
  def method_options_for_params(params, options)
552
565
  opts = super
553
566
  # overwrite searchables with correct values
@@ -560,6 +573,7 @@ module HammerCLIForeman
560
573
  opts
561
574
  end
562
575
 
576
+ extend_with(HammerCLIForeman::CommandExtensions::UpdateCommon.new)
563
577
  end
564
578
 
565
579
 
@@ -9,7 +9,7 @@ module HammerCLIForeman
9
9
  field :id, _('Id')
10
10
  field :name, _('Name')
11
11
  end
12
- build_options
12
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
13
13
  end
14
14
 
15
15
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -25,13 +25,13 @@ module HammerCLIForeman
25
25
  field :vm_attrs, _('VM attributes')
26
26
  end
27
27
  end
28
- build_options
28
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
29
29
  end
30
30
 
31
31
  class CreateCommand < HammerCLIForeman::CreateCommand
32
32
  success_message _('Compute profile created.')
33
33
  failure_message _('Could not create a compute profile')
34
- build_options
34
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
35
35
  end
36
36
 
37
37
  class UpdateCommand < HammerCLIForeman::UpdateCommand
@@ -40,7 +40,7 @@ module HammerCLIForeman
40
40
  validate_options do
41
41
  any(:option_name,:option_id).required
42
42
  end
43
- build_options
43
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
44
44
  end
45
45
 
46
46
  class DeleteCommand < HammerCLIForeman::DeleteCommand
@@ -49,7 +49,7 @@ module HammerCLIForeman
49
49
  validate_options do
50
50
  any(:option_name,:option_id).required
51
51
  end
52
- build_options
52
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
53
53
  end
54
54
 
55
55
  lazy_subcommand('values', _("Create update and delete Compute profile values"),
@@ -28,7 +28,8 @@ module HammerCLIForeman
28
28
  [
29
29
  ['compute_name', _('Compute name, e.g. eth0')],
30
30
  ['compute_network', _('Select one of available networks for a cluster, must be an ID or a name')],
31
- ['compute_interface', _('Interface type')]
31
+ ['compute_interface', _('Interface type')],
32
+ ['compute_vnic_profile', _('Vnic Profile')]
32
33
  ]
33
34
  end
34
35
 
@@ -104,6 +104,15 @@ module HammerCLIForeman
104
104
  build_options
105
105
  end
106
106
 
107
+ class AssociateVmsCommand < HammerCLIForeman::Command
108
+ action :associate
109
+ command_name 'associate-vms'
110
+ success_message _("Virtual machines have been associated.")
111
+ failure_message _("Could not associate the virtual machines")
112
+
113
+ build_options
114
+ end
115
+
107
116
  class AvailableClustersCommand < HammerCLIForeman::ListCommand
108
117
  action :available_clusters
109
118
  command_name 'clusters'
@@ -128,6 +137,19 @@ module HammerCLIForeman
128
137
  build_options
129
138
  end
130
139
 
140
+ class AvailableVnicProfilesCommand < HammerCLIForeman::ListCommand
141
+ action :available_vnic_profiles
142
+ command_name 'vnic-profiles'
143
+
144
+ output do
145
+ field :id, _('VNIC profile ID'), Fields::Field, :max_width => 200, :hide_blank => true
146
+ field :name, _('Name')
147
+ field :network, _('Network ID')
148
+ end
149
+
150
+ build_options
151
+ end
152
+
131
153
  class AvailableImagesCommand < HammerCLIForeman::ListCommand
132
154
  action :available_images
133
155
  command_name 'images'
@@ -8,7 +8,7 @@ module HammerCLIForeman
8
8
  field :name, _("Name")
9
9
  end
10
10
 
11
- build_options
11
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
12
12
  end
13
13
 
14
14
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -16,28 +16,28 @@ module HammerCLIForeman
16
16
  HammerCLIForeman::References.puppetclasses(self)
17
17
  end
18
18
 
19
- build_options
19
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
20
20
  end
21
21
 
22
22
  class CreateCommand < HammerCLIForeman::CreateCommand
23
23
  success_message _("Config group created.")
24
24
  failure_message _("Could not create the config group")
25
25
 
26
- build_options
26
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
27
27
  end
28
28
 
29
29
  class UpdateCommand < HammerCLIForeman::UpdateCommand
30
30
  success_message _("Config group updated.")
31
31
  failure_message _("Could not update the config group")
32
32
 
33
- build_options
33
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
34
34
  end
35
35
 
36
36
  class DeleteCommand < HammerCLIForeman::DeleteCommand
37
37
  success_message _("Config group has been deleted.")
38
38
  failure_message _("Could not delete the config group")
39
39
 
40
- build_options
40
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
41
41
  end
42
42
 
43
43
  autoload_subcommands
@@ -10,6 +10,7 @@ module HammerCLIForeman
10
10
  field :id, _("Id")
11
11
  field :host_name, _("Host")
12
12
  field :reported_at, _("Last report"), Fields::Date
13
+ field :origin, _("Origin")
13
14
  from "status" do
14
15
  field :applied, _("Applied")
15
16
  field :restarted, _("Restarted")
@@ -30,6 +31,7 @@ module HammerCLIForeman
30
31
  field :id, _("Id")
31
32
  field :host_name, _("Host")
32
33
  field :reported_at, _("Reported at"), Fields::Date
34
+ field :origin, _("Origin")
33
35
  label _("Report status") do
34
36
  from "status" do
35
37
  field :applied, _("Applied")
@@ -78,7 +78,7 @@ module HammerCLIForeman
78
78
  class CreateCommand < HammerCLIForeman::CreateCommand
79
79
  include TaxonomyCheck
80
80
 
81
- success_message _("Permission filter for [%<resource_type>s] created.")
81
+ success_message _("Permission filter for [%<resource_type_label>s] created.")
82
82
  failure_message _("Could not create the permission filter")
83
83
 
84
84
  def validate_options
@@ -92,7 +92,7 @@ module HammerCLIForeman
92
92
  class UpdateCommand < HammerCLIForeman::UpdateCommand
93
93
  include TaxonomyCheck
94
94
 
95
- success_message _("Permission filter for [%<resource_type>s] updated.")
95
+ success_message _("Permission filter for [%<resource_type_label>s] updated.")
96
96
  failure_message _("Could not update the permission filter")
97
97
 
98
98
  def request_params
@@ -171,18 +171,7 @@ module HammerCLIForeman
171
171
  end
172
172
 
173
173
 
174
- class PuppetRunCommand < HammerCLIForeman::SingleResourceCommand
175
- command_name "puppetrun"
176
- resource :puppet_hosts
177
- action :puppetrun
178
-
179
- def execute
180
- warn _('The puppetrun feature has been removed, however you can use the Remote Execution Plugin to run Puppet commands')
181
- HammerCLI::EX_SOFTWARE
182
- end
183
-
184
- build_options
185
- end
174
+
186
175
 
187
176
 
188
177
  class FactsCommand < HammerCLIForeman::AssociatedResourceListCommand
@@ -6,7 +6,7 @@ module HammerCLIForeman
6
6
  base.option "--owner", "OWNER_LOGIN", _("Login of the owner"),
7
7
  :attribute_name => :option_user_login
8
8
  base.option "--owner-id", "OWNER_ID", _("ID of the owner"),
9
- :attribute_name => :option_user_id
9
+ :attribute_name => :option_owner_id
10
10
 
11
11
  base.option "--root-password", "ROOT_PW",
12
12
  _("Required if host is managed and value is not inherited from host group or default password in settings")
@@ -134,13 +134,14 @@ module HammerCLIForeman
134
134
 
135
135
  private
136
136
 
137
- def owner_id(name, type = 'User')
137
+
138
+ def owner_id(name, type)
138
139
  return unless name
139
- return resolver.user_id('option_login' => name) if type == 'User'
140
+ return resolver.usergroup_id('option_name' => name) if type == 'Usergroup'
140
141
 
141
- resolver.usergroup_id('option_name' => name)
142
+ resolver.user_id('option_login' => name)
142
143
  end
143
-
144
+
144
145
  def proxy_id(name)
145
146
  resolver.smart_proxy_id('option_name' => name) if name
146
147
  end
@@ -11,7 +11,7 @@ module HammerCLIForeman
11
11
  field :name, _("Name")
12
12
  end
13
13
 
14
- build_options
14
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
15
15
  end
16
16
 
17
17
  class InfoCommand < HammerCLIForeman::InfoCommand
@@ -22,7 +22,7 @@ module HammerCLIForeman
22
22
  field :subscription_type, _("Subscription type")
23
23
  end
24
24
 
25
- build_options
25
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
26
26
  end
27
27
 
28
28
  autoload_subcommands
@@ -13,7 +13,7 @@ module HammerCLIForeman
13
13
  field :hardware_model, _("HW model")
14
14
  end
15
15
 
16
- build_options
16
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
17
17
  end
18
18
 
19
19
 
@@ -23,7 +23,7 @@ module HammerCLIForeman
23
23
  HammerCLIForeman::References.timestamps(self)
24
24
  end
25
25
 
26
- build_options
26
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
27
27
  end
28
28
 
29
29
 
@@ -31,14 +31,14 @@ module HammerCLIForeman
31
31
  success_message _("Hardware model created.")
32
32
  failure_message _("Could not create the hardware model")
33
33
 
34
- build_options
34
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
35
35
  end
36
36
 
37
37
  class DeleteCommand < HammerCLIForeman::DeleteCommand
38
38
  success_message _("Hardware model deleted.")
39
39
  failure_message _("Could not delete the hardware model")
40
40
 
41
- build_options
41
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
42
42
  end
43
43
 
44
44
 
@@ -46,7 +46,7 @@ module HammerCLIForeman
46
46
  success_message _("Hardware model updated.")
47
47
  failure_message _("Could not update the hardware model")
48
48
 
49
- build_options
49
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
50
50
  end
51
51
 
52
52
 
@@ -13,7 +13,7 @@ module HammerCLIForeman
13
13
  field :family, _("Family")
14
14
  end
15
15
 
16
- build_options
16
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
17
17
  end
18
18
 
19
19
 
@@ -36,7 +36,7 @@ module HammerCLIForeman
36
36
  HammerCLIForeman::References.parameters(self)
37
37
  end
38
38
 
39
- build_options
39
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
40
40
  end
41
41
 
42
42
 
@@ -44,7 +44,7 @@ module HammerCLIForeman
44
44
  success_message _("Operating system created.")
45
45
  failure_message _("Could not create the operating system")
46
46
 
47
- build_options
47
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
48
48
  end
49
49
 
50
50
 
@@ -52,7 +52,7 @@ module HammerCLIForeman
52
52
  success_message _("Operating system updated.")
53
53
  failure_message _("Could not update the operating system")
54
54
 
55
- build_options
55
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
56
56
  end
57
57
 
58
58
 
@@ -60,7 +60,7 @@ module HammerCLIForeman
60
60
  success_message _("Operating system deleted.")
61
61
  failure_message _("Could not delete the operating system")
62
62
 
63
- build_options
63
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
64
64
  end
65
65
 
66
66
 
@@ -76,7 +76,7 @@ module HammerCLIForeman
76
76
  validator.any(:option_operatingsystem_id, :option_operatingsystem_title).required
77
77
  end
78
78
 
79
- build_options
79
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
80
80
  end
81
81
 
82
82
 
@@ -90,7 +90,7 @@ module HammerCLIForeman
90
90
  validator.any(:option_operatingsystem_id, :option_operatingsystem_title).required
91
91
  end
92
92
 
93
- build_options
93
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
94
94
  end
95
95
 
96
96
 
@@ -156,7 +156,8 @@ module HammerCLIForeman
156
156
  HammerCLI::EX_OK
157
157
  end
158
158
 
159
- build_options :without => [:template_kind_id, :type]
159
+ build_options expand: { except: %i[organizations locations] },
160
+ without: %i[organization_id location_id template_kind_id type]
160
161
  end
161
162
 
162
163
 
@@ -191,7 +192,7 @@ module HammerCLIForeman
191
192
  {"operatingsystem_id" => option_id}
192
193
  end
193
194
 
194
- build_options
195
+ build_options expand: { except: %i[organizations locations] }, without: %i[organization_id location_id]
195
196
  end
196
197
 
197
198
 
@@ -224,11 +224,11 @@ module HammerCLIForeman
224
224
  resource_name = resource.singular_name
225
225
  aliased_name = aliased(resource_name, resource_name_map)
226
226
  types = searchables.map(&:name).push('id').map(&:capitalize).join('/')
227
- associated_resource = resource.singular_name.to_s.tr('_', ' ')
227
+ associated_resource = aliased_name.to_s.tr('_', ' ')
228
228
  family = HammerCLI::Options::OptionFamily.new(
229
229
  referenced_resource: resource_name,
230
230
  aliased_resource: aliased_name,
231
- description: _('Set the current %{resource} context for the request. %{types} can be used') % { types: types, resource: associated_resource }
231
+ description: _('%{types} of associated %{resource}') % { types: types, resource: associated_resource }
232
232
  )
233
233
 
234
234
  unless searchables.empty?
@@ -256,7 +256,7 @@ module HammerCLIForeman
256
256
  end
257
257
  end
258
258
 
259
- unless options.any? { |o| o.handles?("--#{aliased_name}-id") }
259
+ unless options.any? { |o| o.handles?(optionamize("--#{aliased_name}-id")) }
260
260
  options << family.parent(
261
261
  optionamize("--#{aliased_name}-id"),
262
262
  "#{aliased_name}_id".upcase,
@@ -319,7 +319,7 @@ module HammerCLIForeman
319
319
  end
320
320
  end
321
321
 
322
- unless options.any? { |o| o.handles?("--new-#{aliased_name}-id") }
322
+ unless options.any? { |o| o.handles?(optionamize("--new-#{aliased_name}-id")) }
323
323
  options << family.parent(
324
324
  optionamize("--new-#{aliased_name}-id"),
325
325
  "new_#{aliased_name}_id".upcase,
@@ -347,7 +347,7 @@ module HammerCLIForeman
347
347
  first = searchables[0]
348
348
  remaining = searchables[1..-1] || []
349
349
  types = searchables.map(&:plural_name).map(&:capitalize).join('/')
350
- associated_resource = resource.name.to_s.tr('_', ' ')
350
+ associated_resource = aliased_plural_name.to_s.tr('_', ' ')
351
351
  family = HammerCLI::Options::OptionFamily.new(
352
352
  format: HammerCLI::Options::Normalizers::List.new,
353
353
  referenced_resource: resource_name,
@@ -421,3 +421,4 @@ module HammerCLIForeman
421
421
  end
422
422
 
423
423
  end
424
+
@@ -19,7 +19,12 @@ module HammerCLIForeman
19
19
  response = send_request
20
20
  print_data(response)
21
21
 
22
- return 1 if HammerCLIForeman::CommandExtensions::Ping.failed?(response)
22
+ if HammerCLIForeman::CommandExtensions::Ping.failed?(response)
23
+ HammerCLIForeman::CommandExtensions::Ping.check_for_unrecognized(
24
+ response, output_definition
25
+ )
26
+ return 1
27
+ end
23
28
 
24
29
  HammerCLI::EX_OK
25
30
  end