hammer_cli_katello 1.1.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) 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_units.rb +66 -0
  9. data/lib/hammer_cli_katello/content_view.rb +11 -0
  10. data/lib/hammer_cli_katello/content_view_component.rb +4 -3
  11. data/lib/hammer_cli_katello/content_view_version.rb +3 -3
  12. data/lib/hammer_cli_katello/foreman_search_options_creators.rb +0 -12
  13. data/lib/hammer_cli_katello/host_collection.rb +6 -0
  14. data/lib/hammer_cli_katello/host_errata.rb +2 -3
  15. data/lib/hammer_cli_katello/host_extensions.rb +8 -6
  16. data/lib/hammer_cli_katello/hostgroup_extensions.rb +19 -12
  17. data/lib/hammer_cli_katello/id_resolver.rb +5 -2
  18. data/lib/hammer_cli_katello/option_sources/lifecycle_environment_params.rb +40 -3
  19. data/lib/hammer_cli_katello/organization.rb +28 -3
  20. data/lib/hammer_cli_katello/package.rb +2 -1
  21. data/lib/hammer_cli_katello/ping.rb +7 -0
  22. data/lib/hammer_cli_katello/repository.rb +50 -60
  23. data/lib/hammer_cli_katello/search_options_creators.rb +2 -1
  24. data/lib/hammer_cli_katello/srpm.rb +2 -0
  25. data/lib/hammer_cli_katello/version.rb +1 -1
  26. data/lib/hammer_cli_katello.rb +5 -5
  27. data/test/data/2.5/foreman_api.json +1 -0
  28. data/test/data/3.0/foreman_api.json +1 -0
  29. data/test/data/3.10/foreman_api.json +1 -0
  30. data/test/data/3.11/foreman_api.json +1 -0
  31. data/test/data/3.12/foreman_api.json +1 -0
  32. data/test/data/3.13/foreman_api.json +1 -0
  33. data/test/data/3.14/foreman_api.json +1 -0
  34. data/test/data/3.15/foreman_api.json +1 -0
  35. data/test/data/3.16/foreman_api.json +1 -0
  36. data/test/data/3.17/foreman_api.json +1 -0
  37. data/test/data/3.18/foreman_api.json +1 -0
  38. data/test/data/3.19/foreman_api.json +1 -0
  39. data/test/data/3.2/foreman_api.json +1 -0
  40. data/test/data/3.4/foreman_api.json +1 -0
  41. data/test/data/3.5/foreman_api.json +1 -0
  42. data/test/data/3.6/foreman_api.json +1 -0
  43. data/test/data/3.7/foreman_api.json +1 -0
  44. data/test/data/3.8/foreman_api.json +1 -0
  45. data/test/data/3.9/foreman_api.json +1 -0
  46. data/test/data/4.0/foreman_api.json +1 -0
  47. data/test/data/4.1/foreman_api.json +1 -0
  48. data/test/data/4.3/foreman_api.json +1 -0
  49. data/test/data/Readme.md +5 -0
  50. data/test/functional/activation_key/add_host_collection_test.rb +62 -0
  51. data/test/functional/activation_key/content_override_test.rb +92 -0
  52. data/test/functional/activation_key/create_test.rb +33 -0
  53. data/test/functional/activation_key/data/activation_key.json +17 -0
  54. data/test/functional/activation_key/info_test.rb +29 -0
  55. data/test/functional/activation_key/list_test.rb +68 -0
  56. data/test/functional/activation_key/product_content_test.rb +23 -0
  57. data/test/functional/activation_key/remove_host_collection_test.rb +62 -0
  58. data/test/functional/activation_key/subscriptions_test.rb +74 -0
  59. data/test/functional/activation_key/update_test.rb +26 -0
  60. data/test/functional/apipie_helper_test.rb +31 -0
  61. data/test/functional/capsule/capsule_helpers.rb +13 -0
  62. data/test/functional/capsule/content/add_lifecycle_environment_test.rb +40 -0
  63. data/test/functional/capsule/content/cancel_synchronization_test.rb +42 -0
  64. data/test/functional/capsule/content/capsule_content_helpers.rb +24 -0
  65. data/test/functional/capsule/content/data/library_env.json +47 -0
  66. data/test/functional/capsule/content/data/sync_status.json +6 -0
  67. data/test/functional/capsule/content/data/sync_tasks.json +62 -0
  68. data/test/functional/capsule/content/info_test.rb +61 -0
  69. data/test/functional/capsule/content/lifecycle_environments_test.rb +19 -0
  70. data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +40 -0
  71. data/test/functional/capsule/content/synchronization_status_test.rb +107 -0
  72. data/test/functional/capsule/info_test.rb +25 -0
  73. data/test/functional/capsule/list_test.rb +24 -0
  74. data/test/functional/content_credentials/create_test.rb +32 -0
  75. data/test/functional/content_credentials/data/test_cert.json +43 -0
  76. data/test/functional/content_credentials/info_test.rb +50 -0
  77. data/test/functional/content_credentials/list_test.rb +66 -0
  78. data/test/functional/content_export/complete/library_test.rb +155 -0
  79. data/test/functional/content_export/complete/version_test.rb +252 -0
  80. data/test/functional/content_export/content_export_helpers.rb +26 -0
  81. data/test/functional/content_export/generate_metadata_test.rb +64 -0
  82. data/test/functional/content_export/incremental/library_test.rb +172 -0
  83. data/test/functional/content_export/incremental/version_test.rb +268 -0
  84. data/test/functional/content_export/list_test.rb +64 -0
  85. data/test/functional/content_import/library_test.rb +85 -0
  86. data/test/functional/content_import/list_test.rb +65 -0
  87. data/test/functional/content_import/metadata.json +1 -0
  88. data/test/functional/content_import/version_test.rb +85 -0
  89. data/test/functional/content_units/info_test.rb +29 -0
  90. data/test/functional/content_units/list_test.rb +106 -0
  91. data/test/functional/content_view/add_content_view_version_test.rb +88 -0
  92. data/test/functional/content_view/add_repository_test.rb +21 -0
  93. data/test/functional/content_view/component/add_test.rb +177 -0
  94. data/test/functional/content_view/component/list_test.rb +55 -0
  95. data/test/functional/content_view/component/remove_test.rb +107 -0
  96. data/test/functional/content_view/component/update_test.rb +134 -0
  97. data/test/functional/content_view/content_view_helpers.rb +20 -0
  98. data/test/functional/content_view/copy_test.rb +53 -0
  99. data/test/functional/content_view/create_test.rb +34 -0
  100. data/test/functional/content_view/delete_test.rb +62 -0
  101. data/test/functional/content_view/filter/create_test.rb +57 -0
  102. data/test/functional/content_view/filter/delete_test.rb +90 -0
  103. data/test/functional/content_view/filter/info_test.rb +89 -0
  104. data/test/functional/content_view/filter/list_test.rb +98 -0
  105. data/test/functional/content_view/filter/update_test.rb +91 -0
  106. data/test/functional/content_view/list_test.rb +68 -0
  107. data/test/functional/content_view/publish_test.rb +24 -0
  108. data/test/functional/content_view/purge_test.rb +97 -0
  109. data/test/functional/content_view/remove_content_view_version_test.rb +88 -0
  110. data/test/functional/content_view/remove_test.rb +79 -0
  111. data/test/functional/content_view/update_test.rb +53 -0
  112. data/test/functional/content_view/version/incremental_update_test.rb +108 -0
  113. data/test/functional/content_view/version/list_test.rb +44 -0
  114. data/test/functional/content_view/version/promote_test.rb +75 -0
  115. data/test/functional/content_view/version/republish_repositories_test.rb +34 -0
  116. data/test/functional/content_view/version/update_test.rb +48 -0
  117. data/test/functional/erratum/erratum_helpers.rb +91 -0
  118. data/test/functional/erratum/info_test.rb +29 -0
  119. data/test/functional/erratum/list_test.rb +108 -0
  120. data/test/functional/file/file_helpers.rb +13 -0
  121. data/test/functional/file/info_test.rb +162 -0
  122. data/test/functional/file/list_test.rb +112 -0
  123. data/test/functional/filter_rule/create_test.rb +99 -0
  124. data/test/functional/filter_rule/delete_test.rb +104 -0
  125. data/test/functional/filter_rule/filter_rule_helpers.rb +12 -0
  126. data/test/functional/filter_rule/info_test.rb +104 -0
  127. data/test/functional/filter_rule/list_test.rb +91 -0
  128. data/test/functional/filter_rule/update_test.rb +104 -0
  129. data/test/functional/host/errata/apply_test.rb +45 -0
  130. data/test/functional/host/errata/info_test.rb +27 -0
  131. data/test/functional/host/errata/list_test.rb +49 -0
  132. data/test/functional/host/errata/recalculate_test.rb +26 -0
  133. data/test/functional/host/extensions/create_test.rb +95 -0
  134. data/test/functional/host/extensions/data/host.json +320 -0
  135. data/test/functional/host/extensions/data/host_list.json +117 -0
  136. data/test/functional/host/extensions/info_test.rb +35 -0
  137. data/test/functional/host/extensions/list_test.rb +21 -0
  138. data/test/functional/host/extensions/update_test.rb +70 -0
  139. data/test/functional/host/host_helpers.rb +8 -0
  140. data/test/functional/host/subscription/attach_test.rb +54 -0
  141. data/test/functional/host/subscription/auto_attach_test.rb +35 -0
  142. data/test/functional/host/subscription/content_override_test.rb +96 -0
  143. data/test/functional/host/subscription/product_content_test.rb +27 -0
  144. data/test/functional/host/subscription/register_test.rb +53 -0
  145. data/test/functional/host/subscription/remove_test.rb +52 -0
  146. data/test/functional/host/subscription/unregister_test.rb +37 -0
  147. data/test/functional/host/traces/list_test.rb +37 -0
  148. data/test/functional/host/traces/resolve_test.rb +31 -0
  149. data/test/functional/host_collection/add_host_test.rb +90 -0
  150. data/test/functional/host_collection/content_api_expectations.rb +35 -0
  151. data/test/functional/host_collection/content_install_test.rb +62 -0
  152. data/test/functional/host_collection/content_remove_test.rb +37 -0
  153. data/test/functional/host_collection/content_update_test.rb +37 -0
  154. data/test/functional/host_collection/copy_test.rb +64 -0
  155. data/test/functional/host_collection/create_test.rb +54 -0
  156. data/test/functional/host_collection/delete_test.rb +57 -0
  157. data/test/functional/host_collection/hosts_test.rb +39 -0
  158. data/test/functional/host_collection/info_test.rb +57 -0
  159. data/test/functional/host_collection/list_test.rb +63 -0
  160. data/test/functional/host_collection/remove_host_test.rb +90 -0
  161. data/test/functional/host_collection/update_test.rb +57 -0
  162. data/test/functional/hostgroup/create_test.rb +112 -0
  163. data/test/functional/hostgroup/data/hostgroup.json +50 -0
  164. data/test/functional/hostgroup/info_test.rb +33 -0
  165. data/test/functional/hostgroup/update_test.rb +120 -0
  166. data/test/functional/lifecycle_environment/create_test.rb +14 -0
  167. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +18 -0
  168. data/test/functional/lifecycle_environment/list_test.rb +38 -0
  169. data/test/functional/lifecycle_environment/update_test.rb +14 -0
  170. data/test/functional/local_helper_test.rb +30 -0
  171. data/test/functional/module_stream/info_test.rb +58 -0
  172. data/test/functional/module_stream/list_test.rb +53 -0
  173. data/test/functional/organization/cdn_configuration_test.rb +42 -0
  174. data/test/functional/organization/delete_test.rb +26 -0
  175. data/test/functional/organization/info_test.rb +39 -0
  176. data/test/functional/organization/organization_helpers.rb +10 -0
  177. data/test/functional/package/list_test.rb +160 -0
  178. data/test/functional/package_group/list_test.rb +38 -0
  179. data/test/functional/ping_test.rb +61 -0
  180. data/test/functional/product/create_test.rb +54 -0
  181. data/test/functional/product/delete_test.rb +41 -0
  182. data/test/functional/product/info_test.rb +33 -0
  183. data/test/functional/product/list_test.rb +58 -0
  184. data/test/functional/product/product_helpers.rb +24 -0
  185. data/test/functional/product/remove_sync_plan_test.rb +35 -0
  186. data/test/functional/product/set_sync_plan_test.rb +49 -0
  187. data/test/functional/product/update_proxy.rb +48 -0
  188. data/test/functional/product/update_test.rb +46 -0
  189. data/test/functional/repository/create_test.rb +21 -0
  190. data/test/functional/repository/delete_test.rb +95 -0
  191. data/test/functional/repository/info_test.rb +156 -0
  192. data/test/functional/repository/list_test.rb +68 -0
  193. data/test/functional/repository/remove_content_test.rb +108 -0
  194. data/test/functional/repository/repository_helpers.rb +18 -0
  195. data/test/functional/repository/synchronize_test.rb +57 -0
  196. data/test/functional/repository/update_test.rb +149 -0
  197. data/test/functional/repository/upload_test.rb +368 -0
  198. data/test/functional/repository_set/available_repositories_test.rb +18 -0
  199. data/test/functional/repository_set/disable_test.rb +42 -0
  200. data/test/functional/repository_set/enable_test.rb +42 -0
  201. data/test/functional/repository_set/info_test.rb +17 -0
  202. data/test/functional/repository_set/list_test.rb +18 -0
  203. data/test/functional/repository_set/repository_set_helpers.rb +20 -0
  204. data/test/functional/search_helpers.rb +17 -0
  205. data/test/functional/simple_content_access/disable_test.rb +48 -0
  206. data/test/functional/simple_content_access/enable_test.rb +46 -0
  207. data/test/functional/srpm/list_test.rb +92 -0
  208. data/test/functional/subscription/list_test.rb +86 -0
  209. data/test/functional/sync_plan/create_test.rb +60 -0
  210. data/test/functional/sync_plan/delete_test.rb +46 -0
  211. data/test/functional/sync_plan/info_test.rb +37 -0
  212. data/test/functional/sync_plan/list_test.rb +31 -0
  213. data/test/functional/sync_plan/sync_plan_helpers.rb +8 -0
  214. data/test/functional/sync_plan/update_test.rb +44 -0
  215. data/test/functional/test_helper.rb +24 -0
  216. data/test/task_helper.rb +7 -0
  217. data/test/test_helper.rb +38 -0
  218. data/test/unit/id_name_options_validator_test.rb +96 -0
  219. data/test/unit/id_resolver_test.rb +58 -0
  220. data/test/unit/messages_test.rb +7 -0
  221. data/test/unit/search_options_creators_test.rb +145 -0
  222. metadata +396 -6
  223. data/lib/hammer_cli_katello/host_content_source_options.rb +0 -28
  224. data/lib/hammer_cli_katello/host_kickstart_repository_options.rb +0 -49
  225. data/lib/hammer_cli_katello/ostree_branch.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d5fafd24b632ade65c6e11166ef3e01c7da7cd29c68fd5930a074c0abee1d18
