class Fog::Compute::Proxmox::ContainerConfig

ContainerConfig model

Attributes

interfaces[R]
mount_points[R]

Public Class Methods

new(attributes = {}) click to toggle source
Calls superclass method Fog::Proxmox::Model.new
# File lib/fog/compute/proxmox/models/container_config.rb, line 58
def initialize(attributes = {})
  prepare_service_value(attributes)
  compute_nets(attributes)
  compute_mps(attributes)
  super(attributes)
end

Public Instance Methods

mac_addresses() click to toggle source
# File lib/fog/compute/proxmox/models/container_config.rb, line 69
def mac_addresses
  Fog::Proxmox::NicHelper.to_mac_adresses_array(interfaces)
end
type_console() click to toggle source
# File lib/fog/compute/proxmox/models/container_config.rb, line 73
def type_console
  'vnc' # by default. term is available too
end

Private Instance Methods

compute_mps(attributes) click to toggle source
# File lib/fog/compute/proxmox/models/container_config.rb, line 94
def compute_mps(attributes)
  controllers = Fog::Proxmox::ControllerHelper.collect_controllers(attributes)
  @mount_points ||= 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,
      storage: storage,
      volid: volid,
      size: size
    }
    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)) }
    @mount_points << Fog::Compute::Proxmox::Disk.new(disk_hash)
  end
end
compute_nets(attributes) click to toggle source
# File lib/fog/compute/proxmox/models/container_config.rb, line 79
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,
      name: Fog::Proxmox::NicHelper.extract_name(value),
      mac: Fog::Proxmox::NicHelper.extract_mac_address(value)
    }
    names = Fog::Compute::Proxmox::Interface.attributes.reject { |key, _value| %i[id mac name].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