class Fog::Compute::Proxmox::ServerConfig
ServerConfig model
Attributes
disks[R]
interfaces[R]
Public Class Methods
new(attributes = {})
click to toggle source
Calls superclass method
Fog::Proxmox::Model.new
# File lib/fog/compute/proxmox/models/server_config.rb, line 57 def initialize(attributes = {}) prepare_service_value(attributes) compute_nets(attributes) compute_disks(attributes) super(attributes) end
Public Instance Methods
mac_addresses()
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 64 def mac_addresses Fog::Proxmox::NicHelper.to_mac_adresses_array(interfaces) end
type_console()
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 72 def type_console console = 'vnc' if %w[std cirrus vmware].include?(vga) console = 'spice' if %w[qxl qxl2 qxl3 qxl4].include?(vga) console = 'term' if %w[serial0 serial1 serial2 serial3].include?(vga) console end
Private Instance Methods
compute_disks(attributes)
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 96 def compute_disks(attributes) controllers = Fog::Proxmox::ControllerHelper.collect_controllers(attributes) @disks ||= Fog::Compute::Proxmox::Disks.new controllers.each do |key, value| storage, volid, size = Fog::Proxmox::DiskHelper.extract_storage_volid_size(value) disk_hash = { id: key.to_s, size: size, volid: volid, storage: storage } names = Fog::Compute::Proxmox::Disk.attributes.reject { |key, _value| %i[id size storage volid].include? key } names.each { |name| disk_hash.store(name.to_sym, Fog::Proxmox::ControllerHelper.extract(name, value)) } @disks << Fog::Compute::Proxmox::Disk.new(disk_hash) end end
compute_nets(attributes)
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 81 def compute_nets(attributes) nets = Fog::Proxmox::NicHelper.collect_nics(attributes) @interfaces ||= Fog::Compute::Proxmox::Interfaces.new nets.each do |key, value| nic_hash = { id: key.to_s, model: Fog::Proxmox::NicHelper.extract_model(value), mac: Fog::Proxmox::NicHelper.extract_mac_address(value) } names = Fog::Compute::Proxmox::Interface.attributes.reject { |key, _value| %i[id mac model].include? key } names.each { |name| nic_hash.store(name.to_sym, Fog::Proxmox::ControllerHelper.extract(name, value)) } @interfaces << Fog::Compute::Proxmox::Interface.new(nic_hash) end end