hammer_cli_foreman 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes.md +33 -0
  3. data/doc/testing.md +13 -0
  4. data/lib/hammer_cli_foreman.rb +1 -5
  5. data/lib/hammer_cli_foreman/api/connection.rb +1 -18
  6. data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +0 -1
  7. data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
  8. data/lib/hammer_cli_foreman/audit.rb +7 -0
  9. data/lib/hammer_cli_foreman/auth.rb +4 -4
  10. data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
  11. data/lib/hammer_cli_foreman/commands.rb +3 -1
  12. data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
  13. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +16 -9
  14. data/lib/hammer_cli_foreman/id_resolver.rb +2 -2
  15. data/lib/hammer_cli_foreman/location.rb +2 -0
  16. data/lib/hammer_cli_foreman/option_builders.rb +1 -1
  17. data/lib/hammer_cli_foreman/organization.rb +2 -0
  18. data/lib/hammer_cli_foreman/output/fields.rb +1 -1
  19. data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
  20. data/lib/hammer_cli_foreman/ping.rb +20 -11
  21. data/lib/hammer_cli_foreman/references.rb +16 -0
  22. data/lib/hammer_cli_foreman/sessions.rb +1 -3
  23. data/lib/hammer_cli_foreman/settings.rb +14 -0
  24. data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
  25. data/lib/hammer_cli_foreman/user.rb +4 -0
  26. data/lib/hammer_cli_foreman/user_mail_notification.rb +51 -0
  27. data/lib/hammer_cli_foreman/version.rb +1 -1
  28. data/lib/minitest/coverage_reporter.rb +94 -0
  29. data/lib/minitest/hammer_coverage_plugin.rb +19 -0
  30. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  33. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  34. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  35. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  36. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  43. data/test/data/2.1/foreman_api.json +1 -1
  44. data/test/functional/audit_test.rb +86 -63
  45. data/test/functional/commands/list_test.rb +11 -11
  46. data/test/functional/compute_profile_test.rb +4 -2
  47. data/test/functional/host_test.rb +29 -18
  48. data/test/functional/http_proxy_test.rb +1 -4
  49. data/test/functional/location_test.rb +134 -0
  50. data/test/functional/media_test.rb +130 -0
  51. data/test/functional/organization_test.rb +52 -0
  52. data/test/functional/realm_test.rb +103 -0
  53. data/test/functional/role_test.rb +9 -12
  54. data/test/functional/settings_test.rb +57 -1
  55. data/test/functional/user_mail_notification_test.rb +89 -0
  56. data/test/functional/user_test.rb +39 -0
  57. data/test/reports/TEST-Minitest-Result.xml +4344 -0
  58. data/test/test_helper.rb +5 -2
  59. data/test/unit/api/interactive_basic_auth_test.rb +3 -1
  60. data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
  61. data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
  62. data/test/unit/api_test.rb +3 -4
  63. data/test/unit/apipie_resource_mock.rb +4 -4
  64. data/test/unit/audit_test.rb +1 -0
  65. data/test/unit/commands_test.rb +19 -19
  66. data/test/unit/common_parameter_test.rb +1 -1
  67. data/test/unit/dependency_resolver_test.rb +4 -4
  68. data/test/unit/exception_handler_test.rb +13 -13
  69. data/test/unit/helpers/command.rb +5 -5
  70. data/test/unit/helpers/resource_disabled.rb +2 -2
  71. data/test/unit/host_test.rb +2 -2
  72. data/test/unit/id_resolver_test.rb +23 -23
  73. data/test/unit/media_test.rb +1 -1
  74. data/test/unit/option_builders_test.rb +49 -49
  75. data/test/unit/option_sources/id_params_test.rb +2 -2
  76. data/test/unit/option_sources/ids_params_test.rb +2 -2
  77. data/test/unit/output/formatters_test.rb +21 -21
  78. data/test/unit/param_filters_test.rb +17 -17
  79. data/test/unit/partition_table_test.rb +2 -2
  80. data/test/unit/role_test.rb +2 -2
  81. data/test/unit/sessions_test.rb +26 -37
  82. data/test/unit/template_test.rb +1 -1
  83. metadata +15 -7
  84. data/lib/hammer_cli_foreman/trend.rb +0 -47
  85. data/test/functional/trend_test.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4db93fb25a95e818a8b0b9fdaab9ab8760cc7f42c2607661e99ec4bb990815d4
