Sophie

Sophie

distrib > Fedora > 16 > x86_64 > media > updates-src > by-pkgid > 7ae45ba0d8fdf0bee89ed2ca0c6bf314 > files > 4

deltacloud-core-0.5.0-10.fc16.src.rpm

Return-Path: dev-return-3594-mfojtik=redhat.com@deltacloud.apache.org
Received: from zmta02.collab.prod.int.phx2.redhat.com (LHLO
 zmta02.collab.prod.int.phx2.redhat.com) (10.5.5.32) by
 zmail12.collab.prod.int.phx2.redhat.com with LMTP; Tue, 7 Feb 2012 07:24:46
 -0500 (EST)
Received: from localhost (localhost.localdomain [127.0.0.1])
	by zmta02.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 8837512800B
	for <mfojtik@redhat.com>; Tue,  7 Feb 2012 07:24:46 -0500 (EST)
Received: from zmta02.collab.prod.int.phx2.redhat.com ([127.0.0.1])
	by localhost (zmta02.collab.prod.int.phx2.redhat.com [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id vjAexmWsRGJv for <mfojtik@redhat.com>;
	Tue,  7 Feb 2012 07:24:46 -0500 (EST)
Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25])
	by zmta02.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 762D1128009
	for <mfojtik@mail.corp.redhat.com>; Tue,  7 Feb 2012 07:24:46 -0500 (EST)
Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18])
	by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q17COkHA029886
	for <mfojtik@redhat.com>; Tue, 7 Feb 2012 07:24:46 -0500
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
	by mx1.redhat.com (8.14.4/8.14.4) with SMTP id q17COTIO009297
	for <mfojtik@redhat.com>; Tue, 7 Feb 2012 07:24:30 -0500
Received: (qmail 17806 invoked by uid 500); 7 Feb 2012 12:24:29 -0000
Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm
Precedence: bulk
List-Help: <mailto:dev-help@deltacloud.apache.org>
List-Unsubscribe: <mailto:dev-unsubscribe@deltacloud.apache.org>
List-Post: <mailto:dev@deltacloud.apache.org>
List-Id: <dev.deltacloud.apache.org>
Reply-To: dev@deltacloud.apache.org
Delivered-To: mailing list dev@deltacloud.apache.org
Received: (qmail 17794 invoked by uid 99); 7 Feb 2012 12:24:28 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
    by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 12:24:28 +0000
X-ASF-Spam-Status: No, hits=-5.0 required=5.0
	tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: apache.org
Received-SPF: pass (athena.apache.org: domain of fvollero@redhat.com designates 209.132.183.28 as permitted sender)
Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28)
    by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Feb 2012 12:24:21 +0000
Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q17CO0jp009182
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <dev@deltacloud.apache.org>; Tue, 7 Feb 2012 07:24:00 -0500
Received: from dhcp-2-158.brq.redhat.com (dhcp-2-158.brq.redhat.com [10.34.2.158])
	by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q17CNxAT030590
	for <dev@deltacloud.apache.org>; Tue, 7 Feb 2012 07:24:00 -0500
From: Francesco Vollero <fvollero@redhat.com>
To: dev@deltacloud.apache.org
Subject: [PATCH core] Improved valid_credentials? method on rhevm and vsphere driver
Date: Tue,  7 Feb 2012 13:23:58 +0100
Message-Id: <1328617438-31421-1-git-send-email-fvollero@redhat.com>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
X-RedHat-Spam-Score: -10.01  (RCVD_IN_DNSWL_HI,RCVD_IN_RP_CERTIFIED,RCVD_IN_RP_SAFE,T_RP_MATCHES_RCVD)


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

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 665e2fe..a66b9c6 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -208,13 +208,15 @@ class RHEVMDriver < Deltacloud::BaseDriver
   end
 
   def valid_credentials?(credentials)
-    retval = true
     begin
-      realms(credentials)
-    rescue
+      realms(credentials) && true
+    rescue RestClient::Unauthorized
       retval = false
+    rescue => e
+      safely do
+        raise e
+      end
     end
-    retval
   end
 
   private
diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index a2a5249..51b6648 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -370,10 +370,13 @@ module Deltacloud::Drivers::VSphere
 
     def valid_credentials?(credentials)
       begin
-        RbVmomi::VIM.connect(:host => host_endpoint, :user => credentials.user, :password => credentials.password, :insecure => true)
-        return true
-      rescue
+        RbVmomi::VIM.connect(:host => host_endpoint, :user => credentials.user, :password => credentials.password, :insecure => true) && true
+      rescue RbVmomi::Fault:InvalidLogin
         return false
+      rescue => e
+        safely do
+          raise e
+        end
       end
     end
 
-- 
1.7.7.6