1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-24 02:03:52 +03:00

feature #2259: Add DeleteSnapshot

This commit is contained in:
Daniel Molina 2013-08-14 13:59:13 +02:00
parent c4fb4c6b72
commit 8132fd0cbe
4 changed files with 34 additions and 1 deletions

View File

@ -1297,6 +1297,7 @@ ECO_LIB_VIEW_FILES="src/cloud/ec2/lib/views/describe_images.erb \
src/cloud/ec2/lib/views/describe_availability_zones.erb \
src/cloud/ec2/lib/views/create_volume.erb \
src/cloud/ec2/lib/views/create_snapshot.erb \
src/cloud/ec2/lib/views/delete_snapshot.erb \
src/cloud/ec2/lib/views/create_image.erb \
src/cloud/ec2/lib/views/describe_volumes.erb \
src/cloud/ec2/lib/views/attach_volume.erb \

View File

@ -248,7 +248,7 @@ module EBS
image = ImageEC2.new(Image.build_xml(image_id.to_i), @client)
rc = image.info
if OpenNebula::is_error?(rc) || image["TEMPLATE/EBS_VOLUME"] != "YES"
if OpenNebula::is_error?(rc) || !image.ebs_volume?
rc ||= OpenNebula::Error.new()
rc.ec2_code = "InvalidVolume.NotFound"
return rc
@ -305,4 +305,30 @@ module EBS
return response.result(binding), 200
end
# Deletes the specified snapshot.
#
# @param [Hash] params
# @option params [String] SnapshotId The ID of the Amazon EBS snapshot.
def delete_snapshot(params)
snapshot_id = params['SnapshotId']
snapshot_id = snapshot_id.split('-')[1]
snapshot = ImageEC2.new(Image.build_xml(snapshot_id.to_i), @client)
rc = snapshot.info
if OpenNebula::is_error?(rc) || snapshot.ebs_volume? || snapshot.ec2_ami?
rc ||= OpenNebula::Error.new()
rc.ec2_code = "InvalidSnapshot.NotFound"
return rc
end
rc = snapshot.delete
if OpenNebula::is_error?(rc)
return rc
end
erb_version = params['Version']
response = ERB.new(File.read(@config[:views]+"/delete_snapshot.erb"))
return response.result(binding), 200
end
end

View File

@ -136,6 +136,8 @@ class EC2Application
result,rc = econe_server.describe_availability_zones(params)
when 'CreateSnapshot'
result,rc = econe_server.create_snapshot(params)
when 'DeleteSnapshot'
result,rc = econe_server.delete_snapshot(params)
when 'CreateImage'
result,rc = econe_server.create_image(params)
when 'CreateVolume'

View File

@ -0,0 +1,4 @@
<DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2013-06-15/">
<requestId><%= @request_id %></requestId>
<return>true</return>
</DeleteSnapshotResponse>