From f1768ef7abb9ef183601c528dbd8bac5b315ad35 Mon Sep 17 00:00:00 2001
From: Borne Mace <borne.mace@oracle.com>
Date: Tue, 22 May 2018 16:33:40 -0700
Subject: [PATCH] Updated genpwd to work with python35

Due to the changes in hmac.new and how binary strings
are dumped in yaml.safe_dump some changes were needed to
make sure that we dumped only strings, not binary strings.

Change-Id: Ic2fbcf2347023c1e9e666203dfe40dbeaf24ce5f
---
 kolla_ansible/cmd/genpwd.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kolla_ansible/cmd/genpwd.py b/kolla_ansible/cmd/genpwd.py
index 20c71ab467..8a0ab56420 100755
--- a/kolla_ansible/cmd/genpwd.py
+++ b/kolla_ansible/cmd/genpwd.py
@@ -46,11 +46,11 @@ def generate_RSA(bits=4096):
         encoding=serialization.Encoding.PEM,
         format=serialization.PrivateFormat.PKCS8,
         encryption_algorithm=serialization.NoEncryption()
-    )
+    ).decode()
     public_key = new_key.public_key().public_bytes(
         encoding=serialization.Encoding.OpenSSH,
         format=serialization.PublicFormat.OpenSSH
-    )
+    ).decode()
     return private_key, public_key
 
 
@@ -112,12 +112,12 @@ def main():
                 passwords[k] = uuidutils.generate_uuid()
             elif k in hmac_md5_keys:
                 passwords[k] = (hmac.new(
-                    uuidutils.generate_uuid(), '', md5)
-                    .digest().encode('base64')[:-1])
+                    uuidutils.generate_uuid().encode(), ''.encode(), md5)
+                    .hexdigest())
             elif k in hmac_sha256_keys:
                 passwords[k] = (hmac.new(
-                    uuidutils.generate_uuid(), '', sha256)
-                    .digest().encode('base64')[:-1])
+                    uuidutils.generate_uuid().encode(), ''.encode(), sha256)
+                    .hexdigest())
             else:
                 passwords[k] = ''.join([
                     random.SystemRandom().choice(