Class: Pvectl::Repositories::TimeConfig
- Defined in:
- lib/pvectl/repositories/time_config.rb
Overview
Repository for Proxmox node time and timezone settings.
Wraps the ‘/nodes/node/time` API endpoint:
-
GET fetches ‘localtime, timezone`
-
PUT sets the timezone (the only writable field)
Instance Method Summary collapse
-
#fetch(node_name) ⇒ Models::TimeConfig
Fetches time and timezone settings for a node.
-
#set_timezone(node_name, timezone) ⇒ nil
Sets the timezone on a node.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pvectl::Repositories::Base
Instance Method Details
#fetch(node_name) ⇒ Models::TimeConfig
Fetches time and timezone settings for a node.
26 27 28 29 30 |
# File 'lib/pvectl/repositories/time_config.rb', line 26 def fetch(node_name) response = connection.client["nodes/#{node_name}/time"].get data = extract_data(response) || {} build_model(data.merge(node_name: node_name)) end |
#set_timezone(node_name, timezone) ⇒ nil
Sets the timezone on a node.
37 38 39 40 |
# File 'lib/pvectl/repositories/time_config.rb', line 37 def set_timezone(node_name, timezone) connection.client["nodes/#{node_name}/time"].put(timezone: timezone) nil end |