Class: Pvectl::Commands::Get::Handlers::Services

Inherits:
Object
  • Object
show all
Includes:
ResourceHandler
Defined in:
lib/pvectl/commands/get/handlers/services.rb

Overview

Handler for listing systemd services on Proxmox nodes.

Implements ResourceHandler interface for the “services” resource type. Uses Repositories::Service for data access and Presenters::Service for formatting.

When no node filter is supplied, lists services across all online nodes. The –node flag restricts the listing to a single node.

Examples:

Using via ResourceRegistry

handler = ResourceRegistry.for("services")
services = handler.list(node: "pve1")

See Also:

Instance Method Summary collapse

Methods included from ResourceHandler

#selector_class

Constructor Details

#initialize(repository: nil) ⇒ Services

Creates handler with optional repository for dependency injection.

Parameters:



29
30
31
# File 'lib/pvectl/commands/get/handlers/services.rb', line 29

def initialize(repository: nil)
  @repository = repository
end

Instance Method Details

#list(node: nil, name: nil, **_options) ⇒ Array<Models::Service>

Lists services, optionally filtered by node and service name.

Parameters:

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

    filter by node name

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

    filter by service identifier (exact match)

  • _options (Hash)

    additional CLI options (unused)

Returns:



39
40
41
42
43
# File 'lib/pvectl/commands/get/handlers/services.rb', line 39

def list(node: nil, name: nil, **_options)
  services = repository.list(node: node)
  services = services.select { |s| s.service == name } if name
  services
end

#presenterPresenters::Service

Returns presenter for services.

Returns:



48
49
50
# File 'lib/pvectl/commands/get/handlers/services.rb', line 48

def presenter
  Pvectl::Presenters::Service.new
end