Hide Forgot
Cloned from launchpad blueprint https://blueprints.launchpad.net/glance/+spec/image-location-selection-strategy. Description: An image can be saved to more than one backend storage by multi-location mechanism, therefore Glance should be able to select the best backend storage for improve image consuming performance. As an end user, he can get VM or consuming image faster base on this enhancement. This is not only for 'download' transport handling on the API server side but also for client since they can obtain locations by standard 'direct URL' interface. So the strategy option and the configurations of specific strategy should can be added to API server side and client side [1] consistently, and also the strategy based selection functions should be shared between API server side and client side also. 1. Adding "location_selection_strategy" option, and currently support two strategies: "location_order" or "store_type". 2. Implement two selection functions to support those two strategies, and put #1 and #2 stuff to a common code place. i. "location_order": using image owner or admin given locations arbitrary order. ii. "store_type": using configured backend storage preference, ordered by another option like ['file', 'swift', 's3'], that means using file based location first if image have, then swift and s3 at last. 3. Change Glance v2 'download' action to involve strategy based selection mechanism. [1] We have a plan to do a reusable glance client library for all clients like Nova and Cinder in near period, it can contains common code to provide uniform image service interface for them. This just like Brick in Cinder. Specification URL (additional information): None
Test case for this feature: 1. Enable 'show_image_direct_url' option and/or 'show_multiple_locations' option for glance api service, for example: $ cat /etc/glance/glance-api.conf | grep 'show_' show_image_direct_url = True show_multiple_locations = False 2. Set 'location_strategy' option to 'location_order' or 'store_type' for glance api service as you needed, like this: $ cat /etc/glance/glance-api.conf | grep 'location_strategy' location_strategy = location_order $ glance image-create --disk-format qcow2 --container-format bare --name test +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | None | | container_format | bare | | created_at | 2014-03-21T09:40:57 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | a9ff0a36-c6bd-4c4e-b3b2-50a2a1cf4e44 | | is_public | False | | min_disk | 0 | | min_ram | 0 | | name | test | | owner | 9599f20756514c6085310f2b2998afa1 | | protected | False | | size | 0 | | status | queued | | updated_at | 2014-03-21T09:40:57 | | virtual_size | None | +------------------+--------------------------------------+ This curl command is needed. Support for multi-location is being added to the client: https://review.openstack.org/#/c/72539/3 $ curl -X PATCH -H 'X-Auth-Token: b1f05c68b0534e28b4c45e05f0ac67de' -H 'User-Agent: python-lient' -H 'Content-Type: application/openstack-images-v2.1-json-patch' -i http://127.0.0.1:9292/v2/images/a9ff0a36-c6bd-4c4e-b3b2-50a2a1cf4e44 -d '[{"op": "replace", "path": "/locations", "value": [{"url": "file:///home/fedora/test", "metadata": {}}, {"url": "http://127.0.0.1:9292/image_test_loc_2", "metadata": {}}]}]' Note that file:// is chosen instead of http. [fedora@glance-strategy devstack]$ glance --os-image-api-version 2 image-show a9ff0a36-c6bd-4c4e-b3b2-50a2a1cf4e44 +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | container_format | bare | | created_at | 2014-03-21T09:40:57Z | | direct_url | file:///home/fedora/test | | disk_format | qcow2 | | id | a9ff0a36-c6bd-4c4e-b3b2-50a2a1cf4e44 | | min_disk | 0 | | min_ram | 0 | | name | test | | owner | 9599f20756514c6085310f2b2998afa1 | | protected | False | | size | 4096 | | status | active | | tags | [] | | updated_at | 2014-03-21T09:43:34Z | | visibility | private | +------------------+--------------------------------------+ As alternative location strategy, if end user use 'location_order' strategy, and give 'http, file' as the value for 'store_type_preference' option, then the image locations result will as following: [fedora@glance-strategy devstack]$ cat /etc/glance/glance-api.conf | egrep "(location_strategy|store_type_preference)" location_strategy = store_type [store_type_location_strategy] # location strategy defined by the 'location_strategy' config option. store_type_preference = http, file [fedora@glance-strategy devstack]$ glance --os-image-api-version 2 image-show a9ff0a36-c6bd-4c4e-b3b2-50a2a1cf4e44 +------------------+----------------------------------------+ | Property | Value | +------------------+----------------------------------------+ | container_format | bare | | created_at | 2014-03-21T09:40:57Z | | direct_url | http://127.0.0.1:9292/image_test_loc_2 | | disk_format | qcow2 | | id | a9ff0a36-c6bd-4c4e-b3b2-50a2a1cf4e44 | | min_disk | 0 | | min_ram | 0 | | name | test | | owner | 9599f20756514c6085310f2b2998afa1 | | protected | False | | size | 4096 | | status | active | | tags | [] | | updated_at | 2014-03-21T09:43:34Z | | visibility | private | +------------------+----------------------------------------+
Verified on: RHEL7 python-glance-2014.1-2.el7ost.noarch python-glanceclient-0.12.0-1.el7ost.noarch openstack-glance-2014.1-2.el7ost.noarch Work flow see comment 4 and 13. Output from testing same as mentioned in comment 4.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHEA-2014-0851.html