4
- data.tar.gz: fb8a68f817c2bb3f6bb693b7b5ed2b9b5bb482c9fe7590afc3a6420a4c7dafac
3
+ metadata.gz: 0a00c7f5dd067ab0cc8203da1989be46411dc15ed1079442b38bf27e4c1c5eef
4
+ data.tar.gz: 4088650b9e19e79031e912cfc1f3c49ec11ef448e41c5c97cb41820fe5474bcc
5
5
  SHA512:
6
- metadata.gz: eaafa419371c904704b7ee5b9c776e829d35ad6560d55cc7fa118c5a076dda9617321e2838a1608dfd14067c8a6ea1aecd91d61e4cd2d0e1b5a04841322f8dd1
7
- data.tar.gz: 31ac0a523c9d27c1e84de086dfc79e2868d05a235065b513a4797539f485a988f96c2cbc829192fcb0733f0f3241e9460311ebc1cb50eb84b7b1019cb339ceb5
6
+ metadata.gz: 0b638de29d5f9ebf39fa1962ec41d316f23579c64f9b0bd387bc3bd0323d447368fb9dacf283ea8e10d898e1d2bd4e6956c99f435080f38c835092c154e85f03
7
+ data.tar.gz: 8c59ab30460634b1098d74933284052ee98492897a04d17358166597fb2d53e2412e521228486b5df37c8d8cb2f254565eb79ccb3cc29e5dfd8cfc9b42b4e399
@@ -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
@@ -0,0 +1,66 @@
1
+ module HammerCLIKatello
2
+ class ContentUnitsCommand < HammerCLIKatello::Command
3
+ resource :generic_content_units
4
+
5
+ class ListCommand < HammerCLIKatello::ListCommand
6
+ extend RepositoryScopedToProduct
7
+
8
+ validate_repo_name_requires_product_options(:option_repository_name)
9
+
10
+ output do
11
+ field :id, _("Id")
12
+ field :name, _("Name")
13
+ field :version, _("Version")
14
+ field :filename, _("Filename"), Fields::Field, hide_blank: true
15
+ end
16
+
17
+ validate_options :before, 'IdResolution' do
18
+ organization_options = [:option_organization_id, :option_organization_name,
19
+ :option_organization_label]
20
+ if any(:option_product_name, :option_content_view_name).exist?
21
+ any(*organization_options).required
22
+ end
23
+ end
24
+
25
+ build_options do |o|
26
+ o.expand.including(:products, :organizations, :content_views)
27
+ end
28
+ end
29
+
30
+ class InfoCommand < HammerCLIKatello::InfoCommand
31
+ output do
32
+ field :id, _("Id")
33
+ field :name, _("Name")
34
+ field :version, _("Version")
35
+ field :filename, _("Filename"), Fields::Field, hide_blank: true
36
+ end
37
+
38
+ validate_options :before, 'IdResolution' do
39
+ organization_options = [:option_organization_id, :option_organization_name,
40
+ :option_organization_label]
41
+ product_options = [:option_product_id, :option_product_name]
42
+ repository_options = [:option_repository_id, :option_repository_name]
43
+ content_view_version_options = [:option_content_view_version_id,
44
+ :option_content_view_version_version]
45
+
46
+ if option(:option_product_name).exist?
47
+ any(*organization_options).required
48
+ end
49
+
50
+ if option(:option_repository_name).exist?
51
+ any(*product_options).required
52
+ end
53
+
54
+ if option(:option_name).exist?
55
+ any(*(repository_options + content_view_version_options)).required
56
+ end
57
+ end
58
+
59
+ build_options do |o|
60
+ o.expand.including(:products, :organizations, :content_views, :content_view_versions)
61
+ end
62
+ end
63
+
64
+ autoload_subcommands
65
+ end
66
+ end
@@ -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
@@ -84,16 +84,16 @@ module HammerCLIKatello
84
84
  include OrganizationOptions
