hammer_cli_foreman 3.0.0 → 3.3.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/config/foreman.yml +4 -0
  3. data/doc/configuration.md +30 -0
  4. data/doc/release_notes.md +31 -0
  5. data/lib/hammer_cli_foreman/api/authenticator.rb +9 -0
  6. data/lib/hammer_cli_foreman/api/connection.rb +2 -0
  7. data/lib/hammer_cli_foreman/api/negotiate_auth.rb +36 -0
  8. data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +6 -2
  9. data/lib/hammer_cli_foreman/api.rb +2 -1
  10. data/lib/hammer_cli_foreman/auth.rb +13 -0
  11. data/lib/hammer_cli_foreman/command_extensions/domain.rb +20 -0
  12. data/lib/hammer_cli_foreman/command_extensions/subnet.rb +25 -10
  13. data/lib/hammer_cli_foreman/command_extensions/user.rb +9 -5
  14. data/lib/hammer_cli_foreman/command_extensions.rb +1 -0
  15. data/lib/hammer_cli_foreman/commands.rb +6 -3
  16. data/lib/hammer_cli_foreman/compute_attribute.rb +1 -1
  17. data/lib/hammer_cli_foreman/compute_resource/libvirt.rb +4 -2
  18. data/lib/hammer_cli_foreman/compute_resource/vmware.rb +4 -2
  19. data/lib/hammer_cli_foreman/compute_resource.rb +1 -0
  20. data/lib/hammer_cli_foreman/domain.rb +5 -28
  21. data/lib/hammer_cli_foreman/exception_handler.rb +26 -0
  22. data/lib/hammer_cli_foreman/filter.rb +3 -3
  23. data/lib/hammer_cli_foreman/host.rb +1 -0
  24. data/lib/hammer_cli_foreman/hostgroup.rb +13 -6
  25. data/lib/hammer_cli_foreman/hosts/common_update_options.rb +7 -7
  26. data/lib/hammer_cli_foreman/id_resolver.rb +7 -7
  27. data/lib/hammer_cli_foreman/option_builders.rb +65 -53
  28. data/lib/hammer_cli_foreman/option_sources/id_params.rb +21 -8
  29. data/lib/hammer_cli_foreman/option_sources/ids_params.rb +22 -9
  30. data/lib/hammer_cli_foreman/partition_table.rb +30 -0
  31. data/lib/hammer_cli_foreman/report_template.rb +15 -0
  32. data/lib/hammer_cli_foreman/smart_proxy.rb +18 -5
  33. data/lib/hammer_cli_foreman/template.rb +33 -15
  34. data/lib/hammer_cli_foreman/user.rb +5 -4
  35. data/lib/hammer_cli_foreman/version.rb +1 -1
  36. data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  37. data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  38. data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  39. data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  40. data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  41. data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  42. data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  43. data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  44. data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  45. data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  46. data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  47. data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  48. data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
  49. data/test/data/3.1/foreman_api.json +1 -0
  50. data/test/functional/compute_attribute_test.rb +20 -20
  51. data/test/functional/domain/create_test.rb +91 -0
  52. data/test/functional/domain/update_test.rb +90 -0
  53. data/test/functional/host_test.rb +34 -0
  54. data/test/functional/hostgroup/create_test.rb +11 -0
  55. data/test/functional/hostgroup/update_test.rb +11 -0
  56. data/test/functional/partition_table_test.rb +63 -0
  57. data/test/functional/personal_access_token_test.rb +4 -4
  58. data/test/functional/report_template_test.rb +24 -0
  59. data/test/functional/template_test.rb +134 -14
  60. data/test/functional/user_mail_notification_test.rb +3 -3
  61. data/test/test_helper.rb +1 -1
  62. data/test/unit/commands_test.rb +1 -2
  63. data/test/unit/option_builders_test.rb +88 -83
  64. data/test/unit/option_sources/id_params_test.rb +0 -9
  65. data/test/unit/option_sources/ids_params_test.rb +0 -9
  66. metadata +54 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8287acd52ceb1bea84f8d518c3793d521d084ae771622ea7fc4dcccccd794a1b
