summaryrefslogtreecommitdiff
path: root/nova/crypto.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2015-05-25 13:22:29 +0200
committerVictor Stinner <vstinner@redhat.com>2015-05-25 13:33:59 +0200
commitf0082849dfe435af23b85150efd8dea06799e999 (patch)
tree68c1b9c9cbe0839cda58055048376e528347e4b0 /nova/crypto.py
parent52823c48ef022d4b7f4514dc54e6cefe4490a4db (diff)
downloadnova-f0082849dfe435af23b85150efd8dea06799e999.tar.gz
Fix version unit test on Python 3
With this change, "tox -e py34" now pass. Changes: * Replace unichr() with six.unichr() * Replace StringIO.StringIO() with six.Bytes() in nova.crypto.generate_key_pair() * On Python 3, replace UserDict.IterableUserDict with collections.UserDict * Replace __builtin__.open with six.moves.builtins.open * Replace ConfigParser import with six.moves.configparser * On Python 3, get the original "queue" module instead of the "Queue" module in nova/virt/libvirt/host.py * Replace urllib2 with six.moves.urllib * tox.ini: "tox -e py34" now only runs nova.tests.unit.test_versions Blueprint nova-python3 Change-Id: I056769c7c5b32276894f7aade8c0a27af81c42ae
Diffstat (limited to 'nova/crypto.py')
-rw-r--r--nova/crypto.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/nova/crypto.py b/nova/crypto.py
index 64907e0c2c..937c05a062 100644
--- a/nova/crypto.py
+++ b/nova/crypto.py
@@ -27,7 +27,6 @@ import binascii
import os
import re
import string
-import StringIO
import struct
from oslo_concurrency import processutils
@@ -38,6 +37,7 @@ from oslo_utils import timeutils
import paramiko
from pyasn1.codec.der import encoder as der_encoder
from pyasn1.type import univ
+import six
from nova import context
from nova import db
@@ -166,7 +166,7 @@ def generate_x509_fingerprint(pem_key):
def generate_key_pair(bits=2048):
key = paramiko.RSAKey.generate(bits)
- keyout = StringIO.StringIO()
+ keyout = six.BytesIO()
key.write_private_key(keyout)
private_key = keyout.getvalue()
public_key = '%s %s Generated-by-Nova' % (key.get_name(), key.get_base64())