Class: ForemanFogProxmox::Proxmox

Inherits:
ComputeResource
  • Object
show all
Includes:
ProxmoxComputeAttributes, ProxmoxConnection, ProxmoxConsole, ProxmoxImages, ProxmoxInterfaces, ProxmoxOperatingSystems, ProxmoxVMCommands, ProxmoxVMNew, ProxmoxVMQueries, ProxmoxVersion, ProxmoxVolumes, ProxmoxVMHelper
Defined in:
app/models/foreman_fog_proxmox/proxmox.rb

Constant Summary

Constants included from ProxmoxComputeAttributes

ForemanFogProxmox::ProxmoxComputeAttributes::FOREMAN_INTERFACE_ATTRIBUTES, ForemanFogProxmox::ProxmoxComputeAttributes::PROXMOX_INTERFACE_METADATA, ForemanFogProxmox::ProxmoxComputeAttributes::PROXMOX_MAC_ATTRIBUTES

Constants included from ProxmoxVMUuidHelper

ProxmoxVMUuidHelper::UUID_REGEXP

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ProxmoxConsole

#console

Methods included from ProxmoxVersion

#version, #version_suitable?

Methods included from ProxmoxOperatingSystems

#available_linux_operating_systems, #available_operating_systems, #available_other_operating_systems, #available_windows_operating_systems, #compute_os_types, #os_linux_types_mapping, #os_other_types_mapping, #os_windows_types_mapping

Methods included from ProxmoxImages

#available_images, #clone_from_image, #image_exists?, #images_by_storage, #template, #template_name, #template_uuid, #templates

Methods included from ProxmoxInterfaces

#check_cidr, #cidr_prefix, #cidr_prefix_method, #container?, #container_nic_name_valid?, #dhcp?, #editable_network_interfaces?, #host_interfaces_attrs, #ip_s, #set_container_interface_name, #set_ip, #set_mac, #set_nic_identifier, #to_boolean, #to_cidr_method, #v6_s, #vm_type

Methods included from ProxmoxVolumes

#add_volume, #delete_volume, #extend_volume, #extract_id, #move_volume, #normalize_existing_volume_attributes, #save_volume, #update_cdrom, #update_options, #update_volume, #update_volume_required?, #volume_exists?, #volume_options, #volume_to_delete?

Methods included from ProxmoxVMHelper

#parse_typed_vm, #vm_collection

Methods included from ProxmoxVMEfidiskHelper

#parse_typed_efidisk, #parsed_typed_efidisk

Methods included from ProxmoxVMOsTemplateHelper

#ostemplate_keys, #parse_container_ostemplate, #parse_ostemplate, #parse_ostemplate_without_keys

Methods included from ProxmoxVMConfigHelper

#args_a, #config_a, #config_general_or_ostemplate_key?, #config_options, #config_typed_keys, #general_a, #object_to_config_hash, #parse_typed_cpu, #parse_typed_memory, #parsed_typed_config

Methods included from ProxmoxVMVolumesHelper

#add_disk_options, #add_typed_volume, #parse_hard_disk_volume, #parse_typed_volume, #parse_typed_volumes, #parsed_typed_volumes, #remove_volume_keys, #rootfs_volume?, #set_disk_attributes, #volume_type?

Methods included from ProxmoxVMCloudinitHelper

#attach_cloudinit_iso, #check_template_format, #create_cloudinit_iso, #create_temp_directory, #default_iso_path, #delete_temp_dir, #generate_iso_command, #parse_cloudinit_config, #parse_server_cloudinit, #update_boot_order, #vm_ssh

Methods included from ProxmoxVMCdromHelper

#parse_server_cdrom

Methods included from ProxmoxVMInterfacesHelper

#add_or_delete_typed_interface, #compute_dhcps, #interface_common_typed_keys, #interface_compute_attributes_typed_keys, #parse_typed_interfaces, #parsed_typed_interfaces, #sync_dhcp_for_ip

Methods included from ProxmoxComputeAttributes

#host_compute_attrs, #interface_compute_attributes, #not_config_key?, #vm_compute_attributes, #volume_compute_attributes

Methods included from ProxmoxVMQueries

