Class: Pvectl::Repositories::Apt
- Defined in:
- lib/pvectl/repositories/apt.rb,
sig/pvectl/repositories/apt.rbs
Overview
Repository for Proxmox APT package management on cluster nodes.
Wraps the /nodes/{node}/apt/* API endpoints. Provides:
- listing pending package updates (GET /apt/update)
- refreshing the package index (POST /apt/update — apt-get update)
- reading per-package changelogs (GET /apt/changelog)
- listing important Proxmox package versions (GET /apt/versions)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_model(data) ⇒ Models::AptPackage
Builds AptPackage model from API response data.
-
#changelog(node, package, version: nil) ⇒ String
Fetches the changelog for a package on a node.
-
#pending(node) ⇒ Array<Models::AptPackage>
Lists pending APT updates available on a node.
-
#refresh(node, notify: false, quiet: false) ⇒ String
Refreshes the package index on a node (equivalent to apt-get update).
-
#versions(node) ⇒ Array<Models::AptPackage>
Lists important Proxmox package versions installed on a node.
Methods inherited from Base
#extract_data, #get, #initialize, #list, #models_from, #unwrap
Constructor Details
This class inherits a constructor from Pvectl::Repositories::Base
Instance Method Details
#build_model(data) ⇒ Models::AptPackage
Builds AptPackage model from API response data.
88 89 90 |
# File 'lib/pvectl/repositories/apt.rb', line 88 def build_model(data) Models::AptPackage.new(data) end |
#changelog(node, package, version: nil) ⇒ String
Fetches the changelog for a package on a node.
60 61 62 63 64 65 66 67 68 |
# File 'lib/pvectl/repositories/apt.rb', line 60 def changelog(node, package, version: nil) params = { name: package } params[:version] = version if version response = connection.client["nodes/#{node}/apt/changelog"].get(params: params) data = extract_data(response) data.is_a?(String) ? data : data.to_s rescue StandardError "" end |
#pending(node) ⇒ Array<Models::AptPackage>
Lists pending APT updates available on a node.
29 30 31 32 33 34 35 |
# File 'lib/pvectl/repositories/apt.rb', line 29 def pending(node) response = connection.client["nodes/#{node}/apt/update"].get packages = unwrap(response) packages.map { |data| build_model(data.merge(node: node)) } rescue StandardError [] end |
#refresh(node, notify: false, quiet: false) ⇒ String
Refreshes the package index on a node (equivalent to apt-get update).
Returns the Proxmox task UPID — the operation runs asynchronously.
45 46 47 48 49 50 51 52 |
# File 'lib/pvectl/repositories/apt.rb', line 45 def refresh(node, notify: false, quiet: false) params = {} params[:notify] = 1 if notify params[:quiet] = 1 if quiet response = connection.client["nodes/#{node}/apt/update"].post(params) data = extract_data(response) data.is_a?(String) ? data : data.to_s end |
#versions(node) ⇒ Array<Models::AptPackage>
Lists important Proxmox package versions installed on a node.
74 75 76 77 78 79 80 |
# File 'lib/pvectl/repositories/apt.rb', line 74 def versions(node) response = connection.client["nodes/#{node}/apt/versions"].get packages = unwrap(response) packages.map { |data| build_model(data.merge(node: node)) } rescue StandardError [] end |