hammer_cli_katello 1.1.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/command_extensions/content_source.rb +32 -0
  3. data/lib/hammer_cli_katello/command_extensions/kickstart_repository.rb +50 -0
  4. data/lib/hammer_cli_katello/command_extensions/lifecycle_environment.rb +12 -0
  5. data/lib/hammer_cli_katello/command_extensions.rb +2 -0
  6. data/lib/hammer_cli_katello/commands.rb +1 -1
  7. data/lib/hammer_cli_katello/content_export_helper.rb +6 -2
  8. data/lib/hammer_cli_katello/content_view.rb +11 -0
  9. data/lib/hammer_cli_katello/content_view_version.rb +3 -3
  10. data/lib/hammer_cli_katello/host_collection.rb +6 -0
  11. data/lib/hammer_cli_katello/host_collection_erratum.rb +10 -0
  12. data/lib/hammer_cli_katello/host_collection_package.rb +30 -0
  13. data/lib/hammer_cli_katello/host_collection_package_group.rb +30 -0
  14. data/lib/hammer_cli_katello/host_errata.rb +10 -3
  15. data/lib/hammer_cli_katello/host_extensions.rb +8 -6
  16. data/lib/hammer_cli_katello/host_package.rb +32 -0
  17. data/lib/hammer_cli_katello/host_package_group.rb +16 -0
  18. data/lib/hammer_cli_katello/hostgroup_extensions.rb +19 -12
  19. data/lib/hammer_cli_katello/id_resolver.rb +5 -2
  20. data/lib/hammer_cli_katello/option_sources/lifecycle_environment_params.rb +40 -3
  21. data/lib/hammer_cli_katello/organization.rb +28 -3
  22. data/lib/hammer_cli_katello/package.rb +2 -1
  23. data/lib/hammer_cli_katello/ping.rb +7 -0
  24. data/lib/hammer_cli_katello/repository.rb +10 -31
  25. data/lib/hammer_cli_katello/search_options_creators.rb +2 -1
  26. data/lib/hammer_cli_katello/srpm.rb +2 -0
  27. data/lib/hammer_cli_katello/version.rb +1 -1
  28. data/test/data/4.3/foreman_api.json +1 -0
  29. data/test/functional/activation_key/create_test.rb +1 -1
  30. data/test/functional/activation_key/subscriptions_test.rb +1 -1
  31. data/test/functional/content_view/version/promote_test.rb +41 -0
  32. data/test/functional/content_view/version/republish_repositories_test.rb +1 -1
  33. data/test/functional/host/errata/recalculate_test.rb +8 -22
  34. data/test/functional/host_collection/create_test.rb +11 -0
  35. data/test/functional/module_stream/info_test.rb +1 -1
  36. data/test/functional/organization/cdn_configuration_test.rb +42 -0
  37. data/test/functional/organization/info_test.rb +17 -0
  38. data/test/functional/package/list_test.rb +4 -2
  39. data/test/functional/ping_test.rb +3 -1
  40. data/test/functional/srpm/list_test.rb +1 -1
  41. data/test/functional/subscription/list_test.rb +2 -2
  42. data/test/test_helper.rb +1 -1
  43. metadata +9 -7
  44. data/lib/hammer_cli_katello/host_content_source_options.rb +0 -28
  45. data/lib/hammer_cli_katello/host_kickstart_repository_options.rb +0 -49
  46. data/test/functional/repository/export_test.rb +0 -121
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3483ffbc44017985f8c8c9666c516f16da1de0d56eb29cac303a0a25eddb1aec
4
- data.tar.gz: 430de6ef3e6507a77403c6ec2087d3a14d9e0ba44e7f05a1cd8700dd50370eca
3
+ metadata.gz: 70bd64a3e1a162fa1c50c097a5f6c60cff91f6764a91aa715f575387bc02406c
4
+ data.tar.gz: 9b75290d2868faa302f15f23022bf310ca7f091ec819da5eba988abb17adda4d
5
5
  SHA512:
6
- metadata.gz: 337f924bfdba710b2c1cd0246197167a03a122e6409ae7efb91fc4f3c9ee3a2131dead8e6533b78b9adc9f67df37011ec552e8a05b77eff1d03e8179a533a984
7
- data.tar.gz: 3e8e5ae66a229f028c0134afc1ddf24624260e9202d16443d6a3d80d95ae2d42ae0074000f263abe63278103750785b6d7e5b0947e7d8047fad347b7b381d157
6
+ metadata.gz: 0b5ab6e3272b3336bb11ca0b0e200fab63654f90bdafc5c213807fb9928da84e377132a408f826a58b8b58d2d55d9fa5f8b142284ff8f0f310b74b72cfd18ec7
7
+ data.tar.gz: a114e7f127f3418cadf0a7f9e06a728a6837013eac2245fe4ca49836441486cb7599146a027f22559376fa0ecaf3f44ecd1a5a587f97a9bc0e19b44e62bc8465
@@ -0,0 +1,32 @@
1
+ module HammerCLIKatello
2
+ module CommandExtensions
3
+ class ContentSource < HammerCLI::CommandExtensions
4
+ option_family associate: 'content_source' do
5
+ child '--content-source', 'CONTENT_SOURCE_NAME', _('Content Source name'),
6
+ attribute_name: :option_content_source,
7
+ referenced_resource: :smart_proxy
8
+ end
9
+
10
+ request_params do |params, cmd_obj|
11
+ begin
12
+ resource_name = cmd_obj.resource.singular_name
13
+ if cmd_obj.option_content_source && !cmd_obj.option_content_source_id
14
+ resource_hash = if resource_name == 'hostgroup'
15
+ params[resource_name]
16
+ else
17
+ params[resource_name]['content_facet_attributes']
18
+ end
19
+
20
+ proxy_options = {
21
+ HammerCLI.option_accessor_name('name') => cmd_obj.option_content_source
22
+ }
23
+ resource_hash['content_source_id'] = cmd_obj.resolver.smart_proxy_id(proxy_options)
24
+ end
25
+ rescue HammerCLIForeman::ResolverError => e
26
+ e.message.gsub!('smart_proxy', _('Content Source'))
27
+ raise e
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,50 @@
1
+ module HammerCLIKatello
2
+ module CommandExtensions
3
+ class KickstartRepository < HammerCLI::CommandExtensions
4
+ option_family associate: 'kickstart_repository' do
5
+ child '--kickstart-repository', 'REPOSITORY_NAME', _('Kickstart repository name'),
6
+ attribute_name: :option_kickstart_repository
7
+ end
8
+
9
+ request_params do |params, cmd_obj|
10
+ resource_name = cmd_obj.resource.singular_name
11
+ if cmd_obj.option_kickstart_repository && !cmd_obj.option_kickstart_repository_id
12
+ resource_hash = if resource_name == 'hostgroup'
13
+ params[resource_name]
14
+ else
15
+ params[resource_name]['content_facet_attributes']
16
+ end
17
+
18
+ resource_hash ||= {}
19
+
20
+ env_id = resource_hash['lifecycle_environment_id']
21
+ cv_id = resource_hash['content_view_id']
22
+
23
+ raise _('Please provide --lifecycle-environment-id') unless env_id
24
+
25
+ raise _('Please provide --content-view-id') unless cv_id
26
+ # rubocop:disable LineLength
27
+ resource_hash['kickstart_repository_id'] = HammerCLIKatello::CommandExtensions::KickstartRepository.fetch_repo_id(
28
+ cv_id, env_id, cmd_obj.option_kickstart_repository
29
+ )
30
+ # rubocop:enable LineLength
31
+ end
32
+ end
33
+
34
+ def self.fetch_repo_id(cv_id, env_id, repo_name)
35
+ repo_resource = HammerCLIForeman.foreman_resource(:repositories)
36
+ index_options = {
37
+ content_view_id: cv_id,
38
+ environment_id: env_id,
39
+ name: repo_name
40
+ }
41
+ repos = repo_resource.call(:index, index_options)['results']
42
+ if repos.empty?
43
+ raise _("No such repository with name %{name}, in lifecycle environment"\
44
+ " %{environment_id} and content view %{content_view_id}" % index_options)
45
+ end
46
+ repos.first['id']
47
+ end
48
+ end
49
+ end
50
+ end
@@ -13,6 +13,18 @@ module HammerCLIKatello
13
13
  attribute_name: :option_environment_id
