incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fvoll...@redhat.com
Subject [PATCH core 1/2] Add has_datacenter? method for datacenter existence in cluster object creation
Date Thu, 18 Aug 2011 10:05:39 GMT
From: Francesco Vollero <fvollero@redhat.com>

Signed-off-by: Francesco Vollero <fvollero@redhat.com>
---
 .../lib/deltacloud/drivers/rhevm/rhevm_client.rb   |    9 +++++++--
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |    1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
index b4a2a80..0755ad6 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
@@ -131,8 +131,8 @@ module RHEVM
         [ RHEVM::Cluster::new(self, vm)]
       else
         Client::parse_response(RHEVM::client(@api_entrypoint)["/clusters"].get(headers)).xpath('/clusters/cluster').collect
do |vm|
-          RHEVM::Cluster::new(self, vm)
-        end
+          RHEVM::Cluster::new(self, vm) if has_datacenter?(vm)
+        end.compact
       end
     end
 
@@ -196,6 +196,10 @@ module RHEVM
       Nokogiri::XML(response)
     end
 
+    def has_datacenter?(vm)
+      value=!(vm/'data_center').empty?
+      value
+    end
   end
 
   class BaseObject
@@ -300,6 +304,7 @@ module RHEVM
       @description = ((xml/'description').first.text rescue nil)
       @datacenter = Link::new(@client, (xml/'data_center').first[:id], (xml/'data_center').first[:href])
     end
+
   end
 
   class DataCenter < BaseObject
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index d0d528e..5190598 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -78,6 +78,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
     realm_arr = []
     safely do
       clusters = client.clusters
+      puts clusters.size
       clusters.each do |r|
         d = client.datacenters(:id => r.datacenter.id).first
         realm_arr << convert_realm(r, d)
-- 
1.7.4.4


Mime
View raw message