hammer_cli_foreman 3.4.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/config/foreman.yml +5 -0
  3. data/doc/release_notes.md +9 -0
  4. data/lib/hammer_cli_foreman/api/authenticator.rb +20 -0
  5. data/lib/hammer_cli_foreman/api/basic_auth.rb +71 -0
  6. data/lib/hammer_cli_foreman/api/connection.rb +3 -2
  7. data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +3 -62
  8. data/lib/hammer_cli_foreman/api/interactive_basic_auth_external.rb +17 -0
  9. data/lib/hammer_cli_foreman/api/negotiate_auth.rb +1 -1
  10. data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +2 -2
  11. data/lib/hammer_cli_foreman/auth.rb +21 -0
  12. data/lib/hammer_cli_foreman/command_extensions/compute_resource_subcommand.rb +14 -0
  13. data/lib/hammer_cli_foreman/command_extensions.rb +1 -0
  14. data/lib/hammer_cli_foreman/compute_resource/register_compute_resources.rb +0 -1
  15. data/lib/hammer_cli_foreman/compute_resource/vmware.rb +3 -1
  16. data/lib/hammer_cli_foreman/compute_resource.rb +26 -6
  17. data/lib/hammer_cli_foreman/version.rb +1 -1
  18. data/lib/hammer_cli_foreman/virtual_machine.rb +0 -4
  19. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  20. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  21. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  22. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  23. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  24. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  25. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  26. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  27. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  28. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  29. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  30. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  31. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  32. data/test/functional/compute_resource_test.rb +21 -0
  33. data/test/unit/api/interactive_basic_auth_test.rb +2 -1
  34. metadata +78 -76
  35. data/lib/hammer_cli_foreman/compute_resource/gce.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4787fbc9dbda1fcd2311672da8001300715cfc1448b82f985509a73cab3ab416
4
- data.tar.gz: a2ee1f1044f4422181109b166040b8e83dd9c727310c7753e89d26c23dae3c7a
3
+ metadata.gz: dc16859a1c7009f413c77229f58397aba4b0030da06342777e48a71175c63830
4
+ data.tar.gz: 595d6c7713563d97dea1cceb7d046c5f665d5e07fa2c6a133931959a4b1c0246
5
5
  SHA512:
6
- metadata.gz: d1fe6bb98a5c352f95ce509e7e56f7c398180aa3790d1105f2c7ffb98d8dcfca4e4ab1cda4331a1f70000a834a75671782ed8e1d6b7ba65b3d83b474f8a9f3c6
7
- data.tar.gz: 8e490092a17af3fd13d8c8c5d6ff6f42227e3e9bfa888818975308679a0724e6f6e8183d811a3a47dcbd369da0e0f92ccf4b2131b4e90d9b0d17bda9c01950fc
6
+ metadata.gz: cb12b697b14fc4abc05c05363e16ff77d07a98b11584af354007397aeaf26c6cebdf7086e8d84828f711ef1814cb7307febe269bbb32920e8240ad0b79e714a2
7
+ data.tar.gz: 9e21177108564c9e0bd394fdd2603e06b4d2f3a50c9936d00ca800da2ec8ce28c1ee295f28434da5e011f12332dea7eaaf9ccd4104bf05734adbbec27027479f
data/config/foreman.yml CHANGED
@@ -13,6 +13,11 @@
13
13
  :username: 'admin'
14
14
  #:password: 'example'
15
15
 
16
+ # Basic Auth External:
17
+ #:default_auth_type: 'Basic_Auth_External'
18
+ #:username: 'admin'
19
+ #:password: 'example'
20
+
16
21
  # Oauth using the Password Grant Flow:
17
22
  # This authentication method requires sessions to be enabled, uncomment the following
18
23
  # lines to use this authentication method.
data/doc/release_notes.md CHANGED
@@ -1,5 +1,14 @@
1
1
  Release notes
2
2
  =============
