1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-27 10:50:10 +03:00

feature #2259: Now RegisterImage is required to use an image. It will include EC2_AMI attr

This commit is contained in:
Daniel Molina 2013-08-16 10:47:44 +02:00
parent f668b94e42
commit 2052d9f631
2 changed files with 18 additions and 8 deletions

View File

@ -127,20 +127,30 @@ class EC2QueryServer < CloudServer
return response.result(binding), 200
end
# TODO Kernel, Ramdisk, Arch, BlockDeviceMapping
def register_image(params)
# Get the Image ID
tmp, img=params['ImageLocation'].split('-')
image_id = params['ImageLocation']
image = ImageEC2.new(Image.build_xml(image_id.to_i), @client)
image = Image.new(Image.build_xml(img.to_i), @client)
# Enable the new Image
rc = image.info
if OpenNebula.is_error?(rc)
rc.ec2_code = "InvalidAMIID.NotFound"
return rc
end
image.enable
if image["EBS_VOLUME"] == "YES"
return OpenNebula::Error.new("The image you are trying to register"\
" is already a volume")
elsif image["EBS_SNAPSHOT"] == "YES"
return OpenNebula::Error.new("The image you are trying to register"\
" is already an snapshot")
end
image.add_element('TEMPLATE', {"EC2_AMI" => "YES"})
rc = image.update
if OpenNebula.is_error?(rc)
return rc
end
erb_version = params['Version']

View File

@ -3,7 +3,7 @@
<requestId><%= @request_id %></requestId>
<imagesSet>
<% impool.each do |im| %>
<% if (state_image = im.render_state) && (im['TEMPLATE/EBS_VOLUME'] != 'YES') %>
<% if (state_image = im.render_state) && im.ec2_ami? %>
<item>
<name><%= im['NAME'] %></name>
<% if im['TEMPLATE/DESCRIPTION'] %>
@ -12,7 +12,7 @@
<% if im['TEMPLATE/PLATFORM'] %>
<platform><%= im['TEMPLATE/PLATFORM'] %></platform>
<% end %>
<imageId>ami-<%= sprintf('%08i', im.id) %></imageId>
<imageId><%= im.ec2_id %></imageId>
<imageLocation><%= im['SOURCE'].split('/').last %></imageLocation>
<imageState><%= state_image %></imageState>
<imageOwnerId><%= im['UNAME'] %></imageOwnerId>