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:20:41 UTC

svn commit: r962067 - in /incubator/deltacloud/trunk/framework: app/controllers/ app/models/ app/views/instances/ app/views/realms/ config/ lib/deltacloud/

Author: lutter
Date: Thu Jul  8 23:20:41 2010
New Revision: 962067

URL: http://svn.apache.org/viewvc?rev=962067&view=rev
Log:
Add realms into the model

Added:
    incubator/deltacloud/trunk/framework/app/controllers/realms_controller.rb
    incubator/deltacloud/trunk/framework/app/models/realm.rb
    incubator/deltacloud/trunk/framework/app/views/realms/
    incubator/deltacloud/trunk/framework/app/views/realms/index.html.erb
    incubator/deltacloud/trunk/framework/app/views/realms/show.html.erb
Modified:
    incubator/deltacloud/trunk/framework/app/controllers/api_controller.rb
    incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
    incubator/deltacloud/trunk/framework/app/models/instance.rb
    incubator/deltacloud/trunk/framework/app/views/instances/index.html.erb
    incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb
    incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb
    incubator/deltacloud/trunk/framework/config/environment.rb
    incubator/deltacloud/trunk/framework/config/routes.rb
    incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb

Modified: incubator/deltacloud/trunk/framework/app/controllers/api_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/api_controller.rb?rev=962067&r1=962066&r2=962067&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/api_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/api_controller.rb Thu Jul  8 23:20:41 2010
@@ -5,6 +5,7 @@ class ApiController < ApplicationControl
     @version = 1.0
     @entry_points = [
       [ :flavors, flavors_url ],
+      [ :realms, realms_url ],
       [ :images, images_url ],
       [ :instances, instances_url ],
       [ :storage_volumes, storage_volumes_url ],

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=962067&r1=962066&r2=962067&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:20:41 2010
@@ -40,25 +40,19 @@ class InstancesController < ApplicationC
                 } )
     @image   = driver.image( credentials, :id => params[:image_id] )
     @flavors = driver.flavors( credentials, { :architecture=>@image.architecture } )
+    @realms = driver.realms(credentials)
   end
 
   def create
     @image   = driver.image( credentials, :id=>params[:image_id] )
     respond_to do |format|
       format.html {
-        if ( params[:flavor_id].nil? )
-          @flavors = driver.flavors_by_architecture( credentials, @image.architecture )
-          @instance = Instance.new( {
-                        :id=>params[:id],
-                        :image_id=>params[:image_id],
-                      } )
-          render :action=>:new and return
-        end
-        instance = driver.create_instance( credentials, @image.id, params[:flavor_id] )
+        instance = driver.create_instance( credentials, @image.id, params )
         redirect_to instance_url( instance.id )
       }
       format.xml {
-        instance = driver.create_instance( credentials, @image.id, params[:flavor_id] )
+        instance = driver.create_instance( credentials, @image.id, params )
+        puts "RESULT #{instance.inspect}"
         render :xml=>convert_to_xml( :instance, instance), :status=>:created, :location=>instance_url( instance.id )
       }
     end

Added: incubator/deltacloud/trunk/framework/app/controllers/realms_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/realms_controller.rb?rev=962067&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/realms_controller.rb (added)
+++ incubator/deltacloud/trunk/framework/app/controllers/realms_controller.rb Thu Jul  8 23:20:41 2010
@@ -0,0 +1,31 @@
+class RealmsController < ApplicationController
+
+  include DriverHelper
+  include ConversionHelper
+
+  around_filter :catch_auth
+
+  def index
+    build_filter( :id )
+    build_filter( :architecture )
+    @realms = driver.realms( credentials, @filter )
+    respond_to do |format|
+      format.html
+      format.xml {
+        render :xml=>convert_to_xml( :realm, @realms )
+      }
+    end
+  end
+
+  def show
+    @realm = driver.realm( credentials, :id => params[:id] )
+    respond_to do |format|
+      format.html
+      format.json
+      format.xml {
+        render :xml=>convert_to_xml( :realm, @realm )
+      }
+    end
+  end
+
+end