4
- data.tar.gz: b557d8fbbc7a451cd09084211c6e8a46a46ef3c198744cbb9c8dc7e861090e93
3
+ metadata.gz: 70a45953e142e7d3a67ee81e99bb5cc6fccaf179d2a61e44922f3b809196a178
4
+ data.tar.gz: 6c958ff14e311eef47ac379a41ceb45cbabe7f7ed34b3d28c64c40fe963f2ca5
5
5
  SHA512:
6
- metadata.gz: 283fd640422b5749f6dc9094907bb1c68e72cef15696704f4493f548dd23ca13bd1066fca15616996d4ff6ba48648d904f5633e3cc3305c30464fa9e22c8bf44
7
- data.tar.gz: 94b81f8171c914bdd1435ad00a17c1b1606402bac1ab9b21ca3014056ed285029bc79fe2b0646630d964d3b4715bd94b42a67a35f5399cace731ec44c87e4ee8
6
+ metadata.gz: 6d436e24f99cc80f70aff4ad2c0436a92d63e8b60b5f1aa1ebb787e0fe202404c686fe78397ae16ae9bb3f2261834f8a02db39417a2511fd562c316344933d7a
7
+ data.tar.gz: 828772047e91923c3b6ac365fa942d381483988ed4c7303a1021d560e73d4f591d1656613ef45916cdc565fa3b7989a6b0f577c655c5624f5a5f8e9bdc82f24b
data/config/foreman.yml CHANGED
@@ -29,6 +29,10 @@
29
29
  #:oidc_client_id: example-client-id
30
30
  #:oidc_redirect_uri: urn:ietf:wg:oauth:2.0:oob
31
31
 
32
+ # Negotiate (Kerberos) Auth:
33
+ # User needs to run kinit before using hammer (or initiate kerberos keyring in another way).
34
+ #:default_auth_type: 'Negotiate_Auth'
35
+
32
36
  # Enable using sessions
33
37
  # When sessions are enabled, hammer ignores credentials stored in the config file
34
38
  # and asks for them interactively at the begining of each session.
data/doc/configuration.md CHANGED
@@ -49,3 +49,33 @@ Please note that when you turn sessions on, the credentials stored in your confi
49
49
 
50
50
  The default session timeout is 1 hour. This can be changed in the Foreman: `Settings > Authentication > Idle timeout`
51
51
  When the session expires hammer will prompt for username and password again.
52
+
53
+ ### Negotiate (Kerberos) auth
54
+
55
+ This implements Kerberos authentication, usually implemented in FreeIPA or Microsoft Active Directory.
56
+ For this to work, the host that we are trying to use hammer on, needs to have realm already configured on this host.
57
+ This can be achieved through `realm join`, please refer to that command for more info.
58
+
59
+ **Sessions needs to be enabled**
60
+
61
+ `~/.hammer/cli.modules.d/foreman.yml`
62
+ ```yaml
63
+ :foreman:
64
+ :default_auth_type: 'Negotiate_Auth'
65
+ :use_sessions: true
66
+ ```
67
+
68
+ ```bash
69
+ # To initiate the kerberos keyring (this might be already done on login)
70
+ $ kinit <kerb_user>
71
+ # Enter your password
72
+ $ klist
73
+ Ticket cache: KEYRING:persistent:1000:1000
74
+ Default principal: kerb_user@REALM.EXAMPLE.COM
75
+
76
+ # use hammer as usuall, it will negotiate your auth on the first request
77
+ hammer ...
78
+
79
+ # or if you do not have negotiate as default auth, initiate the auth manually
80
+ hammer auth login negotiate
81
+ ```
data/doc/release_notes.md CHANGED
@@ -1,5 +1,36 @@
1
1
  Release notes
2
2
  =============