85
85
  include CompositeContentViewNameResolvable
86
86
  output do
87
- field :id, _("Id")
87
+ field :content_view_id, _("Content View Id")
88
88
  field :content_view_name, _("Name")
89
89
  field :version, _("Version")
90
+ field :id, _("Component Id")
90
91
  field :current_version, _("Current Version")
91
92
  field :version_id, _("Version Id")
92
93
  end
93
94
 
94
95
  def extend_data(mod)
95
96
  if mod['latest']
96
- mod['content_view_name'] = mod["content_view"]["name"]
97
97
  mod['version'] = _("Latest")
98
98
  if mod['content_view_version']
99
99
  mod['current_version'] = mod['content_view_version']['version']
@@ -102,10 +102,11 @@ module HammerCLIKatello
102
102
  mod['current_version'] = _("No Published Version")
103
103
  end
104
104
  else
105
- mod['content_view_name'] = mod["content_view"]["name"]
106
105
  mod['version'] = mod['content_view_version']['version']
107
106
  mod['version_id'] = mod['content_view_version']['id']
108
107
  end
108
+ mod['content_view_name'] = mod["content_view"]["name"]
109
+ mod['content_view_id'] = mod["content_view"]["id"]
109
110
  mod
110
111
  end
111
112
 
@@ -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)
@@ -48,18 +48,6 @@ module HammerCLIKatello
48
48
  create_search_options_without_katello_api(options, api.resource(:ptables), mode)
