Class: EC2Launcher::DSL::BlockDevice

Inherits:
Object
  • Object
show all
Defined in:
lib/ec2launcher/dsl/block_device.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option_hash = nil) ⇒ BlockDevice

Returns a new instance of BlockDevice.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ec2launcher/dsl/block_device.rb', line 23

def initialize(option_hash = nil)
	if option_hash
		@name = option_hash["name"]
		@count = option_hash["count"]
		@size = option_hash["size"]
		@iops = option_hash["iops"]
		@raid_level = option_hash["raid_level"]
		@mount = option_hash["mount_point"]
		@owner = option_hash["owner"]
		@group = option_hash["group"]
		@block_ra = option_hash["block_ra"]
	end

	# Default values
	@count ||= 1
	@group ||= "root"
	@user ||= "root"
end

Instance Attribute Details

#mount_pointObject (readonly)

Returns the value of attribute mount_point.



10
11
12
# File 'lib/ec2launcher/dsl/block_device.rb', line 10

def mount_point
  @mount_point
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/ec2launcher/dsl/block_device.rb', line 11

def name
  @name
end

Class Method Details

.json_create(o) ⇒ Object



71
72
73
# File 'lib/ec2launcher/dsl/block_device.rb', line 71

def self.json_create(o)
	new(o['data'])
end

Instance Method Details

#as_jsonObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ec2launcher/dsl/block_device.rb', line 50

def as_json(*)
	{
		JSON.create_id => self.class.name,
		"data" => {
			"name" => @name,
			"count" => @count,
			"size" => @size,
			"iops" => @iops,
			"raid_level" => @raid_level,
			"mount_point" => @mount,
			"owner" => @owner,
			"group" => @group,
			"block_ra" => @block_ra
		}
	}
end

#is_raid?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/ec2launcher/dsl/block_device.rb', line 42

def is_raid?()
	@raid_level.nil?
end

#provisioned_iops?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ec2launcher/dsl/block_device.rb', line 46

def provisioned_iops?()
	! @iops.nil? || @iops == 0
end

#to_json(*a) ⇒ Object



67
68
69
# File 'lib/ec2launcher/dsl/block_device.rb', line 67

def to_json(*a)
	as_json.to_json(*a)
end