14
14
  end
15
15
 
16
+ # Add explicitly defined options since option builder won't be
17
+ # able to create options automatically in case there is missing resource
18
+ # in API docs or if the resource name is different
19
+ # (e.g. environment instead of lifecycle_environment)
20
+ # This can happen if API docs contain a param which cannot be mapped
21
+ # via param_name to resource_name mapping
22
+ option_family associate: 'lifecycle_environment' do
23
+ child '--lifecycle-environment', 'ENVIRONMENT_NAME',
24
+ _('Lifecycle environment name to search by'),
25
+ attribute_name: :option_environment_name
26
+ end
27
+
16
28
  option_sources do |sources, command|
17
29
  sources.find_by_name('IdResolution').insert_relative(
18
30
  :after,
@@ -3,3 +3,5 @@
3
3
  require 'hammer_cli_katello/command_extensions/lifecycle_environment'
4
4
  require 'hammer_cli_katello/command_extensions/lifecycle_environments'
5
5
  require 'hammer_cli_katello/command_extensions/ping'
6
+ require 'hammer_cli_katello/command_extensions/content_source'
7
+ require 'hammer_cli_katello/command_extensions/kickstart_repository'
@@ -36,7 +36,7 @@ module HammerCLIKatello
36
36
  end
37
37
 
38
38
  def resource_name_mapping
39
- HammerCLIKatello::RESOURCE_NAME_MAPPING.dup
39
+ super.merge(HammerCLIKatello::RESOURCE_NAME_MAPPING.dup)
40
40
  end
41
41
  end
42
42
  end
@@ -162,14 +162,18 @@ module HammerCLIKatello
162
162
  :required => false
163
163
 
164
164
  base.build_options do |o|
165
- o.expand(:all).including(:content_views, :organizations, :environments)
165
+ o.expand(:all).including(:content_views, :organizations, :lifecycle_environments)
166
166
  o.without(:environment_ids, :environment_id)
167
167
  end
168
168
 
169
169
  base.validate_options do
170
170
  unless option(:option_id).exist?
171
171
  any(:option_id, :option_content_view_name, :option_content_view_id).required
172
- any(:option_version, :option_environment_id, :option_environment_name).required
172
+ any(
173
+ :option_version,
174
+ :option_lifecycle_environment_id,
175
+ :option_lifecycle_environment_name
176
+ ).required
173
177
  unless option(:option_content_view_id).exist?
174
178
  any(:option_organization_id, :option_organization_name, \
175
179
  :option_organization_label).required
@@ -197,6 +197,17 @@ module HammerCLIKatello
197
197
  failure_message _("Could not publish the content view")
198
198
 
199
199
  build_options
200
+
201
+ option_family associate: 'lifecycle_environment' do
202
+ child '--lifecycle-environments', 'LIFECYCLE_ENVIRONMENT_NAMES',
203
+ _('Names for Lifecycle Environment'),
204
+ format: HammerCLI::Options::Normalizers::List.new,
205
+ attribute_name: :option_environment_names
206
+ end
207
+
208
+ extend_with(
209
+ HammerCLIKatello::CommandExtensions::LifecycleEnvironments.new(only: :option_sources)
210
+ )
200
211
  end
201
212
 
202
213
  class RemoveFromEnvironmentCommand < HammerCLIKatello::SingleResourceCommand
@@ -60,7 +60,7 @@ module HammerCLIKatello
60
60
  end
61
61
 
62
62
  build_options do |o|
63
- o.expand(:all).including(:environments, :content_views, :organizations)
63
+ o.expand(:all).including(:lifecycle_environments, :content_views, :organizations)
64
64
  end
65
65
 
66
66
  extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
@@ -143,7 +143,7 @@ module HammerCLIKatello
143
143
  failure_message _("Could not delete the content view")
144
144
 
145
145
  build_options do |o|
146
- o.expand(:all).including(:environments, :content_views, :organizations)
146
+ o.expand(:all).including(:lifecycle_environments, :content_views, :organizations)
147
147
  end
148
148
 
149
149
  extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
@@ -157,7 +157,7 @@ module HammerCLIKatello
157
157
  failure_message _("Could not update the content view version")
158
158
 
159
159
  build_options do |o|
160
- o.expand(:all).including(:environments, :content_views, :organizations)
160
+ o.expand(:all).including(:lifecycle_environments, :content_views, :organizations)
161
161
  end
162
162
 
163
163
  extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
@@ -50,6 +50,12 @@ module HammerCLIKatello
50
50
  success_message _("Host collection created.")
51
51
  failure_message _("Could not create the host collection")
52
52
 
53
+ option "--unlimited-hosts", :flag, "Set hosts max to unlimited"
54
+
55
+ validate_options :before, 'IdResolution' do
56
+ all(:option_unlimited_hosts, :option_max_hosts).rejected
57
+ end
58
+
53
59
  build_options
54
60
  end
55
61
 
@@ -15,6 +15,16 @@ module HammerCLIKatello
15
15
  :format => HammerCLI::Options::Normalizers::List.new,
16
16
  :attribute_name => :content)
