class Fog::Compute::Proxmox::ServerConfig
ServerConfig model
Public Class Methods
new(new_attributes = {})
click to toggle source
Calls superclass method
# File lib/fog/compute/proxmox/models/server_config.rb, line 72 def initialize(new_attributes = {}) prepare_service_value(new_attributes) Fog::Proxmox::Attributes.set_attr_and_sym('vmid', attributes, new_attributes) requires :vmid initialize_interfaces(new_attributes) initialize_disks(new_attributes) super(new_attributes) end
Public Instance Methods
flatten()
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 92 def flatten flat_hash = attributes.reject { |attribute| [:node_id, :type, :vmid, :disks, :interfaces].include? attribute } flat_hash.merge(interfaces_flatten) flat_hash.merge(disks_flatten) flat_hash end
mac_addresses()
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 81 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 85 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
disks_flatten()
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 107 def disks_flatten flat_hash = {} disks.each { |disk| flat_hash.merge(disk.flatten) } flat_hash end
initialize_disks(new_attributes)
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 128 def initialize_disks(new_attributes) controllers = Fog::Proxmox::ControllerHelper.collect_controllers(new_attributes) 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 { |attribute| [:id, :size, :storage, :volid].include? attribute } names.each { |name| disk_hash.store(name.to_sym, Fog::Proxmox::ControllerHelper.extract(name, value)) } attributes[:disks] << Fog::Compute::Proxmox::Disk.new(disk_hash) end end
initialize_interfaces(new_attributes)
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 113 def initialize_interfaces(new_attributes) nets = Fog::Proxmox::NicHelper.collect_nics(new_attributes) attributes[:interfaces] = Fog::Compute::Proxmox::Interfaces.new nets.each do |key, value| nic_hash = { id: key.to_s, model: Fog::Proxmox::NicHelper.extract_nic_id(value), mac: Fog::Proxmox::NicHelper.extract_mac_address(value) } names = Fog::Compute::Proxmox::Interface.attributes.reject { |attribute| [:id, :mac, :model].include? attribute } names.each { |name| nic_hash.store(name.to_sym, Fog::Proxmox::ControllerHelper.extract(name, value)) } attributes[:interfaces] << Fog::Compute::Proxmox::Interface.new(nic_hash) end end
interfaces_flatten()
click to toggle source
# File lib/fog/compute/proxmox/models/server_config.rb, line 101 def interfaces_flatten flat_hash = {} interfaces.each { |interface| flat_hash.merge(interface.flatten) } flat_hash end