Class: Fog::Proxmox::Compute::ServerConfig

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/proxmox/compute/models/server_config.rb

Overview

ServerConfig model: pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/node/qemu|lxc/vmid/config memory, balloon, shares and swap are in Mb

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ ServerConfig

Returns a new instance of ServerConfig.



82
83
84
85
86
87
88
89
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 82

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

Instance Method Details

#flattenObject



102
103
104
105
106
107
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 102

def flatten
  flat_hash = attributes.reject { |attribute| %i[node_id type vmid disks interfaces].include? attribute }
  flat_hash.merge(interfaces_flatten)
  flat_hash.merge(disks_flatten)
  flat_hash
end

#mac_addressesObject



91
92
93
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 91

def mac_addresses
  Fog::Proxmox::NicHelper.to_mac_adresses_array(interfaces)
end

#type_consoleObject



95
96
97
98
99
100
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 95

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