Module: ProxmoxComputeResourcesHelper

Defined in:
app/helpers/proxmox_compute_resources_helper.rb

Overview

You should have received a copy of the GNU General Public License along with ForemanFogProxmox. If not, see <www.gnu.org/licenses/>.

Instance Method Summary collapse

Instance Method Details

#cluster_nodes(compute_resource) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/proxmox_compute_resources_helper.rb', line 34

def cluster_nodes(compute_resource)
  nodes = compute_resource.nodes ? compute_resource.nodes.collect(&:node) : []
rescue ::Foreman::Exception => e
  return [] if e.message == 'User token expired'
rescue StandardError => e
  logger.warn("failed to get cluster nodes: #{e}")
  raise e
else
  nodes
end

#proxmox_auth_methods_mapObject



45
46
47
48
# File 'app/helpers/proxmox_compute_resources_helper.rb', line 45

def proxmox_auth_methods_map
  [OpenStruct.new(id: 'access_ticket', name: '(Default) Access ticket'),
   OpenStruct.new(id: 'user_token', name: 'User token')]
end

#user_token_expiration_date(compute_resource) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/proxmox_compute_resources_helper.rb', line 21

def user_token_expiration_date(compute_resource)
  expire = compute_resource.current_user_token_expire
rescue ::Foreman::Exception => e
  'Has already expired. Please edit the compute resource to set a new valid one.' if e.message == 'User token expired'
rescue StandardError => e
  logger.warn("failed to get identity client version: #{e}")
  raise e
else
  return 'Never' if expire == 0

  Time.at(expire).utc
end