summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitreview2
-rw-r--r--.zuul.yaml25
-rw-r--r--glanceclient/exc.py2
-rw-r--r--glanceclient/tests/unit/v2/test_shell_v2.py23
-rw-r--r--glanceclient/v2/images.py5
-rw-r--r--glanceclient/v2/shell.py16
-rw-r--r--releasenotes/notes/2.16.0_Release-43ebe06b74a272ba.yaml12
-rw-r--r--releasenotes/notes/validation-data-support-dfb2463914818cd2.yaml12
-rw-r--r--releasenotes/source/index.rst1
-rw-r--r--releasenotes/source/stein.rst6
-rw-r--r--tox.ini2
11 files changed, 90 insertions, 16 deletions
diff --git a/.gitreview b/.gitreview
index a0e27a7..047ac56 100644
--- a/.gitreview
+++ b/.gitreview
@@ -1,4 +1,4 @@
[gerrit]
-host=review.openstack.org
+host=review.opendev.org
port=29418
project=openstack/python-glanceclient.git
diff --git a/.zuul.yaml b/.zuul.yaml
index 4bccd7c..c19edd2 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -35,7 +35,16 @@
s-object: true
s-proxy: true
# Hardcode glanceclient path so the job can be run on glance patches
- zuul_work_dir: src/git.openstack.org/openstack/python-glanceclient
+ zuul_work_dir: src/opendev.org/openstack/python-glanceclient
+ irrelevant-files:
+ - ^doc/.*$
+ - ^releasenotes/.*$
+ - ^.*\.rst$
+ - ^(test-|)requirements.txt$
+ - ^lower-constraints.txt$
+ - ^setup.cfg$
+ - ^tox.ini$
+ - ^\.zuul\.yaml$
- job:
name: glanceclient-dsvm-functional
@@ -65,7 +74,16 @@
s-object: true
s-proxy: true
# Hardcode glanceclient path so the job can be run on glance patches
- zuul_work_dir: src/git.openstack.org/openstack/python-glanceclient
+ zuul_work_dir: src/opendev.org/openstack/python-glanceclient
+ irrelevant-files:
+ - ^doc/.*$
+ - ^releasenotes/.*$
+ - ^.*\.rst$
+ - ^(test-|)requirements.txt$
+ - ^lower-constraints.txt$
+ - ^setup.cfg$
+ - ^tox.ini$
+ - ^\.zuul\.yaml$
- job:
name: glanceclient-tox-keystone-tips-base
@@ -133,6 +151,7 @@
- openstack-python-jobs
- openstack-python35-jobs
- openstack-python36-jobs
+ - openstack-python37-jobs
- publish-openstack-docs-pti
- release-notes-jobs-python3
check:
@@ -154,7 +173,7 @@
# The "tips" jobs can be removed from the stable branch .zuul.yaml
# files if someone is so inclined, but that would require manual
# maintenance, so we do not do it by default. Another option is
- # to define these jobs in the openstack-infra/project-config repo.
+ # to define these jobs in the openstack/project-config repo.
# That would make us less agile in adjusting these tests, so we
# aren't doing that either.
- glanceclient-tox-py27-keystone-tips:
diff --git a/glanceclient/exc.py b/glanceclient/exc.py
index c8616c3..eee47ca 100644
--- a/glanceclient/exc.py
+++ b/glanceclient/exc.py
@@ -52,7 +52,7 @@ class HTTPException(ClientException):
self.details = details or self.__class__.__name__
def __str__(self):
- return "%s (HTTP %s)" % (self.details, self.code)
+ return "HTTP %s" % (self.details)
class HTTPMultipleChoices(HTTPException):
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py
index bafa8e5..b8161e3 100644
--- a/glanceclient/tests/unit/v2/test_shell_v2.py
+++ b/glanceclient/tests/unit/v2/test_shell_v2.py
@@ -1518,18 +1518,25 @@ class ShellV2Test(testtools.TestCase):
def test_do_location_add(self):
gc = self.gc
- loc = {'url': 'http://foo.com/', 'metadata': {'foo': 'bar'}}
- args = self._make_args({'id': 'pass',
- 'url': loc['url'],
- 'metadata': json.dumps(loc['metadata'])})
+ loc = {'url': 'http://foo.com/',
+ 'metadata': {'foo': 'bar'},
+ 'validation_data': {'checksum': 'csum',
+ 'os_hash_algo': 'algo',
+ 'os_hash_value': 'value'}}
+ args = {'id': 'pass',
+ 'url': loc['url'],
+ 'metadata': json.dumps(loc['metadata']),
+ 'checksum': 'csum',
+ 'hash_algo': 'algo',
+ 'hash_value': 'value'}
with mock.patch.object(gc.images, 'add_location') as mocked_addloc:
expect_image = {'id': 'pass', 'locations': [loc]}
mocked_addloc.return_value = expect_image
- test_shell.do_location_add(self.gc, args)
- mocked_addloc.assert_called_once_with('pass',
- loc['url'],
- loc['metadata'])
+ test_shell.do_location_add(self.gc, self._make_args(args))
+ mocked_addloc.assert_called_once_with(
+ 'pass', loc['url'], loc['metadata'],
+ validation_data=loc['validation_data'])
utils.print_dict.assert_called_once_with(expect_image)
def test_do_location_delete(self):
diff --git a/glanceclient/v2/images.py b/glanceclient/v2/images.py
index 09d46b9..5252ee3 100644
--- a/glanceclient/v2/images.py
+++ b/glanceclient/v2/images.py
@@ -432,7 +432,7 @@ class Controller(object):
data=json.dumps(patch_body))
return (resp, body), resp
- def add_location(self, image_id, url, metadata):
+ def add_location(self, image_id, url, metadata, validation_data=None):
"""Add a new location entry to an image's list of locations.
It is an error to add a URL that is already present in the list of
@@ -441,10 +441,13 @@ class Controller(object):
:param image_id: ID of image to which the location is to be added.
:param url: URL of the location to add.
:param metadata: Metadata associated with the location.
+ :param validation_data: Validation data for the image.
:returns: The updated image
"""
add_patch = [{'op': 'add', 'path': '/locations/-',
'value': {'url': url, 'metadata': metadata}}]
+ if validation_data:
+ add_patch[0]['value']['validation_data'] = validation_data
response = self._send_image_update_request(image_id, add_patch)
# Get request id from the above update request and pass the same to
# following get request
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 75c3c0d..dec8314 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -750,16 +750,30 @@ def do_image_tag_delete(gc, args):
@utils.arg('--metadata', metavar='<STRING>', default='{}',
help=_('Metadata associated with the location. '
'Must be a valid JSON object (default: %(default)s)'))
+@utils.arg('--checksum', metavar='<STRING>',
+ help=_('md5 checksum of image contents'))
+@utils.arg('--hash-algo', metavar='<STRING>',
+ help=_('Multihash algorithm'))
+@utils.arg('--hash-value', metavar='<STRING>',
+ help=_('Multihash value'))
@utils.arg('id', metavar='<IMAGE_ID>',
help=_('ID of image to which the location is to be added.'))
def do_location_add(gc, args):
"""Add a location (and related metadata) to an image."""
+ validation_data = {}
+ if args.checksum:
+ validation_data['checksum'] = args.checksum
+ if args.hash_algo:
+ validation_data['os_hash_algo'] = args.hash_algo
+ if args.hash_value:
+ validation_data['os_hash_value'] = args.hash_value
try:
metadata = json.loads(args.metadata)
except ValueError:
utils.exit('Metadata is not a valid JSON object.')
else:
- image = gc.images.add_location(args.id, args.url, metadata)
+ image = gc.images.add_location(args.id, args.url, metadata,
+ validation_data=validation_data)
utils.print_dict(image)
diff --git a/releasenotes/notes/2.16.0_Release-43ebe06b74a272ba.yaml b/releasenotes/notes/2.16.0_Release-43ebe06b74a272ba.yaml
new file mode 100644
index 0000000..47b61e7
--- /dev/null
+++ b/releasenotes/notes/2.16.0_Release-43ebe06b74a272ba.yaml
@@ -0,0 +1,12 @@
+---
+prelude: >
+ This version of python-glanceclient adds Python 3.6 classifier and gating
+ on Python 3.7 environment.
+fixes:
+ - |
+ * Bug 1788271_: Add image-list filter for multihash
+ * Bug 1598714_: Remove redundant information from error message
+
+ .. _1788271: https://code.launchpad.net/bugs/1788271
+ .. _1598714: https://code.launchpad.net/bugs/1598714
+
diff --git a/releasenotes/notes/validation-data-support-dfb2463914818cd2.yaml b/releasenotes/notes/validation-data-support-dfb2463914818cd2.yaml
new file mode 100644
index 0000000..499c1fb
--- /dev/null
+++ b/releasenotes/notes/validation-data-support-dfb2463914818cd2.yaml
@@ -0,0 +1,12 @@
+---
+features:
+ - |
+ Support for embedding validation data (checksum and multihash) when adding
+ a location to an image. Requires the Stein release server-side.
+
+ The ``glance.images.add_location()`` method now accepts an optional
+ argument ``validation_data``, in the form of a dictionary containing
+ ``checksum``, ``os_hash_algo`` and ``os_hash_value``.
+
+ The ``location-add`` command now accepts optional arguments ``--checksum``,
+ ``--hash-algo`` and ``--hash-value``.
diff --git a/releasenotes/source/index.rst b/releasenotes/source/index.rst
index 97fc0eb..a67164d 100644
--- a/releasenotes/source/index.rst
+++ b/releasenotes/source/index.rst
@@ -6,6 +6,7 @@ glanceclient Release Notes
:maxdepth: 1
unreleased
+ stein
rocky
queens
pike
diff --git a/releasenotes/source/stein.rst b/releasenotes/source/stein.rst
new file mode 100644
index 0000000..efaceb6
--- /dev/null
+++ b/releasenotes/source/stein.rst
@@ -0,0 +1,6 @@
+===================================
+ Stein Series Release Notes
+===================================
+
+.. release-notes::
+ :branch: stable/stein
diff --git a/tox.ini b/tox.ini
index 85f5f3a..b2b2865 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
[tox]
envlist = py35,py27,pep8
-minversion = 1.6
+minversion = 2.0
skipsdist = True
[testenv]