Fix keypair create --public-key

Commit Id702ccaad239b916340bb17014d1ede0a28aaec9 changed the keypair
create --public-key to use io.open but incorrectly reads the file
in binary mode, which causes JSON serialization to fail.

The unit tests mock out io.ioen (the reason for adding it in the first
place actually) so any testing for this specific problem would have to
be done in functional tests...yet to come.

Closes-bug: 1559125
Change-Id: I7a299a542d9df543bff43d3ea1e7907fc8c5f640
This commit is contained in:
Dean Troyer 2016-03-18 11:36:33 -05:00 committed by Steve Martinelli
parent 3ccc4f7d06
commit 21e414d860
1 changed files with 1 additions and 2 deletions

View File

@ -48,8 +48,7 @@ class CreateKeypair(command.ShowOne):
public_key = parsed_args.public_key
if public_key:
try:
with io.open(os.path.expanduser(parsed_args.public_key),
"rb") as p:
with io.open(os.path.expanduser(parsed_args.public_key)) as p:
public_key = p.read()
except IOError as e:
msg = "Key file %s not found: %s"