Modified: incubator/deltacloud/trunk/framework/app/models/instance.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/models/instance.rb?rev=962067&r1=962066&r2=962067&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/models/instance.rb (original)
+++ incubator/deltacloud/trunk/framework/app/models/instance.rb Thu Jul  8 23:20:41 2010
@@ -4,6 +4,7 @@ class Instance < BaseModel
   attr_accessor :owner_id
   attr_accessor :image_id
   attr_accessor :flavor_id
+  attr_accessor :name
   attr_accessor :state
   attr_accessor :actions
   attr_accessor :public_addresses

Added: incubator/deltacloud/trunk/framework/app/models/realm.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/models/realm.rb?rev=962067&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/models/realm.rb (added)
+++ incubator/deltacloud/trunk/framework/app/models/realm.rb Thu Jul  8 23:20:41 2010
@@ -0,0 +1,12 @@
+
+class Realm < BaseModel
+
+  attr_accessor :realm_id
+  attr_accessor :name
+  attr_accessor :limit
+  attr_accessor :state
+  attr_accessor :actions
+  attr_accessor :public_addresses
+  attr_accessor :private_addresses
+
+end
\ No newline at end of file

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=962067&r1=962066&r2=962067&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:20:41 2010
@@ -9,6 +9,9 @@
       Owner
     </th>
     <th>
+      Name
+    </th>
+    <th>
       Image
     </th>
     <th>
@@ -30,6 +33,9 @@
         <%= link_to instance.owner_id, images_url( :owner=>instance.owner_id ) %>
       </td>
       <td>
+        <%= instance.name %>
+      </td>
+      <td>
         <%= link_to instance.image_id, image_url( instance.image_id ) %>
       </td>
       <td>

Modified: incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb?rev=962067&r1=962066&r2=962067&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb Thu Jul  8 23:20:41 2010
@@ -5,16 +5,34 @@
 
 <% form_tag instances_url do %>
   <%= hidden_field_tag :image_id, @instance.image_id %>
-  <% for flavor in @flavors %>
-    <div class="radio-group">
-      <label for="flavor_id_<%=flavor.id%>">
-        <%= radio_button_tag 'flavor_id', flavor.id %>
-        <%= flavor.id %><br/>
-        <span class="radio-group-details">
-          <%= flavor.architecture %>, <%= flavor.memory %> GB, <%= flavor.storage %> GB
-        </span>
-      </label>
-    </div>
+  <label>Instance Name: </label><%= text_field_tag 'name', '', :size => 30 %>
+  <% if !@flavors.empty? %>
+    <h3>Pick Yer Flavor</h3>
+    <% for flavor in @flavors %>
+      <div class="radio-group">
+        <label for="flavor_id_<%=flavor.id%>">
+          <%= radio_button_tag 'flavor_id', flavor.id %>
+          <%= flavor.id %><br/>
+          <span class="radio-group-details">
+            <%= flavor.architecture %>, <%= flavor.memory %> GB, <%= flavor.storage %> GB
+          </span>
+        </label>
+      </div>
+    <% end %>
+  <% end %>
+  <% if !@realms.empty? %>
+    <h3>Where do you want it?</h3>
+    <% for realm in @realms %>
+      <div class="radio-group">
+        <label for="realm_id_<%=realm.id%>">
+          <%= radio_button_tag 'realm_id', realm.id %>
+          <%= realm.id %><br/>
+          <span class="radio-group-details">
+            <%= realm.name %>, <%= realm.limit %>
+          </span>
+        </label>
+      </div>
+    <% end %>
   <% end %>
   <%= submit_tag 'create' %>
 <% end %>

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=962067&r1=962066&r2=962067&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:20:41 2010
@@ -20,6 +20,14 @@
   </di>
   <di>
     <dt>
+      Name
+    </dt>
+    <dd>
+      <%= @instance.name %>
+    </dd>
+  </di>
+  <di>
+    <dt>
       Flavor
     </dt>
     <dd>

Added: incubator/deltacloud/trunk/framework/app/views/realms/index.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/realms/index.html.erb?rev=962067&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/realms/index.html.erb (added)
+++ incubator/deltacloud/trunk/framework/app/views/realms/index.html.erb Thu Jul  8 23:20:41 2010
@@ -0,0 +1,29 @@
+
+<h1>Realms</h1>
+
+<table>
+  <tr>
+    <th>
+      ID
+    </th>
+    <th>
+      Name
+    </th>
+    <th>
+      Limit
+    </th>
+  </tr>
+  <% for realm in @realms %>
+    <tr>
+      <td>
+        <%= link_to realm.id, realm_url( realm.id ) %>
+      </td>
+      <td>
+        <%= realm.name %>
+      </td>
+      <td>
+        <%= realm.limit %>
+      </td>
+    </tr>
+  <% end %>
+</table>

