Class: Pvectl::Repositories::Disk

Inherits:
Base
  • Object
show all
Defined in:
lib/pvectl/repositories/disk.rb

Overview

Repository for physical disks on Proxmox nodes.

Uses the ‘/nodes/node/disks/list` API endpoint to fetch physical disk information per node.

Examples:

Listing all disks across the cluster

repo = Disk.new(connection)
disks = repo.list
disks.each { |d| puts "#{d.node}: #{d.devpath} (#{d.type})" }

Listing disks on a specific node

disks = repo.list(node: "pve1")

See Also:

Instance Method Summary collapse

Methods inherited from Base

#get, #initialize

Constructor Details

This class inherits a constructor from Pvectl::Repositories::Base

Instance Method Details

#list(node: nil) ⇒ Array<Models::PhysicalDisk>

Lists physical disks, optionally filtered by node.

When node is nil, iterates over all online nodes in the cluster. When node is specified, queries only that node.

Parameters:

  • node (String, nil) (defaults to: nil)

    filter by node name

Returns:



29
30
31
32
33
34
35
# File 'lib/pvectl/repositories/disk.rb', line 29

def list(node: nil)
  if node
    disks_for_node(node)
  else
    online_nodes.flat_map { |node_name| disks_for_node(node_name) }
  end
end

#smart(node_name, disk_path) ⇒ Hash{Symbol => untyped}

Fetches SMART data for a specific disk on a node.

Parameters:

  • node_name (String)

    node name

  • disk_path (String)

    device path (e.g., “/dev/nvme0n1”)

Returns:

  • (Hash{Symbol => untyped})

    SMART data with keys: :health, :type, :attributes, :text



42
43
44
45
46
47
# File 'lib/pvectl/repositories/disk.rb', line 42

def smart(node_name, disk_path)
  response = connection.client["nodes/#{node_name}/disks/smart"].get(params: { disk: disk_path })
  extract_data(response)
rescue StandardError
  {}
end