Python 3: compatibility of StringIO() and dict.iterkeys()

Change-Id: Ia671cacbf1852984c41b374986cc2e9581247b99
Remove "--disabled" for firewall create rule

Allow "--enabled True/False" and remove "--disabled" for consistency across
all commands. Even in other neutron commands, we are using only --enabled
option but not --disabled. firewall-rule-show displays only "enabled" attribute
and there is no "disabled" attribute.

Change-Id: Ie591d827660466a774e431dcb40e04e09773e5f7
Closes-bug: 1327056
Add option for retry number of connection attempts

This patch adds a new option (-r | --retries) to specify how many times the
client should attempt to connect to the Neutron server when using idempotent
methods (GET, PUT and DELETE). The patch also provides more user-friendly
message when it's impossible to connect to Neutron server from CLI and
ensures that connection-related exceptions are raised to the caller by
default when neutronclient is used as a library.

DocImpact
Closes-Bug: #1312225

Change-Id: Id74d7cf9a0e8c5d2cd3ee4851c883d5286bea19d
setup logger name of NeutronCommand automatically

It is a common pattern to add
class XXXCommand(NeutronCommand):
    log = logging.getLogger(__name__ + '.<command name>').
So introduce a metaclass to do that automatically in order to simplify
the code a bit.

Closes-Bug: #1258028
Change-Id: I7908e3e2c0f3f04d9e57360f6ba22e153d0d35bd
Introduce shadow resources for NeutronCommands

With the acceptance of the v2 LBaaS object model we will be required to
support both the original v1 (soon to be deprecated) and v2
side-by-side. Not surprisingly these two modelsshare a number of object
types (ie. pools, members, etc.) In order to handle this overlap of
object names, the API prefixes v1 with /lb whereas v2 is prefixed with
/lbaas.

This presents a problem for python-neutronclient in that resource name
alone (until now) was adequate for the string interpolation that helps
derive the method name to be called. Now that we have, for instance,
two different "pool" objects, we need a way to handle each uniquely.

Therefore, in order to maintain backwards compatibility, and minimize
complexity, this change introduces the concept of a shadow resource.
This shadow recource is used to direct the client at the correct paths
and methods to call internally, get still leverage the same logic that
has enabled resources to be manipulated by the de facto resource name.

Shadow resources are only necessary when an API is in this particular
type of scenario: the deprecation of a previous and overlapping former
API. Otherwise, new and existing API's can continue to use the same
logic as before.

This change also moves the 'resource' attributes from the Neutron
subclasses into NeutronCommand itself  as they were common to all the
subcommands already.

Change-Id: I69270debe25aac2659977d66d7887154ef0cdddf
Partially-implements: blueprint lbaas-api-and-objmodel-improvement
Merge "Python 3: compatibility of StringIO() and dict.iterkeys()"
Merge "setup logger name of NeutronCommand automatically"
Merge "Introduce shadow resources for NeutronCommands"
Merge "Add option for retry number of connection attempts"
Updated from global requirements

Change-Id: I1d4cf640d826e4d18025738511f94b789bb1b62a
Add keystone v3 auth support

This change enables the neutron client to use the keystone v3 API (in
addition to v2).  This allows user domains and tenant/project domains to
be specified.  This is necessary because keystone v2 API is deprecated
as of Icehouse.

The keystone session object (and auth plugin) can now be specified
and are required to use the keystone v3 API.  The existing HTTPClient
is retained for backward compatibility.  See changes in shell.py for
an example of how to construct the session and auth plugin.

Implements: blueprint keystone-api-v3-support

Change-Id: I9d0395d405b9fbe4db08ad3727f9413be7b82811
Provide support for nested objects

With the introduction of the LBaaS v2 API, all objects are capable
of normal CRUD operations. Until now these objects were mostly top-level
constructs, and in then instances where they weren't, they were
manipulated by way of 'actions.'

LBaaS v2, as designed, nests members under pools, and supports all
normal CRUD operations. This means that in order to take action against
a member we need to provide a pool uuid as well as the member uuid. The
python-neutronclient currently does not support this, so this change
makes to possible to do so.

This change adds the capability but does not affect other top-level
object implemenations.

Change-Id: I38c3b78dc077f1f78ebc7e703fe7277a02f53f7a
Partially-implements: blueprint lbaas-api-and-objmodel-improvement
Merge "Updated from global requirements"
Fix unit tests to succeed on any PYTHONHASHSEED

Many tests rely on order of parameters in URL query, but
queries are constructed from dicts and order of parameters
is non-deterministic. The issue doesn't occur if PYTHONHASHSEED
stays constant, but breaks if random. The fix is needed for
tox>1.7 and Py3.

Closes-Bug: 1348818

Change-Id: I01145df689e90ccd6100fa82092ba3ed222af8fc
Merge "Provide support for nested objects"
Merge "Fix unit tests to succeed on any PYTHONHASHSEED"
Remove incorrect super() call

extension.ShowExt.get_parser called super() with the *parent* class,
skipping the parent's own get_parser.  This is quite surprising without
any additional comments to explain the situation.

The only difference between the two get_parsers is the string that
appears in the usage help text (EXT_ALIAS vs EXTENSION).  Rather than
improve the above super() call, this change removes the specialised
ShowExt.get_parser() implementation entirely since it appears the
generic version is sufficient.

Change-Id: I76b901d6a27fbe6f103baf2f03ea17912123a46b
Merge "Remove "--disabled" for firewall create rule"
Print exception when verbose is over DEBUG_LEVEL

Change-Id: I8a2010332be0acfe6762bf3190248fe17f42cadb
Closes-bug: #1353496
Fix typo in cli help

The help message for neutron floatingip-disassociate should say
the argument is the ID of the floating IP to disassociate

Change-Id: I4564d546ca269ab05199a51ffd11678237a4d56f