Hello community,
here is the log from the commit of package python-glanceclient for openSUSE:Factory checked in at 2015-10-30 13:42:44
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-glanceclient (Old)
and /work/SRC/openSUSE:Factory/.python-glanceclient.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-glanceclient"
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-glanceclient/python-glanceclient.changes 2015-09-08 18:05:36.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.python-glanceclient.new/python-glanceclient.changes 2015-10-30 13:42:46.000000000 +0100
@@ -1,0 +2,20 @@
+Wed Sep 16 15:38:45 UTC 2015 - tbechtold@suse.com
+
+- update to 1.1.0:
+ * Change next version in docs
+ * 1.0.1 Release notes
+ * Fixes CLI client called without subcommands
+ * Print the reverting back to v1 to stderr
+ * Updates default --sort behaviour
+ * Invalid output running the command 'glance image-show '
+ * Don't make `help` require auth parameters
+ * check for None value in utils.safe_header
+ * Updated from global requirements
+ * Consider `--os-token` when using v2
+ * Check if v2 is available and fallback
+ * Update path to subunit2html in post_test_hook
+ * Fix the remove property logic in V2
+ * Password should be prompted once
+- adjust Requires according to requirements.txt
+
+-------------------------------------------------------------------
Old:
----
python-glanceclient-1.0.0.tar.gz
New:
----
python-glanceclient-1.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-glanceclient.spec ++++++
--- /var/tmp/diff_new_pack.C9PM3d/_old 2015-10-30 13:42:47.000000000 +0100
+++ /var/tmp/diff_new_pack.C9PM3d/_new 2015-10-30 13:42:47.000000000 +0100
@@ -19,7 +19,7 @@
%define component glanceclient
Name: python-glanceclient
-Version: 1.0.0
+Version: 1.1.0
Release: 0
Summary: Openstack Image (Glance) API Client
License: Apache-2.0
@@ -37,7 +37,6 @@
BuildRequires: python-keystoneclient
BuildRequires: python-oslosphinx
BuildRequires: python-pbr
-BuildRequires: python-pyOpenSSL
BuildRequires: python-warlock
Requires: python >= 2.6.8
Requires: python-Babel >= 1.3
@@ -46,9 +45,8 @@
Requires: python-PrettyTable >= 0.7
Requires: python-keystoneclient >= 1.6.0
Requires: python-oslo.i18n >= 1.5.0
-Requires: python-oslo.utils >= 1.9.0
-Requires: python-pbr >= 1.4
-Requires: python-pyOpenSSL >= 0.11
+Requires: python-oslo.utils >= 2.0.0
+Requires: python-pbr >= 1.6
Requires: python-requests >= 2.5.2
Requires: python-six >= 1.9.0
Requires: python-warlock >= 1.0.1
@@ -71,9 +69,12 @@
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires: python-discover
%endif
+Requires: python-fixtures >= 1.3.1
Requires: python-mock >= 1.2
-Requires: python-mox3 >= 0.7.0
+Requires: python-requests-mock >= 0.6.0
+Requires: python-tempest-lib >= 0.6.1
Requires: python-testrepository >= 0.0.18
+Requires: python-testscenarios >= 0.4
Requires: python-testtools >= 1.4.0
%description test
++++++ python-glanceclient-1.0.0.tar.gz -> python-glanceclient-1.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/AUTHORS new/python-glanceclient-1.1.0/AUTHORS
--- old/python-glanceclient-1.0.0/AUTHORS 2015-08-31 18:27:07.000000000 +0200
+++ new/python-glanceclient-1.1.0/AUTHORS 2015-09-15 13:56:46.000000000 +0200
@@ -35,8 +35,10 @@
Darja Shakhray
Davanum Srinivas
Davanum Srinivas
+David Edery
David Koo
David Peraza
+David Sariel
David Wittman
Dazhao
Dean Troyer
@@ -65,6 +67,7 @@
Hugh Saunders
Ian Cordasco
Ian Wienand
+Jake Yip
Jakub Ruzicka
James E. Blair
James Li
@@ -124,6 +127,7 @@
Sudipta Biswas
Sulochan Acharya
Sushil Kumar
+Takashi NATSUME
Tatyana Leontovich
Thierry Carrez
Thomas Goirand
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/ChangeLog new/python-glanceclient-1.1.0/ChangeLog
--- old/python-glanceclient-1.0.0/ChangeLog 2015-08-31 18:27:07.000000000 +0200
+++ new/python-glanceclient-1.1.0/ChangeLog 2015-09-15 13:56:46.000000000 +0200
@@ -1,6 +1,24 @@
CHANGES
=======
+1.1.0
+-----
+
+* Change next version in docs
+* 1.0.1 Release notes
+* Fixes CLI client called without subcommands
+* Print the reverting back to v1 to stderr
+* Updates default --sort behaviour
+* Invalid output running the command 'glance image-show '
+* Don't make `help` require auth parameters
+* check for None value in utils.safe_header
+* Updated from global requirements
+* Consider `--os-token` when using v2
+* Check if v2 is available and fallback
+* Update path to subunit2html in post_test_hook
+* Fix the remove property logic in V2
+* Password should be prompted once
+
1.0.0
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/PKG-INFO new/python-glanceclient-1.1.0/PKG-INFO
--- old/python-glanceclient-1.0.0/PKG-INFO 2015-08-31 18:27:08.000000000 +0200
+++ new/python-glanceclient-1.1.0/PKG-INFO 2015-09-15 13:56:46.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-glanceclient
-Version: 1.0.0
+Version: 1.1.0
Summary: OpenStack Image API Client Library
Home-page: http://www.openstack.org/
Author: OpenStack
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/doc/source/index.rst new/python-glanceclient-1.1.0/doc/source/index.rst
--- old/python-glanceclient-1.0.0/doc/source/index.rst 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/doc/source/index.rst 2015-09-15 13:55:53.000000000 +0200
@@ -53,6 +53,32 @@
Release Notes
=============
+1.1.0
+-----
+
+* This release provides mainly bugfixes for the bugs discovered after defaulting to v2 API on CLI. If you're using 1.0.0 client, it is highly recommended to upgrade.
+
+* 1494259_: Fixes CLI client called without subcommands
+* 1488914_: Print the reverting back to v1 to stderr
+* 1487645_: Invalid output running the command 'glance image-show '
+* 1490457_: Don't make `help` require auth parameters
+* 1491311_: check for None value in utils.safe_header
+* f0b30f4 Updated from global requirements
+* 1490462_: Consider `--os-token` when using v2
+* 1489381_: Check if v2 is available and fallback
+* 1491646_: Update path to subunit2html in post_test_hook
+* 1488892_: Password should be prompted once
+
+.. _1494259: https://bugs.launchpad.net/python-glanceclient/+bug/1494259
+.. _1488914: https://bugs.launchpad.net/python-glanceclient/+bug/1488914
+.. _1487645: https://bugs.launchpad.net/python-glanceclient/+bug/1487645
+.. _1490457: https://bugs.launchpad.net/python-glanceclient/+bug/1490457
+.. _1491311: https://bugs.launchpad.net/python-glanceclient/+bug/1491311
+.. _1490462: https://bugs.launchpad.net/python-glanceclient/+bug/1490462
+.. _1489381: https://bugs.launchpad.net/python-glanceclient/+bug/1489381
+.. _1491646: https://bugs.launchpad.net/python-glanceclient/+bug/1491646
+.. _1488892: https://bugs.launchpad.net/python-glanceclient/+bug/1488892
+
1.0.0
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/common/http.py new/python-glanceclient-1.1.0/glanceclient/common/http.py
--- old/python-glanceclient-1.0.0/glanceclient/common/http.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/common/http.py 2015-09-15 13:55:48.000000000 +0200
@@ -91,7 +91,10 @@
if not resp.ok:
LOG.debug("Request returned failure status %s." % resp.status_code)
raise exc.from_response(resp, resp.content)
- elif resp.status_code == requests.codes.MULTIPLE_CHOICES:
+ elif (resp.status_code == requests.codes.MULTIPLE_CHOICES and
+ resp.request.path_url != '/versions'):
+ # NOTE(flaper87): Eventually, we'll remove the check on `versions`
+ # which is a bug (1491350) on the server.
raise exc.from_response(resp)
content_type = resp.headers.get('Content-Type')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/common/utils.py new/python-glanceclient-1.1.0/glanceclient/common/utils.py
--- old/python-glanceclient-1.0.0/glanceclient/common/utils.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/common/utils.py 2015-09-15 13:55:48.000000000 +0200
@@ -450,7 +450,7 @@
def safe_header(name, value):
- if name in SENSITIVE_HEADERS:
+ if value is not None and name in SENSITIVE_HEADERS:
v = value.encode('utf-8')
h = hashlib.sha1(v)
d = h.hexdigest()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/shell.py new/python-glanceclient-1.1.0/glanceclient/shell.py
--- old/python-glanceclient-1.0.0/glanceclient/shell.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/shell.py 2015-09-15 13:55:48.000000000 +0200
@@ -442,12 +442,13 @@
ks_session.auth = auth
return ks_session
- def _get_endpoint_and_token(self, args, force_auth=False):
+ def _get_endpoint_and_token(self, args):
image_url = self._get_image_url(args)
auth_token = args.os_auth_token
- auth_reqd = force_auth or (utils.is_authentication_required(args.func)
- and not (auth_token and image_url))
+ auth_reqd = (not (auth_token and image_url) or
+ (hasattr(args, 'func') and
+ utils.is_authentication_required(args.func)))
if not auth_reqd:
endpoint = image_url
@@ -537,9 +538,8 @@
return endpoint, token
- def _get_versioned_client(self, api_version, args, force_auth=False):
- endpoint, token = self._get_endpoint_and_token(args,
- force_auth=force_auth)
+ def _get_versioned_client(self, api_version, args):
+ endpoint, token = self._get_endpoint_and_token(args)
kwargs = {
'token': token,
@@ -553,7 +553,7 @@
client = glanceclient.Client(api_version, endpoint, **kwargs)
return client
- def _cache_schemas(self, options, home_dir='~/.glanceclient'):
+ def _cache_schemas(self, options, client, home_dir='~/.glanceclient'):
homedir = os.path.expanduser(home_dir)
path_prefix = homedir
if options.os_auth_url:
@@ -573,16 +573,11 @@
schema_file_paths = [os.path.join(path_prefix, x + '_schema.json')
for x in ['image', 'namespace', 'resource_type']]
- client = None
failed_download_schema = 0
for resource, schema_file_path in zip(resources, schema_file_paths):
if (not os.path.exists(schema_file_path)) or options.get_schema:
try:
- if not client:
- client = self._get_versioned_client('2', options,
- force_auth=True)
schema = client.schemas.get(resource)
-
with open(schema_file_path, 'w') as f:
f.write(json.dumps(schema.raw()))
except Exception:
@@ -594,6 +589,24 @@
return failed_download_schema >= len(resources)
def main(self, argv):
+
+ def _get_subparser(api_version):
+ try:
+ return self.get_subcommand_parser(api_version)
+ except ImportError as e:
+ if options.debug:
+ traceback.print_exc()
+ if not str(e):
+ # Add a generic import error message if the raised
+ # ImportError has none.
+ raise ImportError('Unable to import module. Re-run '
+ 'with --debug for more info.')
+ raise
+ except Exception:
+ if options.debug:
+ traceback.print_exc()
+ raise
+
# Parse args once to find version
# NOTE(flepied) Under Python3, parsed arguments are removed
@@ -624,49 +637,55 @@
"Supported values are %s" % SUPPORTED_VERSIONS)
utils.exit(msg=msg)
- if api_version == 2:
- switch_version = self._cache_schemas(options)
- if switch_version:
- print('WARNING: The client is falling back to v1 because'
- ' the accessing to v2 failed. This behavior will'
- ' be removed in future versions')
- api_version = 1
-
- try:
- subcommand_parser = self.get_subcommand_parser(api_version)
- except ImportError as e:
- if options.debug:
- traceback.print_exc()
- if not str(e):
- # Add a generic import error message if the raised ImportError
- # has none.
- raise ImportError('Unable to import module. Re-run '
- 'with --debug for more info.')
- raise
- except Exception:
- if options.debug:
- traceback.print_exc()
- raise
-
- self.parser = subcommand_parser
-
# Handle top-level --help/-h before attempting to parse
# a command off the command line
if options.help or not argv:
- self.do_help(options)
+ self.do_help(options, parser=parser)
return 0
- # Parse args again and call whatever callback was selected
- args = subcommand_parser.parse_args(argv)
-
# Short-circuit and deal with help command right away.
+ sub_parser = _get_subparser(api_version)
+ args = sub_parser.parse_args(argv)
+
if args.func == self.do_help:
- self.do_help(args)
+ self.do_help(args, parser=sub_parser)
return 0
elif args.func == self.do_bash_completion:
self.do_bash_completion(args)
return 0
+ if not options.os_image_api_version and api_version == 2:
+ switch_version = True
+ client = self._get_versioned_client('2', options)
+
+ resp, body = client.http_client.get('/versions')
+
+ for version in body['versions']:
+ if version['id'].startswith('v2'):
+ # NOTE(flaper87): We know v2 is enabled in the server,
+ # which means we should be able to get the schemas and
+ # move on.
+ switch_version = self._cache_schemas(options, client)
+ break
+
+ if switch_version:
+ print('WARNING: The client is falling back to v1 because'
+ ' the accessing to v2 failed. This behavior will'
+ ' be removed in future versions', file=sys.stderr)
+ api_version = 1
+
+ sub_parser = _get_subparser(api_version)
+
+ # Parse args again and call whatever callback was selected
+ args = sub_parser.parse_args(argv)
+
+ # NOTE(flaper87): Make sure we re-use the password input if we
+ # have one. This may happen if the schemas were downloaded in
+ # this same command. Password will be asked to download the
+ # schemas and then for the operations below.
+ if not args.os_password and options.os_password:
+ args.os_password = options.os_password
+
LOG = logging.getLogger('glanceclient')
LOG.addHandler(logging.StreamHandler())
LOG.setLevel(logging.DEBUG if args.debug else logging.INFO)
@@ -675,8 +694,7 @@
if profile:
osprofiler_profiler.init(options.profile)
- client = self._get_versioned_client(api_version, args,
- force_auth=False)
+ client = self._get_versioned_client(api_version, args)
try:
args.func(client, args)
@@ -697,16 +715,24 @@
@utils.arg('command', metavar='<subcommand>', nargs='?',
help='Display help for <subcommand>.')
- def do_help(self, args):
+ def do_help(self, args, parser):
"""Display help about this program or one of its subcommands."""
- if getattr(args, 'command', None):
+ command = getattr(args, 'command', '')
+
+ if command:
if args.command in self.subcommands:
self.subcommands[args.command].print_help()
else:
raise exc.CommandError("'%s' is not a valid subcommand" %
args.command)
+ command = ' ' + command
else:
- self.parser.print_help()
+ parser.print_help()
+
+ if not args.os_image_api_version or args.os_image_api_version == '2':
+ print()
+ print(("Run `glance --os-image-api-version 1 help%s` "
+ "for v1 help") % command)
def do_bash_completion(self, _args):
"""Prints arguments for bash_completion.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/tests/functional/hooks/post_test_hook.sh new/python-glanceclient-1.1.0/glanceclient/tests/functional/hooks/post_test_hook.sh
--- old/python-glanceclient-1.0.0/glanceclient/tests/functional/hooks/post_test_hook.sh 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/tests/functional/hooks/post_test_hook.sh 2015-09-15 13:55:48.000000000 +0200
@@ -18,7 +18,7 @@
if [ -f .testrepository/0 ]; then
sudo .tox/functional/bin/testr last --subunit > $WORKSPACE/testrepository.subunit
sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit
- sudo .tox/functional/bin/python /usr/local/jenkins/slave_scripts/subunit2html.py $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
+ sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
sudo gzip -9 $BASE/logs/testrepository.subunit
sudo gzip -9 $BASE/logs/testr_results.html
sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/tests/functional/test_readonly_glance.py new/python-glanceclient-1.1.0/glanceclient/tests/functional/test_readonly_glance.py
--- old/python-glanceclient-1.0.0/glanceclient/tests/functional/test_readonly_glance.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/tests/functional/test_readonly_glance.py 2015-09-15 13:55:48.000000000 +0200
@@ -80,7 +80,7 @@
params=param_image_id)
def test_help(self):
- help_text = self.glance('help')
+ help_text = self.glance('--os-image-api-version 2 help')
lines = help_text.split('\n')
self.assertFirstLineStartsWith(lines, 'usage: glance')
@@ -103,7 +103,7 @@
self.glance('', flags='--version')
def test_debug_list(self):
- self.glance('image-list', flags='--debug')
+ self.glance('--os-image-api-version 2 image-list', flags='--debug')
def test_no_ssl_compression(self):
# Test deprecating this hasn't broken anything
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/tests/unit/test_shell.py new/python-glanceclient-1.1.0/glanceclient/tests/unit/test_shell.py
--- old/python-glanceclient-1.0.0/glanceclient/tests/unit/test_shell.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/tests/unit/test_shell.py 2015-09-15 13:55:48.000000000 +0200
@@ -147,24 +147,36 @@
def test_help_unknown_command(self):
shell = openstack_shell.OpenStackImagesShell()
- argstr = 'help foofoo'
+ argstr = '--os-image-api-version 2 help foofoo'
self.assertRaises(exc.CommandError, shell.main, argstr.split())
def test_help(self):
shell = openstack_shell.OpenStackImagesShell()
- argstr = 'help'
- actual = shell.main(argstr.split())
- self.assertEqual(0, actual)
+ argstr = '--os-image-api-version 2 help'
+ with mock.patch.object(shell, '_get_endpoint_and_token') as et_mock:
+ actual = shell.main(argstr.split())
+ self.assertEqual(0, actual)
+ self.assertFalse(et_mock.called)
+
+ def test_blank_call(self):
+ shell = openstack_shell.OpenStackImagesShell()
+ with mock.patch.object(shell, '_get_endpoint_and_token') as et_mock:
+ actual = shell.main('')
+ self.assertEqual(0, actual)
+ self.assertFalse(et_mock.called)
def test_help_on_subcommand_error(self):
- self.assertRaises(exc.CommandError, shell, 'help bad')
+ self.assertRaises(exc.CommandError, shell,
+ '--os-image-api-version 2 help bad')
def test_help_v2_no_schema(self):
shell = openstack_shell.OpenStackImagesShell()
argstr = '--os-image-api-version 2 help image-create'
- actual = shell.main(argstr.split())
- self.assertEqual(0, actual)
- self.assertNotIn('<unavailable>', actual)
+ with mock.patch.object(shell, '_get_endpoint_and_token') as et_mock:
+ actual = shell.main(argstr.split())
+ self.assertEqual(0, actual)
+ self.assertNotIn('<unavailable>', actual)
+ self.assertFalse(et_mock.called)
def test_get_base_parser(self):
test_shell = openstack_shell.OpenStackImagesShell()
@@ -185,7 +197,9 @@
def test_cert_and_key_args_interchangeable(self,
mock_versioned_client):
# make sure --os-cert and --os-key are passed correctly
- args = '--os-cert mycert --os-key mykey image-list'
+ args = ('--os-image-api-version 2 '
+ '--os-cert mycert '
+ '--os-key mykey image-list')
shell(args)
assert mock_versioned_client.called
((api_version, args), kwargs) = mock_versioned_client.call_args
@@ -193,7 +207,9 @@
self.assertEqual('mykey', args.os_key)
# make sure we get the same thing with --cert-file and --key-file
- args = '--cert-file mycertfile --key-file mykeyfile image-list'
+ args = ('--os-image-api-version 2 '
+ '--cert-file mycertfile '
+ '--key-file mykeyfile image-list')
glance_shell = openstack_shell.OpenStackImagesShell()
glance_shell.main(args.split())
assert mock_versioned_client.called
@@ -214,21 +230,18 @@
self.assertEqual('mytoken', kwargs['token'])
self.assertEqual('https://image:1234', args[0])
- @mock.patch.object(openstack_shell.OpenStackImagesShell, '_cache_schemas',
- return_value=False)
- def test_no_auth_with_token_and_image_url_with_v2(self,
- cache_schemas):
- with mock.patch('glanceclient.v2.client.Client') as v2_client:
- # test no authentication is required if both token and endpoint url
- # are specified
- args = ('--os-auth-token mytoken '
- '--os-image-url https://image:1234/v2 '
- '--os-image-api-version 2 image-list')
- glance_shell = openstack_shell.OpenStackImagesShell()
- glance_shell.main(args.split())
- ((args), kwargs) = v2_client.call_args
- self.assertEqual('https://image:1234', args[0])
- self.assertEqual('mytoken', kwargs['token'])
+ @mock.patch('glanceclient.v2.client.Client')
+ def test_no_auth_with_token_and_image_url_with_v2(self, v2_client):
+ # test no authentication is required if both token and endpoint url
+ # are specified
+ args = ('--os-image-api-version 2 --os-auth-token mytoken '
+ '--os-image-url https://image:1234 image-list')
+ glance_shell = openstack_shell.OpenStackImagesShell()
+ glance_shell.main(args.split())
+ self.assertTrue(v2_client.called)
+ (args, kwargs) = v2_client.call_args
+ self.assertEqual('mytoken', kwargs['token'])
+ self.assertEqual('https://image:1234', args[0])
def _assert_auth_plugin_args(self):
# make sure our auth plugin is invoked with the correct args
@@ -284,18 +297,30 @@
@mock.patch('sys.stdin', side_effect=mock.MagicMock)
@mock.patch('getpass.getpass', return_value='password')
- def test_password_prompted_with_v2(self, mock_getpass, mock_stdin):
+ @mock.patch('glanceclient.v2.client.Client')
+ def test_password_prompted_with_v2(self, v2_client,
+ mock_getpass, mock_stdin):
self.requests.post(self.token_url, exc=requests.ConnectionError)
+
+ cli2 = mock.MagicMock()
+ v2_client.return_value = cli2
+ cli2.http_client.get.return_value = (None, {'versions': []})
glance_shell = openstack_shell.OpenStackImagesShell()
self.make_env(exclude='OS_PASSWORD')
self.assertRaises(ks_exc.ConnectionRefused,
glance_shell.main, ['image-list'])
# Make sure we are actually prompted.
- mock_getpass.assert_called_with('OS Password: ')
+ mock_getpass.assert_called_once_with('OS Password: ')
@mock.patch('sys.stdin', side_effect=mock.MagicMock)
@mock.patch('getpass.getpass', side_effect=EOFError)
- def test_password_prompted_ctrlD_with_v2(self, mock_getpass, mock_stdin):
+ @mock.patch('glanceclient.v2.client.Client')
+ def test_password_prompted_ctrlD_with_v2(self, v2_client,
+ mock_getpass, mock_stdin):
+ cli2 = mock.MagicMock()
+ v2_client.return_value = cli2
+ cli2.http_client.get.return_value = (None, {'versions': []})
+
glance_shell = openstack_shell.OpenStackImagesShell()
self.make_env(exclude='OS_PASSWORD')
# We should get Command Error because we mock Ctl-D.
@@ -381,10 +406,38 @@
msg = 'Unable to import module. Re-run with --debug for more info.'
self.assertEqual(msg, str(e))
+ @mock.patch('glanceclient.v2.client.Client')
+ @mock.patch('glanceclient.v1.images.ImageManager.list')
+ def test_shell_v1_fallback_from_v2(self, v1_imgs, v2_client):
+ self.make_env()
+ cli2 = mock.MagicMock()
+ v2_client.return_value = cli2
+ cli2.http_client.get.return_value = (None, {'versions': []})
+ args = 'image-list'
+ glance_shell = openstack_shell.OpenStackImagesShell()
+ glance_shell.main(args.split())
+ self.assertFalse(cli2.schemas.get.called)
+ self.assertTrue(v1_imgs.called)
+
+ @mock.patch.object(openstack_shell.OpenStackImagesShell,
+ '_cache_schemas')
+ @mock.patch('glanceclient.v2.client.Client')
+ def test_shell_no_fallback_from_v2(self, v2_client, cache_schemas):
+ self.make_env()
+ cli2 = mock.MagicMock()
+ v2_client.return_value = cli2
+ cli2.http_client.get.return_value = (None,
+ {'versions': [{'id': 'v2'}]})
+ cache_schemas.return_value = False
+ args = 'image-list'
+ glance_shell = openstack_shell.OpenStackImagesShell()
+ glance_shell.main(args.split())
+ self.assertTrue(cli2.images.list.called)
+
@mock.patch('glanceclient.v1.client.Client')
def test_auth_plugin_invocation_without_username_with_v1(self, v1_client):
self.make_env(exclude='OS_USERNAME')
- args = 'image-list'
+ args = '--os-image-api-version 2 image-list'
glance_shell = openstack_shell.OpenStackImagesShell()
self.assertRaises(exc.CommandError, glance_shell.main, args.split())
@@ -398,7 +451,7 @@
@mock.patch('glanceclient.v1.client.Client')
def test_auth_plugin_invocation_without_auth_url_with_v1(self, v1_client):
self.make_env(exclude='OS_AUTH_URL')
- args = 'image-list'
+ args = '--os-image-api-version 1 image-list'
glance_shell = openstack_shell.OpenStackImagesShell()
self.assertRaises(exc.CommandError, glance_shell.main, args.split())
@@ -415,7 +468,7 @@
self.make_env(exclude='OS_TENANT_NAME')
if 'OS_PROJECT_ID' in os.environ:
self.make_env(exclude='OS_PROJECT_ID')
- args = 'image-list'
+ args = '--os-image-api-version 1 image-list'
glance_shell = openstack_shell.OpenStackImagesShell()
self.assertRaises(exc.CommandError, glance_shell.main, args.split())
@@ -472,12 +525,13 @@
side_effect=ks_exc.ClientException())
def test_api_discovery_failed_with_unversioned_auth_url(self,
discover):
- args = '--os-auth-url %s image-list' % DEFAULT_UNVERSIONED_AUTH_URL
+ args = ('--os-image-api-version 2 --os-auth-url %s image-list'
+ % DEFAULT_UNVERSIONED_AUTH_URL)
glance_shell = openstack_shell.OpenStackImagesShell()
self.assertRaises(exc.CommandError, glance_shell.main, args.split())
def test_bash_completion(self):
- stdout, stderr = self.shell('bash_completion')
+ stdout, stderr = self.shell('--os-image-api-version 2 bash_completion')
# just check we have some output
required = [
'--status',
@@ -542,8 +596,9 @@
}
schema_odict = OrderedDict(self.schema_dict)
- self.shell._cache_schemas(self._make_args(options),
- home_dir=self.cache_dir)
+ args = self._make_args(options)
+ client = self.shell._get_versioned_client('2', args, force_auth=True)
+ self.shell._cache_schemas(args, client, home_dir=self.cache_dir)
self.assertEqual(12, open.mock_calls.__len__())
self.assertEqual(mock.call(self.cache_files[0], 'w'),
@@ -564,8 +619,9 @@
}
schema_odict = OrderedDict(self.schema_dict)
- self.shell._cache_schemas(self._make_args(options),
- home_dir=self.cache_dir)
+ args = self._make_args(options)
+ client = self.shell._get_versioned_client('2', args, force_auth=True)
+ self.shell._cache_schemas(args, client, home_dir=self.cache_dir)
self.assertEqual(12, open.mock_calls.__len__())
self.assertEqual(mock.call(self.cache_files[0], 'w'),
@@ -585,8 +641,9 @@
'os_auth_url': self.os_auth_url
}
+ client = mock.MagicMock()
self.shell._cache_schemas(self._make_args(options),
- home_dir=self.cache_dir)
+ client, home_dir=self.cache_dir)
os.path.exists.assert_any_call(self.prefix_path)
os.path.exists.assert_any_call(self.cache_files[0])
@@ -604,6 +661,8 @@
self.client.schemas.get.return_value = Exception()
+ client = mock.MagicMock()
switch_version = self.shell._cache_schemas(self._make_args(options),
+ client,
home_dir=self.cache_dir)
self.assertEqual(switch_version, True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/tests/unit/test_utils.py new/python-glanceclient-1.1.0/glanceclient/tests/unit/test_utils.py
--- old/python-glanceclient-1.0.0/glanceclient/tests/unit/test_utils.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/tests/unit/test_utils.py 2015-09-15 13:55:48.000000000 +0200
@@ -177,3 +177,18 @@
i = utils.IterableWithLength(data, 10)
self.assertRaises(IOError, _iterate, i)
data.close.assert_called_with()
+
+ def test_safe_header(self):
+ self.assertEqual(('somekey', 'somevalue'),
+ utils.safe_header('somekey', 'somevalue'))
+ self.assertEqual(('somekey', None),
+ utils.safe_header('somekey', None))
+
+ for sensitive_header in utils.SENSITIVE_HEADERS:
+ (name, value) = utils.safe_header(sensitive_header, 'somestring')
+ self.assertEqual(sensitive_header, name)
+ self.assertTrue(value.startswith("{SHA1}"))
+
+ (name, value) = utils.safe_header(sensitive_header, None)
+ self.assertEqual(sensitive_header, name)
+ self.assertIsNone(value)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/v1/images.py new/python-glanceclient-1.1.0/glanceclient/v1/images.py
--- old/python-glanceclient-1.0.0/glanceclient/v1/images.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/v1/images.py 2015-09-15 13:55:48.000000000 +0200
@@ -73,6 +73,11 @@
meta = {'properties': {}}
safe_decode = encodeutils.safe_decode
for key, value in six.iteritems(headers):
+ # NOTE(flaper87): this is a compatibility fix
+ # for urllib3 >= 1.11. Please, refer to this
+ # bug for more info:
+ # https://bugs.launchpad.net/python-glanceclient/+bug/1487645
+ key = key.lower()
value = safe_decode(value, incoming='utf-8')
if key.startswith('x-image-meta-property-'):
_key = safe_decode(key[22:], incoming='utf-8')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/v2/images.py new/python-glanceclient-1.1.0/glanceclient/v2/images.py
--- old/python-glanceclient-1.0.0/glanceclient/v2/images.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/v2/images.py 2015-09-15 13:55:48.000000000 +0200
@@ -252,7 +252,7 @@
except warlock.InvalidOperation as e:
raise TypeError(utils.exception_to_str(e))
- if remove_props is not None:
+ if remove_props:
cur_props = image.keys()
new_props = kwargs.keys()
# NOTE(esheffield): Only remove props that currently exist on the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/glanceclient/v2/shell.py new/python-glanceclient-1.1.0/glanceclient/v2/shell.py
--- old/python-glanceclient-1.0.0/glanceclient/v2/shell.py 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/glanceclient/v2/shell.py 2015-09-15 13:55:48.000000000 +0200
@@ -142,8 +142,8 @@
help='Sort image list in specified directions.')
@utils.arg('--sort', metavar='<key>[:<direction>]', default=None,
help=(("Comma-separated list of sort keys and directions in the "
- "form of <key>[:]. Valid keys: %s. OPTIONAL: "
- "Default='name:asc'.") % ', '.join(images.SORT_KEY_VALUES)))
+ "form of <key>[:]. Valid keys: %s. OPTIONAL."
+ ) % ', '.join(images.SORT_KEY_VALUES)))
def do_image_list(gc, args):
"""List images you can access."""
filter_keys = ['visibility', 'member_status', 'owner', 'checksum', 'tag']
@@ -169,7 +169,8 @@
if args.sort is not None:
kwargs['sort'] = args.sort
elif not args.sort_dir and not args.sort_key:
- kwargs['sort'] = 'name:asc'
+ kwargs['sort_key'] = 'name'
+ kwargs['sort_dir'] = 'asc'
columns = ['ID', 'Name']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/python_glanceclient.egg-info/PKG-INFO new/python-glanceclient-1.1.0/python_glanceclient.egg-info/PKG-INFO
--- old/python-glanceclient-1.0.0/python_glanceclient.egg-info/PKG-INFO 2015-08-31 18:27:07.000000000 +0200
+++ new/python-glanceclient-1.1.0/python_glanceclient.egg-info/PKG-INFO 2015-09-15 13:56:46.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-glanceclient
-Version: 1.0.0
+Version: 1.1.0
Summary: OpenStack Image API Client Library
Home-page: http://www.openstack.org/
Author: OpenStack
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/python_glanceclient.egg-info/pbr.json new/python-glanceclient-1.1.0/python_glanceclient.egg-info/pbr.json
--- old/python-glanceclient-1.0.0/python_glanceclient.egg-info/pbr.json 2015-08-31 18:27:07.000000000 +0200
+++ new/python-glanceclient-1.1.0/python_glanceclient.egg-info/pbr.json 2015-09-15 13:56:46.000000000 +0200
@@ -1 +1 @@
-{"is_release": true, "git_version": "54ae632"}
\ No newline at end of file
+{"is_release": true, "git_version": "8663586"}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/python_glanceclient.egg-info/requires.txt new/python-glanceclient-1.1.0/python_glanceclient.egg-info/requires.txt
--- old/python-glanceclient-1.0.0/python_glanceclient.egg-info/requires.txt 2015-08-31 18:27:07.000000000 +0200
+++ new/python-glanceclient-1.1.0/python_glanceclient.egg-info/requires.txt 2015-09-15 13:56:46.000000000 +0200
@@ -1,4 +1,4 @@
-pbr<2.0,>=1.4
+pbr<2.0,>=1.6
Babel>=1.3
argparse
PrettyTable<0.8,>=0.7
@@ -6,5 +6,5 @@
requests>=2.5.2
warlock<2,>=1.0.1
six>=1.9.0
-oslo.utils>=1.9.0
+oslo.utils>=2.0.0
oslo.i18n>=1.5.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/python-glanceclient-1.0.0/requirements.txt new/python-glanceclient-1.1.0/requirements.txt
--- old/python-glanceclient-1.0.0/requirements.txt 2015-08-31 18:26:14.000000000 +0200
+++ new/python-glanceclient-1.1.0/requirements.txt 2015-09-15 13:55:48.000000000 +0200
@@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-pbr<2.0,>=1.4
+pbr<2.0,>=1.6
Babel>=1.3
argparse
PrettyTable<0.8,>=0.7
@@ -9,5 +9,5 @@
requests>=2.5.2
warlock<2,>=1.0.1
six>=1.9.0
-oslo.utils>=1.9.0 # Apache-2.0
+oslo.utils>=2.0.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0