Replace utils.ensure_(str|unicode) with strutils.safe(decode|encode)

Glanceclient implemented both functions before they landed into oslo.
Since both functions are already in oslo, it is now possible to pull
them in.

There's a small difference between glance's implementation and oslo's,
that is the later does not convert non-str objects - int, bool - to str
before trying to decode / encode them. This patch takes care of that
where necessary, more precisely, while encoding headers before doing a
new request.

Fixes bug: #1172253

Change-Id: I9a0dca31140bae28d8ec6aede515c5bb852b701b
This commit is contained in:
Flaper Fesp
2013-05-22 11:31:25 +02:00
parent 7daa976d14
commit 7818387d4a
10 changed files with 224 additions and 122 deletions
+2 -1
View File
@@ -25,6 +25,7 @@ else:
from glanceclient import exc
from glanceclient.common import utils
from glanceclient.openstack.common import strutils
import glanceclient.v1.images
#NOTE(bcwaldon): import deprecated cli functions
@@ -309,7 +310,7 @@ def do_image_delete(gc, args):
try:
if args.verbose:
print 'Requesting image delete for %s ...' % \
utils.ensure_str(args_image),
strutils.safe_encode(args_image),
gc.images.delete(image)