3
+ ### 3.3.0 (2022-05-10)
4
+ * Add kerberos negotiate auth support ([PR #555](https://github.com/theforeman/hammer-cli-foreman/pull/555)), [#8923](http://projects.theforeman.org/issues/8923)
5
+ * Pin mocha gem to < 1.14.0
6
+ * Force api docs checksum check, [#28283](http://projects.theforeman.org/issues/28283)
7
+ * Add template report-remplate and partition-table export command ([PR #595](https://github.com/theforeman/hammer-cli-foreman/pull/595)), [#34503](http://projects.theforeman.org/issues/34503)
8
+ * Add template import and partition-table import commands ([PR #596](https://github.com/theforeman/hammer-cli-foreman/pull/596)), [#22692](http://projects.theforeman.org/issues/22692)
9
+ * Add resource information to download command ([PR #598](https://github.com/theforeman/hammer-cli-foreman/pull/598)), [#34621](http://projects.theforeman.org/issues/34621)
10
+ * Add command to import ipv4 subnet from smart proxy ([PR #593](https://github.com/theforeman/hammer-cli-foreman/pull/593)), [#33255](http://projects.theforeman.org/issues/33255)
11
+ * Bump to 3.3.0-develop
12
+
13
+ ### 3.2.0 (2022-02-10)
14
+ * Domain update doesn't reset dns implicitly ([PR #591](https://github.com/theforeman/hammer-cli-foreman/pull/591)), [#34177](http://projects.theforeman.org/issues/34177)
15
+ * Send filter's tax params only when required ([PR #592](https://github.com/theforeman/hammer-cli-foreman/pull/592)), [#34199](http://projects.theforeman.org/issues/34199)
16
+ * Add boot_order to compute-attribute ([PR #588](https://github.com/theforeman/hammer-cli-foreman/pull/588)), [#33910](http://projects.theforeman.org/issues/33910)
17
+ * Add mail_enabled to user list/info command ([PR #589](https://github.com/theforeman/hammer-cli-foreman/pull/589)), [#34180](http://projects.theforeman.org/issues/34180)
18
+ * Add token to host info command ([PR #586](https://github.com/theforeman/hammer-cli-foreman/pull/586)), [#34120](http://projects.theforeman.org/issues/34120)
19
+ * Bump to 3.2.0-develop
20
+
21
+ ### 3.1.0 (2021-11-10)
22
+ * Update test data for 3.1
23
+ * Make sure provided options override defaults, [#33711](http://projects.theforeman.org/issues/33711)
24
+ * Make template create/update commands use resolver, [#33721](http://projects.theforeman.org/issues/33721)
25
+ * Revert fix rake version
26
+ * Fix rake version
27
+ * Show status once for proxy info ([PR #581](https://github.com/theforeman/hammer-cli-foreman/pull/581)), [#19510](http://projects.theforeman.org/issues/19510)
28
+ * Add proxy status and version to info command ([PR #572](https://github.com/theforeman/hammer-cli-foreman/pull/572))
29
+ * Associate a vm via hammer to a compute resource, [#33047](http://projects.theforeman.org/issues/33047)
30
+ * Fix option builders and tests, [#33226](http://projects.theforeman.org/issues/33226)
31
+ * Bump to 3.1.0-develop
32
+ * Add parent title option for hostgroup, [#32878](http://projects.theforeman.org/issues/32878)
33
+
3
34
  ### 3.0.0 (2021-08-04)
4
35
  * Puppet extraction ([PR #571](https://github.com/theforeman/hammer-cli-foreman/pull/571)), [#33174](http://projects.theforeman.org/issues/33174)
5
36
  * Update rel-eng notebook ([PR #573](https://github.com/theforeman/hammer-cli-foreman/pull/573))
@@ -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[:negotiate]
17
+ negotiate_auth
16
18
  elsif auth_type == AUTH_TYPES[:oauth_password_grant]
17
19
  oauth_password_grant
18
20
  elsif auth_type == AUTH_TYPES[:oauth_authentication_code_grant]
@@ -43,6 +45,13 @@ module HammerCLIForeman
43
45
  end
44
46
  end
45
47
 
48
+ def negotiate_auth
49
+ return unless HammerCLIForeman::Sessions.enabled?
50
+
51
+ authenticator = NegotiateAuth.new(uri)
52
+ SessionAuthenticatorWrapper.new(authenticator, uri, auth_type)
53
+ end
54
+
46
55
  def oauth_password_grant
47
56
  return unless HammerCLIForeman::Sessions.enabled?
48
57
 
@@ -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/negotiate_auth'
4
5
  require 'hammer_cli_foreman/api/oauth/authentication_code_grant'
5
6
  require 'hammer_cli_foreman/api/oauth/password_grant'
6
7
  require 'hammer_cli_foreman/api/void_auth'
@@ -10,6 +11,7 @@ module HammerCLIForeman
10
11
  CONNECTION_NAME = 'foreman'
11
12
  AUTH_TYPES = {
12
13
  basic_auth: 'Basic_Auth',
14
+ negotiate: 'Negotiate_Auth',
13
15
  oauth_authentication_code_grant: 'Oauth_Authentication_Code_Grant',
14
16
  oauth_password_grant: 'Oauth_Password_Grant'
15
17
  }.freeze
@@ -0,0 +1,36 @@
1
+ module HammerCLIForeman
2
+ module Api
3
+ class NegotiateAuth < ApipieBindings::Authenticators::Negotiate
4
+ def initialize(foreman_url, **options)
5
+ super("#{foreman_url}/users/extlogin", HammerCLI::SSLOptions.new.get_options(foreman_url).merge(options))
6
+ end
7
+
8
+ def user
9
+ _('current Kerberos user')
10
+ end
11
+
12
+ def session_id
13
+ auth_cookie&.delete_prefix('_session_id=')
14
+ end
15
+
16
+ def status
17
+ if system('klist')
18
+ _('No session, but there is an active Kerberos session, that will be used for negotiate login.')
19
+ else
20
+ _('There is no active Kerberos session. Have you run %s?') % 'kinit'
21
+ end
22
+ end
23
+
24
+ def error(ex)
25
+ super unless ex.is_a?(RestClient::Unauthorized)
26
+
27
+ message = _('Invalid username or password.')
28
+ begin
29
+ message = JSON.parse(ex.response.body)['error']['message']
30
+ rescue
31
+ end
32
+ UnauthorizedError.new(message)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -24,6 +24,8 @@ module HammerCLIForeman
24
24
  def status
25
25
  if session.valid?
26
26
  _("Session exists, currently logged in as '%s'.") % session.user_name
27
+ elsif @authenticator.respond_to?(:status)
28
+ @authenticator.status
27
29
  else
28
30
  _('Using sessions, you are currently not logged in.')
29
31
  end
@@ -66,8 +68,10 @@ module HammerCLIForeman
66
68
  end
67
69
 
68
70
  def response(r)
69
- if (r.cookies['_session_id'] && r.code != 401)
70
- session.id = r.cookies['_session_id']
71
+ session_id = @authenticator.session_id if @authenticator.respond_to?(:session_id)
72
+ session_id ||= r.cookies['_session_id']
73
+ if session_id && r.code != 401
74
+ session.id = session_id
71
75
  session.user_name = @authenticator.user
72
76
  session.store
73
77
  end
@@ -7,4 +7,5 @@ module HammerCLIForeman
7
7
  end
8
8
  end
9
9
 
10
- HammerCLIForeman.init_api_connection
10
+ api = HammerCLIForeman.init_api_connection.api
11
+ api.update_cache(api.check_cache)
@@ -28,6 +28,19 @@ module HammerCLIForeman
28
28
  end
29
29
  end
30
30
 
31
+ class Negotiate < HammerCLI::AbstractCommand
32
+ extend HammerCLIForeman::Authenticate::Login
33
+
34
+ command_name('negotiate')
35
+ desc('negotiate the login credentials from the auth ticket (Kerberos)')
36
+
37
+ def execute
38
+ Negotiate.execute_with_params(AUTH_TYPES[:negotiate])
39
+ print_message(_("Successfully authenticated using negotiate auth, using the KEYRING principal."))
40
+ HammerCLI::EX_OK
41
+ end
42
+ end
43
+
31
44
  class Oauth < HammerCLI::AbstractCommand
32
45
  extend HammerCLIForeman::Authenticate::Login
33
46
 
@@ -0,0 +1,20 @@
1
+ module HammerCLIForeman
2
+ module CommandExtensions
3
+ class Domain < HammerCLI::CommandExtensions
4
+ option_sources do |sources, command|
5
+ sources.find_by_name('IdResolution').insert_relative(
6
+ :after,
7
+ 'IdParams',
8
+ HammerCLIForeman::OptionSources::ReferencedResourceIdParams.new(command)
9
+ )
10
+ sources
11
+ end
12
+
13
+ option_family associate: 'dns' do
14
+ child '--dns', 'DNS_NAME', _('Name of DNS proxy to use within this domain'),
15
+ attribute_name: :option_dns_name,
16
+ referenced_resource: :smart_proxy
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,16 +1,7 @@
1
1
  module HammerCLIForeman
2
2
  module CommandExtensions
3
3
  class Subnet < HammerCLI::CommandExtensions
4
- option "--dns", "DNS_NAME", _("DNS Proxy to use within this subnet"),
5
- attribute_name: :option_dns_name,
6
- referenced_resource: :smart_proxy
7
- option "--dhcp", "DHCP_NAME", _("DHCP Proxy to use within this subnet"),
8
- attribute_name: :option_dhcp_name,
9
- referenced_resource: :smart_proxy
10
- option "--tftp", "TFTP_NAME", _("TFTP Proxy to use within this subnet"),
11
- attribute_name: :option_tftp_name,
12
- referenced_resource: :smart_proxy
13
- option "--prefix", "PREFIX", _("Network prefix in CIDR notation (e.g. 64) for this subnet")
4
+ option '--prefix', 'PREFIX', _('Network prefix in CIDR notation (e.g. 64) for this subnet')
14
5
 
15
6
  option_sources do |sources, command|
16
7
  sources.find_by_name('IdResolution').insert_relative(
@@ -20,6 +11,30 @@ module HammerCLIForeman
20
11
  )
21
12
  sources
22
13
  end
14
+
15
+ option_family associate: 'tftp' do
16
+ child '--tftp', 'TFTP_NAME', _('TFTP Proxy to use within this subnet'),
17
+ attribute_name: :option_tftp_name,
18
+ referenced_resource: :smart_proxy
19
+ end
20
+
21
+ option_family associate: 'dns' do
22
+ child '--dns', 'DNS_NAME', _('DNS Proxy to use within this subnet'),
23
+ attribute_name: :option_dns_name,
24
+ referenced_resource: :smart_proxy
25
+ end
26
+
27
+ option_family associate: 'dhcp' do
28
+ child '--dhcp', 'DHCP_NAME', _('DHCP Proxy to use within this subnet'),
29
+ attribute_name: :option_dhcp_name,
30
+ referenced_resource: :smart_proxy
31
+ end
32
+
33
+ option_family associate: 'bmc' do
34
+ child '--bmc', 'BMC_NAME', _('BMC Proxy to use within this subnet'),
35
+ attribute_name: :option_bmc_name,
36
+ referenced_resource: :smart_proxy
37
+ end
23
38
  end
24
39
  end
25
40
  end
@@ -1,17 +1,21 @@
1
1
  module HammerCLIForeman
2
2
  module CommandExtensions
3
3
  class User < HammerCLI::CommandExtensions
4
- option '--default-organization', 'DEFAULT_ORGANIZATION_NAME', _('Default organization name'),
5
- aliased_resource: 'default_organization', referenced_resource: 'default_organization'
6
- option '--default-location', 'DEFAULT_LOCATION_NAME', _('Default location name'),
7
- aliased_resource: 'default_location', referenced_resource: 'default_location'
8
-
9
4
  option '--ask-password', 'ASK_PW', ' ', format: HammerCLI::Options::Normalizers::Bool.new
10
5
 
11
6
  option_sources do |sources, command|
12
7
  sources << HammerCLIForeman::OptionSources::UserParams.new(command)
13
8
  sources
14
9
  end
10
+
11
+ option_family associate: 'default_organization' do
12
+ child '--default-organization', 'DEFAULT_ORGANIZATION_NAME', _('Default organization name'),
13
+ aliased_resource: 'default_organization', referenced_resource: 'organization'
14
+ end
15
+ option_family associate: 'default_location' do
16
+ child '--default-location', 'DEFAULT_LOCATION_NAME', _('Default location name'),
17
+ aliased_resource: 'default_location', referenced_resource: 'location'
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -6,3 +6,4 @@ require 'hammer_cli_foreman/command_extensions/ping'
6
6
  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
+ require 'hammer_cli_foreman/command_extensions/domain'
@@ -97,9 +97,8 @@ module HammerCLIForeman
97
97
  configurator = BuilderConfigurator.new(searchables, dependency_resolver)
98
98
 
99
99
  builder = ForemanOptionBuilder.new(searchables)
100
- builder.builders = []
100
+ builder.builders = super.builders
101
101
  builder.builders += configurator.builders_for(resource, resource.action(action)) if resource_defined?
102
- builder.builders += super.builders
103
102
  builder
104
103
  end
105
104
 
@@ -745,13 +744,17 @@ module HammerCLIForeman
745
744
  response = send_request
746
745
  if option_path
747
746
  filepath = store_response(response)
748
- print_message(_('The response has been saved to %{path}s.'), {:path => filepath})
747
+ print_message(saved_response_message(filepath))
749
748
  else
750
749
  puts response.body
751
750
  end
752
751
  return HammerCLI::EX_OK
753
752
  end
754
753
 
754
+ def saved_response_message(filepath)
755
+ _("The response has been saved to %{path}.") % { path: filepath }
756
+ end
757
+
755
758
  def default_filename
756
759
  "Downloaded-#{Time.new.strftime("%Y-%m-%d")}.txt"
757
760
  end
@@ -12,7 +12,7 @@ module HammerCLIForeman
12
12
  profile = HammerCLIForeman.record_to_common_format(
13
13
  HammerCLIForeman.foreman_resource(:compute_profiles).call(:show, 'id' => options['option_compute_profile_id'] )
14
14
  )
15
- params['compute_attribute'] = profile['compute_attributes'].select { |hash| hash['compute_resource_id'] == options['option_compute_resource_id']}[0] || {}
15
+ params['compute_attribute'] = profile['compute_attributes'].select { |hash| hash['compute_resource_id'].to_s == options['option_compute_resource_id'].to_s}[0] || {}
16
16
  params['compute_attribute'].delete('attributes') if params['compute_attribute']['attributes']
17
17
  params
18
18
  end
@@ -9,7 +9,8 @@ module HammerCLIForeman
9
9
  [
10
10
  ['cpus', _('Number of CPUs'), { bold: true }],
11
11
  ['memory', _('String, amount of memory, value in bytes'), { bold: true }],
12
- ['cpu_mode', _('Possible values: %{modes}') % { modes: 'default, host-model, host-passthrough' }]
12
+ ['cpu_mode', _('Possible values: %{modes}') % { modes: 'default, host-model, host-passthrough' }],
13
+ ['boot_order', _('Device names to specify the boot order')]
13
14
  ]
14
15
  end
15
16
 
@@ -48,7 +49,8 @@ module HammerCLIForeman
48
49
  Fields::Field.new(:label => _('Status'), :path => [:state]),
49
50
  Fields::Field.new(:label => _('OS Type'), :path => [:os_type]),
50
51
  Fields::Field.new(:label => _('Domain Type'), :path => [:domain_type]),
51
- Fields::Field.new(:label => _('Persistent'), :path => [:persistent])
52
+ Fields::Field.new(:label => _('Persistent'), :path => [:persistent]),
53
+ Fields::List.new(:label => _('Boot order'), :path => [:boot_order])
52
54
  ]
53
55
  end
54
56
 
@@ -25,7 +25,8 @@ module HammerCLIForeman
25
25
  ['scsi_controllers', [_('List with SCSI controllers definitions'),
26
26
  ' type - ' + _('ID of the controller from VMware'),
27
27
  ' key - ' + _('Key of the controller (e.g. 1000)')
28
- ].flatten(1).join("\n")]
28
+ ].flatten(1).join("\n")],
29
+ ['boot_order', _('Device names to specify the boot order')]
29
30
  ]
30
31
  end
31
32
 
@@ -76,7 +77,8 @@ module HammerCLIForeman
76
77
  Fields::Field.new(:label => _('Connection Status'), :path => [:connection_status]),
77
78
  Fields::Field.new(:label => _('Hardware Version'), :path => [:hardware_version]),
78
79
  Fields::Field.new(:label => _('Path'), :path => [:path]),
79
- Fields::Field.new(:label => _('Operating System'), :path => [:operatingsystem])
80
+ Fields::Field.new(:label => _('Operating System'), :path => [:operatingsystem]),
81
+ Fields::List.new(:label => _('Boot order'), :path => [:boot_order])
80
82
  ]
81
83
  end
82
84
 
@@ -107,6 +107,7 @@ module HammerCLIForeman
107
107
  class AssociateVmsCommand < HammerCLIForeman::Command
108
108
  action :associate
109
109
  command_name 'associate-vms'
110
+ option "--vm-id","VM ID", _("Associate a specific VM")
110
111
  success_message _("Virtual machines have been associated.")
111
112
  failure_message _("Could not associate the virtual machines")
112
113
 
@@ -1,28 +1,5 @@
1
1
  module HammerCLIForeman
2
-
3
- module DomainUpdateCreateCommons
4
-
5
- def self.included(base)
6
- base.option "--dns-id", "DNS_ID", _("ID of DNS proxy to use within this domain")
7
- base.option "--dns", "DNS_NAME", _("Name of DNS proxy to use within this domain")
8
- end
9
-
10
- def request_params
11
- params = super
12
- params['domain']["dns_id"] = option_dns_id || dns_id(option_dns)
13
- params
14
- end
15
-
16
- private
17
-
18
- def dns_id(name)
19
- resolver.smart_proxy_id('option_name' => name) if name
20
- end
21
-
22
- end
23
-
24
2
  class Domain < HammerCLIForeman::Command
25
-
26
3
  resource :domains
27
4
 
28
5
  class ListCommand < HammerCLIForeman::ListCommand
@@ -52,24 +29,24 @@ module HammerCLIForeman
52
29
 
53
30
 
54
31
  class CreateCommand < HammerCLIForeman::CreateCommand
55
- include DomainUpdateCreateCommons
56
-
57
32
  success_message _("Domain [%{name}] created.")
58
33
  failure_message _("Could not create the domain")
59
34
 
60
35
  option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
61
- build_options :without => [:domain_parameters_attributes, :fullname, :dns_id]
36
+ build_options :without => [:domain_parameters_attributes, :fullname]
37
+
38
+ extend_with(HammerCLIForeman::CommandExtensions::Domain.new)
62
39
  end
63
40
 
64
41
 
65
42
  class UpdateCommand < HammerCLIForeman::UpdateCommand
66
- include DomainUpdateCreateCommons
67
-
68
43
  success_message _("Domain [%{name}] updated.")
69
44
  failure_message _("Could not update the domain")
70
45
 
71
46
  option "--description", "DESC", _("Full name describing the domain"), :attribute_name => :option_fullname
72
47
  build_options :without => [:domain_parameters_attributes, :fullname]
48
+
49
+ extend_with(HammerCLIForeman::CommandExtensions::Domain.new)
73
50
  end
74
51
 
75
52
 
@@ -12,6 +12,7 @@ module HammerCLIForeman
12
12
  [RestClient::UnprocessableEntity, :handle_unprocessable_entity],
13
13
  [RestClient::MovedPermanently, :handle_moved_permanently],
14
14
  [RestClient::BadRequest, :handle_bad_request],
15
+ [ApipieBindings::AuthenticatorError, :handle_authenticator_error],
15
16
  [HammerCLIForeman::Api::UnauthorizedError, :handle_foreman_unauthorized],
16
17
  [HammerCLIForeman::Api::SessionExpired, :handle_sesion_expired],
17
18
  [ArgumentError, :handle_argument_error],
@@ -112,6 +113,12 @@ module HammerCLIForeman
112
113
  HammerCLI::EX_DATAERR
113
114
  end
114
115
 
116
+ def handle_authenticator_error(e)
117
+ print_error authenticator_error_message(e)
118
+ log_full_error e.original_error
119
+ HammerCLI::EX_USAGE
120
+ end
121
+
115
122
  def ssl_cert_instructions
116
123
  host_url = HammerCLI::Settings.get(:_params, :host) || HammerCLI::Settings.get(:foreman, :host)
117
124
  uri = URI.parse(host_url)
@@ -147,6 +154,25 @@ module HammerCLIForeman
147
154
 
148
155
  private
149
156
 
157
+ def authenticator_error_message(e)
158
+ case e.type
159
+ when :negotiate then negotiation_error_message(e)
160
+ end
161
+ end
162
+
163
+ def negotiation_error_message(e)
164
+ case e.cause
165
+ when :configuration
166
+ _('Server misconfiguration detected') + "\n - " +
167
+ _('have you run installer with option %s?') % '--foreman-ipa-authentication=true' + "\n - " +
168
+ _('the user might come from a different authentication source') + "\n"
169
+ else
170
+ _('Could not authenticate using negotiation protocol') + "\n - " +
171
+ _('have you run %s (for Kerberos)?') % 'kinit' + "\n - " +
172
+ _('is the server down?') + "\n"
173
+ end
174
+ end
175
+
150
176
  def response_message(response)
151
177
  message = JSON.parse(response)["error"]["message"]
152
178
  "\n #{message}"
@@ -97,10 +97,10 @@ module HammerCLIForeman
97
97
 
98
98
  def request_params
99
99
  params = super
100
- if !override?
100
+ unless override?
101
101
  # Clear taxonomies in case the filter is switching override from true to false
102
- params['filter']['location_ids'] = []
103
- params['filter']['organization_ids'] = []
102
+ params['filter']['location_ids'] = [] if !@filter || !@filter['locations'].empty?
103
+ params['filter']['organization_ids'] = [] if !@filter || !@filter['organizations'].empty?
104
104
  end
105
105
  params
106
106
  end
@@ -55,6 +55,7 @@ module HammerCLIForeman
55
55
  field nil, _("Compute Resource"), Fields::SingleReference, :key => :compute_resource
56
56
  field nil, _("Compute Profile"), Fields::SingleReference, :key => :compute_profile, :hide_blank => true
57
57
  field :certname, _("Cert name")
58
+ field :token, _("Token")
58
59
  field :managed, _("Managed"), Fields::Boolean
59
60
 
60
61
  field :installed_at, _("Installed at"), Fields::Date
@@ -3,13 +3,20 @@ module HammerCLIForeman
3
3
  module HostgroupUpdateCreateCommons
4
4
 
5
5
  def self.included(base)
6
- base.option "--parent", "PARENT_NAME", _("Name of parent hostgroup")
7
- base.option ["--root-password"], "ROOT_PASSWORD", _("Root password")
8
- base.option ["--ask-root-password", "--ask-root-pass"], "ASK_ROOT_PW", "",
6
+ base.option '--root-password', 'ROOT_PASSWORD', _('Root password')
7
+ base.option '--ask-root-password', 'ASK_ROOT_PW', '',
9
8
  format: HammerCLI::Options::Normalizers::Bool.new
10
- base.option "--subnet6", "SUBNET6_NAME", _("Subnet IPv6 name")
11
9
 
12
10
  base.build_options without: %i[root_pass]
11
+
12
+ base.option_family associate: 'subnet6' do
13
+ child '--subnet6', 'SUBNET6_NAME', _('Subnet IPv6 name')
14
+ end
15
+
16
+ base.option_family associate: 'parent' do
17
+ child '--parent', 'PARENT_NAME', _('Name of parent hostgroup')
18
+ child '--parent-title', 'PARENT_TITLE', _('Title of parent hostgroup')
19
+ end
13
20
  end
14
21
 
15
22
  def self.ask_password
@@ -19,8 +26,8 @@ module HammerCLIForeman
19
26
 
20
27
  def request_params
21
28
  params = super
22
- params['hostgroup']["parent_id"] ||= resolver.hostgroup_id('option_name' => option_parent) if option_parent
23
-
29
+ params['hostgroup']['parent_id'] ||= resolver.hostgroup_id('option_name' => option_parent) if option_parent
30
+ params['hostgroup']['parent_id'] ||= resolver.hostgroup_id('option_title' => option_parent_title) if option_parent_title
24
31
  params['hostgroup']['root_pass'] = option_root_password if option_root_password
25
32
  params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_password
26
33
 
@@ -3,11 +3,12 @@ module HammerCLIForeman
3
3
  module CommonUpdateOptions
4
4
 
5
5
  def self.included(base)
6
- base.option "--owner", "OWNER_LOGIN", _("Login of the owner"),
7
- :attribute_name => :option_user_login
8
- base.option "--owner-id", "OWNER_ID", _("ID of the owner"),
9
- :attribute_name => :option_owner_id
10
-
6
+ base.option_family do
7
+ parent '--owner-id', 'OWNER_ID', _('ID of the owner'),
8
+ attribute_name: :option_owner_id
9
+ child '--owner', 'OWNER_LOGIN', _('Login of the owner'),
10
+ attribute_name: :option_user_login
11
+ end
11
12
  base.option "--root-password", "ROOT_PW",
12
13
  _("Required if host is managed and value is not inherited from host group or default password in settings")
13
14
 
@@ -112,14 +113,13 @@ module HammerCLIForeman
112
113
 
113
114
  private
114
115
 
115
-
116
116
  def owner_id(name, type)
117
117
  return unless name
118
118
  return resolver.usergroup_id('option_name' => name) if type == 'Usergroup'
119
119
 
120
120
  resolver.user_id('option_login' => name)
121
121
  end
122
-
122
+
123
123
  def proxy_id(name)
124
124
  resolver.smart_proxy_id('option_name' => name) if name
125
125
  end