Class: DopCommon::DataDisk

Inherits:
Object
  • Object
show all
Includes:
HashParser, Utils, Validator
Defined in:
lib/dop_common/data_disk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

sanitize_env

Methods included from HashParser

deep_symbolize_keys, hash_of_pattern_lists_valid?, is_valid_regexp?, key_aliases, load_content, load_content_valid?, parse_hash_of_pattern_lists, parse_pattern_list, pattern_list_valid?, represents_regexp?, symbolize_keys

Methods included from Validator

#log_validation_method, #set_not_valid, #try_validate_obj, #valid?

Constructor Details

#initialize(name, hash, parent = {}) ⇒ DataDisk

Returns a new instance of DataDisk.



9
10
11
12
13
14
# 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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/dop_common/data_disk.rb', line 7

def name
  @name
end

Instance Method Details

#poolObject



23
24
25
# File 'lib/dop_common/data_disk.rb', line 23

def pool
  @pool ||= pool_valid? ? @hash[:pool] : @parsed_infrastructure_properties.default_pool
end

#sizeObject



27
28
29
# File 'lib/dop_common/data_disk.rb', line 27

def size
  @size ||= size_valid? ? DopCommon::Utils::DataSize.new(@hash[:size]) : nil
end

#thin?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/dop_common/data_disk.rb', line 31

def thin?
  @thin ||= thin_valid? ? @hash[:thin] : true
end

#validateObject



16
17
18
19
20
21
# 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