class DopCommon::DataDisk
Attributes
name[R]
Public Class Methods
new(name, hash, parent = {})
click to toggle source
# File lib/dop_common/data_disk.rb, line 9 def initialize(name, hash, parent = {}) @name = name @hash = symbolize_keys(hash) @parsed_infrastructure = parent[:parsed_infrastructure] @parsed_infrastructure_properties = parent[:parsed_infrastructure_properties] end
Public Instance Methods
pool()
click to toggle source
# File lib/dop_common/data_disk.rb, line 23 def pool @pool ||= pool_valid? ? @hash[:pool] : @parsed_infrastructure_properties.default_pool end
size()
click to toggle source
# File lib/dop_common/data_disk.rb, line 27 def size @size ||= size_valid? ? DopCommon::Utils::DataSize.new(@hash[:size]) : nil end
thin?()
click to toggle source
# File lib/dop_common/data_disk.rb, line 31 def thin? @thin ||= thin_valid? ? @hash[:thin] : true end
validate()
click to toggle source
# File lib/dop_common/data_disk.rb, line 16 def validate log_validation_method(:pool_valid?) log_validation_method(:thin_valid?) log_validation_method(:size_valid?) try_validate_obj("Can't validate the 'data_disk' #{@name} because of previous error"){size} end
Private Instance Methods
pool_valid?()
click to toggle source
# File lib/dop_common/data_disk.rb, line 37 def pool_valid? provider = @parsed_infrastructure.provider default_pool = @parsed_infrastructure_properties.default_pool raise PlanParsingError, "Data disk #{@name}: A 'pool' is required for #{provider} provider type" unless @parsed_infrastructure.provides?(:openstack, :baremetal) || @hash.has_key?(:pool) || default_pool return false unless @hash.has_key?(:pool) raise PlanParsingError, "Data disk #{@name}: 'pool', if defined, must be a non-empty string" if !@hash[:pool].kind_of?(String) || @hash[:pool].empty? true end
size_valid?()
click to toggle source
# File lib/dop_common/data_disk.rb, line 48 def size_valid? raise PlanParsingError, "Data disk #{@name}: 'size' is required" if @hash[:size].nil? raise PlanParsingError, "Data disk #{@name}: 'size' must be of string type" unless @hash[:size].kind_of?(String) true end
thin_valid?()
click to toggle source
# File lib/dop_common/data_disk.rb, line 55 def thin_valid? return false unless @hash.has_key?(:thin) raise PlanParsingError, "Data disk #{@name}: thin, if specified, must be boolean" unless [TrueClass, FalseClass].include?(@hash[:thin].class) true end