4
- data.tar.gz: d2187c023afc8dd80ae0247b53475354913950f1416e5f8bc308a48388e807fe
3
+ metadata.gz: 1cb3de28c168226867cc9b1f4f63ea96bf2ff8746b831e2cdf01e6fe6670a53b
4
+ data.tar.gz: 55b321941992865b2339fd1e0d11b3845c1396c0699f90c52ab4ba774974b70f
5
5
  SHA512:
6
- metadata.gz: ac00a2af523db5f7cf5c881273f715128fbc1df82604ecd01bf6c06b95a09963fac84e76c79260b77908925f38e4864ace72a8f3b31f4b1e60179b8b89b716d6
7
- data.tar.gz: 5300260e5c63d59ba8971dd784bb5f1e23a18a2de5b1611be02204c8a6b670368678742d8fa60815118b0f3b50127a4db92c599fb797d4bf045deb6ed366d263
6
+ metadata.gz: 7e50e0beb69a60b01613b3d7c282b927e54872de4533364e079f768e22f4a1e63aea967d7113e72a32ee35a20d4475a1cefef03055af956027e7fb3ce0fde00e
7
+ data.tar.gz: 8ec8cc1402c57faa1b5bbb960bb9b4963e2c4c0e21b9e0a62e88c7e02ca2a01f976c83795c21b7c801aa635842df6fc5fb0794283bd8f666364bd91f404c661d
@@ -1,5 +1,38 @@
1
1
  Release notes
2
2
  =============