17
17
 
18
+ def execute
19
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
20
+ "in a future release."
21
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
22
+ "katello_errata_install`. Specify the host collection with the --search-query " \
23
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
24
+ "`--search-query \"host_collection_id=6\"`."
25
+ super
26
+ end
27
+
18
28
  def content_type
19
29
  'errata'
20
30
  end
@@ -23,6 +23,16 @@ module HammerCLIKatello
23
23
  desc _("Install packages on content hosts contained within a host collection")
24
24
  success_message _("Successfully scheduled installation of package(s).")
25
25
  failure_message _("Could not schedule installation of package(s)")
26
+
27
+ def execute
28
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
29
+ "in a future release."
30
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
31
+ "katello_package_install`. Specify the host collection with the --search-query " \
32
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
33
+ "`--search-query \"host_collection_id=6\"`."
34
+ super
35
+ end
26
36
  end
27
37
 
28
38
  class UpdateCommand < HammerCLIKatello::HostCollection::UpdateContentBaseCommand
@@ -30,6 +40,16 @@ module HammerCLIKatello
30
40
  desc _("Update packages on content hosts contained within a host collection")
31
41
  success_message _("Successfully scheduled update of package(s).")
32
42
  failure_message _("Could not schedule update of package(s)")
43
+
44
+ def execute
45
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
46
+ "in a future release."
47
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
48
+ "katello_package_update`. Specify the host collection with the --search-query " \
49
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
50
+ "`--search-query \"host_collection_id=6\"`."
51
+ super
52
+ end
33
53
  end
34
54
 
35
55
  class RemoveCommand < HammerCLIKatello::HostCollection::RemoveContentBaseCommand
@@ -37,6 +57,16 @@ module HammerCLIKatello
37
57
  desc _("Remove packages on content hosts contained within a host collection")
38
58
  success_message _("Successfully scheduled removal of package(s).")
39
59
  failure_message _("Could not schedule removal of package(s)")
60
+
61
+ def execute
62
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
63
+ "in a future release."
64
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
65
+ "katello_package_remove`. Specify the host collection with the --search-query " \
66
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
67
+ "`--search-query \"host_collection_id=6\"`."
68
+ super
69
+ end
40
70
  end
41
71
 
42
72
  autoload_subcommands
@@ -23,6 +23,16 @@ module HammerCLIKatello
23
23
  desc _("Install package-groups on content hosts contained within a host collection")
24
24
  success_message _("Successfully scheduled installation of package-group(s).")
25
25
  failure_message _("Could not schedule installation of package-group(s)")
26
+
27
+ def execute
28
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
29
+ "in a future release."
30
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
31
+ "katello_group_install`. Specify the host collection with the --search-query " \
32
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
33
+ "`--search-query \"host_collection_id=6\"`."
34
+ super
35
+ end
26
36
  end
27
37
 
28
38
  class UpdateCommand < HammerCLIKatello::HostCollection::UpdateContentBaseCommand
@@ -30,6 +40,16 @@ module HammerCLIKatello
30
40
  desc _("Update package-groups on content hosts contained within a host collection")
31
41
  success_message _("Successfully scheduled update of package-groups(s).")
32
42
  failure_message _("Could not schedule update of package-group(s)")
43
+
44
+ def execute
45
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
46
+ "in a future release."
47
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
48
+ "katello_group_update`. Specify the host collection with the --search-query " \
49
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
50
+ "`--search-query \"host_collection_id=6\"`."
51
+ super
52
+ end
33
53
  end
