Sha256: 1aa1d82201c6ae083dc9b042225e4ed18b212dd9f1a7c3140395851e24a4f395

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require 'vagrant'

module VagrantPlugins
  module OVirtProvider
    class Config < Vagrant.plugin('2', :config)

      attr_accessor :url
      attr_accessor :username
      attr_accessor :password
      attr_accessor :datacenter
      attr_accessor :cluster

      # Domain specific settings used while creating new machine.
      attr_accessor :memory
      attr_accessor :cpus
      attr_accessor :template
      attr_accessor :console
      attr_accessor :disk_size

      def initialize
        @url            = UNSET_VALUE
        @username       = UNSET_VALUE
        @password       = UNSET_VALUE
        @datacenter     = UNSET_VALUE
        @cluster        = UNSET_VALUE

        # Domain specific settings.
        @memory     = UNSET_VALUE
        @cpus       = UNSET_VALUE
        @template   = UNSET_VALUE
        @console    = UNSET_VALUE
        @disk_size  = UNSET_VALUE

        @ca_no_verify = UNSET_VALUE
      end

      def finalize!
        @url = nil if @url == UNSET_VALUE
        @username = nil if @username == UNSET_VALUE
        @password = nil if @password == UNSET_VALUE
        @datacenter = nil if @datacenter == UNSET_VALUE
        @cluster = nil if @cluster == UNSET_VALUE

        # Domain specific settings.
        @memory = 512 if @memory == UNSET_VALUE
        @cpus = 1 if @cpus == UNSET_VALUE
        @template = 'Blank' if @template == UNSET_VALUE
        @console = 'spice' if @console == UNSET_VALUE
        @disk_size = nil if @disk_size == UNSET_VALUE

        @ca_no_verify = false if @ca_no_verify == UNSET_VALUE
      end

      def validate(machine)
        valid_console_types = ['vnc', 'spice']
        raise Error::InvalidConsoleType,
          :console => @console unless valid_console_types.include? @console
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-ovirt3-1.1.1 lib/vagrant-ovirt3/config.rb
vagrant-ovirt3-1.1.0 lib/vagrant-ovirt3/config.rb