---
 server/lib/deltacloud/base_driver/features.rb      |   12 +++++
 server/lib/deltacloud/drivers/mock/mock_driver.rb  |    2 +
 .../lib/deltacloud/helpers/application_helper.rb   |   12 +++++-
 server/views/images/index.xml.haml                 |   11 +++--
 server/views/instances/index.xml.haml              |   43 ++++++++++---------
 5 files changed, 54 insertions(+), 26 deletions(-)

diff --git a/server/lib/deltacloud/base_driver/features.rb 
b/server/lib/deltacloud/base_driver/features.rb
index 8ad354a..39f0a94 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -151,6 +151,18 @@ module Deltacloud
       end
     end
 
+    declare_feature :images, :brief_listing_mode do
+      operation :index do
+        param :listing_mode, :string, :optional
+      end
+    end
+
+    declare_feature :instances, :brief_listing_mode do
+      operation :index do
+        param :listing_mode, :string, :optional
+      end
+    end
+
     declare_feature :instances, :hardware_profiles do
       description "Size instances according to changes to a hardware profile"
       # The parameters are filled in from the hardware profiles
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb 
b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 9671f02..3096cd6 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -75,6 +75,8 @@ class MockDriver < Deltacloud::BaseDriver
   end
 
   feature :instances, :user_name
+  feature :images, :brief_listing_mode
+  feature :instances, :brief_listing_mode
 
   def initialize
     if ENV["DELTACLOUD_MOCK_STORAGE"]
diff --git a/server/lib/deltacloud/helpers/application_helper.rb 
b/server/lib/deltacloud/helpers/application_helper.rb
index 850fab4..1428ec0 100644
--- a/server/lib/deltacloud/helpers/application_helper.rb
+++ b/server/lib/deltacloud/helpers/application_helper.rb
@@ -40,8 +40,8 @@ module ApplicationHelper
     collections[:instances].operations[action.to_sym].method
   end
 
-  def driver_has_feature?(feature_name)
-    not driver.features(:instances).select{ |f| f.name.eql?(feature_name) 
}.empty?
+  def driver_has_feature?(feature_name, default_collection = :instances)
+    not driver.features(default_collection).select{ |f| 
f.name.eql?(feature_name) }.empty?
   end
 
   def driver_has_auth_features?
@@ -53,4 +53,12 @@ module ApplicationHelper
     return 'password' if driver_has_feature?(:authentication_password)
   end
 
+  def full_listing_mode?(collection)
+    if driver_has_feature?(:brief_listing_mode, collection) and not 
params[:listing_mode]=='full'
+      return false
+    else
+      return true
+    end
+  end
+
 end
diff --git a/server/views/images/index.xml.haml 
b/server/views/images/index.xml.haml
index 6d14b21..a86cc5b 100644
--- a/server/views/images/index.xml.haml
+++ b/server/views/images/index.xml.haml
@@ -1,7 +1,10 @@
 !!! XML
 %images
   - @elements.each do |image|
-    %image{:href => image_url(image.id)}
-      - image.attributes.each do |attribute|
-        - haml_tag(attribute, :<) do
-          - haml_concat image.send(attribute)
+    - if full_listing_mode?(:images)
+      %image{:href => image_url(image.id)}
+        - image.attributes.each do |attribute|
+          - haml_tag(attribute, :<) do
+            - haml_concat image.send(attribute)
+    - else
+      %image{ :href => image_url(image.id), :id => image.id }
diff --git a/server/views/instances/index.xml.haml 
b/server/views/instances/index.xml.haml
index f2bb8f0..176d706 100644
--- a/server/views/instances/index.xml.haml
+++ b/server/views/instances/index.xml.haml
@@ -1,23 +1,26 @@
 !!! XML
 %instances
   - @elements.each do |instance|
-    %instance{:href => instance_url(instance.id)}
-      %id #{instance.id}
-      %name #{instance.name}
-      %owner_id #{instance.owner_id}
-      %image{:href => image_url(instance.image_id)}
-      %realm{:href => realm_url(instance.realm_id)}
-      %state #{instance.state}
-      - haml_tag :"hardware-profile", { :href => 
hardware_profile_url(instance.instance_profile.id)} do
-        %id #{instance.instance_profile.id}
-        - instance.instance_profile.overrides.each do |p, v|
-          %property{:kind => 'fixed', :name => p, :value => v, :unit => 
Deltacloud::HardwareProfile::unit(p)}
-      %actions
-        - instance.actions.compact.each do |action|
-          %link{:rel => action, :href => self.send("#{action}_instance_url", 
instance.id), :method => instance_action_method(action)}
-      %public-addresses
-        - instance.public_addresses.each do |address|
-          %address  #{address}
-      %private-addresses
-        - instance.private_addresses.each do |address|
-          %address  #{address}
+    - if full_listing_mode?(:instances)
+      %instance{:href => instance_url(instance.id)}
+        %id #{instance.id}
+        %name #{instance.name}
+        %owner_id #{instance.owner_id}
+        %image{:href => image_url(instance.image_id)}
+        %realm{:href => realm_url(instance.realm_id)}
+        %state #{instance.state}
+        - haml_tag :"hardware-profile", { :href => 
hardware_profile_url(instance.instance_profile.id)} do
+          %id #{instance.instance_profile.id}
+          - instance.instance_profile.overrides.each do |p, v|
+            %property{:kind => 'fixed', :name => p, :value => v, :unit => 
Deltacloud::HardwareProfile::unit(p)}
+        %actions
+          - instance.actions.compact.each do |action|
+            %link{:rel => action, :href => self.send("#{action}_instance_url", 
instance.id), :method => instance_action_method(action)}
+        %public-addresses
+          - instance.public_addresses.each do |address|
+            %address  #{address}
+        %private-addresses
+          - instance.private_addresses.each do |address|
+            %address  #{address}
+    - else
+      %instance{ :id => instance.id, :href => instance_url(instance.id)}
-- 
1.7.1

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to