I have a Rocky installation where glance is configured with multiple backends. This [*] is the relevant part of the glance configuration.
I now need to dismiss the file backend and move the images-snapshots stored there to rbd.
I had in mind to follow this procedure (already successfully tested with an older version of OpenStack):
1) download the image from the file backend (glance image-download --file <file> <imageid>
# glance --debug location-add --url rbd://8162f291-00b6-4b40-a8b4-1981a8c09b64/images-prod/6bcc4eab-ed35-42dc-88bd-1d45de73b628/snap 6bcc4eab-ed35-42dc-88bd-1d45de73b628
...
...
DEBUG:keystoneauth.session:PATCH call to image for
https://cloud-areapd.pd.infn.it:9292/v2/images/6bcc4eab-ed35-42dc-88bd-1d45de73b628 used request id req-6c0598cc-582c-4ce7-a14c-5d1bb6ec4f14
Request returned failure status 400.
DEBUG:glanceclient.common.http:Request returned failure status 400.
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/glanceclient/shell.py", line 687, in main
OpenStackImagesShell().main(argv)
File "/usr/lib/python2.7/site-packages/glanceclient/shell.py", line 591, in main
args.func(client, args)
File "/usr/lib/python2.7/site-packages/glanceclient/v2/shell.py", line 749, in do_location_add
image = gc.images.add_location(
args.id, args.url, metadata)
File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 448, in add_location
response = self._send_image_update_request(image_id, add_patch)
File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 598, in inner
return RequestIdProxy(wrapped(*args, **kwargs))
File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 432, in _send_image_update_request
data=json.dumps(patch_body))
File "/usr/lib/python2.7/site-packages/keystoneauth1/adapter.py", line 340, in patch
return self.request(url, 'PATCH', **kwargs)
File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 377, in request
return self._handle_response(resp)
File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 126, in _handle_response
raise exc.from_response(resp, resp.content)
HTTPBadRequest: 400 Bad Request: Invalid location (HTTP 400)
400 Bad Request: Invalid location (HTTP 400)
As far as I can see with the "openstack" client there is not something to add/delete a location.
So I guess it is necessary to change the 'direct_url' and 'locations' properties.
# openstack image set --property direct_url='rbd://8162f291-00b6-4b40-a8b4-1981a8c09b64/images-prod/6bcc4eab-ed35-42dc-88bd-1d45de73b628/snap' 6bcc4eab-ed35-42dc-88bd-1d45de73b628
403 Forbidden: Attribute 'direct_url' is read-only. (HTTP 403)