v2 image-update does not accept --location parameters

Bug #1271452 reported by David Koo
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
David Koo

Bug Description

Step1: Create an empty image (no image data) - doesn't matter which image api version you use.

Step2: Use glanceclient's v2 image-update API to set the location property of the image. It will fail with the following error:

  glance image-update: error: too few arguments

This is an argparse error: according to the schema 'locations' is a list and so argparse treats the image ID as one of the positional arguments for 'locations'. The mandatory 'ID' positional parameter is therefore left empty, leading to this error.

Note: The Glance REST APIs allow modification of an image's 'location' property (provided it's in the queued state).

David Koo (kpublicmail)
Changed in python-glanceclient:
assignee: nobody → David Koo (kpublicmail)
David Koo (kpublicmail)
Changed in python-glanceclient:
status: New → In Progress
Revision history for this message
Feilong Wang (flwang) wrote :

I have noticed this issue as well. But I have no time to dig into it. I think the root cause is 'locations' is a 'wrapping' attribute based on the v2 image schema.

Thanks for working on this.

Changed in python-glanceclient:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-glanceclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/72539

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-glanceclient (master)

Reviewed: https://review.openstack.org/72539
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=323d32cc6d28434ad57f3ddd5253b9a8950b4c8a
Submitter: Jenkins
Branch: master

commit 323d32cc6d28434ad57f3ddd5253b9a8950b4c8a
Author: David Koo <email address hidden>
Date: Tue Feb 11 11:06:02 2014 +0800

    Add support for location parameters in v2 commands

    Currently glanceclient's v2 commands don't support modification
    operations on an image's location attribute - the argparse specification
    for the location attribute of the image-update command causes the image
    id argument to be included in list of locations and so the command
    parsing fails (because it causes the image id to appear to be missing).

    Furthermore even if the 'locations' argument were to be accepted by
    argparse (e.g. by changing the argument specs and using --id to specify
    the image id) the command would still fail because the arguments are
    passed directly to the schema which expects the value of the 'locations'
    argument to be a valid dictionary (there is nobody to convert the
    argument string to a python dictionary that the schema expects).

    This commit adds the following location related commands to
        --location-add: Add a new location to the list of image locations.
        --location-delete: Remove an existing location from the list of
            image locations.
        --location-update: Update the metadata of existing location.

    The glanceclient.v2.images.Controller class has been agumented with
    three new methods to support the commands listed above:
        - add_location
        - delete_locations
        - update_location

    The server has not been modified, i.e. all location related API requests
    are passed to the server via HTTP PATCH requests and handled by the
    server's image update function.

    The v2 'image' and 'shell' related tests have also been supplemented.

    Note that in order to use these options the server must be first
    configured to expose location related info to the clients (i.e.
    'show_multiple_locations' must be set to 'True").

    I also added a mailmap entry for myself.

    Closes-bug: #1271452
    Co-Author: David Koo (koofoss) <email address hidden>

    Change-Id: Id1f320af05d9344645836359758e4aa227aafc69

Changed in python-glanceclient:
status: In Progress → Fix Committed
Louis Taylor (kragniz)
Changed in python-glanceclient:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.