incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fvoll...@redhat.com
Subject [PATCH core] Added check for datacenter in cluster
Date Thu, 18 Aug 2011 09:03:42 GMT
From: Francesco Vollero <fvollero@redhat.com>

Signed-off-by: Francesco Vollero <fvollero@redhat.com>
---
 .../lib/deltacloud/drivers/rhevm/rhevm_client.rb   |   10 ++++++++--
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |    1 +
 2 files changed, 9 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..fcc25e2 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,11 @@ module RHEVM
       Nokogiri::XML(response)
     end
 
+    def has_datacenter?(vm)
+      value=!(vm/'data_center').empty?
+      puts "has_datacenter value: #{value}"
+      value
+    end
   end
 
   class BaseObject
@@ -300,6 +305,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