Fix error when using SSH key auth with Python 3

When using SSH key authentication, the randomly generated HEX password for 
admin account is encoded as bytes which results in a JSON serialization error. 
Changed the encoding to UTF-8.

Signed-off-by: Quentin Pradet <quent...@apache.org>


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

Branch: refs/heads/trunk
Commit: 4e42f86bb9b3824e92874e0aedea83d7b649d1ed
Parents: fe0a848
Author: SElsharkawy <elshark...@nilogix.com>
Authored: Tue May 2 13:50:48 2017 -0400
Committer: Quentin Pradet <quent...@apache.org>
Committed: Wed Sep 27 08:25:25 2017 +0400

----------------------------------------------------------------------
 CHANGES.rst                           | 3 +++
 libcloud/compute/drivers/azure_arm.py | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/4e42f86b/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index fe13a41..7ba1806 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -28,6 +28,9 @@ Compute
 - [ARM] Fix checking for "location is None" in several functions 
(LIBCLOUD-926, GITHUB-1098)
   [Sameh Elsharkawy]
 
+- [ARM] Fix error when using SSH key auth with Python 3 (GITHUB-1098)
+  [Sameh Elsharkawy]
+
 Changes in Apache Libcloud 2.2.1
 --------------------------------
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/4e42f86b/libcloud/compute/drivers/azure_arm.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure_arm.py 
b/libcloud/compute/drivers/azure_arm.py
index 45db5a1..38ca2ae 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -623,7 +623,7 @@ class AzureNodeDriver(NodeDriver):
 
         if isinstance(auth, NodeAuthSSHKey):
             data["properties"]["osProfile"]["adminPassword"] = \
-                binascii.hexlify(os.urandom(20))
+                binascii.hexlify(os.urandom(20)).decode("utf-8")
             data["properties"]["osProfile"]["linuxConfiguration"] = {
                 "disablePasswordAuthentication": "true",
                 "ssh": {

Reply via email to