class VagrantPlugins::OVirtProvider::Config

Attributes

affinity[RW]
bios_serial[RW]
cloud_init[RW]
cluster[RW]
comment[RW]
console[RW]
cpu_cores[RW]
cpu_sockets[RW]
cpu_threads[RW]
debug[RW]
description[RW]
disk_size[RW]
filtered_api[RW]
insecure[RW]
memory_guaranteed[RW]
memory_maximum[RW]
memory_size[RW]
optimized_for[RW]
password[RW]
placement_host[RW]
template[RW]
url[RW]
username[RW]

Public Class Methods

new() click to toggle source
# File lib/vagrant-ovirt4/config.rb, line 33
def initialize
  @url               = UNSET_VALUE
  @username          = UNSET_VALUE
  @password          = UNSET_VALUE
  @insecure          = UNSET_VALUE
  @debug             = UNSET_VALUE
  @disk_size         = UNSET_VALUE
  @filtered_api      = UNSET_VALUE
  @cpu_cores         = UNSET_VALUE
  @cpu_sockets       = UNSET_VALUE
  @cpu_threads       = UNSET_VALUE
  @template          = UNSET_VALUE
  @memory_size       = UNSET_VALUE
  @memory_maximum    = UNSET_VALUE
  @memory_guaranteed = UNSET_VALUE
  @cluster           = UNSET_VALUE
  @console           = UNSET_VALUE
  @cloud_init        = UNSET_VALUE
  @affinity          = UNSET_VALUE
  @placement_host    = UNSET_VALUE
  @bios_serial       = UNSET_VALUE
  @optimized_for     = UNSET_VALUE
  @description       = UNSET_VALUE
  @comment           = UNSET_VALUE

end

Public Instance Methods

finalize!() click to toggle source
# File lib/vagrant-ovirt4/config.rb, line 60
def finalize!
  @url = nil if @url == UNSET_VALUE
  @username = nil if @username == UNSET_VALUE
  @password = nil if @password == UNSET_VALUE
  @insecure = false if @insecure == UNSET_VALUE
  @debug = false if @debug == UNSET_VALUE
  @disk_size = nil if @disk_size == UNSET_VALUE
  @filtered_api = false if @filtered_api == UNSET_VALUE
  @cpu_cores = 1 if @cpu_cores == UNSET_VALUE
  @cpu_sockets = 1 if @cpu_sockets == UNSET_VALUE
  @cpu_threads = 1 if @cpu_threads == UNSET_VALUE
  @cluster = nil if @cluster == UNSET_VALUE
  @console = nil if @console == UNSET_VALUE
  @memory_size = '256 MB' if @memory_size == UNSET_VALUE
  @memory_maximum = @memory_size if @memory_maximum == UNSET_VALUE
  @memory_guaranteed = @memory_size if @memory_guaranteed == UNSET_VALUE
  @template = nil if @template == UNSET_VALUE
  @cloud_init = nil if @cloud_init == UNSET_VALUE
  @affinity = nil if @affinity == UNSET_VALUE
  @placement_host = nil if @placement_host == UNSET_VALUE
  @bios_serial = nil if @bios_serial == UNSET_VALUE
  @optimized_for = nil if @optimized_for == UNSET_VALUE
  @description = '' if @description == UNSET_VALUE
  @comment = '' if @comment == UNSET_VALUE

  unless optimized_for.nil?
    raise "Invalid 'optimized_for'. Must be one of #{OvirtSDK4::VmType.constants.map { |s| "'#{s.downcase}'" }.join(' ')}" unless OvirtSDK4::VmType.constants.include? optimized_for.upcase.to_sym
  end

  unless affinity.nil?
    raise "Invalid affinity. Must be one of #{OvirtSDK4::VmAffinity.constants.map { |s| "'#{s.downcase}'" }.join(' ')}" unless OvirtSDK4::VmAffinity.constants.include? affinity.upcase.to_sym
  end

  unless disk_size.nil?
    begin
      @disk_size = Filesize.from(@disk_size).to_f('B').to_i
    rescue ArgumentError
      raise "Not able to parse 'disk_size'. Please verify and check again."
    end
  end

  begin
    @memory_size = Filesize.from(@memory_size).to_f('B').to_i
    @memory_maximum = Filesize.from(@memory_maximum).to_f('B').to_i
    @memory_guaranteed = Filesize.from(@memory_guaranteed).to_f('B').to_i
  rescue ArgumentError 
    raise "Not able to parse either `memory_size` or `memory_guaranteed`. Please verify and check again."
  end
end