Skip to content

Commit

Permalink
Fixes #38127 - Add hammer host bootc images subcommamd
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Jan 13, 2025
1 parent 49bffbb commit 3db1839
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/hammer_cli_katello/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'hammer_cli_katello/host_deb'
require 'hammer_cli_katello/host_package_group'
require 'hammer_cli_katello/host_traces'
require 'hammer_cli_katello/host_bootc'

module HammerCLIKatello
HammerCLIForeman::Host.subcommand "errata",
Expand All @@ -31,4 +32,8 @@ module HammerCLIKatello
HammerCLIForeman::Host.subcommand "traces",
HammerCLIKatello::HostTraces.desc,
HammerCLIKatello::HostTraces

HammerCLIForeman::Host.subcommand "bootc",
HammerCLIKatello::HostBootc.desc,
HammerCLIKatello::HostBootc
end
34 changes: 34 additions & 0 deletions lib/hammer_cli_katello/host_bootc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module HammerCLIKatello
class HostBootc < HammerCLIKatello::Command
resource :host_bootc_images
desc "Manage bootc images on your hosts"

class ImagesCommand < HammerCLIKatello::ListCommand
action :bootc_images
command_name "images"

output do
field :bootc_booted_image, _("Bootc running image")
field :bootc_booted_digest, _("Bootc running image digest")
field :host_count, _("Host count")
end

def send_request
self.class.parse_data(super)
end

def self.parse_data(data_collection)
data = data_collection.inject([]) do |list, item|
list + item["digests"].collect do |digest|
digest.merge(:bootc_booted_image => item["bootc_booted_image"])
end
end
HammerCLI::Output::RecordCollection.new(data, :meta => data_collection.meta)
end

build_options
end

autoload_subcommands
end
end
1 change: 1 addition & 0 deletions lib/hammer_cli_katello/host_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'hammer_cli_katello/host_package'
require 'hammer_cli_katello/host_package_group'
require 'hammer_cli_katello/host_traces'
require 'hammer_cli_katello/host_bootc'

module HammerCLIKatello
module HostExtensions
Expand Down

0 comments on commit 3db1839

Please sign in to comment.