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

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

Overview

ServerConfig model: https://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.



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

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)
  initialize_efidisk(new_attributes)
  super(new_attributes)
end

Instance Method Details

#flattenObject



105
106
107
108
109
110
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 105

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



94
95
96
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 94

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

#type_consoleObject



98
99
100
101
102
103
# File 'lib/fog/proxmox/compute/models/server_config.rb', line 98

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