3
+ ### 3.5.1 (2023-02-28)
4
+ * Support basic auth for external sources, [#11317](http://projects.theforeman.org/issues/11317)
5
+
6
+ ### 3.5.0 (2022-10-31)
7
+ * Extract gce related info ([PR #606](https://github.com/theforeman/hammer-cli-foreman/pull/606)), [#35659](http://projects.theforeman.org/issues/35659)
8
+ * Change auth endpoint for negotiation, [#35473](http://projects.theforeman.org/issues/35473)
9
+ * Enhance vmware listing commands and switch to cluster_name param ([PR #604](https://github.com/theforeman/hammer-cli-foreman/pull/604)), [#35438](http://projects.theforeman.org/issues/35438)
10
+ * Bump to 3.5.0-develop
11
+
3
12
  ### 3.4.0 (2022-08-09)
4
13
  * Add options for table preferences cli ([PR #603](https://github.com/theforeman/hammer-cli-foreman/pull/603)), [#35219](http://projects.theforeman.org/issues/35219)
5
14
  * I18n - extracting new, pulling from tx, [#34629](http://projects.theforeman.org/issues/34629)
@@ -13,6 +13,8 @@ module HammerCLIForeman
13
13
  void_auth
14
14
  elsif auth_type == AUTH_TYPES[:basic_auth]
15
15
  basic_auth
16
+ elsif auth_type == AUTH_TYPES[:basic_auth_external]
17
+ basic_auth_external
16
18
  elsif auth_type == AUTH_TYPES[:negotiate]
17
19
  negotiate_auth
18
20
  elsif auth_type == AUTH_TYPES[:oauth_password_grant]
@@ -45,6 +47,24 @@ module HammerCLIForeman
45
47
  end
46
48
  end
47
49
 
50
+ def basic_auth_external
51
+ if HammerCLIForeman::Sessions.enabled?
52
+ authenticator = InteractiveBasicAuthExternal.new(
53
+ settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'],
54
+ settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'],
55
+ uri
56
+ )
57
+ SessionAuthenticatorWrapper.new(authenticator, uri, auth_type)
58
+ else
59
+ username = settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || settings.get(:foreman, :username)
60
+ password = settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD']
61
+ if password.nil? && (username == settings.get(:foreman, :username))
62
+ password = settings.get(:foreman, :password)
63
+ end
64
+ InteractiveBasicAuthExternal.new(username, password, uri)
65
+ end
66
+ end
67
+
48
68
  def negotiate_auth
49
69
  return unless HammerCLIForeman::Sessions.enabled?
50
70
 
@@ -0,0 +1,71 @@
1
+ module HammerCLIForeman
2
+ module Api
3
+ module BasicAuth
4
+ def authenticate(request, args)
5
+ if HammerCLI.interactive?
6
+ get_user
7
+ get_password
8
+ end
9
+ super
10
+ end
11
+
12
+ def error(ex)
13
+ return unless ex.is_a?(RestClient::Unauthorized)
14
+
15
+ clear
16
+ default_message = _('Invalid username or password.')
17
+ message = begin
18
+ response_msg = JSON.parse(ex.response.body)['error']
19
+ response_msg.is_a?(Hash) ? response_msg['message'] : response_msg
20
+ rescue
21
+ end
22
+ return UnauthorizedError.new(default_message) unless message
23
+
24
+ UnauthorizedError.new("#{message}\n#{default_message}")
25
+ end
26
+
27
+ def status
28
+ unless @user.nil? || @password.nil?
29
+ _("Using configured credentials for user '%s'.") % @user
30
+ else
31
+ _('Credentials are not configured.')
32
+ end
33
+ end
34
+
35
+ def user(ask = nil)
36
+ @user ||= ask && get_user
37
+ end
38
+
39
+ def password(ask = nil)
40
+ @password ||= ask && get_password
41
+ end
42
+
43
+ def set_credentials(user, password)
44
+ @user = user
45
+ @password = password
46
+ end
47
+
48
+ def clear
49
+ set_credentials(nil, nil)
50
+ end
51
+
52
+ private
53
+
54
+ def get_user
55
+ @user ||= ask_user(_('[Foreman] Username:%s') % ' ')
56
+ end
57
+
58
+ def get_password
59
+ @password ||= ask_user(_("[Foreman] Password for %{user}:%{wsp}") % { user: @user, wsp: ' ' }, true)
60
+ end
61
+
62
+ def ask_user(prompt, silent = false)
63
+ if silent
64
+ HammerCLI.interactive_output.ask(prompt) { |q| q.echo = false }
65
+ else
66
+ HammerCLI.interactive_output.ask(prompt)
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,6 +1,7 @@
1
1
  require 'hammer_cli_foreman/api/session_authenticator_wrapper'
2
2
  require 'hammer_cli_foreman/api/authenticator'
3
3
  require 'hammer_cli_foreman/api/interactive_basic_auth'
4
+ require 'hammer_cli_foreman/api/interactive_basic_auth_external'
4
5
  require 'hammer_cli_foreman/api/negotiate_auth'
5
6
  require 'hammer_cli_foreman/api/oauth/authentication_code_grant'
6
7
  require 'hammer_cli_foreman/api/oauth/password_grant'
@@ -11,6 +12,7 @@ module HammerCLIForeman
11
12
  CONNECTION_NAME = 'foreman'
12
13
  AUTH_TYPES = {
13
14
  basic_auth: 'Basic_Auth',
15
+ basic_auth_external: 'Basic_Auth_External',
14
16
  negotiate: 'Negotiate_Auth',
15
17
  oauth_authentication_code_grant: 'Oauth_Authentication_Code_Grant',
16
18
  oauth_password_grant: 'Oauth_Password_Grant'
@@ -44,8 +46,7 @@ module HammerCLIForeman
44
46
 
45
47
  protected
46
48
 
47
- def default_auth_type(settings)
48
- return AUTH_TYPES[:basic_auth] unless HammerCLIForeman::Sessions.enabled?
49
+ def default_auth_type(_settings)
49
50
  HammerCLI::Settings.get(:foreman, :default_auth_type) || AUTH_TYPES[:basic_auth]
50
51
  end
51
52
 
@@ -1,68 +1,9 @@
1
+ require 'hammer_cli_foreman/api/basic_auth'
2
+
1
3
  module HammerCLIForeman
2
4
  module Api
3
5
  class InteractiveBasicAuth < ApipieBindings::Authenticators::BasicAuth
4
- def authenticate(request, args)
5
- if HammerCLI.interactive?
6
- get_user
7
- get_password
8
- end
9
- super
10
- end
11
-
12
- def error(ex)
13
- if ex.is_a?(RestClient::Unauthorized)
14
- self.clear
15
- message = _('Invalid username or password.')
16
- begin
17
- message = JSON.parse(ex.response.body)['error']['message']
18
- rescue
19
- end
20
- UnauthorizedError.new(message)
21
- end
22
- end
23
-
24
- def status
25
- unless @user.nil? || @password.nil?
26
- _("Using configured credentials for user '%s'.") % @user
27
- else
28
- _("Credentials are not configured.")
29
- end
30
- end
31
-
32
- def user(ask=nil)
33
- @user ||= ask && get_user
34
- end
35
-
36
- def password(ask=nil)
37
- @password ||= ask && get_password
38
- end
39
-
40
- def set_credentials(user, password)
41
- @user = user
42
- @password = password
43
- end
44
-
45
- def clear
46
- set_credentials(nil, nil)
47
- end
48
-
49
- private
50
-
51
- def get_user
52
- @user ||= ask_user(_("[Foreman] Username:%s") % " ")
53
- end
54
-
55
- def get_password
56
- @password ||= ask_user(_("[Foreman] Password for %{user}:%{wsp}") % {:user => @user, :wsp => " "}, true)
57
- end
58
-
59
- def ask_user(prompt, silent=false)
60
- if silent
61
- HammerCLI.interactive_output.ask(prompt) { |q| q.echo = false }
62
- else
63
- HammerCLI.interactive_output.ask(prompt)
64
- end
65
- end
6
+ include HammerCLIForeman::Api::BasicAuth
66
7
  end
67
8
  end
68
9
  end
@@ -0,0 +1,17 @@
1
+ require 'hammer_cli_foreman/api/basic_auth'
2
+
3
+ module HammerCLIForeman
4
+ module Api
5
+ class InteractiveBasicAuthExternal < ApipieBindings::Authenticators::BasicAuthExternal
6
+ include HammerCLIForeman::Api::BasicAuth
7
+
8
+ def initialize(user, password, foreman_url)
9
+ super(user, password, "#{foreman_url}/api/users/extlogin", HammerCLI::SSLOptions.new.get_options(foreman_url))
10
+ end
11
+
12
+ def session_id
13
+ auth_cookie&.delete_prefix('_session_id=')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -2,7 +2,7 @@ module HammerCLIForeman
2
2
  module Api
3
3
  class NegotiateAuth < ApipieBindings::Authenticators::Negotiate
4
4
  def initialize(foreman_url, **options)
5
- super("#{foreman_url}/users/extlogin", HammerCLI::SSLOptions.new.get_options(foreman_url).merge(options))
5
+ super("#{foreman_url}/api/users/extlogin", HammerCLI::SSLOptions.new.get_options(foreman_url).merge(options))
6
6
  end
7
7
 
8
8
  def user
@@ -80,7 +80,7 @@ module HammerCLIForeman
80
80
 
81
81
  def user(ask=nil)
82
82
  return unless @authenticator.respond_to?(:user)
83
- if @auth_type == AUTH_TYPES[:basic_auth]
83
+ if [AUTH_TYPES[:basic_auth], AUTH_TYPES[:basic_auth_external]].include?(@auth_type)
84
84
  @authenticator.user(ask)
85
85
  elsif @auth_type == AUTH_TYPES[:oauth_authentication_code_grant] ||
86
86
  @auth_type = AUTH_TYPES[:oauth_password_grant]
@@ -93,7 +93,7 @@ module HammerCLIForeman
93
93
  end
94
94
 
95
95
  def set_auth_params(*args)
96
- if @auth_type == AUTH_TYPES[:basic_auth]
96
+ if [AUTH_TYPES[:basic_auth], AUTH_TYPES[:basic_auth_external]].include?(@auth_type)
97
97
  @authenticator.set_credentials(*args)
98
98
  elsif @auth_type == AUTH_TYPES[:oauth_authentication_code_grant] ||
99
99
  @auth_type == AUTH_TYPES[:oauth_password_grant]
@@ -28,6 +28,27 @@ module HammerCLIForeman
28
28
  end
29
29
  end
30
30
 
31
+ class BasicExternal < HammerCLI::AbstractCommand
32
+ extend HammerCLIForeman::Authenticate::Login
33
+
34
+ command_name 'basic-external'
35
+ desc _('Authenticate against external source (IPA/PAM) with credentials')
36
+
37
+ option ['-u', '--username'], 'USERNAME', _('Username to access the remote system')
38
+ option ['-p', '--password'], 'PASSWORD', _('Password to access the remote system')
39
+
40
+ def execute
41
+ Basic.execute_with_params(
42
+ AUTH_TYPES[:basic_auth_external],
43
+ option_username || HammerCLI::Settings.get('_params', 'username'),
44
+ option_password || HammerCLI::Settings.get('_params', 'password')
45
+ )
46
+ logged_user = HammerCLIForeman.foreman_api_connection.authenticator.user
47
+ print_message(_("Successfully logged in as '%s'.") % logged_user)
48
+ HammerCLI::EX_OK
49
+ end
50
+ end
51
+
31
52
  class Negotiate < HammerCLI::AbstractCommand
32
53
  extend HammerCLIForeman::Authenticate::Login
33
54
 
@@ -0,0 +1,14 @@
1
+ module HammerCLIForeman
2
+ module CommandExtensions
3
+ class ComputeResourceSubcommand < HammerCLI::CommandExtensions
4
+ option '--cluster-id', 'ID', _('Cluster ID'),
5
+ deprecated: _('Use --cluster-name instead')
6
+ option '--cluster-name', 'NAME', _('Cluster name or path to search by'),
7
+ attribute_name: :option_cluster_id
8
+
9
+ request_params do |params|
10
+ params['cluster_id'] = params['cluster_id'].gsub('/', '%2F') if params['cluster_id']
11
+ end
12
+ end
13
+ end
14
+ end
@@ -7,3 +7,4 @@ require 'hammer_cli_foreman/command_extensions/status'
7
7
  require 'hammer_cli_foreman/command_extensions/user'
8
8
  require 'hammer_cli_foreman/command_extensions/subnet'
9
9
  require 'hammer_cli_foreman/command_extensions/domain'
10
+ require 'hammer_cli_foreman/command_extensions/compute_resource_subcommand'
@@ -10,7 +10,6 @@ module HammerCLIForeman
10
10
 
11
11
  require 'hammer_cli_foreman/compute_resource/base'
12
12
  require 'hammer_cli_foreman/compute_resource/ec2.rb'
13
- require 'hammer_cli_foreman/compute_resource/gce.rb'
14
13
  require 'hammer_cli_foreman/compute_resource/libvirt.rb'
15
14
  require 'hammer_cli_foreman/compute_resource/openstack.rb'
16
15
  require 'hammer_cli_foreman/compute_resource/ovirt.rb'
@@ -64,7 +64,9 @@ module HammerCLIForeman
64
64
  def provider_specific_fields
65
65
  super + [
66
66
  Fields::Field.new(:label => _('Datacenter'), :path => [:datacenter]),
67
- Fields::Field.new(:label => _('Server'), :path => [:server])
67
+ Fields::Field.new(:label => _('Server'), :path => [:server]),
68
+ Fields::Boolean.new(:label => _('Console password set'), :path => [:set_console_password]),
69
+ Fields::Boolean.new(:label => _('Caching enabled'), :path => [:caching_enabled])
68
70
  ]
69
71
  end
70
72
 
@@ -121,6 +121,9 @@ module HammerCLIForeman
121
121
  output do
122
122
  field :id, _('Id')
123
123
  field :name, _('Name')
124
+ field :datacenter, _('Datacenter')
125
+ field :num_host, _('Hosts')
126
+ field :full_path, _('Cluster path')
124
127
  end
125
128
 
126
129
  build_options
@@ -133,9 +136,13 @@ module HammerCLIForeman
133
136
  output do
134
137
  field :id, _('Id'), Fields::Field, :max_width => 200, :hide_blank => true
135
138
  field :name, _('Name')
139
+ field :datacenter, _('Datacenter')
140
+ field :virtualswitch, _('Virtual switch')
141
+ field :vlanid, _('VLAN ID')
136
142
  end
137
143
 
138
- build_options
144
+ build_options without: :cluster_id
145
+ extend_with(HammerCLIForeman::CommandExtensions::ComputeResourceSubcommand.new(only: %i[option request_params]))
139
146
  end
140
147
 
141
148
  class AvailableVnicProfilesCommand < HammerCLIForeman::ListCommand
@@ -158,6 +165,7 @@ module HammerCLIForeman
158
165
  output do
159
166
  field :uuid, _('Uuid')
160
167
  field :name, _('Name')
168
+ field :path, _('Path'), Fields::Field, :hide_blank => true
161
169
  end
162
170
 
163
171
  build_options
@@ -182,6 +190,10 @@ module HammerCLIForeman
182
190
  output do
183
191
  field :id, _('Id')
184
192
  field :name, _('Name')
193
+ field :parent, _('Parent')
194
+ field :datacenter, _('Datacenter')
195
+ field :path, _('Path'), Fields::Field, :max_width => 50
196
+ field :type, _('Type')
185
197
  end
186
198
 
187
199
  build_options
@@ -206,9 +218,12 @@ module HammerCLIForeman
206
218
  output do
207
219
  field :id, _('Id')
208
220
  field :name, _('Name')
221
+ field :cluster, _('Cluster')
222
+ field :datacenter, _('Datacenter')
209
223
  end
210
224
 
211
- build_options
225
+ build_options without: :cluster_id
226
+ extend_with(HammerCLIForeman::CommandExtensions::ComputeResourceSubcommand.new(only: %i[option request_params]))
212
227
  end
213
228
 
214
229
  class AvailableStorageDomainsCommand < HammerCLIForeman::ListCommand
@@ -220,7 +235,8 @@ module HammerCLIForeman
220
235
  field :name, _('Name')
221
236
  end
222
237
 
223
- build_options
238
+ build_options without: :cluster_id
239
+ extend_with(HammerCLIForeman::CommandExtensions::ComputeResourceSubcommand.new(only: %i[option request_params]))
224
240
  end
225
241
 
226
242
  class AvailableStoragePodsCommand < HammerCLIForeman::ListCommand
@@ -230,9 +246,11 @@ module HammerCLIForeman
230
246
  output do
231
247
  field :id, _('Id')
232
248
  field :name, _('Name')
249
+ field :datacenter, _('Datacenter')
233
250
  end
234
251
 
235
- build_options
252
+ build_options without: :cluster_id
253
+ extend_with(HammerCLIForeman::CommandExtensions::ComputeResourceSubcommand.new(only: %i[option request_params]))
236
254
  end
237
255
 
238
256
  class AvailableSecurityGroupsCommand < HammerCLIForeman::ListCommand
@@ -252,8 +270,10 @@ module HammerCLIForeman
252
270
  command_name 'virtual-machines'
253
271
 
254
272
  output do
255
- field :id, _("Id")
256
- field :name, _("Name")
273
+ field :id, _('Id')
274
+ field :name, _('Name')
275
+ field :path, _('Path'), Fields::Field, :max_width => 50
276
+ field :state, _('State')
257
277
  end
258
278
 
259
279
  build_options
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new "3.4.0"
3
+ @version ||= Gem::Version.new "3.5.1"
4
4
  end
5
5
  end
@@ -9,7 +9,6 @@ module HammerCLIForeman
9
9
  class PowerVmCommand < HammerCLIForeman::Command
10
10
  action :power_vm
11
11
  command_name 'power'
12
- option "--vm-id", "VM-ID", _("Virtual machine id, for gce use virtual machine name")
13
12
 
14
13
  success_message _("Virtual machine is powering.")
15
14
  failure_message _("Could not power the virtual machine")
@@ -19,7 +18,6 @@ module HammerCLIForeman
19
18
 
20
19
  class InfoCommand < HammerCLIForeman::InfoCommand
21
20
  action :show_vm
22
- option "--vm-id", "VM-ID", _("Virtual machine id, for gce use virtual machine name")
23
21
 
24
22
  output do
25
23
  field :id, _("Id")
@@ -39,8 +37,6 @@ module HammerCLIForeman
39
37
 
40
38
  class DeleteCommand < HammerCLIForeman::DeleteCommand
41
39
  action :destroy_vm
42
- option "--vm-id", "VM-ID", _("Virtual machine id, for gce use virtual machine name")
43
-
44
40
 
45
41
  success_message _("Virtual machine deleted.")
46
42
  failure_message _("Could not delete the virtual machine")
@@ -355,10 +355,31 @@ end
355
355
  ]
356
356
  )
357
357
  expected_result = success_result(output)
358
+ expected_result.expected_err = "Warning: Option --cluster-id is deprecated. Use --cluster-name instead\n"
358
359
 
359
360
  result = run_cmd(cmd + params)
360
361
  assert_cmd(expected_result, result)
361
362
  end
363
+
364
+ it 'lists available resource_pools for a compute resource with updated cluster_name param' do
365
+ api_expects(:compute_resources, :available_resource_pools, 'resource-pools').with_params(
366
+ 'id' => '1', 'cluster_id' => 'test%2Ftest1'
367
+ ).returns(index_response(resource_pools))
368
+
369
+ cluster_param = base_params + ['--cluster-name=test/test1']
370
+
371
+ output = IndexMatcher.new(
372
+ [
373
+ %w[ID NAME],
374
+ %w[1 resource_pool1],
375
+ %w[2 resource_pool2]
376
+ ]
377
+ )
378
+ expected_result = success_result(output)
379
+
380
+ result = run_cmd(cmd + cluster_param)
381
+ assert_cmd(expected_result, result)
382
+ end
362
383
  end
363
384
 
364
385
  describe 'storage_domains' do
@@ -105,8 +105,9 @@ describe HammerCLIForeman::Api::InteractiveBasicAuth do
105
105
  response.stubs(:body).returns('{"error": {"message": "Unable to authenticate user admin"}}')
106
106
  ex.response = response
107
107
  new_ex = auth.error(ex)
108
+ expected = "Unable to authenticate user admin\nInvalid username or password."
108
109
 
109
- assert_equal 'Unable to authenticate user admin', new_ex.message
110
+ assert_equal expected, new_ex.message
110
111
  end
111
112
  end
112
113
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Strachota
8
8
  - Martin Bačovský
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-09 00:00:00.000000000 Z
12
+ date: 2023-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hammer_cli
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.3.0
20
+ version: 3.5.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.3.0
27
+ version: 3.5.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: apipie-bindings
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -75,19 +75,19 @@ dependencies:
75
75
  version: 2.2.1
76
76
  description: 'Foreman commands for Hammer CLI
77
77
 
78
- '
78
+ '
79
79
  email: tstracho@redhat.com
80
80
  executables: []
81
81
  extensions: []
82
82
  extra_rdoc_files:
83
- - doc/name_id_resolution.md
84
- - doc/option_builder.md
85
- - doc/using_hammer_cli_foreman_command.md
83
+ - doc/configuration.md
86
84
  - doc/developer_docs.md
87
85
  - doc/host_create.md
86
+ - doc/name_id_resolution.md
87
+ - doc/option_builder.md
88
88
  - doc/plugin.md
89
89
  - doc/testing.md
90
- - doc/configuration.md
90
+ - doc/using_hammer_cli_foreman_command.md
91
91
  - doc/release_notes.md
92
92
  - README.md
93
93
  files:
@@ -106,8 +106,10 @@ files:
106
106
  - lib/hammer_cli_foreman.rb
107
107
  - lib/hammer_cli_foreman/api.rb
108
108
  - lib/hammer_cli_foreman/api/authenticator.rb
109
+ - lib/hammer_cli_foreman/api/basic_auth.rb
109
110
  - lib/hammer_cli_foreman/api/connection.rb
110
111
  - lib/hammer_cli_foreman/api/interactive_basic_auth.rb
112
+ - lib/hammer_cli_foreman/api/interactive_basic_auth_external.rb
111
113
  - lib/hammer_cli_foreman/api/negotiate_auth.rb
112
114
  - lib/hammer_cli_foreman/api/oauth/authentication_code_grant.rb
113
115
  - lib/hammer_cli_foreman/api/oauth/password_grant.rb
@@ -124,6 +126,7 @@ files:
124
126
  - lib/hammer_cli_foreman/bookmark.rb
125
127
  - lib/hammer_cli_foreman/combination.rb
126
128
  - lib/hammer_cli_foreman/command_extensions.rb
129
+ - lib/hammer_cli_foreman/command_extensions/compute_resource_subcommand.rb
127
130
  - lib/hammer_cli_foreman/command_extensions/domain.rb
128
131
  - lib/hammer_cli_foreman/command_extensions/fields.rb
129
132
  - lib/hammer_cli_foreman/command_extensions/hosts.rb
@@ -143,7 +146,6 @@ files:
143
146
  - lib/hammer_cli_foreman/compute_resource.rb
144
147
  - lib/hammer_cli_foreman/compute_resource/base.rb
145
148
  - lib/hammer_cli_foreman/compute_resource/ec2.rb
146
- - lib/hammer_cli_foreman/compute_resource/gce.rb
147
149
  - lib/hammer_cli_foreman/compute_resource/libvirt.rb
148
150
  - lib/hammer_cli_foreman/compute_resource/openstack.rb
149
151
  - lib/hammer_cli_foreman/compute_resource/ovirt.rb
@@ -350,7 +352,7 @@ homepage: https://github.com/theforeman/hammer-cli-foreman
350
352
  licenses:
351
353
  - GPL-3.0+
352
354
  metadata: {}
353
- post_install_message:
355
+ post_install_message:
354
356
  rdoc_options: []
355
357
  require_paths:
356
358
  - lib
@@ -365,8 +367,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
365
367
  - !ruby/object:Gem::Version
366
368
  version: '0'
367
369
  requirements: []
368
- rubygems_version: 3.1.2
369
- signing_key:
370
+ rubygems_version: 3.1.6
371
+ signing_key:
370
372
  specification_version: 4
371
373
  summary: Foreman commands for Hammer
372
374
  test_files:
@@ -384,106 +386,106 @@ test_files:
384
386
  - test/data/1.24/foreman_api.json
385
387
  - test/data/2.0/foreman_api.json
386
388
  - test/data/2.1/foreman_api.json
387
- - test/data/README.md
388
389
  - test/data/2.4/foreman_api.json
389
390
  - test/data/2.5/foreman_api.json
390
391
  - test/data/3.1/foreman_api.json
391
392
  - test/data/3.4/foreman_api.json
393
+ - test/data/README.md
394
+ - test/functional/architecture_test.rb
395
+ - test/functional/associating_commands_test.rb
396
+ - test/functional/audit_test.rb
392
397
  - test/functional/auth_source_test.rb
398
+ - test/functional/bookmark_test.rb
393
399
  - test/functional/commands/list_test.rb
394
- - test/functional/hostgroup/create_test.rb
395
- - test/functional/hostgroup/update_test.rb
396
- - test/functional/architecture_test.rb
397
400
  - test/functional/compute_attribute_test.rb
398
- - test/functional/ping_test.rb
399
- - test/functional/user_test.rb
400
- - test/functional/ssh_keys_test.rb
401
- - test/functional/subnet/update_test.rb
402
- - test/functional/subnet/create_test.rb
403
- - test/functional/test_helper.rb
404
- - test/functional/location_test.rb
405
- - test/functional/media_test.rb
406
- - test/functional/partition_table_test.rb
407
- - test/functional/personal_access_token_test.rb
408
- - test/functional/report_template_test.rb
409
- - test/functional/settings_test.rb
410
- - test/functional/status_test.rb
411
- - test/functional/user_mail_notification_test.rb
412
401
  - test/functional/compute_profile_test.rb
413
- - test/functional/realm_test.rb
414
- - test/functional/usergroup_test.rb
415
- - test/functional/organization_test.rb
416
- - test/functional/virtual_machine_test.rb
417
402
  - test/functional/compute_resource_test.rb
418
403
  - test/functional/domain/create_test.rb
419
404
  - test/functional/domain/update_test.rb
420
405
  - test/functional/filter_test.rb
421
406
  - test/functional/host_test.rb
407
+ - test/functional/hostgroup/create_test.rb
408
+ - test/functional/hostgroup/update_test.rb
422
409
  - test/functional/http_proxy_test.rb
410
+ - test/functional/location_test.rb
423
411
  - test/functional/mail_notification_test.rb
424
- - test/functional/operating_system_test.rb
425
- - test/functional/template_test.rb
426
- - test/functional/associating_commands_test.rb
427
- - test/functional/audit_test.rb
428
- - test/functional/role_test.rb
429
- - test/functional/bookmark_test.rb
412
+ - test/functional/media_test.rb
430
413
  - test/functional/model_test.rb
414
+ - test/functional/operating_system_test.rb
415
+ - test/functional/organization_test.rb
416
+ - test/functional/partition_table_test.rb
417
+ - test/functional/personal_access_token_test.rb
418
+ - test/functional/ping_test.rb
419
+ - test/functional/realm_test.rb
431
420
  - test/functional/registration_test.rb
421
+ - test/functional/report_template_test.rb
422
+ - test/functional/role_test.rb
423
+ - test/functional/settings_test.rb
424
+ - test/functional/ssh_keys_test.rb
425
+ - test/functional/status_test.rb
426
+ - test/functional/subnet/create_test.rb
427
+ - test/functional/subnet/update_test.rb
432
428
  - test/functional/table_preference_test.rb
433
- - test/unit/api/void_auth_test.rb
434
- - test/unit/api/interactive_basic_auth_test.rb
429
+ - test/functional/template_test.rb
430
+ - test/functional/test_helper.rb
431
+ - test/functional/user_mail_notification_test.rb
432
+ - test/functional/user_test.rb
433
+ - test/functional/usergroup_test.rb
434
+ - test/functional/virtual_machine_test.rb
435
+ - test/test_helper.rb
435
436
  - test/unit/api/oauth/oauth_authentication_code_grant_test.rb
436
437
  - test/unit/api/oauth/oauth_password_grant_test.rb
437
438
  - test/unit/api/session_authenticator_wrapper_test.rb
438
- - test/unit/test_output_adapter.rb
439
- - test/unit/host_test.rb
439
+ - test/unit/api/void_auth_test.rb
440
+ - test/unit/api/interactive_basic_auth_test.rb
441
+ - test/unit/api_test.rb
442
+ - test/unit/apipie_resource_mock.rb
443
+ - test/unit/architecture_test.rb
444
+ - test/unit/audit_test.rb
445
+ - test/unit/auth_source_external.rb
440
446
  - test/unit/auth_source_ldap_test.rb
441
- - test/unit/config_report_test.rb
447
+ - test/unit/bookmark_test.rb
448
+ - test/unit/commands_test.rb
449
+ - test/unit/common_parameter_test.rb
450
+ - test/unit/compute_profile_test.rb
442
451
  - test/unit/compute_resource_test.rb
452
+ - test/unit/config_report_test.rb
443
453
  - test/unit/data/test_api.json
444
454
  - test/unit/defaults_test.rb
445
- - test/unit/id_resolver_test.rb
455
+ - test/unit/dependency_resolver_test.rb
456
+ - test/unit/domain_test.rb
457
+ - test/unit/exception_handler_test.rb
446
458
  - test/unit/external_usergroup_test.rb
447
459
  - test/unit/fact_test.rb
460
+ - test/unit/filter_test.rb
461
+ - test/unit/helpers/command.rb
448
462
  - test/unit/helpers/fake_searchables.rb
449
463
  - test/unit/helpers/resource_disabled.rb
450
- - test/unit/helpers/command.rb
464
+ - test/unit/host_test.rb
465
+ - test/unit/hostgroup_test.rb
466
+ - test/unit/id_resolver_test.rb
451
467
  - test/unit/image_test.rb
452
468
  - test/unit/location_test.rb
453
- - test/unit/messages_test.rb
454
469
  - test/unit/mail_notification_test.rb
470
+ - test/unit/media_test.rb
471
+ - test/unit/messages_test.rb
472
+ - test/unit/model_test.rb
473
+ - test/unit/operating_system_test.rb
474
+ - test/unit/option_builders_test.rb
455
475
  - test/unit/option_sources/id_params_test.rb
456
476
  - test/unit/option_sources/ids_params_test.rb
457
477
  - test/unit/organization_test.rb
458
478
  - test/unit/output/formatters_test.rb
459
- - test/unit/common_parameter_test.rb
479
+ - test/unit/param_filters_test.rb
480
+ - test/unit/partition_table_test.rb
460
481
  - test/unit/realm_test.rb
482
+ - test/unit/role_test.rb
483
+ - test/unit/sessions_test.rb
461
484
  - test/unit/settings_test.rb
462
- - test/unit/usergroup_test.rb
485
+ - test/unit/smart_proxy_test.rb
463
486
  - test/unit/subnet_test.rb
487
+ - test/unit/template_test.rb
464
488
  - test/unit/test_helper.rb
489
+ - test/unit/test_output_adapter.rb
465
490
  - test/unit/user_test.rb
466
- - test/unit/param_filters_test.rb
467
- - test/unit/role_test.rb
468
- - test/unit/model_test.rb
469
- - test/unit/operating_system_test.rb
470
- - test/unit/option_builders_test.rb
471
- - test/unit/architecture_test.rb
472
- - test/unit/commands_test.rb
473
- - test/unit/audit_test.rb
474
- - test/unit/auth_source_external.rb
475
- - test/unit/dependency_resolver_test.rb
476
- - test/unit/exception_handler_test.rb
477
- - test/unit/filter_test.rb
478
- - test/unit/media_test.rb
479
- - test/unit/sessions_test.rb
480
- - test/unit/bookmark_test.rb
481
- - test/unit/hostgroup_test.rb
482
- - test/unit/api_test.rb
483
- - test/unit/apipie_resource_mock.rb
484
- - test/unit/compute_profile_test.rb
485
- - test/unit/partition_table_test.rb
486
- - test/unit/template_test.rb
487
- - test/unit/smart_proxy_test.rb
488
- - test/unit/domain_test.rb
489
- - test/test_helper.rb
491
+ - test/unit/usergroup_test.rb
@@ -1,47 +0,0 @@
1
- module HammerCLIForeman
2
- module ComputeResources
3
- class GCE < Base
4
- def name
5
- 'GCE'
6
- end
7
-
8
- def compute_attributes
9
- %w[machine_type network associate_external_ip]
10
- end
11
-
12
- def interfaces_attrs_name
13
- 'network_interfaces_nics_attributes'
14
- end
15
-
16
- def volume_attributes
17
- [
18
- ['size_gb', _('Volume size in GB, integer value')]
19
- ]
20
- end
21
-
22
- def provider_specific_fields
23
- [
24
- Fields::Field.new(:label => _('Project'), :path => [:project]),
25
- Fields::Field.new(:label => _('Email'), :path => [:email]),
26
- Fields::Field.new(:label => _('Key Path'), :path => [:key_path]),
27
- Fields::Field.new(:label => _('Zone'), :path => [:zone])
28
- ]
29
- end
30
-
31
- def provider_vm_specific_fields
32
- [
33
- Fields::Field.new(:label => _('Machine Type'), :path => [:machine_type]),
34
- Fields::Field.new(:label => _('Status'), :path => [:status]),
35
- Fields::Field.new(:label => _('Description'), :path => [:description]),
36
- Fields::Field.new(:label => _('Zone'), :path => [:zone])
37
- ]
38
- end
39
-
40
- def mandatory_resource_options
41
- super + %I{project key_path zone}
42
- end
43
- end
44
-
45
- HammerCLIForeman.register_compute_resource('gce', GCE.new)
46
- end
47
- end