hammer_cli_foreman 3.1.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/foreman.yml +4 -0
- data/doc/configuration.md +30 -0
- data/doc/release_notes.md +24 -0
- data/lib/hammer_cli_foreman/api/authenticator.rb +9 -0
- data/lib/hammer_cli_foreman/api/connection.rb +2 -0
- data/lib/hammer_cli_foreman/api/negotiate_auth.rb +36 -0
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +6 -2
- data/lib/hammer_cli_foreman/api.rb +2 -1
- data/lib/hammer_cli_foreman/auth.rb +13 -0
- data/lib/hammer_cli_foreman/command_extensions/domain.rb +20 -0
- data/lib/hammer_cli_foreman/command_extensions.rb +1 -0
- data/lib/hammer_cli_foreman/commands.rb +5 -1
- data/lib/hammer_cli_foreman/compute_resource/libvirt.rb +4 -2
- data/lib/hammer_cli_foreman/compute_resource/vmware.rb +4 -2
- data/lib/hammer_cli_foreman/domain.rb +5 -28
- data/lib/hammer_cli_foreman/exception_handler.rb +26 -0
- data/lib/hammer_cli_foreman/filter.rb +3 -3
- data/lib/hammer_cli_foreman/host.rb +1 -0
- data/lib/hammer_cli_foreman/id_resolver.rb +2 -1
- data/lib/hammer_cli_foreman/partition_table.rb +30 -0
- data/lib/hammer_cli_foreman/report_template.rb +15 -0
- data/lib/hammer_cli_foreman/smart_proxy.rb +11 -0
- data/lib/hammer_cli_foreman/table_preference.rb +48 -0
- data/lib/hammer_cli_foreman/template.rb +30 -0
- data/lib/hammer_cli_foreman/user.rb +4 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/data/3.4/foreman_api.json +1 -0
- data/test/functional/domain/create_test.rb +91 -0
- data/test/functional/domain/update_test.rb +90 -0
- data/test/functional/partition_table_test.rb +63 -0
- data/test/functional/report_template_test.rb +24 -0
- data/test/functional/table_preference_test.rb +100 -0
- data/test/functional/template_test.rb +60 -0
- data/test/test_helper.rb +1 -1
- metadata +58 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4787fbc9dbda1fcd2311672da8001300715cfc1448b82f985509a73cab3ab416
|
4
|
+
data.tar.gz: a2ee1f1044f4422181109b166040b8e83dd9c727310c7753e89d26c23dae3c7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1fe6bb98a5c352f95ce509e7e56f7c398180aa3790d1105f2c7ffb98d8dcfca4e4ab1cda4331a1f70000a834a75671782ed8e1d6b7ba65b3d83b474f8a9f3c6
|
7
|
+
data.tar.gz: 8e490092a17af3fd13d8c8c5d6ff6f42227e3e9bfa888818975308679a0724e6f6e8183d811a3a47dcbd369da0e0f92ccf4b2131b4e90d9b0d17bda9c01950fc
|
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,29 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
+
### 3.4.0 (2022-08-09)
|
4
|
+
* 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
|
+
* I18n - extracting new, pulling from tx, [#34629](http://projects.theforeman.org/issues/34629)
|
6
|
+
* Fix config for transifex, [#34629](http://projects.theforeman.org/issues/34629)
|
7
|
+
* Bump to 3.4.0-develop
|
8
|
+
|
9
|
+
### 3.3.0 (2022-05-10)
|
10
|
+
* Add kerberos negotiate auth support ([PR #555](https://github.com/theforeman/hammer-cli-foreman/pull/555)), [#8923](http://projects.theforeman.org/issues/8923)
|
11
|
+
* Pin mocha gem to < 1.14.0
|
12
|
+
* Force api docs checksum check, [#28283](http://projects.theforeman.org/issues/28283)
|
13
|
+
* 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)
|
14
|
+
* 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)
|
15
|
+
* Add resource information to download command ([PR #598](https://github.com/theforeman/hammer-cli-foreman/pull/598)), [#34621](http://projects.theforeman.org/issues/34621)
|
16
|
+
* 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)
|
17
|
+
* Bump to 3.3.0-develop
|
18
|
+
|
19
|
+
### 3.2.0 (2022-02-10)
|
20
|
+
* 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)
|
21
|
+
* 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)
|
22
|
+
* Add boot_order to compute-attribute ([PR #588](https://github.com/theforeman/hammer-cli-foreman/pull/588)), [#33910](http://projects.theforeman.org/issues/33910)
|
23
|
+
* 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)
|
24
|
+
* Add token to host info command ([PR #586](https://github.com/theforeman/hammer-cli-foreman/pull/586)), [#34120](http://projects.theforeman.org/issues/34120)
|
25
|
+
* Bump to 3.2.0-develop
|
26
|
+
|
3
27
|
### 3.1.0 (2021-11-10)
|
4
28
|
* Update test data for 3.1
|
5
29
|
* Make sure provided options override defaults, [#33711](http://projects.theforeman.org/issues/33711)
|
@@ -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
|
-
|
70
|
-
|
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
|
@@ -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
|
@@ -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'
|
@@ -744,13 +744,17 @@ module HammerCLIForeman
|
|
744
744
|
response = send_request
|
745
745
|
if option_path
|
746
746
|
filepath = store_response(response)
|
747
|
-
print_message(
|
747
|
+
print_message(saved_response_message(filepath))
|
748
748
|
else
|
749
749
|
puts response.body
|
750
750
|
end
|
751
751
|
return HammerCLI::EX_OK
|
752
752
|
end
|
753
753
|
|
754
|
+
def saved_response_message(filepath)
|
755
|
+
_("The response has been saved to %{path}.") % { path: filepath }
|
756
|
+
end
|
757
|
+
|
754
758
|
def default_filename
|
755
759
|
"Downloaded-#{Time.new.strftime("%Y-%m-%d")}.txt"
|
756
760
|
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
|
|
@@ -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
|
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
|
-
|
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
|
@@ -66,7 +66,8 @@ module HammerCLIForeman
|
|
66
66
|
:user => [ s("login", _("User's login to search by")) ],
|
67
67
|
:common_parameter => [ s_name(_("Common parameter name")) ],
|
68
68
|
:template_combination => [],
|
69
|
-
:compute_attribute => []
|
69
|
+
:compute_attribute => [],
|
70
|
+
:table_preference => []
|
70
71
|
}
|
71
72
|
DEFAULT_SEARCHABLES = [ s_name(_("Name to search by")) ]
|
72
73
|
|
@@ -71,6 +71,36 @@ module HammerCLIForeman
|
|
71
71
|
build_options
|
72
72
|
end
|
73
73
|
|
74
|
+
class ImportCommand < HammerCLIForeman::Command
|
75
|
+
command_name "import"
|
76
|
+
action :import
|
77
|
+
option '--file', 'PATH', _('Path to a file that contains the template content including metadata'),
|
78
|
+
:attribute_name => :option_template, :format => HammerCLI::Options::Normalizers::File.new
|
79
|
+
|
80
|
+
validate_options do
|
81
|
+
all(:option_name, :option_template).required
|
82
|
+
end
|
83
|
+
|
84
|
+
success_message _("Import partition table template succeeded.")
|
85
|
+
failure_message _("Could not import partition table template")
|
86
|
+
|
87
|
+
build_options :without => [:template]
|
88
|
+
end
|
89
|
+
|
90
|
+
class ExportCommand < HammerCLIForeman::DownloadCommand
|
91
|
+
command_name "export"
|
92
|
+
action :export
|
93
|
+
|
94
|
+
def default_filename
|
95
|
+
"Partition Table Template-#{Time.new.strftime("%Y-%m-%d")}.txt"
|
96
|
+
end
|
97
|
+
|
98
|
+
def saved_response_message(filepath)
|
99
|
+
_("The partition table template has been saved to %{path}.") % { path: filepath }
|
100
|
+
end
|
101
|
+
|
102
|
+
build_options
|
103
|
+
end
|
74
104
|
|
75
105
|
HammerCLIForeman::AssociatingCommands::OperatingSystem.extend_command(self)
|
76
106
|
|
@@ -148,6 +148,21 @@ module HammerCLIForeman
|
|
148
148
|
build_options :without => [:template]
|
149
149
|
end
|
150
150
|
|
151
|
+
class ExportCommand < HammerCLIForeman::DownloadCommand
|
152
|
+
command_name "export"
|
153
|
+
action :export
|
154
|
+
|
155
|
+
def default_filename
|
156
|
+
"Report Template-#{Time.new.strftime("%Y-%m-%d")}.txt"
|
157
|
+
end
|
158
|
+
|
159
|
+
def saved_response_message(filepath)
|
160
|
+
_("The report template has been saved to %{path}.") % { path: filepath }
|
161
|
+
end
|
162
|
+
|
163
|
+
build_options
|
164
|
+
end
|
165
|
+
|
151
166
|
class ReportDataCommand < HammerCLIForeman::DownloadCommand
|
152
167
|
command_name "report-data"
|
153
168
|
action :report_data
|
@@ -73,6 +73,17 @@ module HammerCLIForeman
|
|
73
73
|
build_options
|
74
74
|
end
|
75
75
|
|
76
|
+
class ImportSubnetsCommand < HammerCLIForeman::Command
|
77
|
+
|
78
|
+
action :import_subnets
|
79
|
+
|
80
|
+
command_name "import-subnets"
|
81
|
+
success_message _("Import subnets succeeded.")
|
82
|
+
failure_message _("Could not import subnets")
|
83
|
+
|
84
|
+
build_options
|
85
|
+
end
|
86
|
+
|
76
87
|
autoload_subcommands
|
77
88
|
end
|
78
89
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
class TablePreference < HammerCLIForeman::Command
|
3
|
+
resource :table_preferences
|
4
|
+
command_name "table-preference"
|
5
|
+
|
6
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
7
|
+
output do
|
8
|
+
field :id, _("Id")
|
9
|
+
field :name, _("Name")
|
10
|
+
field :columns, _("Columns"), Fields::List
|
11
|
+
end
|
12
|
+
|
13
|
+
build_options
|
14
|
+
end
|
15
|
+
|
16
|
+
class CreateCommand < HammerCLIForeman::CreateCommand
|
17
|
+
success_message _('Table preference created.')
|
18
|
+
failure_message _('Could not create table preference')
|
19
|
+
|
20
|
+
build_options
|
21
|
+
end
|
22
|
+
|
23
|
+
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
24
|
+
success_message _('Table preference updated.')
|
25
|
+
failure_message _('Could not update table preference')
|
26
|
+
|
27
|
+
build_options
|
28
|
+
end
|
29
|
+
|
30
|
+
class InfoCommand < HammerCLIForeman::InfoCommand
|
31
|
+
output ListCommand.output_definition do
|
32
|
+
field :created_at, _("Created at"), Fields::Date
|
33
|
+
field :updated_at, _("Updated at"), Fields::Date
|
34
|
+
end
|
35
|
+
|
36
|
+
build_options
|
37
|
+
end
|
38
|
+
|
39
|
+
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
40
|
+
success_message _('Table preference deleted.')
|
41
|
+
failure_message _('Could not remove table preference')
|
42
|
+
|
43
|
+
build_options
|
44
|
+
end
|
45
|
+
|
46
|
+
autoload_subcommands
|
47
|
+
end
|
48
|
+
end
|
@@ -142,7 +142,37 @@ module HammerCLIForeman
|
|
142
142
|
build_options
|
143
143
|
end
|
144
144
|
|
145
|
+
class ImportCommand < HammerCLIForeman::Command
|
146
|
+
command_name "import"
|
147
|
+
action :import
|
148
|
+
option '--file', 'PATH', _('Path to a file that contains the template content including metadata'),
|
149
|
+
:attribute_name => :option_template, :format => HammerCLI::Options::Normalizers::File.new
|
145
150
|
|
151
|
+
validate_options do
|
152
|
+
all(:option_name, :option_template).required
|
153
|
+
end
|
154
|
+
|
155
|
+
success_message _("Import provisioning template succeeded.")
|
156
|
+
failure_message _("Could not import provisioning template")
|
157
|
+
|
158
|
+
build_options :without => [:template]
|
159
|
+
end
|
160
|
+
|
161
|
+
class ExportCommand < HammerCLIForeman::DownloadCommand
|
162
|
+
command_name "export"
|
163
|
+
action :export
|
164
|
+
|
165
|
+
def default_filename
|
166
|
+
"Template-#{Time.new.strftime("%Y-%m-%d")}.txt"
|
167
|
+
end
|
168
|
+
|
169
|
+
def saved_response_message(filepath)
|
170
|
+
_("The provisioning template has been saved to %{path}.") % { path: filepath }
|
171
|
+
end
|
172
|
+
|
173
|
+
build_options
|
174
|
+
end
|
175
|
+
|
146
176
|
class BuildPXEDefaultCommand < HammerCLIForeman::Command
|
147
177
|
|
148
178
|
action :build_pxe_default
|
@@ -29,6 +29,7 @@ module HammerCLIForeman
|
|
29
29
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
30
30
|
|
31
31
|
output ListCommand.output_definition do
|
32
|
+
field :mail_enabled, _("Email enabled"), Fields::Boolean
|
32
33
|
field :effective_admin, _("Effective admin"), Fields::Boolean
|
33
34
|
field :locale, _("Locale")
|
34
35
|
field :timezone, _("Timezone")
|
@@ -89,6 +90,9 @@ module HammerCLIForeman
|
|
89
90
|
lazy_subcommand('mail-notification', _("Managing personal mail notifications"),
|
90
91
|
'HammerCLIForeman::UserMailNotification', 'hammer_cli_foreman/user_mail_notification'
|
91
92
|
)
|
93
|
+
lazy_subcommand('table-preference', _("Managing table preferences"),
|
94
|
+
'HammerCLIForeman::TablePreference', 'hammer_cli_foreman/table_preference'
|
95
|
+
)
|
92
96
|
autoload_subcommands
|
93
97
|
end
|
94
98
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|