34
54
 
35
55
  class RemoveCommand < HammerCLIKatello::HostCollection::RemoveContentBaseCommand
@@ -37,6 +57,16 @@ module HammerCLIKatello
37
57
  desc _("Remove package-groups on content hosts contained within a host collection")
38
58
  success_message _("Successfully scheduled removal of package-groups(s).")
39
59
  failure_message _("Could not schedule removal of package-group(s)")
60
+
61
+ def execute
62
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
63
+ "in a future release."
64
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
65
+ "katello_group_remove`. Specify the host collection with the --search-query " \
66
+ "parameter, e.g. `--search-query \"host_collection = MyCollection\"` or " \
67
+ "`--search-query \"host_collection_id=6\"`."
68
+ super
69
+ end
40
70
  end
41
71
 
42
72
  autoload_subcommands
@@ -11,7 +11,15 @@ module HammerCLIKatello
11
11
  success_message _("Errata is being applied with task %{id}.")
12
12
  failure_message _("Could not apply errata")
13
13
 
14
- build_options
14
+ build_options(without: ['ids'])
15
+
16
+ def execute
17
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
18
+ "in a future release."
19
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
20
+ "katello_errata_install`."
21
+ super
22
+ end
15
23
  end
16
24
 
17
25
  class ListCommand < HammerCLIKatello::ListCommand
@@ -38,10 +46,9 @@ module HammerCLIKatello
38
46
  end
39
47
 
40
48
  class RecalculateCommand < HammerCLIKatello::SingleResourceCommand
41
- include HammerCLIForemanTasks::Async
42
49
  resource :host_errata, :applicability
43
50
  command_name "recalculate"
44
- success_message _("Errata recalculated with task %{id}.")
51
+ success_message _("Errata recalculation started.")
45
52
  failure_message _("Could not recalculate errata")
46
53
 
47
54
  build_options
@@ -3,23 +3,25 @@ require 'hammer_cli_katello/host_errata'
3
3
  require 'hammer_cli_katello/host_subscription'
4
4
  require 'hammer_cli_katello/host_package'
5
5
  require 'hammer_cli_katello/host_package_group'
6
- require 'hammer_cli_katello/host_kickstart_repository_options'
7
- require 'hammer_cli_katello/host_content_source_options'
8
6
  require 'hammer_cli_katello/host_traces'
9
7
 
10
8
  module HammerCLIKatello
11
9
  module HostExtensions
12
10
  ::HammerCLIForeman::Host::CreateCommand.instance_eval do
13
11
  include HammerCLIKatello::ResolverCommons
14
- include HammerCLIKatello::HostContentSourceOptions
15
- include ::HammerCLIKatello::HostKickstartRepositoryOptions
16
12
  end
13
+ ::HammerCLIForeman::Host::CreateCommand.extend_with(
14
+ HammerCLIKatello::CommandExtensions::ContentSource.new,
15
+ HammerCLIKatello::CommandExtensions::KickstartRepository.new
16
+ )
17
17
 
18
18
  ::HammerCLIForeman::Host::UpdateCommand.instance_eval do
19
19
  include HammerCLIKatello::ResolverCommons
20
- include HammerCLIKatello::HostContentSourceOptions
21
- include ::HammerCLIKatello::HostKickstartRepositoryOptions
22
20
  end
21
+ ::HammerCLIForeman::Host::UpdateCommand.extend_with(
22
+ HammerCLIKatello::CommandExtensions::ContentSource.new,
23
+ HammerCLIKatello::CommandExtensions::KickstartRepository.new
24
+ )
23
25
 
24
26
  ::HammerCLIForeman::Host::ListCommand.instance_eval do
25
27
  output do
@@ -24,6 +24,14 @@ module HammerCLIKatello
24
24
  end
25
25
 
26
26
  build_options :without => [:groups]
27
+
28
+ def execute
29
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
30
+ "in a future release."
31
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
32
+ "katello_package_install`."
33
+ super
34
+ end
27
35
  end
28
36
 
29
37
  class UpgradeCommand < HammerCLIKatello::SingleResourceCommand
