py33: don't encode security_group

In Python 3, str and bytes can not be mixed. str.encode() will
return bytes in py33, which will induce the mismatch.

Bypass the s.name.encode() in py33.

Change-Id: Iee8d69aab9df4af126e94e4363f79e32fdd70fcd
Close-bug: #1231868
py33: sort the files parameters of "--files"

In Python 3.3, hash randomization is enabled by default. It causes the
iteration order of dicts and sets to be unpredictable and differ across
Python runs.

Sort the files parameters when multiple files are designated.

Close-Bug #1235096

Change-Id: I0db645b3fb92408bd8c6780bfabe7ce8265a65a8
py33: use six.StringIO() to mock stdout/stderr

six.StringIO() is the right way to keep Python2/3 compatibiliby
while mocking stdout/stderr.

Close-Bug #1235086

Change-Id: I33d9223b2202896331d24339056d57d4ca9acdc5
Align mocking pattern for test case

Mock sys.stderr/sys.stdout with mock.patch()

In novaclient/tests/test_shell.py, ShellTest.shell(), it is another
case that should be aligned. But it may induce test error if changed.
So, let's keep it as is.

Close-Bug #1237093

Change-Id: I8908dc1593dbbbaf2813cc8fb034be32972140a0
Merge "py33: don't encode security_group"
Revert "Add-in some re-auth logic when using os_cache"

This patch didn't do what it was supposed to do, make os_cache work. Instead it just adds complexity, so just remove it.

This reverts commit 8eed73ce20ff0808d350fc9af66d6ba55ebda017.

Change-Id: I7c118cbf8d8e2218e198d603f1984a9de18266c4
Document and make OS_CACHE work

Before the --os-no-cache option logic would overwrite any value set in env['OS_CACHE'].
Since os-no-cache  is deprecated, and also the default value, just remove it.
Also update the help message for --os-cache to mention the environment variable.

Change-Id: Ie2569d5cdf0f12f3a29e9a6f20faef75956d2209
Make os-cache retry on an invalid token

client.authenticate doesn't actually do any rest calls if a token is present,
it just assumes the token is valid.  Instead re-authentication is done if the
request raises an Unauthorized exception, at which point we want to
unauthenticate (delete the token from in-memory) and overwrite the old token
in the keyring. Also if a password is present allways pass it into the client
so re-authentication is possible during _cs_request.

Change-Id: I86d0356d5685ffa802f1bdc97e33727ff2dd075e
Merge "py33: use six.StringIO() to mock stdout/stderr"
Print dicts in alphabetical order

Instead of iterating over dicts, print them in alphabetical order.

Change-Id: I630c28ea36266037b1ab4098831f4f960e6c5dc5
Closes-Bug: #1239511
Remove deprecated NOVA_RAX_AUTH

NOVA_RAX_AUTH has been deprecated in favor of a generic pluggable auth,
which in this case rackspace users can set OS_AUTH_SYSTEM=rackspace

Fixes bug 966329

Change-Id: Ie55fc36a0ac1cba61efa8bdd2f20809530d3365f
Merge "Remove deprecated NOVA_RAX_AUTH"
Merge "Revert "Add-in some re-auth logic when using os_cache""
Merge "Document and make OS_CACHE work"
Merge "Make os-cache retry on an invalid token"
Updated from global requirements

Change-Id: I2cc2769b89bd040064408faea30c448350fa5f00
Apply six for metaclass

The way to using metaclass has changed in Python3.

Python 2.7 way:

class Foo(object):
  __metaclass__ = FooMeta

Python 3 way:

class Foo(object, metaclass=FooMeta):
  ...

The six.add_metaclass() decorator allows us to use one syntax that
works for both Python 2.7 and Python 3.

Change-Id: Ibd31a9f91bac6ec220d802f16c77ee0306e211b3
Closes-Bug: #1236648
Add --insecure to curl output if required

Change-Id: I5762f6659a6687b86c94a6e371ccc7509d1e26f9
Quote URL in curl output to handle query params

Copy and pasting the generated curl output into a shell doesn't
work when the URL includes an ampersand, as the URL isn't quoted.

This simplifies the logic in client.http_log_req to be able to
output the URL and method separately and quote the URL.

Change-Id: I1e497886ea9334771ab91e657e7c1121d89f7f33
Make 'nova ssh' automatically fall back to private address

If no public IP address is available automatically revert to the private address.

Change-Id: Iaf780fde77c4a1eae99c27be7e21841ca87d69dc