Added: incubator/deltacloud/trunk/framework/app/views/realms/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/realms/show.html.erb?rev=962067&view=auto
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/realms/show.html.erb (added)
+++ incubator/deltacloud/trunk/framework/app/views/realms/show.html.erb Thu Jul  8 23:20:41 2010
@@ -0,0 +1,20 @@
+<h1><%= @realm.id %></h1>
+
+<dl>
+  <di>
+    <dt>
+      Name
+    </dt>
+    <dd>
+      <%= @realm.name %>
+    </dd>
+  </di>
+  <di>
+    <dt>
+      Limit
+    </dt>
+    <dd>
+      <%= @realm.limit %>
+    </dd>
+  </di>
+</dl>

Modified: incubator/deltacloud/trunk/framework/config/environment.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/config/environment.rb?rev=962067&r1=962066&r2=962067&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/config/environment.rb (original)
+++ incubator/deltacloud/trunk/framework/config/environment.rb Thu Jul  8 23:20:41 2010
@@ -53,6 +53,8 @@ end
 
 #DRIVER=:ec2
 DRIVER=:mock
+#DRIVER=:rhevm
+>>>>>>> Add realms into the model
 
 DRIVER_ROOT = File.dirname( __FILE__ ) + "/../../deltacloud-driver-#{DRIVER}"
 $: << DRIVER_ROOT+'/lib'
@@ -66,4 +68,3 @@ case DRIVER
   when :rhevm
     DRIVER_CLASS_NAME = "RHEVMDriver"
 end
-

Modified: incubator/deltacloud/trunk/framework/config/routes.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/config/routes.rb?rev=962067&r1=962066&r2=962067&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/config/routes.rb (original)
+++ incubator/deltacloud/trunk/framework/config/routes.rb Thu Jul  8 23:20:41 2010
@@ -7,7 +7,7 @@ ActionController::Routing::Routes.draw d
   map.resource :api, :controller=>'Api'
 
   map.resources :flavors, :path_prefix=>'api'
-
+  map.resources :realms, :path_prefix=>'api'
   map.resources :images, :path_prefix=>'api'
   map.resources :instances, :path_prefix=>'api',
     :member=>{

Modified: incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb?rev=962067&r1=962066&r2=962067&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/deltacloud/base_driver.rb Thu Jul  8 23:20:41 2010
@@ -12,10 +12,23 @@ module DeltaCloud
       nil
     end
 
+    def flavors(credentials, ops)
+      []
+    end
+
     def flavors_by_architecture(credentials, architecture)
       flavors(credentials, :architecture => architecture)
     end
 
+    def realm(credentials, opts)
+      realms = realms(credentials, opts)
+      return realms.first unless realms.empty?
+      nil
+    end
+
+    def realms(credentials, ops)
+      []
+    end
 
     def image(credentials, opts)
       images = images(credentials, opts)
@@ -23,12 +36,22 @@ module DeltaCloud
       nil
     end
 
+    def images(credentials, ops)
+      []
+    end
+
     def instance(credentials, opts)
       instances = instances(credentials, opts)
       return instances.first unless instances.empty?
       nil
     end
 
+    def instances(credentials, ops)
+      []
+    end
+
+    def create_instance(credentials, image_id, opts)
+    end
     def start_instance(credentials, id)
     end
     def stop_instance(credentials, id)
@@ -43,11 +66,15 @@ module DeltaCloud
     end
 
     def storage_snapshot(credentials, opts)
-      snapshots = storage_snapshots(credentials, opts)
+      snapshots = snapshots(credentials, opts)
       return snapshots.first unless snapshots.empty?
       nil
     end
 
+    def snapshots(credentials, ops)
+      []
+    end
+
     def filter_on(collection, attribute, opts)
       return collection if opts.nil?
       return collection if opts[attribute].nil?