You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/05/21 12:07:25 UTC

[PATCH core 44/51] Core: Advertise the hardware_profiles only if driver support them.

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/collections/hardware_profiles.rb        |    6 ++++--
 server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb |    2 ++
 server/lib/deltacloud/drivers/openstack/openstack_driver.rb   |    2 ++
 server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb   |    6 ++++--
 server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb       |    2 ++
 server/lib/deltacloud/helpers/rabbit_helper.rb                |    8 ++++----
 6 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/server/lib/deltacloud/collections/hardware_profiles.rb b/server/lib/deltacloud/collections/hardware_profiles.rb
index ff01d4a..5c72aff 100644
--- a/server/lib/deltacloud/collections/hardware_profiles.rb
+++ b/server/lib/deltacloud/collections/hardware_profiles.rb
@@ -16,10 +16,12 @@
 module Deltacloud::Collections
   class HardwareProfiles < Base
 
+    check_capability :for => lambda { |m| !driver.class.send(m).empty? }
+
     collection :hardware_profiles do
 
-      standard_index_operation
-      standard_show_operation
+      standard_index_operation :capability => :hardware_profiles
+      standard_show_operation :capability => :hardware_profiles
 
     end
 
diff --git a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
index 2c6203b..cc1f13e 100644
--- a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
+++ b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
@@ -27,6 +27,8 @@ module Deltacloud
 
 class OpennebulaDriver < Deltacloud::BaseDriver
 
+  define_hardware_profile('default')
+
   ######################################################################
   # Hardware profiles
   #####################################################################
diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
index 12dadef..0ed2baf 100644
--- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
+++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
@@ -36,6 +36,8 @@ module Deltacloud
           stopped.to( :finish )         .automatically
         end
 
+        define_hardware_profile('default')
+
         def hardware_profiles(credentials, opts = {})
           os = new_client(credentials)
           results = []
diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
index c8030ad..ca1c236 100644
--- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
+++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
@@ -29,6 +29,8 @@ class RackspaceDriver < Deltacloud::BaseDriver
   feature :instances, :user_files
   feature :images, :user_name
 
+  define_hardware_profile('default')
+
   def hardware_profiles(credentials, opts = {})
     rs = new_client( credentials )
     results = []
@@ -189,8 +191,8 @@ class RackspaceDriver < Deltacloud::BaseDriver
     start.to( :pending )          .on( :create )
     pending.to( :running )        .automatically
     running.to( :running )        .on( :reboot )
-    running.to( :shutting_down )  .on( :stop )
-    shutting_down.to( :stopped )  .automatically
+    running.to( :stopping )  .on( :stop )
+    stopping.to( :stopped )  .automatically
     stopped.to( :finish )         .automatically
   end
 
diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index a6a1e58..6d30cd4 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -33,6 +33,8 @@ module Deltacloud::Drivers::Vsphere
     feature :instances, :user_data
     feature :instances, :user_name
 
+    define_hardware_profile('default')
+
     # There is just one hardware profile where memory is measured using maximum
     # memory available on ESX for virtual machines and CPU using maximum free
     # CPU cores in ESX.
diff --git a/server/lib/deltacloud/helpers/rabbit_helper.rb b/server/lib/deltacloud/helpers/rabbit_helper.rb
index 252abe2..d6a472a 100644
--- a/server/lib/deltacloud/helpers/rabbit_helper.rb
+++ b/server/lib/deltacloud/helpers/rabbit_helper.rb
@@ -16,16 +16,16 @@
 
 Sinatra::Rabbit::Collection.class_eval do
 
-  def self.standard_index_operation
+  def self.standard_index_operation(opts={})
     collection_name = @collection_name
-    operation :index, :with_capability => collection_name do
+    operation :index, :with_capability => opts[:capability] || collection_name do
       control { filter_all collection_name }
     end
   end
 
-  def self.standard_show_operation
+  def self.standard_show_operation(opts={})
     collection_name = @collection_name
-    operation :show, :with_capability => collection_name do
+    operation :show, :with_capability => opts[:capability] || collection_name do
       control { show collection_name.to_s.singularize.intern }
     end
   end
-- 
1.7.10.1