incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r961988 - in /incubator/deltacloud/trunk/framework: app/controllers/ app/models/ app/views/images/ app/views/instances/ app/views/storage_snapshots/ app/views/storage_volumes/ config/ lib/drivers/ public/stylesheets/ public/stylesheets/sass/
Date Thu, 08 Jul 2010 23:15:08 GMT
Author: lutter
Date: Thu Jul  8 23:15:07 2010
New Revision: 961988

URL: http://svn.apache.org/viewvc?rev=961988&view=rev
Log:
Start working on storage volumes and snapshots.

Added:
    incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb
    incubator/deltacloud/trunk/framework/app/controllers/storage_volumes_controller.rb
    incubator/deltacloud/trunk/framework/app/views/storage_snapshots/
    incubator/deltacloud/trunk/framework/app/views/storage_snapshots/index.html.erb
    incubator/deltacloud/trunk/framework/app/views/storage_snapshots/show.html.erb
    incubator/deltacloud/trunk/framework/app/views/storage_volumes/
    incubator/deltacloud/trunk/framework/app/views/storage_volumes/index.html.erb
    incubator/deltacloud/trunk/framework/app/views/storage_volumes/show.html.erb
Removed:
    incubator/deltacloud/trunk/framework/app/controllers/accounts_controller.rb
    incubator/deltacloud/trunk/framework/app/models/account.rb
    incubator/deltacloud/trunk/framework/app/models/base.rb
Modified:
    incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
    incubator/deltacloud/trunk/framework/app/views/images/index.html.erb
    incubator/deltacloud/trunk/framework/app/views/images/show.html.erb
    incubator/deltacloud/trunk/framework/app/views/instances/index.html.erb
    incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb
    incubator/deltacloud/trunk/framework/config/routes.rb
    incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
    incubator/deltacloud/trunk/framework/public/stylesheets/application.css
    incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass

Modified: incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb Thu Jul 
8 23:15:07 2010
@@ -25,10 +25,14 @@ class InstancesController < ApplicationC
   def show
     @instance = driver.instance( credentials, params[:id] )
 
+
     respond_to do |format|
-      format.html
+      format.html {
+        render :text=>'resource not found', :status=>404 and return unless @instance
+      }
       format.json
       format.xml { 
+        render :nothing=>true, :status=>404 and return unless @instance
         render :xml=>convert_to_xml( :instance, @instance )
       }
     end

Added: incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb?rev=961988&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb (added)
+++ incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb Thu
Jul  8 23:15:07 2010
@@ -0,0 +1,27 @@
+load 'drivers/ec2.rb'
+
+class StorageSnapshotsController < ApplicationController
+
+  include DriverHelper
+  include ConversionHelper
+
+  around_filter :catch_auth
+
+  def index
+    @snapshots = driver.snapshots( credentials )
+    respond_to do |format|
+      format.html
+    end
+  end
+
+  def show
+    @snapshot = driver.snapshot( credentials, params[:id] )
+    respond_to do |format|
+      format.html
+      format.json
+      format.xml {
+      }
+    end
+  end
+
+end

Added: incubator/deltacloud/trunk/framework/app/controllers/storage_volumes_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/storage_volumes_controller.rb?rev=961988&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/storage_volumes_controller.rb (added)
+++ incubator/deltacloud/trunk/framework/app/controllers/storage_volumes_controller.rb Thu
Jul  8 23:15:07 2010
@@ -0,0 +1,28 @@
+load 'drivers/ec2.rb'
+
+class StorageVolumesController < ApplicationController
+
+  include DriverHelper
+  include ConversionHelper
+
+  around_filter :catch_auth
+
+  def index
+    @volumes = driver.volumes( credentials )
+    puts @volumes.inspect
+    respond_to do |format|
+      format.html
+    end
+  end
+
+  def show
+    @volume = driver.volume( credentials, params[:id] )
+    respond_to do |format|
+      format.html
+      format.json
+      format.xml {
+      }
+    end
+  end
+
+end

Modified: incubator/deltacloud/trunk/framework/app/views/images/index.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/images/index.html.erb?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/images/index.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/images/index.html.erb Thu Jul  8 23:15:07
2010
@@ -19,7 +19,7 @@
         <%= link_to image[:id], image_url( image[:id] ) %>
       </td>
       <td>
-        <%= link_to image[:owner_id], account_url( image[:owner_id] ) %>
+        <%= link_to image[:owner_id], images_url( :owner=>image[:owner_id] ) %>
       </td>
       <td>
         <%= image[:description] %>

Modified: incubator/deltacloud/trunk/framework/app/views/images/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/images/show.html.erb?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/images/show.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/images/show.html.erb Thu Jul  8 23:15:07
2010
@@ -8,7 +8,7 @@
       Owner
     </dt>
     <dd>
-      <%= link_to @image[:owner_id], account_url( @image[:owner_id] ) %>
+      <%= link_to @image[:owner_id], images_url( :owner=>@image[:owner_id] ) %>
     </dd>
   </di>
   <di>