49
49
  end
50
50
 
51
- def create_puppet_ca_proxies_search_options(options, mode = nil)
52
- create_search_options_without_katello_api(options, api.resource(:puppet_ca_proxies), mode)
53
- end
54
-
55
- def create_puppet_proxies_search_options(options, mode = nil)
56
- create_search_options_without_katello_api(options, api.resource(:puppet_proxies), mode)
57
- end
58
-
59
- def create_puppetclasses_search_options(options, mode = nil)
60
- create_search_options_without_katello_api(options, api.resource(:puppetclasses), mode)
61
- end
62
-
63
51
  def create_subnets_search_options(options, mode = nil)
64
52
  create_search_options_without_katello_api(options, api.resource(:subnets), mode)
65
53
  end
@@ -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
 
@@ -11,7 +11,7 @@ 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
15
 
16
16
  def execute
17
17
  warn "This command uses katello agent and will be removed in favor of remote execution " \
@@ -46,10 +46,9 @@ module HammerCLIKatello
46
46
  end
47
47
 
48
48
  class RecalculateCommand < HammerCLIKatello::SingleResourceCommand
49
- include HammerCLIForemanTasks::Async
50
49
  resource :host_errata, :applicability
51
50
  command_name "recalculate"
52
- success_message _("Errata recalculated with task %{id}.")
51
+ success_message _("Errata recalculation started.")
53
52
  failure_message _("Could not recalculate errata")