3
+ ### 2.3.0 (2020-11-03)
4
+ * Hammer ping skip authentication ([PR #550](https://github.com/theforeman/hammer-cli-foreman/pull/550)), [#31140](http://projects.theforeman.org/issues/31140)
5
+ * Return non-zero exit code if services failed, [#30496](http://projects.theforeman.org/issues/30496)
6
+ * Better option assignment for nested params ([PR #544](https://github.com/theforeman/hammer-cli-foreman/pull/544)), [#30910](http://projects.theforeman.org/issues/30910)
7
+ * Use parent resource instead of hardcoded one, [#30938](http://projects.theforeman.org/issues/30938)
8
+ * Added missing tests to setting, [#30886](http://projects.theforeman.org/issues/30886)
9
+ * Added missing tests to installation medium test, [#30805](http://projects.theforeman.org/issues/30805)
10
+ * Added missing tests to location test, [#30829](http://projects.theforeman.org/issues/30829)
11
+ * Added missing tests to organization test, [#30794](http://projects.theforeman.org/issues/30794)
12
+ * Added missing tests to audit test ([PR #537](https://github.com/theforeman/hammer-cli-foreman/pull/537)), [#30740](http://projects.theforeman.org/issues/30740)
13
+ * 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)
14
+ * Drop trends from hammer-cli-foreman ([PR #535](https://github.com/theforeman/hammer-cli-foreman/pull/535)), [#30134](http://projects.theforeman.org/issues/30134)
15
+ * Added highly available option to ovirt ([PR #532](https://github.com/theforeman/hammer-cli-foreman/pull/532)), [#30494](http://projects.theforeman.org/issues/30494)
16
+ * 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)
17
+ * Bump to 2.3.0-develop
18
+ * Bump to 2.2.0
19
+ * Added missing tests to user test, [#30593](http://projects.theforeman.org/issues/30593)
20
+
21
+ ### 2.2.0 (2020-08-11)
22
+ * Change config templates to provisioning templates ([PR #531](https://github.com/theforeman/hammer-cli-foreman/pull/531)), [#29971](http://projects.theforeman.org/issues/29971)
23
+ * Fix minitest deprecation ([PR #523](https://github.com/theforeman/hammer-cli-foreman/pull/523))
24
+ * Add a coverage test ([PR #522](https://github.com/theforeman/hammer-cli-foreman/pull/522))
25
+ * 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)
26
+ * Display request uuid for audit ([PR #528](https://github.com/theforeman/hammer-cli-foreman/pull/528)), [#30130](http://projects.theforeman.org/issues/30130)
27
+ * 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)
28
+ * Added missing tests to realm command ([PR #526](https://github.com/theforeman/hammer-cli-foreman/pull/526)), [#30096](http://projects.theforeman.org/issues/30096)
29
+ * Added missing tests to trend test ([PR #525](https://github.com/theforeman/hammer-cli-foreman/pull/525)), [#30070](http://projects.theforeman.org/issues/30070)
30
+ * 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)
31
+ * Eliminate auth_type from sessions file ([PR #521](https://github.com/theforeman/hammer-cli-foreman/pull/521)), [#29876](http://projects.theforeman.org/issues/29876)
32
+ * Add disable option for user ([PR #497](https://github.com/theforeman/hammer-cli-foreman/pull/497)), [#28973](http://projects.theforeman.org/issues/28973)
33
+ * 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)
34
+ * Bump to 2.2.0-develop
35
+
3
36
  ### 2.1.0 (2020-05-14)
4
37
  * Bump hammer_cli to 2.1.0 ([PR #519](https://github.com/theforeman/hammer-cli-foreman/pull/519))
5
38
  * Ask for oauth code only when needed ([PR #517](https://github.com/theforeman/hammer-cli-foreman/pull/517)), [#29635](http://projects.theforeman.org/issues/29635)
@@ -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
  )
@@ -42,26 +42,9 @@ module HammerCLIForeman
42
42
 
43
43
  protected
44
44
 
45
- # If the settings in foreman.yml has use_sessions as false, use :basic_auth
46
- # Else if the settings in foreman.yml has use_sessions as true
47
- # and if there exists a session_file with valid contents, we use the auth_type from sessions_file
48
- # Thus if the session expires (indicated by nil session_id), we use the
49
- # same auth_type for re-authentication as was used by the previous session.
50
- # Else we use the passed auth_type.
51
45
  def default_auth_type(settings)
52
46
  return AUTH_TYPES[:basic_auth] unless HammerCLIForeman::Sessions.enabled?
53
-
54
- url = settings.get(:_params, :host) || settings.get(:foreman, :host)
55
- username = settings.get(:_params, :username) || settings.get(:foreman, :username)
56
- session = HammerCLIForeman::Sessions.get(url)
57
- if !session.valid? && session.user_name == username && !session.auth_type.nil?
58
- session.auth_type
59
- else
60
- # If the caller has not sepcified an 'auth_type'
61
- # and the 'default_auth_type' in settings is also undefined
62
- # use :basic_auth for authentication.
63
- HammerCLI::Settings.get(:foreman, :default_auth_type) || AUTH_TYPES[:basic_auth]
64
- end
47
+ HammerCLI::Settings.get(:foreman, :default_auth_type) || AUTH_TYPES[:basic_auth]
65
48
  end
66
49
 
67
50
  def create_authenticator(uri, settings, auth_type)
@@ -69,7 +69,6 @@ module HammerCLIForeman
69
69
  if (r.cookies['_session_id'] && r.code != 401)
70
70
  session.id = r.cookies['_session_id']
71
71
  session.user_name = @authenticator.user
72
- session.auth_type = @auth_type
73
72
  session.store
74
73
  end
75
74
  @authenticator.response(r)
@@ -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
  ]
@@ -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
@@ -55,7 +55,7 @@ module HammerCLIForeman
55
55
  end
56
56
 
57
57
  class Session
58
- attr_accessor :id, :user_name, :auth_type
58
+ attr_accessor :id, :user_name
59
59
 
60
60
  def initialize(session_path)
61
61
  @session_path = File.expand_path(session_path)
@@ -63,7 +63,6 @@ module HammerCLIForeman
63
63
  session_data = JSON.parse(File.read(@session_path))
64
64
  @id = session_data['id']
65
65
  @user_name = session_data['user_name']
66
- @auth_type = session_data['auth_type']
67
66
  end
68
67
  rescue JSON::ParserError
69
68
  warn _('Invalid session data. Resetting the session.')
@@ -73,7 +72,6 @@ module HammerCLIForeman
73
72
  File.open(@session_path,"w") do |f|
74
73
  f.write({
75
74
  id: id,
76
- auth_type: auth_type,
77
75
  user_name: user_name
78
76
  }.to_json)
79
77
  end