libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [1/2] libcloud git commit: Fix cloudstack user data on Python 3
Date Thu, 16 Jun 2016 22:20:49 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 4b4a01946 -> a4a58f9c5


Fix cloudstack user data on Python 3

A wrongly nested string decode caused a TypeError as b64encode
expects a byte string in Python 3 and conversely the url parameter
needs to be a normal string.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8a629fed
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8a629fed
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8a629fed

Branch: refs/heads/trunk
Commit: 8a629fed41cec626d566d813ad33e72a64b4216d
Parents: 4b4a019
Author: Stefan Friesel <stefan.friesel@exoscale.ch>
Authored: Thu Jun 2 09:25:19 2016 +0200
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Fri Jun 17 08:20:19 2016 +1000

----------------------------------------------------------------------
 libcloud/compute/drivers/cloudstack.py   |  2 +-
 libcloud/test/compute/test_cloudstack.py | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8a629fed/libcloud/compute/drivers/cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/cloudstack.py b/libcloud/compute/drivers/cloudstack.py
index 85b9a64..aff5192 100644
--- a/libcloud/compute/drivers/cloudstack.py
+++ b/libcloud/compute/drivers/cloudstack.py
@@ -1633,7 +1633,7 @@ class CloudStackNodeDriver(CloudStackDriverMixIn, NodeDriver):
             server_params['keypair'] = ex_key_name
 
         if ex_user_data:
-            ex_user_data = base64.b64encode(b(ex_user_data).decode('ascii'))
+            ex_user_data = base64.b64encode(b(ex_user_data)).decode('ascii')
             server_params['userdata'] = ex_user_data
 
         if ex_security_groups:

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8a629fed/libcloud/test/compute/test_cloudstack.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_cloudstack.py b/libcloud/test/compute/test_cloudstack.py
index 12449e3..2faeb21 100644
--- a/libcloud/test/compute/test_cloudstack.py
+++ b/libcloud/test/compute/test_cloudstack.py
@@ -221,6 +221,18 @@ class CloudStackCommonTestCase(TestCaseMixin):
         self.assertEqual(node.name, 'test')
         self.assertEqual(node.extra['key_name'], 'foobar')
 
+    def test_create_node_ex_userdata(self):
+        size = self.driver.list_sizes()[0]
+        image = self.driver.list_images()[0]
+        location = self.driver.list_locations()[0]
+        CloudStackMockHttp.fixture_tag = 'deploykeyname'
+        node = self.driver.create_node(name='test',
+                                       location=location,
+                                       image=image,
+                                       size=size,
+                                       ex_userdata='foobar')
+        self.assertEqual(node.name, 'test')
+
     def test_create_node_project(self):
         size = self.driver.list_sizes()[0]
         image = self.driver.list_images()[0]


Mime
View raw message