#bridges, #find_vm_by_uuid, #find_vm_in_servers_by_vmid, #nodes, #storages, #vms

Methods included from ProxmoxVMUuidHelper

#extract, #extract_vmid, #match_uuid?

Methods included from ProxmoxPools

#add_vm_to_pool, #pool_owner, #pools, #remove_vm_from_pool, #update_pool

Methods included from ProxmoxVMCommands

#assign_vmid, #compute_clone_attributes, #compute_config_attributes, #create_vm, #destroy_vm, #save_vm, #start_on_boot, #supports_update?, #user_data_supported?

Methods included from ProxmoxEfidisks

#delete_efidisk

Methods included from ProxmoxVMNew

#add_default_typed_interface, #add_default_typed_volume, #cdrom_defaults, #cloudinit_defaults, #config_attributes, #convert_config_attributes, #default_node, #default_node_id, #hard_disk_typed_defaults, #interface_defaults, #interface_typed_defaults, #new_interface, #new_typed_interface, #new_typed_vm, #new_typed_volume, #new_vm, #new_volume, #next_vmid, #vm_instance_defaults, #vm_typed_instance_defaults

Methods included from ProxmoxConnection

#access_ticket?, #connection_options, #credentials_valid?, #current_user_token_expire, #disconnect, #test_connection, #user_token?

Class Method Details

.model_nameObject



61
62
63
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 61

def self.model_name
  ComputeResource.model_name
end

.provider_friendly_nameObject



53
54
55
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 53

def self.provider_friendly_name
  'Proxmox'
end

Instance Method Details

#associate_by(name, attributes) ⇒ Object



69
70
71
72
73
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 69

def associate_by(name, attributes)
  return nil if attributes.blank?
  Host.authorized(:view_hosts,
    Host).joins(:primary_interface).where(:nics => { :primary => true }).where("nics.#{name}".downcase => attributes.downcase).readonly(false).first
end

#associated_host(vm) ⇒ Object



65
66
67
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 65

def associated_host(vm)
  associate_by('mac', vm&.mac)
end

#auth_methodObject



105
106
107
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 105

def auth_method
  attrs[:auth_method] || 'access_ticket'
end

#auth_method=(value) ⇒ Object



109
110
111
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 109

def auth_method=(value)
  attrs[:auth_method] = value
end

#capabilitiesObject



57
58
59
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 57

def capabilities
  [:build, :new_volume, :new_interface, :image]
end

#certs_to_storeObject



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 83

def certs_to_store
  return if ssl_certs.blank?

  store = OpenSSL::X509::Store.new
  ssl_certs.split(/(?=-----BEGIN)/).each do |cert|
    x509_cert = OpenSSL::X509::Certificate.new cert
    store.add_cert x509_cert
  end
  store
rescue StandardError => e
  logger.error(e)
  raise ::Foreman::Exception, N_('Unable to store X509 certificates')
end

#provided_attributesObject



46
47
48
49
50
51
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 46

def provided_attributes
  super.merge(
    :uuid => :foreman_uuid,
    :mac => :mac
  )
end

#ssl_certsObject



75
76
77
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 75

def ssl_certs
  attrs[:ssl_certs]
end

#ssl_certs=(value) ⇒ Object



79
80
81
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 79

def ssl_certs=(value)
  attrs[:ssl_certs] = value
end

#ssl_verify_peerObject



97
98
99
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 97

def ssl_verify_peer
  attrs[:ssl_verify_peer].blank? ? false : Foreman::Cast.to_bool(attrs[:ssl_verify_peer])
end

#ssl_verify_peer=(value) ⇒ Object



101
102
103
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 101

def ssl_verify_peer=(value)
  attrs[:ssl_verify_peer] = value
end

#tokenObject



121
122
123
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 121

def token
  attrs[:token]
end

#token=(value) ⇒ Object



125
126
127
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 125

def token=(value)
  attrs[:token] = value
end

#token_idObject



113
114
115
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 113

def token_id
  attrs[:token_id]
end

#token_id=(value) ⇒ Object



117
118
119
# File 'app/models/foreman_fog_proxmox/proxmox.rb', line 117

def token_id=(value)
  attrs[:token_id] = value
end