mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
first pass at snapshot functions
This commit is contained in:
parent
7a5c99ef0f
commit
c256b8f388
5 changed files with 131 additions and 0 deletions
|
@ -85,6 +85,20 @@ module Fog
|
|||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Create a snapshot of an EBS volume and store it in S3
|
||||
#
|
||||
# ==== Parameters
|
||||
# * volume_id<~String> - Id of EBS volume to snapshot
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def create_snapshot(volume_id)
|
||||
request({
|
||||
'Action' => 'CreateSnapshot',
|
||||
'VolumeId' => 'VolumeId'
|
||||
}, Fog::Parsers::AWS::EC2::CreateSnapshot.new)
|
||||
end
|
||||
|
||||
# Create an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
|
@ -134,6 +148,7 @@ module Fog
|
|||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_security_group(name)
|
||||
request({
|
||||
|
@ -142,6 +157,23 @@ module Fog
|
|||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Delete a snapshot of an EBS volume that you own
|
||||
#
|
||||
# ==== Parameters
|
||||
# * snapshot_id<~String> - ID of snapshot to delete
|
||||
# ==== Returns
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_snapshot(snapshot_id)
|
||||
request({
|
||||
'Action' => 'DeleteSnapshot',
|
||||
'SnapshotId' => snapshot_id
|
||||
}, Fog::Parsers::AWS::EC2::Basic.new)
|
||||
end
|
||||
|
||||
# Delete an EBS volume
|
||||
#
|
||||
# ==== Parameters
|
||||
|
@ -150,6 +182,7 @@ module Fog
|
|||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * :request_id<~String> - Id of request
|
||||
# * :return<~Boolean> - success?
|
||||
def delete_volume(volume_id)
|
||||
request({
|
||||
|
@ -259,6 +292,20 @@ module Fog
|
|||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeSecurityGroups.new)
|
||||
end
|
||||
|
||||
# Describe all or specified snapshots
|
||||
#
|
||||
# ==== Parameters
|
||||
# * snapshot_id<~Array> - List of snapshots to describe, defaults to all
|
||||
#
|
||||
# ==== Returns
|
||||
# FIXME: docs
|
||||
def describe_snapshots(snapshot_id = [])
|
||||
params = indexed_params('SnapshotId', snapshot_id)
|
||||
request({
|
||||
'Action' => 'DescribeSnapshots'
|
||||
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeSnapshots.new)
|
||||
end
|
||||
|
||||
# Describe all or specified volumes.
|
||||
#
|
||||
# ==== Parameters
|
||||
|
|
|
@ -52,6 +52,25 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
class CreateSnapshot < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'progress'
|
||||
@response[:progress] = @value
|
||||
when 'snapshotId'
|
||||
@response[:snapshot_id] = @value
|
||||
when 'startTime'
|
||||
@response[:start_time] = Time.parse(@value)
|
||||
when 'status'
|
||||
@response[:status] = @value
|
||||
when 'volumeId'
|
||||
@response[:volume_id] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class CreateVolume < Fog::Parsers::Base
|
||||
|
||||
def end_element(name)
|
||||
|
@ -337,6 +356,33 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
class DescribeSnapshots < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { :snapshot_set => [] }
|
||||
@snapshot = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'item'
|
||||
@response[:snapshot_set] << @snapshot
|
||||
@snapshot = {}
|
||||
when 'progress'
|
||||
@snapshot[:progress] = @value
|
||||
when 'snapshotId'
|
||||
@snapshot[:snapshot_id] = @value
|
||||
when 'startTime'
|
||||
@snapshot[:start_time] = Time.parse(@value)
|
||||
when 'status'
|
||||
@snapshot[:status] = @value
|
||||
when 'volumeId'
|
||||
@snapshot[:volume_id] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class DescribeVolumes < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
|
|
13
spec/aws/ec2/create_snapshot_spec.rb
Normal file
13
spec/aws/ec2/create_snapshot_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe 'EC2.create_snapshot' do
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
pending
|
||||
# actual = ec2.create_snapshot(volume_id)
|
||||
# p actual
|
||||
end
|
||||
|
||||
it "should return proper attributes with params"
|
||||
|
||||
end
|
13
spec/aws/ec2/delete_snapshot_spec.rb
Normal file
13
spec/aws/ec2/delete_snapshot_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe 'EC2.delete_snapshot' do
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
pending
|
||||
# actual = ec2.delete_snapshot(snapshot_id)
|
||||
# p actual
|
||||
end
|
||||
|
||||
it "should return proper attributes with params"
|
||||
|
||||
end
|
12
spec/aws/ec2/describe_snapshot_spec.rb
Normal file
12
spec/aws/ec2/describe_snapshot_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe 'EC2.describe_snapshots' do
|
||||
|
||||
it "should return proper attributes with no params" do
|
||||
actual = ec2.describe_snapshots
|
||||
p actual
|
||||
end
|
||||
|
||||
it "should return proper attributes with params"
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue