diff --git a/lib/hammer_cli_katello/capsule.rb b/lib/hammer_cli_katello/capsule.rb index cec5c014d..be5dc4d3e 100644 --- a/lib/hammer_cli_katello/capsule.rb +++ b/lib/hammer_cli_katello/capsule.rb @@ -105,6 +105,22 @@ class SyncCommand < HammerCLIKatello::SingleResourceCommand extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new) end + class UpdateCountsCommand < HammerCLIKatello::SingleResourceCommand + include HammerCLIForemanTasks::Async + + resource :capsule_content, :update_counts + command_name "update-counts" + + success_message _("Capsule content counts are being updated in task %{id}.") + failure_message _("Could not update capsule content counts") + + option "--organization-id", "ID", _("Organization ID"), + :attribute_name => :option_organization_id + option "--organization", "NAME", _("Organization name"), + :attribute_name => :option_organization_name + build_options + end + class SyncStatusCommand < HammerCLIKatello::InfoCommand resource :capsule_content, :sync_status command_name "synchronization-status" @@ -170,21 +186,44 @@ class InfoCommand < HammerCLIKatello::InfoCommand field nil, _("Name"), Fields::Reference field :composite, _('Composite'), Fields::Boolean field :last_published, _('Last Published'), Fields::Date - label _('Content') do - from :counts do - field :content_hosts, _('Hosts') - field :products, _('Products') - field :yum_repositories, _('Yum repos') - field :docker_repositories, _('Container Image repos') - field :packages, _('Packages') - field :package_groups, _('Package groups') - field :errata, _('Errata') + collection :repositories, _('Repositories') do + field :id, _("Repository ID") + field :name, _("Repository Name") + label _('Content Counts') do + from :_content_counts do + field :rpm, _('Packages') + field :srpm, _('SRPMs') + field :module_stream, _('Module Streams') + field :package_group, _('Package Groups') + field :erratum, _('Errata') + field :deb, _('Debian Packages') + field :docker_tag, _('Container Tags') + field :docker_manifest, _('Container Manifests') + field :docker_manifest_list, _('Container Manifest Lists') + field :file, _('Files') + field :ansible_collection, _('Ansible Collections') + field :ostree_ref, _('OSTree Refs') + field :python_package, _('Python Packages') + end end end end end end + private + + def extend_data(data) + data["lifecycle_environments"].each do |lce| + lce["content_views"].each do |cv| + cv["repositories"].each do |repo| + repo["_content_counts"] = lce.dig("counts", "content_counts", "content_view_versions", cv["cvv_id"].to_s, "repositories", repo["id"].to_s) + end + end + end + data + end + build_options end diff --git a/test/functional/capsule/content/data/library_env.json b/test/functional/capsule/content/data/library_env.json index 116d89dec..5dec76caf 100644 --- a/test/functional/capsule/content/data/library_env.json +++ b/test/functional/capsule/content/data/library_env.json @@ -1,47 +1,35 @@ { - "library": true, - "id": 3, - "name": "Library", - "label": "Library", - "description": null, - "organization": { - "name": "Default Organization", - "label": "Default_Organization", - "id": 1 + "library":false, + "id":4, + "name":"Test", + "label":"Test", + "description":null, + "organization_id":1, + "organization":{ + "name":"Default Organization", + "label":"Default_Organization", + "id":1 }, - "syncable": true, - "counts": { - "content_hosts": 0, - "content_views": 1, - "products": 3, - "yum_repositories": 1, - "packages": 32, - "package_groups": 2, - "errata": 4, - "puppet_repositories": 0, - "puppet_modules": 0, - "docker_repositories": 0, - "docker_images": 0 + "syncable":false, + "counts":{ + "content_views":1, + "content_counts":{ + "content_view_versions":{ + "2":{"repositories":{"2":{"rpm":32,"erratum":4}}}} + } }, - "content_views": [ + "content_views": + [ { - "id": 3, - "label": "CV1", - "name": "CV1", - "composite": false, - "last_published": "2016-01-08 15:44:10 +0100", - "counts": { - "content_hosts": 0, - "products": 3, - "yum_repositories": 1, - "packages": 32, - "package_groups": 2, - "errata": 4, - "puppet_repositories": 0, - "puppet_modules": 0, - "docker_repositories": 0, - "docker_images": 0 - } + "id":2, + "cvv_id":2, + "label":"Zoo_View", + "name":"Zoo View", + "composite":false, + "last_published":"2023-10-09 19:18:15 UTC", + "default":false,"up_to_date":true, + "counts":{"repositories":1}, + "repositories":[{"id":2,"name":"Zoo","library_id":1}] } ] -} +} \ No newline at end of file diff --git a/test/functional/capsule/content/info_test.rb b/test/functional/capsule/content/info_test.rb index 8399df561..921a09e07 100644 --- a/test/functional/capsule/content/info_test.rb +++ b/test/functional/capsule/content/info_test.rb @@ -22,20 +22,18 @@ output = OutputMatcher.new([ "Lifecycle Environments:", - " 1) Name: Library", + " 1) Name: Test", " Organization: Default Organization", " Content Views:", - " 1) Name: CV1", + " 1) Name: Zoo View", " Composite: no", - " Last Published: 2016/01/08 15:44:10", - " Content:", - " Hosts: 0", - " Products: 3", - " Yum repos: 1", - " Container Image repos: 0", - " Packages: 32", - " Package groups: 2", - " Errata: 4" + " Last Published: 2023/10/09 19:18:15", + " Repositories:", + " 1) Repository ID: 2", + " Repository Name: Zoo", + " Content Counts:", + " Packages: 32", + " Errata: 4", ]) expected_result = success_result(output)