Class: Bosh::AwsCloud::VolumeProperties

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/cloud/aws/volume_properties.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#cloud_error, #default_ephemeral_disk_mapping, #ebs_ephemeral_disk_mapping, #extract_security_groups

Constructor Details

#initialize(options) ⇒ VolumeProperties

Returns a new instance of VolumeProperties.



8
9
10
11
12
13
14
# File 'lib/cloud/aws/volume_properties.rb', line 8

def initialize(options)
  @size = options[:size] || 0
  @type = options[:type] || 'standard'
  @iops = options[:iops]
  @az = options[:az]
  @encrypted = options[:encrypted] || false
end

Instance Attribute Details

#azObject (readonly)

Returns the value of attribute az.



6
7
8
# File 'lib/cloud/aws/volume_properties.rb', line 6

def az
  @az
end

#encryptedObject (readonly)

Returns the value of attribute encrypted.



6
7
8
# File 'lib/cloud/aws/volume_properties.rb', line 6

def encrypted
  @encrypted
end

#iopsObject (readonly)

Returns the value of attribute iops.



6
7
8
# File 'lib/cloud/aws/volume_properties.rb', line 6

def iops
  @iops
end

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/cloud/aws/volume_properties.rb', line 6

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/cloud/aws/volume_properties.rb', line 6

def type
  @type
end

Instance Method Details

#validate!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cloud/aws/volume_properties.rb', line 16

def validate!
  case @type
    when 'standard'
      cloud_error('AWS CPI minimum disk size is 1 GiB') if @size < 1024
      cloud_error('AWS CPI maximum disk size is 1 TiB') if @size > 1024 * 1000
      cloud_error("Cannot specify an 'iops' value when disk type is '#{@type}'. 'iops' is only allowed for 'io1' volume types.") unless @iops.nil?
    when 'gp2'
      cloud_error('AWS CPI minimum disk size is 1 GiB') if @size < 1024
      cloud_error('AWS CPI maximum disk size is 16 TiB') if @size > 1024 * 16000
      cloud_error("Cannot specify an 'iops' value when disk type is '#{@type}'. 'iops' is only allowed for 'io1' volume types.") unless @iops.nil?
    when 'io1'
      validate_iops
    else
      cloud_error("AWS CPI supports only gp2, io1, or standard disk type, received: #{@type}")
  end
end