class VagrantPlugins::PersistentStorage::Config
Attributes
create[RW]
create?[RW]
diskdevice[RW]
drive_letter[RW]
enabled[RW]
enabled?[RW]
filesystem[RW]
format[RW]
format?[RW]
location[RW]
manage[RW]
manage?[RW]
mount[RW]
mount?[RW]
mountname[RW]
mountoptions[RW]
mountpoint[RW]
size[RW]
use_lvm[RW]
use_lvm?[RW]
volgroupname[RW]
Public Class Methods
new()
click to toggle source
# File lib/vagrant-persistent-storage/config.rb, line 30 def initialize @size = UNSET_VALUE @create = true @mount = true @manage = true @format = true @use_lvm = true @enabled = false @location = UNSET_VALUE @mountname = UNSET_VALUE @mountpoint = UNSET_VALUE @mountoptions = UNSET_VALUE @diskdevice = UNSET_VALUE @filesystem = UNSET_VALUE @volgroupname = UNSET_VALUE @drive_letter = UNSET_VALUE end
Public Instance Methods
finalize!()
click to toggle source
# File lib/vagrant-persistent-storage/config.rb, line 48 def finalize! @size = 0 if @size == UNSET_VALUE @create = true if @create == UNSET_VALUE @mount = true if @mount == UNSET_VALUE @manage = true if @manage == UNSET_VALUE @format = true if @format == UNSET_VALUE @use_lvm = true if @use_lvm == UNSET_VALUE @enabled = false if @enabled == UNSET_VALUE @location = 0 if @location == UNSET_VALUE @mountname = 0 if @mountname == UNSET_VALUE @mountpoint = 0 if @mountpoint == UNSET_VALUE @mountoptions = 0 if @mountoptions == UNSET_VALUE @diskdevice = 0 if @diskdevice == UNSET_VALUE @filesystem = 0 if @filesystem == UNSET_VALUE @volgroupname = 0 if @volgroupname == UNSET_VALUE @drive_letter = 0 if @drive_letter == UNSET_VALUE end
validate(machine)
click to toggle source
# File lib/vagrant-persistent-storage/config.rb, line 66 def validate(machine) errors = [] errors << validate_bool('persistent_storage.create', @create) errors << validate_bool('persistent_storage.mount', @mount) errors << validate_bool('persistent_storage.mount', @manage) errors << validate_bool('persistent_storage.mount', @format) errors << validate_bool('persistent_storage.mount', @use_lvm) errors << validate_bool('persistent_storage.mount', @enabled) errors.compact! if !machine.config.persistent_storage.size.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.size', :is_class => size.class.to_s, }) end if !machine.config.persistent_storage.location.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.location', :is_class => location.class.to_s, }) end if !machine.config.persistent_storage.mountname.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.mountname', :is_class => mountname.class.to_s, }) end if !machine.config.persistent_storage.mountpoint.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.mountpoint', :is_class => mountpoint.class.to_s, }) end if !machine.config.persistent_storage.diskdevice.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.diskdevice', :is_class => diskdevice.class.to_s, }) end if !machine.config.persistent_storage.filesystem.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.filesystem', :is_class => filesystem.class.to_s, }) end if !machine.config.persistent_storage.volgroupname.kind_of?(String) errors << I18n.t('vagrant_persistent_storage.config.not_a_string', { :config_key => 'persistent_storage.volgroupname', :is_class => volgroupname.class.to_s, }) end mount_point_path = Pathname.new("#{machine.config.persistent_storage.location}") if ! mount_point_path.absolute? errors << I18n.t('vagrant_persistent_storage.config.not_a_path', { :config_key => 'persistent_storage.location', :is_path => location.class.to_s, }) end { 'Persistent Storage configuration' => errors } if ! File.exists?@location.to_s and ! @create == "true" return { "location" => ["file doesn't exist, and create set to false"] } end {} end
Private Instance Methods
validate_bool(key, value)
click to toggle source
# File lib/vagrant-persistent-storage/config.rb, line 138 def validate_bool(key, value) if ![TrueClass, FalseClass].include?(value.class) && value != UNSET_VALUE I18n.t('vagrant_persistent_storage.config.not_a_bool', { :config_key => key, :value => value.class.to_s }) else nil end end