hammer_cli_foreman 2.1.2 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +32 -4
  3. data/doc/testing.md +13 -0
  4. data/lib/hammer_cli_foreman.rb +0 -4
  5. data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
  6. data/lib/hammer_cli_foreman/auth.rb +4 -4
  7. data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
  8. data/lib/hammer_cli_foreman/commands.rb +3 -1
  9. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
  10. data/lib/hammer_cli_foreman/host.rb +3 -2
  11. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
  12. data/lib/hammer_cli_foreman/location.rb +2 -0
  13. data/lib/hammer_cli_foreman/option_builders.rb +21 -2
  14. data/lib/hammer_cli_foreman/organization.rb +2 -0
  15. data/lib/hammer_cli_foreman/output/fields.rb +1 -1
  16. data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
  17. data/lib/hammer_cli_foreman/ping.rb +20 -11
  18. data/lib/hammer_cli_foreman/references.rb +16 -0
  19. data/lib/hammer_cli_foreman/settings.rb +14 -0
  20. data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
  21. data/lib/hammer_cli_foreman/version.rb +1 -1
  22. data/lib/minitest/coverage_reporter.rb +94 -0
  23. data/lib/minitest/hammer_coverage_plugin.rb +19 -0
  24. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  25. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  26. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  27. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  28. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  29. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  30. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/test/functional/audit_test.rb +86 -63
  38. data/test/functional/commands/list_test.rb +11 -11
  39. data/test/functional/compute_profile_test.rb +4 -2
  40. data/test/functional/host_test.rb +43 -18
  41. data/test/functional/location_test.rb +134 -0
  42. data/test/functional/media_test.rb +130 -0
  43. data/test/functional/organization_test.rb +52 -0
  44. data/test/functional/realm_test.rb +103 -0
  45. data/test/functional/role_test.rb +9 -12
  46. data/test/functional/settings_test.rb +57 -1
  47. data/test/functional/user_test.rb +39 -0
  48. data/test/test_helper.rb +5 -2
  49. data/test/unit/api/interactive_basic_auth_test.rb +3 -1
  50. data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
  51. data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
  52. data/test/unit/api_test.rb +3 -4
  53. data/test/unit/apipie_resource_mock.rb +4 -4
  54. data/test/unit/commands_test.rb +19 -19
  55. data/test/unit/common_parameter_test.rb +1 -1
  56. data/test/unit/dependency_resolver_test.rb +4 -4
  57. data/test/unit/exception_handler_test.rb +13 -13
  58. data/test/unit/helpers/command.rb +5 -5
  59. data/test/unit/helpers/resource_disabled.rb +2 -2
  60. data/test/unit/host_test.rb +1 -24
  61. data/test/unit/id_resolver_test.rb +23 -23
  62. data/test/unit/media_test.rb +1 -1
  63. data/test/unit/option_builders_test.rb +49 -49
  64. data/test/unit/option_sources/id_params_test.rb +2 -2
  65. data/test/unit/option_sources/ids_params_test.rb +2 -2
  66. data/test/unit/output/formatters_test.rb +21 -21
  67. data/test/unit/param_filters_test.rb +17 -17
  68. data/test/unit/partition_table_test.rb +2 -2
  69. data/test/unit/role_test.rb +2 -2
  70. data/test/unit/sessions_test.rb +24 -24
  71. data/test/unit/template_test.rb +1 -1
  72. metadata +105 -104
  73. data/lib/hammer_cli_foreman/trend.rb +0 -47
  74. data/test/functional/trend_test.rb +0 -22
  75. data/test/reports/TEST-Minitest-Result.xml +0 -4344
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76e95389bb3b76b95c4c58d9faf7e7ff7e1b5c8bf2bcaed44aee693ef2fe9d02
4
- data.tar.gz: 94cef7601ae22edec554dbfbccf4ffde70b45db465e3746f510437513d3b477e
3
+ metadata.gz: b30a6bc396c149912681a2a600c7dcc84fc5144b90b5b4b8cf45f57690bbaa39
4
+ data.tar.gz: de18a4c812f92f1988791f404986a2e7b0c5464d401b001ddedee3c934a1f137
5
5
  SHA512:
6
- metadata.gz: 441c7dc0803a50667feafe17fc0fa5674e79ef10859fd2e06c4929ef7fe18dded59e354986e15f57c950a9e3be5bd8ec2701da1e090f36cc353fc06d150b25b4
7
- data.tar.gz: bc7f373ce2e39987744a9a05c5cede008de26f0198e6ec3026a4be1b051452de701e0ae5245527768d2851dfbbd24d3f9417d1fd3939ddb7d4da7a63e2002e62
6
+ metadata.gz: 4fe825dd7cb98c62c1093d11d33e1d488b80bd55f6927089cb4a84e9214d3fbedb7add28d5436492c63f6d8b5cf8b7c3f64d6d30de9aac1fc39fdace9324c465
7
+ data.tar.gz: 2d317a4070fa04020b10aa0f7c5c43a000c325ac2cde01a888c4d82fe8a6a01e746e0d4d9a66a92a239e4597f7e25daf5399e5b97d892fd84ac43e0b80052f02
data/doc/release_notes.md CHANGED
@@ -1,15 +1,43 @@
1
1
  Release notes
2
2
  =============
