summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-27 15:03:52 -0500
committerBarry Warsaw <barry@python.org>2015-01-27 15:03:52 -0500
commit6e742d20e9ed56498925c7c850cd5da65d063b4b (patch)
tree3e584ae2381d72d2b77c6f2d98c9be93bcb9e413 /cloudinit/config
parent69c64029997599b3f1764ef48fe571094e2ee5f2 (diff)
downloadvyos-cloud-init-6e742d20e9ed56498925c7c850cd5da65d063b4b.tar.gz
vyos-cloud-init-6e742d20e9ed56498925c7c850cd5da65d063b4b.zip
Respond to review:
- Refactor both the base64 encoding and decoding into utility functions. Also: - Mechanically fix some other broken untested code.
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_seed_random.py8
-rw-r--r--cloudinit/config/cc_ssh_authkey_fingerprints.py2
2 files changed, 2 insertions, 8 deletions
diff --git a/cloudinit/config/cc_seed_random.py b/cloudinit/config/cc_seed_random.py
index 981e1b08..bb64b0f5 100644
--- a/cloudinit/config/cc_seed_random.py
+++ b/cloudinit/config/cc_seed_random.py
@@ -38,13 +38,7 @@ def _decode(data, encoding=None):
if not encoding or encoding.lower() in ['raw']:
return data
elif encoding.lower() in ['base64', 'b64']:
- # Try to give us a native string in both Python 2 and 3, and remember
- # that b64decode() returns bytes in Python 3.
- decoded = base64.b64decode(data)
- try:
- return decoded.decode('utf-8')
- except UnicodeDecodeError:
- return decoded
+ return util.b64d(data)
elif encoding.lower() in ['gzip', 'gz']:
return util.decomp_gzip(data, quiet=False)
else:
diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py
index 51580633..6ce831bc 100644
--- a/cloudinit/config/cc_ssh_authkey_fingerprints.py
+++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py
@@ -32,7 +32,7 @@ from cloudinit import util
def _split_hash(bin_hash):
split_up = []
- for i in xrange(0, len(bin_hash), 2):
+ for i in range(0, len(bin_hash), 2):
split_up.append(bin_hash[i:i + 2])
return split_up