refactor handling of extension list

Change-Id: I922c17523197497139da92d8be33dba10349a369
Sync apiclient from oslo

In the process of unification of the clients code we should
reuse common functionality from Oslo.

Hash of latest commit which affected apiclient in oslo at time of sync:
- be81d6ba70152e5cdd7e8e9d789b9733c6ff527f

Related to blueprint common-client-library-2

Change-Id: I93d5dae3a2ba124d6fba91f02c486dca25c5e09e
Improve output of "keystone help discover"

The current output of "keystone help discover" is:

usage: keystone discover

Discover Keystone servers, supported API versions and extensions.  Usage:: $
keystone discover Keystone found at http://localhost:35357 - supports version
v1.0 (DEPRECATED) here http://localhost:35357/v1.0 - supports version v1.1
(CURRENT) here http://localhost:35357/v1.1 - supports version v2.0 (CURRENT)
here http://localhost:35357/v2.0 - and RAX-KSKEY: Rackspace API Key
Authentication Admin Extension - and RAX-KSGRP: Rackspace Keystone Group
Extensions

The reason is that our parser strips away all the line ends. Let's
rephrase the text so that it formats more nicely.

Now the output is:
Discover Keystone servers, supported API versions and extensions.

Change-Id: Ic9f9e3e407ae299eb091a0a7093c955dc6cab8f2
Python3: webob.Response.body must be bytes

Remove duplicate assignement for 'resp.body'. Use bytes in Python3.

Change-Id: Ice1beb997ae401ebb87762e5499970409c63d801
cms: Use universal_newlines=True in subprocess.Popen()

The Python documentation states that "the type of [the first argument of
subprocess.communicate()] must be bytes or, if universal_newlines was True, a
string"[1]. Currently, in Python 3, a text string is given to
subprocess.communicate(), even though the process was created with
universal_newlines=False (the default value).

Rather than converting strings to bytes (and the other way around) everywhere
in the code, just create the process with universal_newlines=True. The side
effect is that '\n', '\r\n' and '\r' will be recognized as ending lines[2],
which should not be an issue.

[1] http://docs.python.org/3/library/subprocess.html?highlight=popen#subprocess.Popen.communicate
[2] http://docs.python.org/3/glossary.html#term-universal-newlines

Change-Id: I668b187ba8ed00ad6d55ec487af623b79b21589d
Python3: fix test_insecure

test_insecure() fails because it ends up calling guess_json_utf8() in the
requests module, where the count() method of the str type is called with bytes
input:

    nullcount = sample.count(_null)

This patch makes sure that we pass 'sample' as bytes.

Change-Id: I70071623d425ebbf910d3568a7b5c5d857892402
Merge "refactor handling of extension list"
Python3: httpretty.last_request().body is now bytes

In Python 3, we must decode it before using it.

Change-Id: I473ba7b9732555ef5f9011a50d8684260e1f7f71
Merge "Python3: fix test_insecure"
Merge "Python3: webob.Response.body must be bytes"
Merge "Python3: httpretty.last_request().body is now bytes"
Merge "cms: Use universal_newlines=True in subprocess.Popen()"
Merge "Sync apiclient from oslo"
Merge "Improve output of "keystone help discover""