You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:14:43 UTC

svn commit: r961984 - in /incubator/deltacloud/trunk/framework: app/views/instances/show.html.erb lib/drivers/ec2.rb

Author: lutter
Date: Thu Jul  8 23:14:43 2010
New Revision: 961984

URL: http://svn.apache.org/viewvc?rev=961984&view=rev
Log:
Begin simplifying the SPI between driver and framework.

Modified:
    incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb
    incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb

Modified: incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb?rev=961984&r1=961983&r2=961984&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb Thu Jul  8 23:14:43 2010
@@ -1,5 +1,5 @@
 
-<h1><%= @instance.id %></h1>
+<h1><%= @instance[:id] %></h1>
 
 <dl>
   <di>
@@ -7,7 +7,7 @@
       Image
     </dt>
     <dd>
-      <%= link_to @instance.image, @instance.image %>
+      <%= link_to @instance[:image_id], image_url( @instance[:image_id] ) %>
     </dd>
   </di>
   <di>
@@ -15,7 +15,7 @@
       Owner
     </dt>
     <dd>
-      <%= link_to @instance.owner, @instance.owner %>
+      <%= link_to @instance[:owner], @instance[:owner] %>
     </dd>
   </di>
   <di>
@@ -23,7 +23,7 @@
       State
     </dt>
     <dd>
-      <%= @instance.state %>
+      <%= @instance[:state] %>
     </dd>
   </di>
   <di>
@@ -31,7 +31,7 @@
       Public Address
     </dt>
     <dd>
-      <%= @instance.public_address || '-' %>
+      <%= @instance[:public_address] %>
     </dd>
   </di>
   <di>
@@ -39,14 +39,14 @@
       Private Address
     </dt>
     <dd>
-      <%= @instance.private_address || '-' %>
+      <%= @instance[:private_address] %>
     </dd>
   </di>
 </dl>
 
 <div>
-  <% @instance.class.actions.each do |action| %>
-    <%= link_to action, polymorphic_url( @instance, :action=>action ), :method=>:post %>
-  <% end %>
-  <%= link_to 'delete', @instance, :method=>:delete %>
+  <%# @instance.class.actions.each do |action| %>
+    <%#= link_to action, polymorphic_url( @instance, :action=>action ), :method=>:post %>
+  <%# end %>
+  <%= link_to 'delete', instance_url( @instance[:id] ), :method=>:delete %>
 </div>

Modified: incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb?rev=961984&r1=961983&r2=961984&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb Thu Jul  8 23:14:43 2010
@@ -47,8 +47,10 @@ module Drivers
     def instances(credentials, *ids)
       ec2 = new_client(credentials)
       instances = []
-      ec2.describe_instances(ids).each do |ec2_instance|
-        instances << convert_instance( ec2_instance )
+      safely do
+        ec2.describe_instances(ids).each do |ec2_instance|
+          instances << convert_instance( ec2_instance )
+        end
       end
       instances
     end
@@ -63,10 +65,12 @@ module Drivers
     def accounts(credentials, *ids)
       ec2 = new_client( credentials )
       accounts = {}
-      ec2.describe_images(*ids).each do |ec2_image|
-        if ( ec2_image[:aws_id] =~ /^ami-/ )
-          unless ( accounts[ec2_image[:aws_owner]] ) 
-            accounts[ec2_image[:aws_owner]] = Account.new( :id=>ec2_image[:aws_owner] )
+      safely do
+        ec2.describe_images(*ids).each do |ec2_image|
+          if ( ec2_image[:aws_id] =~ /^ami-/ )
+            unless ( accounts[ec2_image[:aws_owner]] ) 
+              accounts[ec2_image[:aws_owner]] = Account.new( :id=>ec2_image[:aws_owner] )
+            end
           end
         end
       end
@@ -133,14 +137,14 @@ module Drivers
     end
    
     def convert_instance(ec2_instance)
-      Instance.new( {
+      {
         :id=>ec2_instance[:aws_instance_id], 
         :state=>ec2_instance[:aws_state].upcase,
-        :image=>Image.new( :id=>ec2_instance[:aws_image_id] ),
+        :image_id=>Image.new( :id=>ec2_instance[:aws_image_id] ),
         :owner=>Account.new( :id=>ec2_instance[:aws_owner] ),
         :public_address=>( ec2_instance[:dns_name] == '' ? nil : ec2_instance[:dns_name] ),
         :private_address=>( ec2_instance[:private_dns_name] == '' ? nil : ec2_instance[:private_dns_name] ),
-      } )
+      } 
     end
 
   end