hammer_cli_foreman 0.15.2 → 0.16.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.
- checksums.yaml +5 -5
- data/doc/name_id_resolution.md +19 -7
- data/doc/release_notes.md +7 -2
- data/lib/hammer_cli_foreman/auth_source.rb +1 -1
- data/lib/hammer_cli_foreman/commands.rb +38 -4
- data/lib/hammer_cli_foreman/host.rb +1 -1
- data/lib/hammer_cli_foreman/hostgroup.rb +3 -0
- data/lib/hammer_cli_foreman/option_sources/id_params.rb +1 -1
- data/lib/hammer_cli_foreman/option_sources/ids_params.rb +1 -1
- data/lib/hammer_cli_foreman/option_sources/self_param.rb +1 -1
- data/lib/hammer_cli_foreman/option_sources/user_params.rb +1 -1
- 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/functional/commands/list_test.rb +15 -0
- data/test/functional/host_test.rb +1 -1
- data/test/functional/smart_class_parameter_test.rb +2 -1
- data/test/unit/commands_test.rb +12 -0
- data/test/unit/messages_test.rb +13 -0
- metadata +5 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c8e1d9e2bdf020465f92034a08e8348496fe4b4f
|
4
|
+
data.tar.gz: 8e5b33da07245341c8a0b8df40662736f5c4c83d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4262e878d4e0cd9254cccf99ed75827559b525b55e42a402da594331d85df2ce8e1e23c7cc439271cb8649bbca14dfe4063b4913e99e01b7e88251adcf9feb2
|
7
|
+
data.tar.gz: 959f424ddfc94a4a60ca5da344945cb4859005e4529fdd14bcce61ff5ca5beb17bab7b937d308356cc73e969dd8bc36012642d94bc1e0a38296af4d446ac9c3d
|
data/doc/name_id_resolution.md
CHANGED
@@ -10,6 +10,18 @@ The ID resolution process consists of two parts:
|
|
10
10
|
- building correct parameters (option builders are described [here](https://github.com/theforeman/hammer-cli-foreman/blob/master/doc/option_builder.md#option-builders))
|
11
11
|
- the translation process itself ([IdResolver](https://github.com/theforeman/hammer-cli-foreman/blob/master/lib/hammer_cli_foreman/id_resolver.rb) takes care of that)
|
12
12
|
|
13
|
+
The latter part is implemented three option sources wrapped in `IdResolution` for easier addressing.
|
14
|
+
With this extension the whole structure of option processors in `hammer-cli-foreman` is:
|
15
|
+
```
|
16
|
+
- DefaultInputs
|
17
|
+
- CommandLine
|
18
|
+
- SavedDefaults
|
19
|
+
- IdResolution
|
20
|
+
- IdParams
|
21
|
+
- IdsParams
|
22
|
+
- SelfParam
|
23
|
+
```
|
24
|
+
|
13
25
|
ID resolution step by step
|
14
26
|
--------------------------
|
15
27
|
|
@@ -31,7 +43,7 @@ Differences in resolution of list of id's
|
|
31
43
|
|
32
44
|
the lookup method is called `<resource_name>_ids` and in addition:
|
33
45
|
- returns `cli_options['option_ids']` if it's not nil
|
34
|
-
- returns empty list (`[]`) when the search option is set to empty string or empty list
|
46
|
+
- returns empty list (`[]`) when the search option is set to empty string or empty list
|
35
47
|
|
36
48
|
It also ends up with exception when any of the ids was not resolved.
|
37
49
|
|
@@ -58,15 +70,15 @@ Behaviour tuning
|
|
58
70
|
|
59
71
|
The resolution can be tuned at various levels.
|
60
72
|
|
61
|
-
Most of the resources are searchable by name. However there are exceptions that either don't have a name
|
62
|
-
or offer more searchable fields. In such cases you have to update the definition
|
73
|
+
Most of the resources are searchable by name. However there are exceptions that either don't have a name
|
74
|
+
or offer more searchable fields. In such cases you have to update the definition
|
63
75
|
of searchable fields (SEARCHABLES) in [id_resolver](https://github.com/theforeman/hammer-cli-foreman/blob/master/lib/hammer_cli_foreman/id_resolver.rb).
|
64
76
|
|
65
|
-
If you need to modify the lookup query (the `search` field) you can override the default one by adding a method
|
77
|
+
If you need to modify the lookup query (the `search` field) you can override the default one by adding a method
|
66
78
|
returning the correct lookup options to the resolver class.
|
67
|
-
The method should be called according to the following schema:
|
68
|
-
- `create_<resource_name>_search_options(options)` for single id lookup (takes precedence over the next one for single id lookups)
|
69
|
-
- `create_<resource_plural_name>_search_options(options)` combine for single and/or multiple ids lookup
|
79
|
+
The method should be called according to the following schema:
|
80
|
+
- `create_<resource_name>_search_options(options)` for single id lookup (takes precedence over the next one for single id lookups)
|
81
|
+
- `create_<resource_plural_name>_search_options(options)` combine for single and/or multiple ids lookup
|
70
82
|
- `create_<resource_plural_name>_search_options(options, mode)` combined with extra parameter suggesting the lookup mode and being set to `:single`, `:multi` or `nil`
|
71
83
|
|
72
84
|
For examples check the `id_resolver`.
|
data/doc/release_notes.md
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
-
### 0.
|
3
|
+
### 0.16.0 (2019-01-16)
|
4
|
+
* Use make targets for translations from core ([#25724](http://projects.theforeman.org/issues/25724))
|
5
|
+
* Allow mixing option sources and validations ([PR #402](https://github.com/theforeman/hammer-cli-foreman/pull/402)) ([#22253](http://projects.theforeman.org/issues/22253))
|
6
|
+
* Include information about search fields ([#11431](http://projects.theforeman.org/issues/11431))
|
7
|
+
* IPv6 subnet option in hostgroup create/update ([#18752](http://projects.theforeman.org/issues/18752))
|
8
|
+
* Tests for message formats ([#7451](http://projects.theforeman.org/issues/7451))
|
4
9
|
* Report templates - inputs, clone, interactive updates ([#24489](http://projects.theforeman.org/issues/24489))
|
5
10
|
* Update API doc in tests to match Foreman 1.20 ([#25376](http://projects.theforeman.org/issues/25376))
|
6
11
|
* Add a command for report templates ([#24489](http://projects.theforeman.org/issues/24489))
|
7
|
-
* Request password regardless of redirection ([#14832](http://projects.theforeman.org/issues/14832))
|
8
12
|
* Re-add --thin into host list ([PR #395](https://github.com/theforeman/hammer-cli-foreman/pull/395)) ([#25349](http://projects.theforeman.org/issues/25349))
|
13
|
+
* Request password regardless of redirection ([#14832](http://projects.theforeman.org/issues/14832))
|
9
14
|
|
10
15
|
### 0.15.0 (2018-10-24)
|
11
16
|
* Use SPDX 2.0 codes
|
@@ -7,7 +7,7 @@ module HammerCLIForeman
|
|
7
7
|
subcommand 'ldap', HammerCLIForeman::AuthSourceLdap.desc, HammerCLIForeman::AuthSourceLdap
|
8
8
|
|
9
9
|
class ListCommand < HammerCLIForeman::ListCommand
|
10
|
-
desc _('List all auth sources
|
10
|
+
desc _('List all auth sources')
|
11
11
|
|
12
12
|
output do
|
13
13
|
field :id, _('Id')
|
@@ -190,10 +190,13 @@ module HammerCLIForeman
|
|
190
190
|
|
191
191
|
def option_sources
|
192
192
|
sources = super
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
193
|
+
|
194
|
+
id_resolution = HammerCLI::Options::ProcessorList.new(name: 'IdResolution')
|
195
|
+
id_resolution << HammerCLIForeman::OptionSources::IdParams.new(self)
|
196
|
+
id_resolution << HammerCLIForeman::OptionSources::IdsParams.new(self)
|
197
|
+
id_resolution << HammerCLIForeman::OptionSources::SelfParam.new(self)
|
198
|
+
|
199
|
+
sources << id_resolution
|
197
200
|
end
|
198
201
|
|
199
202
|
private
|
@@ -250,6 +253,20 @@ module HammerCLIForeman
|
|
250
253
|
return HammerCLI::EX_OK
|
251
254
|
end
|
252
255
|
|
256
|
+
def help
|
257
|
+
meta = resource.action(action).apidoc[:metadata]
|
258
|
+
return super if meta.nil?
|
259
|
+
|
260
|
+
if meta && meta[:search] && respond_to?(:option_search)
|
261
|
+
self.class.extend_help do |h|
|
262
|
+
h.section(_('Search fields'), id: :search_fields_section) do |h|
|
263
|
+
h.list(search_fields_help(meta[:search]))
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
super
|
268
|
+
end
|
269
|
+
|
253
270
|
protected
|
254
271
|
|
255
272
|
def retrieve_all
|
@@ -277,6 +294,23 @@ module HammerCLIForeman
|
|
277
294
|
retrieve_all
|
278
295
|
end
|
279
296
|
|
297
|
+
def search_fields_help(search_fields)
|
298
|
+
return [] if search_fields.nil?
|
299
|
+
|
300
|
+
search_fields.each_with_object([]) do |field, help_list|
|
301
|
+
help_list << [
|
302
|
+
field[:name], search_field_help_value(field)
|
303
|
+
]
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
def search_field_help_value(field)
|
308
|
+
if field[:values] && field[:values].is_a?(Array)
|
309
|
+
_('Values') + ': ' + field[:values].join(', ')
|
310
|
+
else
|
311
|
+
field[:type] || field[:values]
|
312
|
+
end
|
313
|
+
end
|
280
314
|
end
|
281
315
|
|
282
316
|
|
@@ -489,7 +489,7 @@ module HammerCLIForeman
|
|
489
489
|
|
490
490
|
command_name "disassociate"
|
491
491
|
desc _("Disassociate a host")
|
492
|
-
success_message _("The host has been disassociated from VM")
|
492
|
+
success_message _("The host has been disassociated from VM.")
|
493
493
|
failure_message _("Failed to disassociated host from VM")
|
494
494
|
|
495
495
|
build_options
|
@@ -17,6 +17,7 @@ module HammerCLIForeman
|
|
17
17
|
base.option "--root-pass", "ROOT_PASSWORD", _("Root password")
|
18
18
|
base.option "--ask-root-pass", "ASK_ROOT_PW", "",
|
19
19
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
20
|
+
base.option "--subnet6", "SUBNET6_NAME", _("Subnet IPv6 name")
|
20
21
|
end
|
21
22
|
|
22
23
|
def self.ask_password
|
@@ -35,6 +36,8 @@ module HammerCLIForeman
|
|
35
36
|
|
36
37
|
params['hostgroup']['root_pass'] = option_root_pass if option_root_pass
|
37
38
|
params['hostgroup']['root_pass'] = HammerCLIForeman::HostgroupUpdateCreateCommons::ask_password if option_ask_root_pass
|
39
|
+
|
40
|
+
params['hostgroup']['subnet6_id'] = resolver.subnet_id('option_name' => option_subnet6) if option_subnet6
|
38
41
|
params
|
39
42
|
end
|
40
43
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -33,6 +33,21 @@ describe HammerCLIForeman::ListCommand do
|
|
33
33
|
HammerCLI::Settings.clear
|
34
34
|
end
|
35
35
|
|
36
|
+
context 'help' do
|
37
|
+
let(:cmd) { ['host', 'list'] }
|
38
|
+
let(:params) { ['--help'] }
|
39
|
+
|
40
|
+
it 'shows search fields in help' do
|
41
|
+
result = run_cmd(cmd + params)
|
42
|
+
result.out.must_match(/.*Search fields:\s+(\S+\s+\S+)*\s+name\s+string/)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'formats enum values' do
|
46
|
+
result = run_cmd(cmd + params)
|
47
|
+
result.out.must_match(/.*Search fields:\s+(\S+\s+\S+)*\s+managed\s+Values: true, false/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
36
51
|
describe "api interaction" do
|
37
52
|
context "without per_page in settings" do
|
38
53
|
it "fetches only first page when there's not enough records" do
|
@@ -276,7 +276,7 @@ describe 'disassociate host from vm' do
|
|
276
276
|
|
277
277
|
it 'successful disassociate host' do
|
278
278
|
params = ['--id=1']
|
279
|
-
expected_result = success_result("The host has been disassociated from VM
|
279
|
+
expected_result = success_result("The host has been disassociated from VM.\n")
|
280
280
|
api_expects(:hosts, :disassociate, 'disassociate hosts') do |params|
|
281
281
|
params['id'] == "1"
|
282
282
|
end.returns({})
|
data/test/unit/commands_test.rb
CHANGED
@@ -196,3 +196,15 @@ describe HammerCLIForeman::Command do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
end
|
199
|
+
|
200
|
+
describe HammerCLIForeman::ListCommand do
|
201
|
+
class OpenListCommand < HammerCLIForeman::ListCommand
|
202
|
+
public :search_field_help_value
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'formats enum values in search fields help' do
|
206
|
+
search_field = { name: 'managed', values: [true, false] }
|
207
|
+
expected_output = 'Values: true, false'
|
208
|
+
OpenListCommand.new({}).search_field_help_value(search_field).must_equal(expected_output)
|
209
|
+
end
|
210
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
require 'hammer_cli/testing/messages'
|
3
|
+
|
4
|
+
include HammerCLI::Testing::Messages
|
5
|
+
describe "message formatting" do
|
6
|
+
check_all_command_messages(
|
7
|
+
HammerCLI::MainCommand,
|
8
|
+
HammerCLIForeman::Command,
|
9
|
+
except: {
|
10
|
+
'HammerCLIForeman::PersonalAccessToken::CreateCommand' => [:success_message]
|
11
|
+
}
|
12
|
+
)
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Strachota
|
@@ -9,16 +9,13 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hammer_cli
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 0.15.1
|
21
|
-
- - "<"
|
22
19
|
- !ruby/object:Gem::Version
|
23
20
|
version: 0.16.0
|
24
21
|
type: :runtime
|
@@ -26,9 +23,6 @@ dependencies:
|
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - ">="
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: 0.15.1
|
31
|
-
- - "<"
|
32
26
|
- !ruby/object:Gem::Version
|
33
27
|
version: 0.16.0
|
34
28
|
- !ruby/object:Gem::Dependency
|
@@ -498,6 +492,7 @@ files:
|
|
498
492
|
- test/unit/image_test.rb
|
499
493
|
- test/unit/location_test.rb
|
500
494
|
- test/unit/media_test.rb
|
495
|
+
- test/unit/messages_test.rb
|
501
496
|
- test/unit/model_test.rb
|
502
497
|
- test/unit/operating_system_test.rb
|
503
498
|
- test/unit/option_builders_test.rb
|
@@ -540,7 +535,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
540
535
|
version: '0'
|
541
536
|
requirements: []
|
542
537
|
rubyforge_project:
|
543
|
-
rubygems_version: 2.
|
538
|
+
rubygems_version: 2.6.14.1
|
544
539
|
signing_key:
|
545
540
|
specification_version: 4
|
546
541
|
summary: Foreman commands for Hammer
|
@@ -832,6 +827,7 @@ test_files:
|
|
832
827
|
- test/unit/architecture_test.rb
|
833
828
|
- test/unit/defaults_test.rb
|
834
829
|
- test/unit/puppet_class_test.rb
|
830
|
+
- test/unit/messages_test.rb
|
835
831
|
- test/unit/config_group_test.rb
|
836
832
|
- test/unit/template_test.rb
|
837
833
|
- test/unit/param_filters_test.rb
|