Class: Pvectl::Commands::Get::Handlers::Disks
- Inherits:
-
Object
- Object
- Pvectl::Commands::Get::Handlers::Disks
- Includes:
- ResourceHandler
- Defined in:
- lib/pvectl/commands/get/handlers/disks.rb
Overview
Handler for listing physical disks on Proxmox nodes.
Implements ResourceHandler interface for the “disks” resource type. Uses Repositories::Disk for data access and Presenters::Disk for formatting.
Instance Method Summary collapse
-
#describe(name:, node: nil, args: [], vmid: nil) ⇒ Models::PhysicalDisk
Describes a single physical disk with SMART data.
-
#initialize(repository: nil) ⇒ Disks
constructor
Creates handler with optional repository for dependency injection.
-
#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::PhysicalDisk>
Lists physical disks with optional filtering.
-
#presenter ⇒ Presenters::Disk
Returns presenter for physical disks.
-
#selector_class ⇒ Class
Returns selector class for client-side filtering.
Constructor Details
#initialize(repository: nil) ⇒ Disks
Creates handler with optional repository for dependency injection.
26 27 28 |
# File 'lib/pvectl/commands/get/handlers/disks.rb', line 26 def initialize(repository: nil) @repository = repository end |
Instance Method Details
#describe(name:, node: nil, args: [], vmid: nil) ⇒ Models::PhysicalDisk
Describes a single physical disk with SMART data.
Locates the disk by devpath across all nodes (or a specific node), then fetches SMART data and merges it into the model.
54 55 56 57 58 59 60 61 62 |
# File 'lib/pvectl/commands/get/handlers/disks.rb', line 54 def describe(name:, node: nil, args: [], vmid: nil) disks = repository.list(node: node) disk = disks.find { |d| d.devpath == name } raise Pvectl::ResourceNotFoundError, "Disk not found: #{name}" unless disk smart_data = repository.smart(disk.node, name) disk.merge_smart(smart_data) disk end |
#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::PhysicalDisk>
Lists physical disks with optional filtering.
37 38 39 40 41 |
# File 'lib/pvectl/commands/get/handlers/disks.rb', line 37 def list(node: nil, name: nil, args: [], storage: nil, **) disks = repository.list(node: node) disks = disks.select { |d| d.devpath == name } if name disks end |
#presenter ⇒ Presenters::Disk
Returns presenter for physical disks.
67 68 69 |
# File 'lib/pvectl/commands/get/handlers/disks.rb', line 67 def presenter Pvectl::Presenters::Disk.new end |