Modified: incubator/deltacloud/trunk/framework/app/views/instances/index.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/instances/index.html.erb?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/instances/index.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/instances/index.html.erb Thu Jul  8 23:15:07
2010
@@ -24,7 +24,7 @@
         <%= link_to instance[:id], instance_url( instance[:id] ) %>
       </td>
       <td>
-        <%= link_to instance[:owner_id], account_url( instance[:owner_id] ) %>
+        <%= link_to instance[:owner_id], images_url( :owner=>instance[:owner_id] )
%>
       </td>
       <td>
         <%= link_to instance[:image_id], image_url( instance[:image_id] ) %>

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=961988&r1=961987&r2=961988&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:15:07
2010
@@ -15,7 +15,7 @@
       Owner
     </dt>
     <dd>
-      <%= link_to @instance[:owner_id], account_url( @instance[:owner_id] ) %>
+      <%= @instance[:owner_id] %>
     </dd>
   </di>
   <di>

Added: incubator/deltacloud/trunk/framework/app/views/storage_snapshots/index.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/storage_snapshots/index.html.erb?rev=961988&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/storage_snapshots/index.html.erb (added)
+++ incubator/deltacloud/trunk/framework/app/views/storage_snapshots/index.html.erb Thu Jul
 8 23:15:07 2010
@@ -0,0 +1,17 @@
+
+<h1>Storage Snapshots</h1>
+
+<table>
+  <tr>
+    <th>
+      ID
+    </th>
+  </tr>
+  <% for snapshot in @snapshots %>
+    <tr>
+      <td>
+        <%= link_to snapshot[:id], storage_snapshot_url( snapshot[:id] ) %>
+      </td>
+    </tr>
+  <% end %>
+</table>

Added: incubator/deltacloud/trunk/framework/app/views/storage_snapshots/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/storage_snapshots/show.html.erb?rev=961988&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/storage_snapshots/show.html.erb (added)
+++ incubator/deltacloud/trunk/framework/app/views/storage_snapshots/show.html.erb Thu Jul
 8 23:15:07 2010
@@ -0,0 +1,21 @@
+
+<h1><%= @snapshot[:id] %></h1>
+
+<dl>
+  <di>
+    <dt>
+      State
+    </dt>
+    <dd>
+      <%= @snapshot[:state] %>
+    </dd>
+  </di>
+  <di>
+    <dt>
+      Volume
+    </dt>
+    <dd>
+      <%= @snapshot[:volume_id] %>
+    </dd>
+  </di>
+</dl>

Added: incubator/deltacloud/trunk/framework/app/views/storage_volumes/index.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/storage_volumes/index.html.erb?rev=961988&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/storage_volumes/index.html.erb (added)
+++ incubator/deltacloud/trunk/framework/app/views/storage_volumes/index.html.erb Thu Jul
 8 23:15:07 2010
@@ -0,0 +1,35 @@
+
+<h1>Storage Volumes</h1>
+
+<table>
+  <tr>
+    <th>
+      ID
+    </th>
+    <th>
+      Created
+    </th>
+    <th>
+      Capacity
+    </th>
+    <th>
+      Status
+    </th>
+  </tr>
+  <% for volume in @volumes %>
+    <tr>
+      <td>
+        <%= link_to volume[:id], storage_volume_url( volume[:id] ) %>
+      </td>
+      <td>
+        <%= volume[:created_at] %>
+      </td>
+      <td>
+        <%= volume[:capacity] %> GB
+      </td>
+      <td>
+        <%= volume[:state] %>
+      </td>
+    </tr>
+  <% end %>
+</table>

Added: incubator/deltacloud/trunk/framework/app/views/storage_volumes/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/storage_volumes/show.html.erb?rev=961988&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/storage_volumes/show.html.erb (added)
+++ incubator/deltacloud/trunk/framework/app/views/storage_volumes/show.html.erb Thu Jul 
8 23:15:07 2010
@@ -0,0 +1,37 @@
+
+<h1><%= @volume[:id] %></h1>
+
+<dl>
+  <di>
+    <dt>
+      Created
+    </dt>
+    <dd>
+      <%= @volume[:created_at] %>
+    </dd>
+  </di>
+  <di>
+    <dt>
+      Capacity
+    </dt>
+    <dd>
+      <%= @volume[:capacity] %> GB
+    </dd>
+  </di>
+  <di>
+    <dt>
+      State
+    </dt>
+    <dd>
+      <%= @volume[:state] %>
+    </dd>
+  </di>
+  <di>
+    <dt>
+      Attached
+    </dt>
+    <dd>
+      <%= @volume[:instance_id] %> <%= @volume[:device] %>
+    </dd>
+  </di>
+</dl>

Modified: incubator/deltacloud/trunk/framework/config/routes.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/config/routes.rb?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/config/routes.rb (original)
+++ incubator/deltacloud/trunk/framework/config/routes.rb Thu Jul  8 23:15:07 2010
@@ -12,7 +12,10 @@ ActionController::Routing::Routes.draw d
       :reboot=>:post,
     }
 
