Class: Pvectl::Services::Wakeonlan
- Inherits:
-
Object
- Object
- Pvectl::Services::Wakeonlan
- Defined in:
- lib/pvectl/services/wakeonlan.rb
Overview
Sends a Wake-on-LAN packet to a cluster node.
Verifies the node exists in the cluster, calls the WoL API endpoint, and wraps the outcome in a NodeOperationResult. The Proxmox API returns the MAC address used for the magic packet on success, which is surfaced in the result message for confirmation.
Instance Method Summary collapse
-
#execute(node_name:) ⇒ Models::NodeOperationResult
Sends the WoL packet to a node.
-
#initialize(node_repository:) ⇒ Wakeonlan
constructor
Creates a new service.
Constructor Details
#initialize(node_repository:) ⇒ Wakeonlan
Creates a new service.
25 26 27 |
# File 'lib/pvectl/services/wakeonlan.rb', line 25 def initialize(node_repository:) @node_repository = node_repository end |
Instance Method Details
#execute(node_name:) ⇒ Models::NodeOperationResult
Sends the WoL packet to a node.
33 34 35 36 37 38 39 40 41 |
# File 'lib/pvectl/services/wakeonlan.rb', line 33 def execute(node_name:) node = @node_repository.get(node_name) return not_found_result(node_name) unless node mac = @node_repository.wakeonlan(node_name) build_result(node, success: true, message: (mac)) rescue StandardError => e build_result(node || Models::Node.new(name: node_name), success: false, error: e.) end |