3
- ### 2.1.2 (2020-07-14)
3
+ ### 2.3.2 (2021-05-04)
4
+ * Apply option family on searchablesoptionbuilder, [#30996](http://projects.theforeman.org/issues/30996)
5
+
6
+ ### 2.3.1 (2021-01-27)
7
+ * Deprecating puppetrun command ([PR #554](https://github.com/theforeman/hammer-cli-foreman/pull/554)), [#31536](http://projects.theforeman.org/issues/31536)
8
+
9
+ ### 2.3.0 (2020-11-03)
10
+ * Hammer ping skip authentication ([PR #550](https://github.com/theforeman/hammer-cli-foreman/pull/550)), [#31140](http://projects.theforeman.org/issues/31140)
11
+ * Return non-zero exit code if services failed, [#30496](http://projects.theforeman.org/issues/30496)
12
+ * Better option assignment for nested params ([PR #544](https://github.com/theforeman/hammer-cli-foreman/pull/544)), [#30910](http://projects.theforeman.org/issues/30910)
13
+ * Use parent resource instead of hardcoded one, [#30938](http://projects.theforeman.org/issues/30938)
14
+ * Added missing tests to setting, [#30886](http://projects.theforeman.org/issues/30886)
15
+ * Added missing tests to installation medium test, [#30805](http://projects.theforeman.org/issues/30805)
16
+ * Added missing tests to location test, [#30829](http://projects.theforeman.org/issues/30829)
17
+ * Added missing tests to organization test, [#30794](http://projects.theforeman.org/issues/30794)
18
+ * Added missing tests to audit test ([PR #537](https://github.com/theforeman/hammer-cli-foreman/pull/537)), [#30740](http://projects.theforeman.org/issues/30740)
19
+ * 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)
20
+ * Drop trends from hammer-cli-foreman ([PR #535](https://github.com/theforeman/hammer-cli-foreman/pull/535)), [#30134](http://projects.theforeman.org/issues/30134)
21
+ * Added highly available option to ovirt ([PR #532](https://github.com/theforeman/hammer-cli-foreman/pull/532)), [#30494](http://projects.theforeman.org/issues/30494)
22
+ * 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)
23
+ * Bump to 2.3.0-develop
24
+ * Bump to 2.2.0
25
+ * Added missing tests to user test, [#30593](http://projects.theforeman.org/issues/30593)
26
+
27
+ ### 2.2.0 (2020-08-11)
4
28
  * Change config templates to provisioning templates ([PR #531](https://github.com/theforeman/hammer-cli-foreman/pull/531)), [#29971](http://projects.theforeman.org/issues/29971)
29
+ * Fix minitest deprecation ([PR #523](https://github.com/theforeman/hammer-cli-foreman/pull/523))
30
+ * Add a coverage test ([PR #522](https://github.com/theforeman/hammer-cli-foreman/pull/522))
5
31
  * 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)
6
- * Display request uuid for audit ([PR #528](https://github.com/theforeman/hammer-cli-foreman/pull/528)) ([PR #529](https://github.com/theforeman/hammer-cli-foreman/pull/529)), [#30130](http://projects.theforeman.org/issues/30130)
7
-
8
- ### 2.1.1 (2020-05-29)
32
+ * Display request uuid for audit ([PR #528](https://github.com/theforeman/hammer-cli-foreman/pull/528)), [#30130](http://projects.theforeman.org/issues/30130)
33
+ * 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)
34
+ * Added missing tests to realm command ([PR #526](https://github.com/theforeman/hammer-cli-foreman/pull/526)), [#30096](http://projects.theforeman.org/issues/30096)
35
+ * Added missing tests to trend test ([PR #525](https://github.com/theforeman/hammer-cli-foreman/pull/525)), [#30070](http://projects.theforeman.org/issues/30070)
9
36
  * 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)
10
37
  * Eliminate auth_type from sessions file ([PR #521](https://github.com/theforeman/hammer-cli-foreman/pull/521)), [#29876](http://projects.theforeman.org/issues/29876)
11
38
  * Add disable option for user ([PR #497](https://github.com/theforeman/hammer-cli-foreman/pull/497)), [#28973](http://projects.theforeman.org/issues/28973)
12
39
  * 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)
40
+ * Bump to 2.2.0-develop
13
41
 
14
42
  ### 2.1.0 (2020-05-14)
15
43
  * Bump hammer_cli to 2.1.0 ([PR #519](https://github.com/theforeman/hammer-cli-foreman/pull/519))
data/doc/testing.md CHANGED
@@ -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
+ ```
@@ -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
 
@@ -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
 
@@ -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)
@@ -170,15 +170,34 @@ module HammerCLIForeman
170
170
  attr_reader :resource
171
171
 
172
172
  def build(builder_params={})
173
+ resource_name_map = builder_params[:resource_mapping] || {}
173
174
  @searchables.for(@resource).collect do |s|
174
- option(
175
+ family = HammerCLI::Options::OptionFamily.new
176
+ family.parent(
175
177
  optionamize("--#{s.name}"),
176
178
  s.name.upcase,
177
179
  s.description,
178
- :referenced_resource => @resource.singular_name
180
+ referenced_resource: @resource.singular_name,
181
+ aliased_resource: aliased_name(resource_name(s.name), resource_name_map)
179
182
  )
180
183
  end
181
184
  end
185
+
186
+ def aliased_name(name, resource_name_map)
187
+ return if name.nil?
188
+
189
+ resource_name_map[name.to_s] || resource_name_map[name.to_sym] || name
190
+ end
191
+
192
+ def resource_name(param)
193
+ if param =~ /^id[s]?$/
194
+ @resource.singular_name
195
+ elsif param =~ /_id[s]?$/
196
+ param.gsub(/_id[s]?$/, '')
197
+ else
198
+ nil
199
+ end
200
+ end
182
201
  end
183
202
 
184
203
 
@@ -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