-  map.resources :accounts
+  map.resource :storage do |s|
+    s.resources :volumes, :controller=>'StorageVolumes'
+    s.resources :snapshots, :controller=>'StorageSnapshots'
+  end
 
 
   #####

Modified: incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb Thu Jul  8 23:15:07 2010
@@ -70,33 +70,6 @@ module Drivers
       convert_instance( ec2_instances.first )
     end
 
-    def accounts(credentials, *ids)
-      ec2 = new_client( credentials )
-      accounts = {}
-      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]] = { :id=>ec2_image[:aws_owner] }
-            end
-          end
-        end
-      end
-      accounts.values.sort!{|l,r| l[:id] <=> r[:id]}
-    end
-
-    def account(credentials, id)
-      ec2 = new_client( credentials )
-      image_ids = []
-      ec2.describe_images_by_owner(id).each do |ec2_image|
-        image_ids << ec2_image[:aws_id]
-      end
-      {
-        :id=>id,
-        :image_ids=>image_ids,
-      } 
-    end
-
     def create_instance(credentials, image_id)
       ec2 = new_client( credentials )
       ec2_instances = ec2.run_instances( 
@@ -124,6 +97,37 @@ module Drivers
       ec2.terminate_instances( id )
     end
 
+    def volumes(credentials, ids=nil)
+      ec2 = new_client( credentials ) 
+      volumes = []
+      ec2.describe_volumes(ids).each do |ec2_volume|
+        volumes << convert_volume( ec2_volume )
+      end
+      volumes
+    end
+
+    def volume(credentials, id)
+      volumes = volumes( credentials, [ id] )
+      return volumes.first unless volumes.empty?
+      nil
+    end
+
+    def snapshots(credentials, ids=nil)
+      ec2 = new_client( credentials ) 
+      snapshots = []
+      ec2.describe_snapshots(ids).each do |ec2_snapshot|
+        snapshots << convert_snapshot( ec2_snapshot )
+      end
+      snapshots
+    end
+
+    def snapshot(credentials, id)
+      snapshots = snapshots( credentials, [ id ] )
+      return snapshots.first unless snapshots.empty?
+      nil
+    end
+
+
     private
 
     def new_client(credentials)
@@ -153,6 +157,25 @@ module Drivers
       } 
     end
 
+    def convert_volume(ec2_volume)
+      {
+        :id=>ec2_volume[:aws_id],
+        :created_at=>ec2_volume[:aws_created_at],
+        :state=>ec2_volume[:aws_status].upcase,
+        :capacity=>ec2_volume[:aws_size],
+        :instance_id=>ec2_volume[:aws_instance_id],
+        :device=>ec2_volume[:aws_device],
+      }
+    end
+
+    def convert_snapshot(ec2_snapshot)
+      { 
+        :id=>ec2_snapshot[:aws_id],
+        :state=>ec2_snapshot[:aws_status].upcase,
+        :volume_id=>ec2_snapshot[:aws_volume_id],
+      }
+    end
+
   end
 
 end

Modified: incubator/deltacloud/trunk/framework/public/stylesheets/application.css
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/public/stylesheets/application.css?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/public/stylesheets/application.css (original)
+++ incubator/deltacloud/trunk/framework/public/stylesheets/application.css Thu Jul  8 23:15:07
2010
@@ -23,19 +23,25 @@ body {
   font-size: 120%;
   margin-bottom: 1ex; }
 #bd dl {
+  font-size: 90%;
   margin-bottom: 1em; }
   #bd dl di {
     display: block;
     margin-bottom: 1em; }
+    #bd dl di dt, #bd dl di dd {
+      padding: .5ex; }
     #bd dl di dt {
-      font-weight: bold; }
+      font-weight: bold;
+      background-color: #cccccc; }
     #bd dl di dd {
-      margin-left: 1em; }
+      padding-left: 1em;
+      background-color: #eeeeee; }
 
 table {
   width: 100%; }
   table th, table td {
-    padding: .5ex; }
+    padding: .5ex;
+    font-size: 90%; }
   table th {
     font-weight: bold;
     background-color: #cccccc; }

Modified: incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass?rev=961988&r1=961987&r2=961988&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass (original)
+++ incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass Thu Jul
 8 23:15:07 2010
@@ -30,20 +30,26 @@ body
     :font-size     120%
     :margin-bottom 1ex
   dl
+    :font-size 90%
     :margin-bottom 1em
     di
       :display block
       :margin-bottom 1em
+      dt, dd
+        :padding .5ex
       dt
         :font-weight bold
+        :background-color = !th_bg
       dd
-        :margin-left 1em
+        :padding-left 1em
+        :background-color = !td_bg
 
 
 table
   :width 100%
   th, td
     :padding .5ex
+    :font-size 90%
   th
     :font-weight bold
     :background-color = !th_bg



Mime
View raw message