@@ -34,6 +42,14 @@ module HammerCLIKatello
34
42
  failure_message "Could not upgrade packages"
35
43
 
36
44
  build_options
45
+
46
+ def execute
47
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
48
+ "in a future release."
49
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
50
+ "katello_package_update`."
51
+ super
52
+ end
37
53
  end
38
54
 
39
55
  class UpgradeAllCommand < HammerCLIKatello::SingleResourceCommand
@@ -44,6 +60,14 @@ module HammerCLIKatello
44
60
  failure_message "Could not upgrade all packages"
45
61
 
46
62
  build_options
63
+
64
+ def execute
65
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
66
+ "in a future release."
67
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
68
+ "katello_package_update`."
69
+ super
70
+ end
47
71
  end
48
72
 
49
73
  class RemoveCommand < HammerCLIKatello::SingleResourceCommand
@@ -58,6 +82,14 @@ module HammerCLIKatello
58
82
  end
59
83
 
60
84
  build_options :without => [:groups]
85
+
86
+ def execute
87
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
88
+ "in a future release."
89
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
90
+ "katello_package_remove`."
91
+ super
92
+ end
61
93
  end
62
94
 
63
95
  autoload_subcommands
@@ -14,6 +14,14 @@ module HammerCLIKatello
14
14
  end
15
15
 
16
16
  build_options :without => [:packages]
17
+
18
+ def execute
19
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
20
+ "in a future release."
21
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
22
+ "katello_group_install`."
23
+ super
24
+ end
17
25
  end
18
26
 
19
27
  class RemoveCommand < HammerCLIKatello::SingleResourceCommand
@@ -28,6 +36,14 @@ module HammerCLIKatello
28
36
  end
29
37
 
30
38
  build_options :without => [:packages]
39
+
40
+ def execute
41
+ warn "This command uses katello agent and will be removed in favor of remote execution " \
42
+ "in a future release."
43
+ warn "The remote execution equivalent is `hammer job-invocation create --feature " \
44
+ "katello_group_remove`."
45
+ super
46
+ end
31
47
  end
32
48
 
33
49
  autoload_subcommands
@@ -1,16 +1,19 @@
1
1
  require 'hammer_cli_foreman/hostgroup'
2
- require 'hammer_cli_katello/host_kickstart_repository_options'
3
- require 'hammer_cli_katello/host_content_source_options'
4
2
 
5
3
  module HammerCLIKatello
6
4
  module QueryOrganizationOptions
7
5
  def self.included(base)
8
- base.option '--query-organization-id', 'ORGANIZATION_ID',
9
- _('Organization ID to search by'), attribute_name: :option_organization_id
10
- base.option '--query-organization', 'ORGANIZATION_NAME',
11
- _('Organization name to search by'), attribute_name: :option_organization_name
12
- base.option '--query-organization-label', 'ORGANIZATION_LABEL',
13
- _('Organization label to search by'), attribute_name: :option_organization_label
6
+ base.option_family do
7
+ parent '--query-organization-id', 'ORGANIZATION_ID',
8
+ _('Organization ID to search by'),
9
+ attribute_name: :option_organization_id
10
+ child '--query-organization', 'ORGANIZATION_NAME',
11
+ _('Organization name to search by'),
12
+ attribute_name: :option_organization_name
13
+ child '--query-organization-label', 'ORGANIZATION_LABEL',
14
+ _('Organization label to search by'),
15
+ attribute_name: :option_organization_label
16
+ end
14
17
 
15
18
  base.validate_options :before, 'IdResolution' do