54
53
 
55
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
@@ -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
@@ -20,9 +20,17 @@ module HammerCLIKatello
20
20
  output do
21
21
  field :label, _("Label")
22
22
  field :description, _("Description")
23
- field :redhat_repository_url, _("Red Hat Repository URL")
24
23
  field :simple_content_access_label, _("Simple Content Access")
25
24
  field :service_levels, _("Service Levels"), Fields::List
25
+ from :cdn_configuration do
26
+ label "CDN configuration", hide_blank: true do
27
+ field :url, _("URL"), Fields::Field, hide_blank: true
28
+ field :upstream_organization_label, _("Upstream Organization"),
29
+ Fields::Field, hide_blank: true
30
+ field :username, _("Username"), Fields::Field, hide_blank: true
31
+ field :ssl_ca_credential_id, _("SSL CA Credential ID"), Fields::Field, hide_blank: true
32
+ end
33
+ end
26
34
  end
27
35
 
28
36
  def extend_data(data)
@@ -44,7 +52,9 @@ module HammerCLIKatello
44
52
  success_message _("Organization updated.")
45
53
  failure_message _("Could not update the organization")
46
54
 
47
- build_options
55
+ build_options do |o|
56
+ o.expand(:all).except(:environments)
57
+ end
48
58
  end
