refactor handling of extension list

Change-Id: I922c17523197497139da92d8be33dba10349a369
Provide a conversion function for creating session

Session.construct will create a session based upon the kwargs that used
to be passed to a client __init__ function. This will allow clients an
easy path to providing compatibility with deprecated arguments.

Make use of the function throughout discovery. Discovery was initially
released prior to the session object being completed and was therefore
handled with the same arguments as a client. Instead we should use a
session object so use the conversion function to convert those kwargs
into a session object if one is not provided.

Change-Id: I8dc1e0810ea6ebc6ea648ec37d7881825c566676
Create Authentication Plugins

Provides the framework for creating authentication plugins and using
them from a session object.

To allow this system to co-exist with the original client there is a bit
of a hack. The client object itself is now also an authentication
plugin, that supports the original client pattern. If a client is
created without a session object then that session object uses the
client as it's authentication plugin.

Change-Id: I682c8dcd3705148aaa804a91f4ed48a5b74bdc12
blueprint: auth-plugins
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
Check for any monkeypatching

Checking oinly for monkeypatching of the ``os`` module is
insufficient.  A process might have chosen not to patch ``os`` but
still needs to use the eventlet version of Popen to deal with proper
forks.  This version checks if any modules have been monkeypatched
with the eventlet versions.

Closes-Bug: #1277231

Change-Id: Ia8d7150e9e7ced58132e8e90e7ad68fb3c7c3b9f
Merge "Check for any monkeypatching"
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
Merge "Provide a conversion function for creating session"
Merge "Create Authentication Plugins"
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""