hammer_cli_foreman 2.5.1 → 3.0.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 +4 -4
- data/doc/release_notes.md +10 -1
- data/lib/hammer_cli_foreman.rb +0 -21
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +0 -24
- data/lib/hammer_cli_foreman/bookmark.rb +5 -5
- data/lib/hammer_cli_foreman/combination.rb +3 -13
- data/lib/hammer_cli_foreman/command_extensions.rb +0 -2
- data/lib/hammer_cli_foreman/commands.rb +2 -9
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +0 -35
- data/lib/hammer_cli_foreman/hostgroup.rb +2 -53
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -23
- data/lib/hammer_cli_foreman/id_resolver.rb +0 -61
- data/lib/hammer_cli_foreman/location.rb +0 -6
- data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
- data/lib/hammer_cli_foreman/model.rb +5 -5
- data/lib/hammer_cli_foreman/operating_system.rb +10 -10
- data/lib/hammer_cli_foreman/option_sources.rb +0 -1
- data/lib/hammer_cli_foreman/option_sources/id_params.rb +27 -10
- data/lib/hammer_cli_foreman/option_sources/ids_params.rb +25 -6
- data/lib/hammer_cli_foreman/organization.rb +0 -6
- data/lib/hammer_cli_foreman/references.rb +0 -16
- data/lib/hammer_cli_foreman/settings.rb +3 -3
- data/lib/hammer_cli_foreman/smart_proxy.rb +0 -52
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/minitest/coverage_reporter.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/architecture_test.rb +6 -4
- data/test/functional/bookmark_test.rb +3 -1
- data/test/functional/compute_profile_test.rb +3 -1
- data/test/functional/host_test.rb +0 -1
- data/test/functional/hostgroup/create_test.rb +0 -117
- data/test/functional/hostgroup/update_test.rb +0 -79
- data/test/functional/location_test.rb +0 -3
- data/test/functional/mail_notification_test.rb +3 -1
- data/test/functional/model_test.rb +3 -1
- data/test/functional/operating_system_test.rb +3 -1
- data/test/functional/settings_test.rb +4 -4
- data/test/functional/template_test.rb +4 -37
- data/test/functional/usergroup_test.rb +3 -1
- data/test/unit/apipie_resource_mock.rb +1 -39
- data/test/unit/architecture_test.rb +10 -10
- data/test/unit/bookmark_test.rb +10 -14
- data/test/unit/compute_profile_test.rb +10 -10
- data/test/unit/helpers/command.rb +0 -8
- data/test/unit/host_test.rb +14 -61
- data/test/unit/hostgroup_test.rb +7 -26
- data/test/unit/id_resolver_test.rb +0 -28
- data/test/unit/mail_notification_test.rb +4 -4
- data/test/unit/model_test.rb +47 -47
- data/test/unit/operating_system_test.rb +10 -16
- data/test/unit/option_sources/id_params_test.rb +9 -0
- data/test/unit/option_sources/ids_params_test.rb +9 -0
- data/test/unit/settings_test.rb +4 -4
- data/test/unit/smart_proxy_test.rb +0 -12
- data/test/unit/usergroup_test.rb +10 -10
- metadata +64 -85
- data/lib/hammer_cli_foreman/command_extensions/puppet_environment.rb +0 -29
- data/lib/hammer_cli_foreman/command_extensions/puppet_environments.rb +0 -29
- data/lib/hammer_cli_foreman/config_group.rb +0 -45
- data/lib/hammer_cli_foreman/option_sources/puppet_environment_params.rb +0 -59
- data/lib/hammer_cli_foreman/puppet_class.rb +0 -61
- data/lib/hammer_cli_foreman/puppet_environment.rb +0 -65
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +0 -189
- data/test/functional/config_group_test.rb +0 -50
- data/test/functional/proxy_test.rb +0 -86
- data/test/functional/smart_class_parameter_test.rb +0 -97
- data/test/unit/config_group_test.rb +0 -82
- data/test/unit/puppet_class_test.rb +0 -72
- data/test/unit/puppet_environment_test.rb +0 -114
- data/test/unit/smart_class_parameter_test.rb +0 -113
@@ -14,22 +14,6 @@ module HammerCLIForeman
|
|
14
14
|
base.option "--ask-root-password", "ASK_ROOT_PW", " ",
|
15
15
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
16
16
|
|
17
|
-
base.option '--puppet-proxy', 'PUPPET_PROXY_NAME', '',
|
18
|
-
referenced_resource: 'puppet_proxy',
|
19
|
-
aliased_resource: 'puppet_proxy'
|
20
|
-
base.option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', '',
|
21
|
-
referenced_resource: 'puppet_ca_proxy',
|
22
|
-
aliased_resource: 'puppet_ca_proxy'
|
23
|
-
base.option_family(
|
24
|
-
format: HammerCLI::Options::Normalizers::List.new,
|
25
|
-
aliased_resource: 'puppet-class',
|
26
|
-
description: 'Names/Ids of associated puppet classes'
|
27
|
-
) do
|
28
|
-
parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', '',
|
29
|
-
attribute_name: :option_puppetclass_ids
|
30
|
-
child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
|
31
|
-
attribute_name: :option_puppetclass_names
|
32
|
-
end
|
33
17
|
bme_options = {}
|
34
18
|
bme_options[:default] = 'true' if base.action.to_sym == :create
|
35
19
|
|
@@ -56,7 +40,7 @@ module HammerCLIForeman
|
|
56
40
|
:capabilities, :flavour_ref, :image_ref, :start,
|
57
41
|
:network, :cpus, :memory, :provider, :type, :tenant_id, :image_id,
|
58
42
|
# ----------------------------------------------------------------------------------
|
59
|
-
:
|
43
|
+
:host_parameters_attributes, :interfaces_attributes, :root_pass]
|
60
44
|
end
|
61
45
|
|
62
46
|
def self.ask_password
|
@@ -69,12 +53,6 @@ module HammerCLIForeman
|
|
69
53
|
owner_id = owner_id(option_user_login, params['host']['owner_type'])
|
70
54
|
params['host']['owner_id'] ||= owner_id unless owner_id.nil?
|
71
55
|
|
72
|
-
puppet_proxy_id = proxy_id(option_puppet_proxy)
|
73
|
-
params['host']['puppet_proxy_id'] ||= puppet_proxy_id unless puppet_proxy_id.nil?
|
74
|
-
|
75
|
-
puppet_ca_proxy_id = proxy_id(option_puppet_ca_proxy)
|
76
|
-
params['host']['puppet_ca_proxy_id'] ||= puppet_ca_proxy_id unless puppet_ca_proxy_id.nil?
|
77
|
-
|
78
56
|
if action == :create
|
79
57
|
params['host']['build'] = true if option_build.nil?
|
80
58
|
params['host']['managed'] = true if option_managed.nil?
|
@@ -42,8 +42,6 @@ module HammerCLIForeman
|
|
42
42
|
:compute_resource => [ s_name(_("Compute resource name")) ],
|
43
43
|
:compute_profile => [ s_name(_("Compute profile name")) ],
|
44
44
|
:domain => [ s_name(_("Domain name")) ],
|
45
|
-
:environment => [s_name(_('Puppet environment name'))],
|
46
|
-
:puppet_environment => [s_name(_('Puppet environment name'))],
|
47
45
|
:fact_value => [],
|
48
46
|
:filter => [],
|
49
47
|
:host => [ s_name(_("Host name")) ],
|
@@ -66,7 +64,6 @@ module HammerCLIForeman
|
|
66
64
|
:override_value => [],
|
67
65
|
:ptable => [ s_name(_("Partition table name")) ],
|
68
66
|
:proxy => [ s_name(_("Proxy name")) ],
|
69
|
-
:puppetclass => [ s_name(_("Puppet class name")) ],
|
70
67
|
:config_report => [],
|
71
68
|
:role => [ s_name(_("User role name")) ],
|
72
69
|
:setting => [ s_name(_("Setting name"), :editable => false) ],
|
@@ -74,7 +71,6 @@ module HammerCLIForeman
|
|
74
71
|
:template => [],
|
75
72
|
:user => [ s("login", _("User's login to search by")) ],
|
76
73
|
:common_parameter => [ s_name(_("Common parameter name")) ],
|
77
|
-
:smart_class_parameter => [ s_name(_("Smart class parameter name"), :editable => false) ],
|
78
74
|
:template_combination => [],
|
79
75
|
:compute_attribute => []
|
80
76
|
}
|
@@ -129,44 +125,6 @@ module HammerCLIForeman
|
|
129
125
|
scoped_options
|
130
126
|
end
|
131
127
|
|
132
|
-
def puppetclass_ids(options)
|
133
|
-
resource_name = :puppetclasses
|
134
|
-
resource = @api.resource(resource_name)
|
135
|
-
results = if (ids = options[HammerCLI.option_accessor_name("ids")])
|
136
|
-
ids
|
137
|
-
elsif (ids = nil_from_searchables(resource_name, options, :plural => true))
|
138
|
-
ids
|
139
|
-
elsif options_not_set?(resource, options)
|
140
|
-
raise MissingSearchOptions.new(_("Missing options to search %s") % resource.name, resource)
|
141
|
-
elsif options_empty?(resource, options)
|
142
|
-
[]
|
143
|
-
else
|
144
|
-
require('hammer_cli_foreman/puppet_class')
|
145
|
-
results = HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(
|
146
|
-
resolved_call(resource_name, :index, options, :multi)
|
147
|
-
)
|
148
|
-
raise ResolverError.new(_("one of %s not found.") % resource.name, resource) if results.count < expected_record_count(options, resource, :multi)
|
149
|
-
|
150
|
-
results.map { |r| r['id'] }
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def environment_id(options)
|
155
|
-
puppet_environment_id(options)
|
156
|
-
end
|
157
|
-
|
158
|
-
def puppet_environment_id(options)
|
159
|
-
get_id(:environments, options)
|
160
|
-
end
|
161
|
-
|
162
|
-
def environment_ids(options)
|
163
|
-
puppet_environment_ids(options)
|
164
|
-
end
|
165
|
-
|
166
|
-
def puppet_environment_ids(options)
|
167
|
-
get_ids(:environments, options)
|
168
|
-
end
|
169
|
-
|
170
128
|
def searchables(resource)
|
171
129
|
resource = @api.resource(resource) if resource.is_a? Symbol
|
172
130
|
@searchables.for(resource)
|
@@ -331,17 +289,6 @@ module HammerCLIForeman
|
|
331
289
|
0
|
332
290
|
end
|
333
291
|
|
334
|
-
# puppet class search results are in non-standard format
|
335
|
-
# and needs to be un-hashed first
|
336
|
-
def puppetclass_id(options)
|
337
|
-
return options[HammerCLI.option_accessor_name("id")] if options[HammerCLI.option_accessor_name("id")]
|
338
|
-
resource = @api.resource(:puppetclasses)
|
339
|
-
results = find_resource_raw(:puppetclasses, options)
|
340
|
-
require('hammer_cli_foreman/puppet_class')
|
341
|
-
results = HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(results)
|
342
|
-
pick_result(results, resource)['id']
|
343
|
-
end
|
344
|
-
|
345
292
|
def options_empty?(resource, options)
|
346
293
|
searchables(resource).all? do |s|
|
347
294
|
values = options[HammerCLI.option_accessor_name(s.plural_name.to_s)]
|
@@ -356,14 +303,6 @@ module HammerCLIForeman
|
|
356
303
|
end
|
357
304
|
end
|
358
305
|
|
359
|
-
def create_smart_class_parameters_search_options(options, mode = nil)
|
360
|
-
search_options = {}
|
361
|
-
value = options[HammerCLI.option_accessor_name('name')]
|
362
|
-
search_options[:search] = "key = \"#{value}\""
|
363
|
-
search_options[:puppetclass_id] = puppetclass_id(scoped_options("puppetclass", options))
|
364
|
-
search_options
|
365
|
-
end
|
366
|
-
|
367
306
|
# @param mode [Symbol] mode in which ids are searched :single, :multi, nil for old beahvior
|
368
307
|
def create_search_options(options, resource, mode = nil)
|
369
308
|
searchables(resource).each do |s|
|
@@ -36,7 +36,6 @@ module HammerCLIForeman
|
|
36
36
|
HammerCLIForeman::References.partition_tables(self)
|
37
37
|
HammerCLIForeman::References.domains(self)
|
38
38
|
HammerCLIForeman::References.realms(self)
|
39
|
-
HammerCLIForeman::References.environments(self)
|
40
39
|
HammerCLIForeman::References.hostgroups(self)
|
41
40
|
HammerCLIForeman::References.parameters(self)
|
42
41
|
collection :organizations, _("Organizations"), :numbered => false, :hide_blank => true do
|
@@ -58,8 +57,6 @@ module HammerCLIForeman
|
|
58
57
|
failure_message _("Could not create the location")
|
59
58
|
|
60
59
|
build_options
|
61
|
-
|
62
|
-
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironments.new)
|
63
60
|
end
|
64
61
|
|
65
62
|
|
@@ -72,8 +69,6 @@ module HammerCLIForeman
|
|
72
69
|
failure_message _("Could not update the location")
|
73
70
|
|
74
71
|
build_options
|
75
|
-
|
76
|
-
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironments.new)
|
77
72
|
end
|
78
73
|
|
79
74
|
|
@@ -112,7 +107,6 @@ module HammerCLIForeman
|
|
112
107
|
end
|
113
108
|
|
114
109
|
HammerCLIForeman::AssociatingCommands::Hostgroup.extend_command(self)
|
115
|
-
HammerCLIForeman::AssociatingCommands::PuppetEnvironment.extend_command(self)
|
116
110
|
HammerCLIForeman::AssociatingCommands::Domain.extend_command(self)
|
117
111
|
HammerCLIForeman::AssociatingCommands::Medium.extend_command(self)
|
118
112
|
HammerCLIForeman::AssociatingCommands::Subnet.extend_command(self)
|
@@ -11,7 +11,7 @@ module HammerCLIForeman
|
|
11
11
|
field :name, _("Name")
|
12
12
|
end
|
13
13
|
|
14
|
-
build_options
|
14
|
+
build_options
|
15
15
|
end
|
16
16
|
|
17
17
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
@@ -22,7 +22,7 @@ module HammerCLIForeman
|
|
22
22
|
field :subscription_type, _("Subscription type")
|
23
23
|
end
|
24
24
|
|
25
|
-
build_options
|
25
|
+
build_options
|
26
26
|
end
|
27
27
|
|
28
28
|
autoload_subcommands
|
@@ -13,7 +13,7 @@ module HammerCLIForeman
|
|
13
13
|
field :hardware_model, _("HW model")
|
14
14
|
end
|
15
15
|
|
16
|
-
build_options
|
16
|
+
build_options
|
17
17
|
end
|
18
18
|
|
19
19
|
|
@@ -23,7 +23,7 @@ module HammerCLIForeman
|
|
23
23
|
HammerCLIForeman::References.timestamps(self)
|
24
24
|
end
|
25
25
|
|
26
|
-
build_options
|
26
|
+
build_options
|
27
27
|
end
|
28
28
|
|
29
29
|
|
@@ -31,14 +31,14 @@ module HammerCLIForeman
|
|
31
31
|
success_message _("Hardware model created.")
|
32
32
|
failure_message _("Could not create the hardware model")
|
33
33
|
|
34
|
-
build_options
|
34
|
+
build_options
|
35
35
|
end
|
36
36
|
|
37
37
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
38
38
|
success_message _("Hardware model deleted.")
|
39
39
|
failure_message _("Could not delete the hardware model")
|
40
40
|
|
41
|
-
build_options
|
41
|
+
build_options
|
42
42
|
end
|
43
43
|
|
44
44
|
|
@@ -46,7 +46,7 @@ module HammerCLIForeman
|
|
46
46
|
success_message _("Hardware model updated.")
|
47
47
|
failure_message _("Could not update the hardware model")
|
48
48
|
|
49
|
-
build_options
|
49
|
+
build_options
|
50
50
|
end
|
51
51
|
|
52
52
|
|
@@ -13,7 +13,7 @@ module HammerCLIForeman
|
|
13
13
|
field :family, _("Family")
|
14
14
|
end
|
15
15
|
|
16
|
-
build_options
|
16
|
+
build_options
|
17
17
|
end
|
18
18
|
|
19
19
|
|
@@ -36,7 +36,7 @@ module HammerCLIForeman
|
|
36
36
|
HammerCLIForeman::References.parameters(self)
|
37
37
|
end
|
38
38
|
|
39
|
-
build_options
|
39
|
+
build_options
|
40
40
|
end
|
41
41
|
|
42
42
|
|
@@ -44,7 +44,7 @@ module HammerCLIForeman
|
|
44
44
|
success_message _("Operating system created.")
|
45
45
|
failure_message _("Could not create the operating system")
|
46
46
|
|
47
|
-
build_options
|
47
|
+
build_options
|
48
48
|
end
|
49
49
|
|
50
50
|
|
@@ -52,7 +52,7 @@ module HammerCLIForeman
|
|
52
52
|
success_message _("Operating system updated.")
|
53
53
|
failure_message _("Could not update the operating system")
|
54
54
|
|
55
|
-
build_options
|
55
|
+
build_options
|
56
56
|
end
|
57
57
|
|
58
58
|
|
@@ -60,7 +60,7 @@ module HammerCLIForeman
|
|
60
60
|
success_message _("Operating system deleted.")
|
61
61
|
failure_message _("Could not delete the operating system")
|
62
62
|
|
63
|
-
build_options
|
63
|
+
build_options
|
64
64
|
end
|
65
65
|
|
66
66
|
|
@@ -76,7 +76,7 @@ module HammerCLIForeman
|
|
76
76
|
validator.any(:option_operatingsystem_id, :option_operatingsystem_title).required
|
77
77
|
end
|
78
78
|
|
79
|
-
build_options
|
79
|
+
build_options
|
80
80
|
end
|
81
81
|
|
82
82
|
|
@@ -90,7 +90,7 @@ module HammerCLIForeman
|
|
90
90
|
validator.any(:option_operatingsystem_id, :option_operatingsystem_title).required
|
91
91
|
end
|
92
92
|
|
93
|
-
build_options
|
93
|
+
build_options
|
94
94
|
end
|
95
95
|
|
96
96
|
|
@@ -156,8 +156,8 @@ module HammerCLIForeman
|
|
156
156
|
HammerCLI::EX_OK
|
157
157
|
end
|
158
158
|
|
159
|
-
build_options
|
160
|
-
|
159
|
+
build_options without: [:template_kind_id, :type]
|
160
|
+
|
161
161
|
end
|
162
162
|
|
163
163
|
|
@@ -192,7 +192,7 @@ module HammerCLIForeman
|
|
192
192
|
{"operatingsystem_id" => option_id}
|
193
193
|
end
|
194
194
|
|
195
|
-
build_options
|
195
|
+
build_options
|
196
196
|
end
|
197
197
|
|
198
198
|
|
@@ -3,6 +3,5 @@ require 'hammer_cli_foreman/option_sources/ids_params'
|
|
3
3
|
require 'hammer_cli_foreman/option_sources/self_param'
|
4
4
|
require 'hammer_cli_foreman/option_sources/user_params'
|
5
5
|
require 'hammer_cli_foreman/option_sources/fields_params'
|
6
|
-
require 'hammer_cli_foreman/option_sources/puppet_environment_params'
|
7
6
|
require 'hammer_cli_foreman/option_sources/new_params'
|
8
7
|
require 'hammer_cli_foreman/option_sources/referenced_resource_id_params'
|
@@ -13,22 +13,39 @@ module HammerCLIForeman
|
|
13
13
|
IdParamsFilter.new(:only_required => false).for_action(@command.resource.action(@command.action))
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def needs_resolving?(param_option, param_resource, all_opts)
|
17
|
+
return false unless param_updatable?(param_resource)
|
18
|
+
|
19
|
+
searchables_set = @command.searchables.for(param_resource).any? do |s|
|
20
|
+
option = HammerCLI.option_accessor_name("#{param_resource.singular_name}_#{s.name}")
|
21
|
+
!all_opts[option].nil?
|
22
|
+
end
|
23
|
+
return all_opts[param_option].nil? unless searchables_set
|
24
|
+
|
25
|
+
# Remove set '<resource_name>_id' option to force resolving in case of
|
26
|
+
# '<resource_name>_[name|title]' was set
|
27
|
+
all_opts.delete(param_option)
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_options(_defined_options, result)
|
17
32
|
# resolve all '<resource_name>_id' parameters if they are defined as options
|
18
33
|
# (they can be skipped using .without or .expand.except)
|
19
34
|
return result if @command.action.nil?
|
35
|
+
|
20
36
|
available_id_params.each do |api_param|
|
21
37
|
param_resource = HammerCLIForeman.param_to_resource(api_param.name)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
38
|
+
param_option = HammerCLI.option_accessor_name(api_param.name)
|
39
|
+
next unless needs_resolving?(param_option, param_resource, result)
|
40
|
+
|
41
|
+
resource_id = @command.get_resource_id(
|
42
|
+
param_resource, scoped: true, required: api_param.required?, all_options: result
|
43
|
+
)
|
44
|
+
result[param_option] = resource_id if resource_id
|
26
45
|
end
|
27
46
|
result
|
28
|
-
|
29
47
|
rescue HammerCLIForeman::MissingSearchOptions => e
|
30
|
-
|
31
|
-
switches = @command.class.find_options(:referenced_resource => e.resource.singular_name).map(&:long_switch)
|
48
|
+
switches = @command.class.find_options(referenced_resource: e.resource.singular_name).map(&:long_switch)
|
32
49
|
|
33
50
|
if switches.empty?
|
34
51
|
error_message = _("Could not find %{resource}. Some search options were missing, please see --help.")
|
@@ -40,8 +57,8 @@ module HammerCLIForeman
|
|
40
57
|
|
41
58
|
raise MissingSearchOptions.new(
|
42
59
|
error_message % {
|
43
|
-
:
|
44
|
-
:
|
60
|
+
resource: e.resource.singular_name,
|
61
|
+
switches: switches.join(', ')
|
45
62
|
},
|
46
63
|
e.resource
|
47
64
|
)
|
@@ -13,15 +13,34 @@ module HammerCLIForeman
|
|
13
13
|
IdArrayParamsFilter.new(:only_required => false).for_action(@command.resource.action(@command.action))
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
return
|
16
|
+
def needs_resolving?(param_option, param_resource, all_opts)
|
17
|
+
return false unless param_updatable?(param_resource)
|
18
|
+
|
19
|
+
searchables_set = @command.searchables.for(param_resource).any? do |s|
|
20
|
+
option = HammerCLI.option_accessor_name("#{param_resource.singular_name}_#{s.plural_name}")
|
21
|
+
!all_opts[option].nil?
|
22
|
+
end
|
23
|
+
return all_opts[param_option].nil? unless searchables_set
|
24
|
+
|
25
|
+
# Remove set '<resource_name>_ids' option to force resolving in case of
|
26
|
+
# '<resource_name>_[names|titles]' was set
|
27
|
+
all_opts.delete(param_option)
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_options(_defined_options, result)
|
18
32
|
# resolve all '<resource_name>_ids' parameters if they are defined as options
|
33
|
+
return result if @command.action.nil?
|
34
|
+
|
19
35
|
available_ids_params.each do |api_param|
|
20
36
|
param_resource = HammerCLIForeman.param_to_resource(api_param.name)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
37
|
+
param_option = HammerCLI.option_accessor_name(api_param.name)
|
38
|
+
next unless needs_resolving?(param_option, param_resource, result)
|
39
|
+
|
40
|
+
resource_ids = @command.get_resource_ids(
|
41
|
+
param_resource, scoped: true, required: api_param.required?, all_options: result
|
42
|
+
)
|
43
|
+
result[param_option] = resource_ids if resource_ids
|
25
44
|
end
|
26
45
|
result
|
27
46
|
end
|
@@ -36,7 +36,6 @@ module HammerCLIForeman
|
|
36
36
|
HammerCLIForeman::References.partition_tables(self)
|
37
37
|
HammerCLIForeman::References.domains(self)
|
38
38
|
HammerCLIForeman::References.realms(self)
|
39
|
-
HammerCLIForeman::References.environments(self)
|
40
39
|
HammerCLIForeman::References.hostgroups(self)
|
41
40
|
HammerCLIForeman::References.parameters(self)
|
42
41
|
collection :locations, _("Locations"), :numbered => false, :hide_blank => true do
|
@@ -59,8 +58,6 @@ module HammerCLIForeman
|
|
59
58
|
failure_message _("Could not create the organization")
|
60
59
|
|
61
60
|
build_options
|
62
|
-
|
63
|
-
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironments.new)
|
64
61
|
end
|
65
62
|
|
66
63
|
|
@@ -73,8 +70,6 @@ module HammerCLIForeman
|
|
73
70
|
failure_message _("Could not update the organization")
|
74
71
|
|
75
72
|
build_options
|
76
|
-
|
77
|
-
extend_with(HammerCLIForeman::CommandExtensions::PuppetEnvironments.new)
|
78
73
|
end
|
79
74
|
|
80
75
|
|
@@ -114,7 +109,6 @@ module HammerCLIForeman
|
|
114
109
|
|
115
110
|
|
116
111
|
HammerCLIForeman::AssociatingCommands::Hostgroup.extend_command(self)
|
117
|
-
HammerCLIForeman::AssociatingCommands::PuppetEnvironment.extend_command(self)
|
118
112
|
HammerCLIForeman::AssociatingCommands::Domain.extend_command(self)
|
119
113
|
HammerCLIForeman::AssociatingCommands::Medium.extend_command(self)
|
120
114
|
HammerCLIForeman::AssociatingCommands::Subnet.extend_command(self)
|