mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
feature #1291: Update ec2 imageState
This commit is contained in:
1 parent
ec2040694e
commit
1c754efcab
2 files changed
+34
-24
No files matched your search
@@ -59,6 +59,18 @@ class EC2QueryServer < CloudServer
|
||||
'unkn' => :terminated
|
||||
}
|
||||
|
||||
EC2_IMAGE_STATES={
|
||||
"INIT" => "pending",
|
||||
"READY" => "available",
|
||||
"USED" => "available",
|
||||
"DISABLED" => nil,
|
||||
"LOCKED" => "pending",
|
||||
"ERROR" => "failed",
|
||||
"CLONE" => "available",
|
||||
"DELETE" => nil,
|
||||
"USED_PERS" => "available"
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
|
||||
def initialize(client, oneadmin_client, config, logger)
|
||||
@@ -251,6 +263,10 @@ class EC2QueryServer < CloudServer
|
||||
<name>#{ec2_state[:name]}</name>"
|
||||
end
|
||||
|
||||
def render_image_state(image)
|
||||
EC2_IMAGE_STATES[image.state_str]
|
||||
end
|
||||
|
||||
def render_launch_time(vm)
|
||||
return "<launchTime>#{Time.at(vm["STIME"].to_i).xmlschema}</launchTime>"
|
||||
end
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/<%=erb_version%>/">
|
||||
<imagesSet>
|
||||
<% impool.each do |im| %>
|
||||
<item>
|
||||
<imageId>ami-<%= sprintf('%08i', im.id) %></imageId>
|
||||
<imageLocation><%= im['SOURCE'].split('/').last %></imageLocation>
|
||||
<% if im['STATE'] == '3' || im['STATE'] == '5' %>
|
||||
<imageState>failed</imageState>
|
||||
<% elsif im['STATE'] == '1' || im['STATE'] == '2' %>
|
||||
<imageState>available</imageState>
|
||||
<% elsif im['STATE'] == '4'%>
|
||||
<imageState>pending</imageState>
|
||||
<% end %>
|
||||
<imageOwnerId><%= im['UNAME'] %></imageOwnerId>
|
||||
<% if im['PUBLIC'] == '0' %>
|
||||
<isPublic>false</isPublic>
|
||||
<% elsif im['PUBLIC'] == '1' %>
|
||||
<isPublic>true</isPublic>
|
||||
<% end %>
|
||||
<architecture>i386</architecture>
|
||||
<imageType>machine</imageType>
|
||||
</item>
|
||||
<% end %>
|
||||
</imagesSet>
|
||||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/<%=erb_version%>/">
|
||||
<imagesSet>
|
||||
<% impool.each do |im| %>
|
||||
<% if state_image = render_image_state(im) %>
|
||||
<item>
|
||||
<imageId>ami-<%= sprintf('%08i', im.id) %></imageId>
|
||||
<imageLocation><%= im['SOURCE'].split('/').last %></imageLocation>
|
||||
<imageState><%= state_image %></imageState>
|
||||
<imageOwnerId><%= im['UNAME'] %></imageOwnerId>
|
||||
<isPublic><%= im.public? ? "true" : "false" %></isPublic>
|
||||
<architecture>i386</architecture>
|
||||
<imageType>machine</imageType>
|
||||
</item>
|
||||
<% else
|
||||
next
|
||||
end
|
||||
end %>
|
||||
</imagesSet>
|
||||
</DescribeImagesResponse>
|
||||
Reference in new issue
Block a user