49
59
 
50
60
  class CreateCommand < HammerCLIForeman::Organization::CreateCommand
@@ -54,7 +64,9 @@ module HammerCLIKatello
54
64
  success_message _("Organization created.")
55
65
  failure_message _("Could not create the organization")
56
66
 
57
- build_options
67
+ build_options do |o|
68
+ o.expand(:all).except(:environments)
69
+ end
58
70
  end
59
71
 
60
72
  class DeleteCommand < HammerCLIForeman::Organization::DeleteCommand
@@ -68,6 +80,19 @@ module HammerCLIKatello
68
80
  build_options
69
81
  end
70
82
 
83
+ class ConfigureCdnCommand < HammerCLIKatello::SingleResourceCommand
84
+ include HammerCLIKatello::ResolverCommons
85
+ resource :organizations, :cdn_configuration
86
+ command_name "configure-cdn"
87
+ success_message _("Updated CDN configuration.")
88
+ failure_message _("Could not update CDN configuration.")
89
+
90
+ build_options do |o|
91
+ o.expand(:all).except(:organizations, :locations)
92
+ o.without(:organization_id, :location_id)
93
+ end
94
+ end
95
+
71
96
  autoload_subcommands
72
97
  end
73
98
  end
@@ -3,7 +3,6 @@ module HammerCLIKatello
3
3
  resource :packages
4
4
 
5
5
  class ListCommand < HammerCLIKatello::ListCommand
6
- extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
7
6
  include LifecycleEnvironmentNameMapping
8
7
 
9
8
  output do
@@ -40,6 +39,8 @@ module HammerCLIKatello
40
39
  build_options do |o|
41
40
  o.expand.including(:products, :content_views)
42
41
  end
42
+
43
+ extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
43
44
  end
44
45
 
45
46
  class InfoCommand < HammerCLIKatello::InfoCommand
@@ -51,6 +51,13 @@ module HammerCLIKatello
51
51
  end
52
52
  end
53
53
 
54
+ label "pulp3_content", :hide_blank => true do
55
+ from "pulp3_content" do
56
+ field "status", _("Status"), Fields::Field, :hide_blank => true
57
+ field "_response", _("Server Response"), Fields::Field, :hide_blank => true
58
+ end
59
+ end
60
+
54
61
  label "foreman_tasks" do
55
62
  from "foreman_tasks" do
56
63
  field "status", _("Status")