hammer_cli_foreman 2.1.1 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +31 -1
  3. data/doc/testing.md +13 -0
  4. data/lib/hammer_cli_foreman.rb +1 -5
  5. data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
  6. data/lib/hammer_cli_foreman/audit.rb +7 -0
  7. data/lib/hammer_cli_foreman/auth.rb +4 -4
  8. data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
  9. data/lib/hammer_cli_foreman/commands.rb +3 -1
  10. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
  11. data/lib/hammer_cli_foreman/host.rb +3 -2
  12. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
  13. data/lib/hammer_cli_foreman/id_resolver.rb +2 -2
  14. data/lib/hammer_cli_foreman/location.rb +2 -0
  15. data/lib/hammer_cli_foreman/option_builders.rb +1 -1
  16. data/lib/hammer_cli_foreman/organization.rb +2 -0
  17. data/lib/hammer_cli_foreman/output/fields.rb +1 -1
  18. data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
  19. data/lib/hammer_cli_foreman/ping.rb +20 -11
  20. data/lib/hammer_cli_foreman/references.rb +16 -0
  21. data/lib/hammer_cli_foreman/settings.rb +14 -0
  22. data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
  23. data/lib/hammer_cli_foreman/version.rb +1 -1
  24. data/lib/minitest/coverage_reporter.rb +94 -0
  25. data/lib/minitest/hammer_coverage_plugin.rb +19 -0
  26. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  27. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  28. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  29. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  30. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/test/functional/audit_test.rb +86 -63
  40. data/test/functional/commands/list_test.rb +11 -11
  41. data/test/functional/compute_profile_test.rb +4 -2
  42. data/test/functional/host_test.rb +43 -18
  43. data/test/functional/location_test.rb +134 -0
  44. data/test/functional/media_test.rb +130 -0
  45. data/test/functional/organization_test.rb +52 -0
  46. data/test/functional/realm_test.rb +103 -0
  47. data/test/functional/role_test.rb +9 -12
  48. data/test/functional/settings_test.rb +57 -1
  49. data/test/functional/user_test.rb +39 -0
  50. data/test/reports/TEST-Minitest-Result.xml +4344 -0
  51. data/test/test_helper.rb +5 -2
  52. data/test/unit/api/interactive_basic_auth_test.rb +3 -1
  53. data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
  54. data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
  55. data/test/unit/api_test.rb +3 -4
  56. data/test/unit/apipie_resource_mock.rb +4 -4
  57. data/test/unit/audit_test.rb +1 -0
  58. data/test/unit/commands_test.rb +19 -19
  59. data/test/unit/common_parameter_test.rb +1 -1
  60. data/test/unit/dependency_resolver_test.rb +4 -4
  61. data/test/unit/exception_handler_test.rb +13 -13
  62. data/test/unit/helpers/command.rb +5 -5
  63. data/test/unit/helpers/resource_disabled.rb +2 -2
  64. data/test/unit/host_test.rb +1 -24
  65. data/test/unit/id_resolver_test.rb +23 -23
  66. data/test/unit/media_test.rb +1 -1
  67. data/test/unit/option_builders_test.rb +49 -49
  68. data/test/unit/option_sources/id_params_test.rb +2 -2
  69. data/test/unit/option_sources/ids_params_test.rb +2 -2
  70. data/test/unit/output/formatters_test.rb +21 -21
  71. data/test/unit/param_filters_test.rb +17 -17
  72. data/test/unit/partition_table_test.rb +2 -2
  73. data/test/unit/role_test.rb +2 -2
  74. data/test/unit/sessions_test.rb +24 -24
  75. data/test/unit/template_test.rb +1 -1
  76. metadata +108 -103
  77. data/lib/hammer_cli_foreman/trend.rb +0 -47
  78. data/test/functional/trend_test.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c937e9c178ca90874c6807da863508ebd631bb3d2d4b09a3ef2babf992866c9
4
- data.tar.gz: 9d80d80f23f1f653b1f7342a1f978651ea765468497dd9537876043d0ef444c1
3
+ metadata.gz: d3602bf5d1cda5fed0ace9196b7aa5dbd0622079db5ab77f252cd134d0e05d5d
4
+ data.tar.gz: e341fb0eb8b606c519199c36fc1a14a520661a010f62bd946cb0b3c394fdd267
5
5
  SHA512:
6
- metadata.gz: '061920937107ab4af20dd3d02a86c679186376b2eab355a8587b3e405709dd8b14c924d907b8cfcf73ec24cdd1b02ed866c28c722a9cdb0167a6bf733ae83b34'
7
- data.tar.gz: 56f1841eef3af5cdaa2350529ec4bff88544d5ef0d523dc4a311efc76e083d003e80642b96118705e40c628192ebfe5be6b7f3bfb28624ed142ebe9199f1f668
6
+ metadata.gz: 75f923de0d55217bf30a6c6d12afe19e5b806b360892f1d429d18aa39bab2443151c7317ed5d39f979af8c934edd8134d1767efacfe52a353b9546a29f1983de
7
+ data.tar.gz: 833444008fa0f26d711708980a65f39e8cc485409acdb6c23e6afff8998645c2f2c34acd3cf70b84638fe0569c299ee11a5aabb2ba916d5524abcc19b9c78be2
@@ -1,10 +1,40 @@
1
1
  Release notes
2
2
  =============
3
- ### 2.1.1 (2020-05-29)
3
+ ### 2.3.1 (2021-01-27)
4
+ * Deprecating puppetrun command ([PR #554](https://github.com/theforeman/hammer-cli-foreman/pull/554)), [#31536](http://projects.theforeman.org/issues/31536)
5
+
6
+ ### 2.3.0 (2020-11-03)
7
+ * Hammer ping skip authentication ([PR #550](https://github.com/theforeman/hammer-cli-foreman/pull/550)), [#31140](http://projects.theforeman.org/issues/31140)
8
+ * Return non-zero exit code if services failed, [#30496](http://projects.theforeman.org/issues/30496)
9
+ * Better option assignment for nested params ([PR #544](https://github.com/theforeman/hammer-cli-foreman/pull/544)), [#30910](http://projects.theforeman.org/issues/30910)
10
+ * Use parent resource instead of hardcoded one, [#30938](http://projects.theforeman.org/issues/30938)
11
+ * Added missing tests to setting, [#30886](http://projects.theforeman.org/issues/30886)
12
+ * Added missing tests to installation medium test, [#30805](http://projects.theforeman.org/issues/30805)
13
+ * Added missing tests to location test, [#30829](http://projects.theforeman.org/issues/30829)
14
+ * Added missing tests to organization test, [#30794](http://projects.theforeman.org/issues/30794)
15
+ * Added missing tests to audit test ([PR #537](https://github.com/theforeman/hammer-cli-foreman/pull/537)), [#30740](http://projects.theforeman.org/issues/30740)
16
+ * Use underscores in `login oauth` option values ([PR #536](https://github.com/theforeman/hammer-cli-foreman/pull/536)), [#30720](http://projects.theforeman.org/issues/30720)
17
+ * Drop trends from hammer-cli-foreman ([PR #535](https://github.com/theforeman/hammer-cli-foreman/pull/535)), [#30134](http://projects.theforeman.org/issues/30134)
18
+ * Added highly available option to ovirt ([PR #532](https://github.com/theforeman/hammer-cli-foreman/pull/532)), [#30494](http://projects.theforeman.org/issues/30494)
19
+ * Add ptables and realms to location and organization info ([PR #534](https://github.com/theforeman/hammer-cli-foreman/pull/534)), [#30663](http://projects.theforeman.org/issues/30663)
20
+ * Bump to 2.3.0-develop
21
+ * Bump to 2.2.0
22
+ * Added missing tests to user test, [#30593](http://projects.theforeman.org/issues/30593)
23
+
24
+ ### 2.2.0 (2020-08-11)
25
+ * Change config templates to provisioning templates ([PR #531](https://github.com/theforeman/hammer-cli-foreman/pull/531)), [#29971](http://projects.theforeman.org/issues/29971)
26
+ * Fix minitest deprecation ([PR #523](https://github.com/theforeman/hammer-cli-foreman/pull/523))
27
+ * Add a coverage test ([PR #522](https://github.com/theforeman/hammer-cli-foreman/pull/522))
28
+ * Return 'set current context for request' to help ([PR #530](https://github.com/theforeman/hammer-cli-foreman/pull/530)), [#30182](http://projects.theforeman.org/issues/30182)
29
+ * Display request uuid for audit ([PR #528](https://github.com/theforeman/hammer-cli-foreman/pull/528)), [#30130](http://projects.theforeman.org/issues/30130)
30
+ * Use parent resource instead of hardcoded one ([PR #527](https://github.com/theforeman/hammer-cli-foreman/pull/527)), [#30125](http://projects.theforeman.org/issues/30125)
31
+ * Added missing tests to realm command ([PR #526](https://github.com/theforeman/hammer-cli-foreman/pull/526)), [#30096](http://projects.theforeman.org/issues/30096)
32
+ * Added missing tests to trend test ([PR #525](https://github.com/theforeman/hammer-cli-foreman/pull/525)), [#30070](http://projects.theforeman.org/issues/30070)
4
33
  * Revert "skip one test on ruby 2.7" ([PR #520](https://github.com/theforeman/hammer-cli-foreman/pull/520)), [#28601](http://projects.theforeman.org/issues/28601)
5
34
  * Eliminate auth_type from sessions file ([PR #521](https://github.com/theforeman/hammer-cli-foreman/pull/521)), [#29876](http://projects.theforeman.org/issues/29876)
6
35
  * Add disable option for user ([PR #497](https://github.com/theforeman/hammer-cli-foreman/pull/497)), [#28973](http://projects.theforeman.org/issues/28973)
7
36
  * Added manage command to user mail notifications ([PR #513](https://github.com/theforeman/hammer-cli-foreman/pull/513)), [#7665](http://projects.theforeman.org/issues/7665)
37
+ * Bump to 2.2.0-develop
8
38
 
9
39
  ### 2.1.0 (2020-05-14)
10
40
  * Bump hammer_cli to 2.1.0 ([PR #519](https://github.com/theforeman/hammer-cli-foreman/pull/519))
@@ -131,3 +131,16 @@ connection = api_connection
131
131
  api = APIExpectationsDecorator.new(connection.api)
132
132
  api.expects_search(:users, 'login=admin')
133
133
  ```
134
+ ## Checking the coverage against the API
135
+ You can check how many API endpoints are covered by Hammer, this test runs all hammer tests,
136
+ and check which API actions run, therefore there could be two reasons for an endpoint to not be covered:
137
+ 1. there is no test for this action
138
+ 2. there is no hammer command for the API endpoint.
139
+ ### running the coverage test
140
+ ```bash
141
+
142
+ rake test TESTOPTS="-c"
143
+
144
+ TEST_API_VERSION=2.0 rake test TESTOPTS="-c"
145
+
146
+ ```
@@ -154,7 +154,7 @@ module HammerCLIForeman
154
154
  'HammerCLIForeman::Subnet', 'hammer_cli_foreman/subnet'
155
155
  )
156
156
 
157
- HammerCLI::MainCommand.lazy_subcommand('template', _("Manipulate config templates"),
157
+ HammerCLI::MainCommand.lazy_subcommand('template', _("Manipulate provisioning templates"),
158
158
  'HammerCLIForeman::Template', 'hammer_cli_foreman/template'
159
159
  )
160
160
 
@@ -178,10 +178,6 @@ module HammerCLIForeman
178
178
  'HammerCLIForeman::StatusCommand', 'hammer_cli_foreman/status'
179
179
  )
180
180
 
181
- HammerCLI::MainCommand.lazy_subcommand('trend', _("Manage trends"),
182
- 'HammerCLIForeman::Trend', 'hammer_cli_foreman/trend'
183
- )
184
-
185
181
  HammerCLI::MainCommand.lazy_subcommand('mail-notification', _("Manage mail notifications"),
186
182
  'HammerCLIForeman::MailNotification', 'hammer_cli_foreman/mail_notification'
187
183
  )
@@ -244,8 +244,7 @@ module HammerCLIForeman
244
244
 
245
245
  def request_params
246
246
  params = super
247
-
248
- template_ids = params['operatingsystem']['provisioning_template_ids']
247
+ template_ids = params[resource.singular_name]['provisioning_template_ids']
249
248
  if options['option_provisioning_template_search']
250
249
  templates = HammerCLIForeman.collection_to_common_format(
251
250
  associated_resource.call(
@@ -259,7 +258,7 @@ module HammerCLIForeman
259
258
  template_ids << template_id.to_s
260
259
  end
261
260
  end
262
- params['operatingsystem']['provisioning_template_ids'] = template_ids.uniq
261
+ params[resource.singular_name]['provisioning_template_ids'] = template_ids.uniq
263
262
  params
264
263
  end
265
264
 
@@ -281,7 +280,7 @@ module HammerCLIForeman
281
280
  def request_params
282
281
  params = super
283
282
 
284
- template_ids = params['operatingsystem']['provisioning_template_ids']
283
+ template_ids = params[resource.singular_name]['provisioning_template_ids']
285
284
  if options['option_provisioning_template_search']
286
285
  templates = HammerCLIForeman.collection_to_common_format(
287
286
  associated_resource.call(
@@ -295,7 +294,7 @@ module HammerCLIForeman
295
294
  template_ids.delete(template_id.to_s)
296
295
  end
297
296
  end
298
- params['operatingsystem']['provisioning_template_ids'] = template_ids.uniq
297
+ params[resource.singular_name]['provisioning_template_ids'] = template_ids.uniq
299
298
  params
300
299
  end
301
300
 
@@ -28,6 +28,7 @@ module HammerCLIForeman
28
28
  field :action, _("Action")
29
29
  field :auditable_type, _("Audit type")
30
30
  field nil, _("Audit record"), Fields::SingleReference, :key => :auditable
31
+ field :request_uuid, _("Request UUID"), Fields::Field, sets: ['ALL']
31
32
  end
32
33
 
33
34
  build_options
@@ -63,6 +64,12 @@ module HammerCLIForeman
63
64
  end
64
65
  end
65
66
 
67
+ extend_output_definition do |definition|
68
+ definition.insert(:replace, :request_uuid) do
69
+ field :request_uuid, _("Request UUID"), Fields::Field, sets: ['ALL', 'DEFAULT']
70
+ end
71
+ end
72
+
66
73
  build_options
67
74
  end
68
75
 
@@ -36,11 +36,11 @@ module HammerCLIForeman
36
36
 
37
37
  option ["-u", "--username"], "USERNAME", _("Username to access the remote system")
38
38
  option ["-p", "--password"], "PASSWORD", _("Password to access the remote system")
39
- option ["-t", "--oidc-token-endpoint"], "OPENIDC-TOKEN-ENDPOINT", _("Openidc provider URL which issues access token")
40
- option ["-a", "--oidc-authorization-endpoint"], "OPENIDC-AUTHORIZATION-ENDPOINT", _("Openidc provider URL which issues authentication code (two factor only)")
41
- option ["-c", "--oidc-client-id"], "OPENIDC-CLIENT-ID", _("Client id used in the Openidc provider")
39
+ option ["-t", "--oidc-token-endpoint"], "OPENIDC_TOKEN_ENDPOINT", _("Openidc provider URL which issues access token")
40
+ option ["-a", "--oidc-authorization-endpoint"], "OPENIDC_AUTHORIZATION_ENDPOINT", _("Openidc provider URL which issues authentication code (two factor only)")
41
+ option ["-c", "--oidc-client-id"], "OPENIDC_CLIENT_ID", _("Client id used in the Openidc provider")
42
42
  option ["-f", "--two-factor"], :flag, _("Authenticate with two factor")
43
- option ["-r", "--oidc-redirect-uri"], "OPENIDC-REDIRECT-URI", _("Redirect URI for the authentication code grant flow")
43
+ option ["-r", "--oidc-redirect-uri"], "OPENIDC_REDIRECT_URI", _("Redirect URI for the authentication code grant flow")
44
44
 
45
45
  def execute
46
46
  if option_two_factor?
@@ -6,9 +6,18 @@ module HammerCLIForeman
6
6
  status = data['results']['foreman']['database']['active']
7
7
  data['results']['foreman']['database']['active'] = status ? 'ok' : 'FAIL'
8
8
  duration = data['results']['foreman']['database']['duration_ms']
9
- data['results']['foreman']['database']['duration_ms'] = _("Duration: %sms") % duration
9
+ data['results']['foreman']['database']['duration_ms'] = _('Duration: %sms') % duration
10
10
  end
11
11
  end
12
+
13
+ def self.failed?(services)
14
+ services.each_value.any? { |s| s['status'] == _('FAIL') } ||
15
+ services['foreman']['database']['active'] == 'FAIL'
16
+ end
17
+
18
+ request_options do |options|
19
+ options[:with_authentication] = false
20
+ end
12
21
  end
13
22
  end
14
23
  end
@@ -548,10 +548,12 @@ module HammerCLIForeman
548
548
  builder
549
549
  end
550
550
 
551
- def method_options_for_params(params, include_nil=true)
551
+ def method_options_for_params(params, options)
552
552
  opts = super
553
553
  # overwrite searchables with correct values
554
554
  searchables.for(resource).each do |s|
555
+ next unless params.map(&:name).include?(s.name)
556
+
555
557
  new_value = get_option_value("new_#{s.name}")
556
558
  opts[s.name] = new_value unless new_value.nil?
557
559
  end
@@ -12,6 +12,7 @@ module HammerCLIForeman
12
12
  ['cores', _('Integer value, number of cores')],
13
13
  ['sockets', _('Integer value, number of sockets')],
14
14
  ['memory', _('Amount of memory, integer value in bytes')],
15
+ ['ha', _('Boolean, set 1 to high availability')],
15
16
  ['display_type', _('Possible values: %s') % 'VNC, SPICE'],
16
17
  ['keyboard_layout', _('Possible values: %s. Not usable if display type is SPICE.') % 'ar, de-ch, es, fo, fr-ca, hu, ja, mk, no, pt-br, sv, da, en-gb, et, fr, fr-ch, is, lt, nl, pl, ru, th, de, en-us, fi, fr-be, hr, it, lv, nl-be, pt, sl, tr']
17
18
  ]
@@ -176,8 +176,9 @@ module HammerCLIForeman
176
176
  resource :puppet_hosts
177
177
  action :puppetrun
178
178
 
179
- def print_data(records)
180
- print_message _('Puppet run triggered')
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
181
182
  end
182
183
 
183
184
  build_options
@@ -84,18 +84,16 @@ module HammerCLIForeman
84
84
 
85
85
  params['host']['host_parameters_attributes'] = parameter_attributes unless option_parameters.nil?
86
86
  params['host']['host_parameters_attributes'] ||= option_typed_parameters unless option_typed_parameters.nil?
87
- params['host']['compute_attributes'] = option_compute_attributes || {}
88
87
 
89
- compute_attributes = params['host']['compute_attributes']
90
- compute_attributes['display'] = {} unless compute_attributes['display_type'].nil? && compute_attributes['keyboard_layout'].nil?
91
- compute_attributes['display']['type'] = compute_attributes['display_type'] unless compute_attributes['display_type'].nil?
92
- compute_attributes['display']['keyboard_layout'] = compute_attributes['keyboard_layout'] unless compute_attributes['keyboard_layout'].nil?
93
- compute_attributes.delete('display_type')
94
- compute_attributes.delete('keyboard_layout')
95
- params['host']['compute_attributes'] = compute_attributes
88
+ if option_compute_attributes && !option_compute_attributes.empty?
89
+ params['host']['compute_attributes'] = host_compute_attrs(option_compute_attributes)
90
+ end
96
91
 
97
92
  if action == :update
98
- params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list) unless option_volume_list.empty?
93
+ unless option_volume_list.empty?
94
+ params['host']['compute_attributes'] ||= {}
95
+ params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
96
+ end
99
97
  params['host']['interfaces_attributes'] = interfaces_attributes unless option_interface_list.empty?
100
98
  if options['option_new_location_id']
101
99
  params['host']['location_id'] = options['option_new_location_id']
@@ -108,6 +106,7 @@ module HammerCLIForeman
108
106
  params['host'].delete('organization_id')
109
107
  end
110
108
  else
109
+ params['host']['compute_attributes'] ||= {}
111
110
  params['host']['compute_attributes']['volumes_attributes'] = nested_attributes(option_volume_list)
112
111
  params['host']['interfaces_attributes'] = interfaces_attributes
113
112
  end
@@ -121,6 +120,7 @@ module HammerCLIForeman
121
120
  end
122
121
  raise ArgumentError, "Missing argument for 'compute_resource'" if compute_resource_id.nil?
123
122
  image_uuid = ::HammerCLIForeman::ComputeResources.get_image_uuid(compute_resource_id, options["option_image_id"])
123
+ params['host']['compute_attributes'] ||= {}
124
124
  params['host']['compute_attributes']['image_id'] = image_uuid
125
125
  end
126
126
  params['host']['root_pass'] = option_root_password unless option_root_password.nil?
@@ -164,6 +164,13 @@ module HammerCLIForeman
164
164
  end
165
165
  end
166
166
 
167
+ def host_compute_attrs(attrs)
168
+ attrs['display'] = {} unless attrs['display_type'].nil? && attrs['keyboard_layout'].nil?
169
+ attrs['display']['type'] = attrs.delete('display_type') unless attrs['display_type'].nil?
170
+ attrs['display']['keyboard_layout'] = attrs.delete('keyboard_layout') unless attrs['keyboard_layout'].nil?
171
+ attrs
172
+ end
173
+
167
174
  def nested_attributes(attrs)
168
175
  return {} unless attrs
169
176
 
@@ -50,8 +50,8 @@ module HammerCLIForeman
50
50
  :hostgroup => [ s_name(_("Hostgroup name")), s("title", _("Hostgroup title"), :editable => false) ],
51
51
  # :image => [],
52
52
  :interface => [],
53
- :location => [ s('name', _('Location Name, Set the current location context for the request')),
54
- s('title', _('Location title, Set the current location context for the request' ),
53
+ :location => [ s('name', _('Set the current location context for the request')),
54
+ s('title', _('Set the current location context for the request' ),
55
55
  editable: false
56
56
  )
57
57
  ],
@@ -33,7 +33,9 @@ module HammerCLIForeman
33
33
  HammerCLIForeman::References.compute_resources(self)
34
34
  HammerCLIForeman::References.media(self)
35
35
  HammerCLIForeman::References.provisioning_templates(self)
36
+ HammerCLIForeman::References.partition_tables(self)
36
37
  HammerCLIForeman::References.domains(self)
38
+ HammerCLIForeman::References.realms(self)
37
39
  HammerCLIForeman::References.environments(self)
38
40
  HammerCLIForeman::References.hostgroups(self)
39
41
  HammerCLIForeman::References.parameters(self)
@@ -209,7 +209,7 @@ module HammerCLIForeman
209
209
  family = HammerCLI::Options::OptionFamily.new(
210
210
  referenced_resource: resource_name,
211
211
  aliased_resource: aliased_name,
212
- description: _('%{types} of associated %{resource}') % { types: types, resource: associated_resource }
212
+ description: _('Set the current %{resource} context for the request. %{types} can be used') % { types: types, resource: associated_resource }
213
213
  )
214
214
 
215
215
  unless searchables.empty?
@@ -33,7 +33,9 @@ module HammerCLIForeman
33
33
  HammerCLIForeman::References.compute_resources(self)
34
34
  HammerCLIForeman::References.media(self)
35
35
  HammerCLIForeman::References.provisioning_templates(self)
36
+ HammerCLIForeman::References.partition_tables(self)
36
37
  HammerCLIForeman::References.domains(self)
38
+ HammerCLIForeman::References.realms(self)
37
39
  HammerCLIForeman::References.environments(self)
38
40
  HammerCLIForeman::References.hostgroups(self)
39
41
  HammerCLIForeman::References.parameters(self)
@@ -19,7 +19,7 @@ module Fields
19
19
 
20
20
  def id_detail
21
21
  {
22
- :label => _('id'),
22
+ :label => {:target => _('id')},
23
23
  :structured_label => _('Id'),
24
24
  :key => @options[:id_key] || :id,
25
25
  :id => true
@@ -35,7 +35,7 @@ module HammerCLIForeman::Output
35
35
  if detail.is_a?(Hash)
36
36
  next if detail[:id] && !show_ids
37
37
  if detail[:label]
38
- "#{detail[:label]}: #{get_value(data, detail[:key])}"
38
+ "#{detail[:label][:target]}: #{get_value(data, detail[:key])}"
39
39
  else
40
40
  get_value(data, detail[:key])
41
41
  end
@@ -1,23 +1,32 @@
1
1
  module HammerCLIForeman
2
2
  class PingCommand < HammerCLIForeman::Command
3
- resource :ping
3
+ resource :ping
4
4
 
5
- class ForemanCommand < HammerCLIForeman::Command
6
- action :ping
7
- command_name 'foreman'
5
+ class ForemanCommand < HammerCLIForeman::Command
6
+ action :ping
7
+ command_name 'foreman'
8
8
 
9
- output do
10
- from 'foreman' do
11
- field :database, _('database'), Fields::Label do
12
- field :active, _('Status')
13
- field :duration_ms, _('Server Response')
14
- end
9
+ output do
10
+ from 'foreman' do
11
+ field :database, _('database'), Fields::Label do
12
+ field :active, _('Status')
13
+ field :duration_ms, _('Server Response')
15
14
  end
16
15
  end
16
+ end
17
+
18
+ def execute
19
+ response = send_request
20
+ print_data(response)
17
21
 
18
- extend_with(HammerCLIForeman::CommandExtensions::Ping.new)
22
+ return 1 if HammerCLIForeman::CommandExtensions::Ping.failed?(response)
23
+
24
+ HammerCLI::EX_OK
19
25
  end
20
26
 
27
+ extend_with(HammerCLIForeman::CommandExtensions::Ping.new)
28
+ end
29
+
21
30
  self.default_subcommand = 'foreman'
22
31
  autoload_subcommands
23
32
  end
@@ -88,6 +88,14 @@ module HammerCLIForeman
88
88
  end
89
89
  end
90
90
 
91
+ def self.partition_tables(dsl)
92
+ dsl.build do
93
+ collection :ptables, _("Partition Tables"), :numbered => false do
94
+ custom_field Fields::Reference
95
+ end
96
+ end
97
+ end
98
+
91
99
  def self.domains(dsl)
92
100
  dsl.build do
93
101
  collection :domains, _("Domains"), :numbered => false do
@@ -96,6 +104,14 @@ module HammerCLIForeman
96
104
  end
97
105
  end
98
106
 
107
+ def self.realms(dsl)
108
+ dsl.build do
109
+ collection :realms, _("Realms"), :numbered => false do
110
+ custom_field Fields::Reference
111
+ end
112
+ end
113
+ end
114
+
99
115
  def self.environments(dsl)
100
116
  dsl.build do
101
117
  collection :environments, _("Environments"), :numbered => false do
@@ -32,6 +32,20 @@ module HammerCLIForeman
32
32
  build_options
33
33
  end
34
34
 
35
+ class InfoCommand < HammerCLIForeman::InfoCommand
36
+ output do
37
+ field :id, _("Id")
38
+ field :name, _("Name")
39
+ field :description, _("Description")
40
+ field :category_name, _("Category")
41
+ field :settings_type, _("Settings type")
42
+ field :value, _("Value")
43
+ end
44
+
45
+ build_options
46
+ end
47
+
48
+
35
49
  autoload_subcommands
36
50
  end
37
51
 
@@ -1,6 +1,11 @@
1
1
  module HammerCLIForeman
2
2
  module Testing
3
3
  module APIExpectations
4
+
5
+ def self.api_calls
6
+ @api_calls ||= []
7
+ end
8
+
4
9
  class APICallMatcher < Mocha::ParameterMatchers::Base
5
10
  attr_accessor :expected_params, :expected_resource, :expected_action, :block
6
11
 
@@ -160,7 +165,12 @@ module HammerCLIForeman
160
165
  }.merge(options))
161
166
  end
162
167
 
168
+ def api_calls
169
+ HammerCLIForeman::Testing::APIExpectations.api_calls
170
+ end
171
+
163
172
  def api_expects(resource=nil, action=nil, note=nil, &block)
173
+ api_calls << [resource, action]
164
174
  APIExpectationsDecorator.new.expects_call(resource, action, note, &block)
165
175
  end
166
176