16
19
  organization_options = [
@@ -30,17 +33,21 @@ module HammerCLIKatello
30
33
  include HammerCLIKatello::ResolverCommons
31
34
  include HammerCLIKatello::ContentViewNameResolvable
32
35
  include HammerCLIKatello::QueryOrganizationOptions
33
- include HammerCLIKatello::HostContentSourceOptions
34
- include HammerCLIKatello::HostKickstartRepositoryOptions
35
36
  end
37
+ ::HammerCLIForeman::Hostgroup::CreateCommand.extend_with(
38
+ HammerCLIKatello::CommandExtensions::ContentSource.new,
39
+ HammerCLIKatello::CommandExtensions::KickstartRepository.new
40
+ )
36
41
 
37
42
  ::HammerCLIForeman::Hostgroup::UpdateCommand.instance_eval do
38
43
  include HammerCLIKatello::ResolverCommons
39
44
  include HammerCLIKatello::ContentViewNameResolvable
40
45
  include HammerCLIKatello::QueryOrganizationOptions
41
- include HammerCLIKatello::HostContentSourceOptions
42
- include HammerCLIKatello::HostKickstartRepositoryOptions
43
46
  end
47
+ ::HammerCLIForeman::Hostgroup::UpdateCommand.extend_with(
48
+ HammerCLIKatello::CommandExtensions::ContentSource.new,
49
+ HammerCLIKatello::CommandExtensions::KickstartRepository.new
50
+ )
44
51
 
45
52
  ::HammerCLIForeman::Hostgroup::InfoCommand.instance_eval do
46
53
  output do
@@ -74,12 +74,15 @@ module HammerCLIKatello
74
74
  return options['option_lifecycle_environment_ids']
75
75
  end
76
76
 
77
- key_names = HammerCLI.option_accessor_name 'lifecycle_environment_names'
77
+ names = options[HammerCLI.option_accessor_name('lifecycle_environment_names')] ||
78
+ options[HammerCLI.option_accessor_name('environment_names')] ||
79
+ options[HammerCLI.option_accessor_name('names')]
78
80
  key_organization_id = HammerCLI.option_accessor_name 'organization_id'
79
81
  options[key_organization_id] ||= organization_id(scoped_options('organization', options))
80
82
 
83
+ options['option_lifecycle_environment_names'] = names
81
84
  find_resources(:lifecycle_environments, options)
82
- .select { |repo| options[key_names].include? repo['name'] }.map { |repo| repo['id'] }
85
+ .select { |repo| names.include? repo['name'] }.map { |repo| repo['id'] }
83
86
  end
84
87
 
85
88
  def repository_id(options)
@@ -6,15 +6,52 @@ module HammerCLIKatello
6
6
  end
7
7
 
8
8
  def get_options(_defined_options, result)
9
+ legacy_option_id(result)
10
+ legacy_option_ids(result)
11
+ ensure_option_id(result)
12
+ ensure_option_ids(result)
13
+ result
14
+ end
15
+
16
+ private
17
+
18
+ def lifecycle_environment_resource_name
19
+ (HammerCLIForeman.param_to_resource('environment') ||
20
+ HammerCLIForeman.param_to_resource('lifecycle_environment')).singular_name
21
+ end
22
+
23
+ def legacy_option_id(result)
9
24
  if result['option_environment_name'] && result['option_environment_id'].nil?
10
25
  result['option_environment_id'] = @command.resolver.lifecycle_environment_id(
11
- @command.resolver.scoped_options('environment', result, :single))
26
+ @command.resolver.scoped_options(lifecycle_environment_resource_name, result, :single))
12
27
  end
28
+ end
29
+
30
+ def legacy_option_ids(result)
13
31
  if result['option_environment_names'] && result['option_environment_ids'].nil?
14
32
  result['option_environment_ids'] = @command.resolver.lifecycle_environment_ids(
15
- @command.resolver.scoped_options('environment', result, :multi))
33
+ @command.resolver.scoped_options(lifecycle_environment_resource_name, result, :multi))
34
+ end
35
+ end
36
+
37
+ def ensure_option_id(result)
38
+ if result['option_environment_id'].nil? && result['option_lifecycle_environment_name']
39
+ id = @command.resolver.lifecycle_environment_id(
40
+ @command.resolver.scoped_options(lifecycle_environment_resource_name, result, :single)
41
+ )
42
+ result['option_environment_id'] = id
43
+ result['option_lifecycle_environment_id'] = id
44
+ end
45
+ end
46
+
47
+ def ensure_option_ids(result)
48
+ if result['option_environment_ids'].nil? && result['option_lifecycle_environment_names']
49
+ ids = @command.resolver.lifecycle_environment_ids(
50
+ @command.resolver.scoped_options(lifecycle_environment_resource_name, result, :multi)
51
+ )
52
+ result['option_environment_ids'] = ids
53
+ result['option_lifecycle_environment_ids'] = ids
16
54
  end
17
- result
18
55
  end
19
56
  end
20
57
  end