libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1209922 - in /libcloud/branches/py3k: libcloud/compute/drivers/opennebula.py test/compute/test_opennebula.py
Date Sat, 03 Dec 2011 14:50:36 GMT
Author: tomaz
Date: Sat Dec  3 14:50:35 2011
New Revision: 1209922

URL: http://svn.apache.org/viewvc?rev=1209922&view=rev
Log:
OpenNebula driver tests now pass on py3k.

Modified:
    libcloud/branches/py3k/libcloud/compute/drivers/opennebula.py
    libcloud/branches/py3k/test/compute/test_opennebula.py

Modified: libcloud/branches/py3k/libcloud/compute/drivers/opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/opennebula.py?rev=1209922&r1=1209921&r2=1209922&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/opennebula.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/opennebula.py Sat Dec  3 14:50:35 2011
@@ -30,7 +30,10 @@ except ImportError:
 from xml.etree import ElementTree as ET
 from base64 import b64encode
 import hashlib
-import httplib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import next
+from libcloud.py3 import b
 
 from libcloud.compute.base import NodeState, NodeDriver, Node, NodeLocation
 from libcloud.common.base import ConnectionUserAndKey, XmlResponse
@@ -113,9 +116,9 @@ class OpenNebulaConnection(ConnectionUse
         @rtype:  C{dict}
         @return: Dictionary containing updated headers.
         """
-        pass_sha1 = hashlib.sha1(self.key).hexdigest()
-        headers['Authorization'] = ('Basic %s' % b64encode('%s:%s' %
-                                                (self.user_id, pass_sha1)))
+        pass_sha1 = hashlib.sha1(b(self.key)).hexdigest()
+        headers['Authorization'] = ('Basic %s' % b64encode(b('%s:%s' %
+                                                (self.user_id, pass_sha1))))
         return headers
 
 
@@ -194,7 +197,7 @@ class OpenNebulaNetwork(object):
         @rtype:  C{string}
         @return: Unique identifier for this instance.
         """
-        return hashlib.sha1("%s:%d" % (self.id, self.driver.type)).hexdigest()
+        return hashlib.sha1(b("%s:%d" % (self.id, self.driver.type))).hexdigest()
 
     def destroy(self):
         """
@@ -859,8 +862,8 @@ class OpenNebula_2_0_NodeDriver(OpenNebu
         instance_type = compute.find('INSTANCE_TYPE')
 
         try:
-            return (node_size for node_size in self.list_sizes()
-                    if node_size.name == instance_type.text).next()
+            return next((node_size for node_size in self.list_sizes()
+                    if node_size.name == instance_type.text))
         except StopIteration:
             return None
 

Modified: libcloud/branches/py3k/test/compute/test_opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_opennebula.py?rev=1209922&r1=1209921&r2=1209922&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_opennebula.py (original)
+++ libcloud/branches/py3k/test/compute/test_opennebula.py Sat Dec  3 14:50:35 2011
@@ -23,9 +23,10 @@ OpenNebula.org test suite.
 __docformat__ = 'epytext'
 
 import unittest
-import httplib
 import sys
 
+from libcloud.py3 import httplib
+
 from libcloud.compute.base import Node, NodeImage, NodeSize, NodeState
 from libcloud.compute.drivers.opennebula import *
 



Mime
View raw message