Module: Pipette::Ec2

Included in:
Pipette
Defined in:
lib/pipette/ec2.rb

Instance Method Summary collapse

Instance Method Details

#create_volume(size) ⇒ Object



10
11
12
13
14
15
# File 'lib/pipette/ec2.rb', line 10

def create_volume(size)
  say_with_time "Creating new volume of size #{size}G" do
    res = ec2.create_volume(nil, size, zone)
    res[:aws_id]
  end
end

#ec2Object



6
7
8
# File 'lib/pipette/ec2.rb', line 6

def ec2
  @ec2 ||= RightAws::Ec2.new(opts[:access_key], opts[:secret_access_key])
end

#instance_idObject



28
29
30
# File 'lib/pipette/ec2.rb', line 28

def instance_id
  @instance_id ||= meta("instance-id")
end

#meta(path) ⇒ Object



32
33
34
# File 'lib/pipette/ec2.rb', line 32

def meta(path)
  open("http://169.254.169.254/latest/meta-data/#{path}").read.strip
end

#mount_volume(volume_id, mount_point) ⇒ Object



17
18
19
20
21
22
# File 'lib/pipette/ec2.rb', line 17

def mount_volume(volume_id, mount_point)
  say_with_time "Mounting #{volume_id} at #{mount_point}" do
    res = ec2.attach_volume(volume_id, instance_id, mount_point)
    res[:aws_device]
  end
end

#zoneObject



24
25
26
# File 'lib/pipette/ec2.rb', line 24

def zone
  @zone ||= meta("placement/availability-zone")
end