v2 api Image-create --file, 403 forbidden attribute 'file' is read-only

Bug #1324067 reported by Tzach Shefi
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
High
Erno Kuvaja

Bug Description

Description of problem:
On a semi distributed setup, Glance back-end is a Gluster volume, v2 API image-create from source --file fails.

[root@puma31 ~(keystone_admin)]# glance --os-image-api-version 2 image-create --name apiV2FromFile --disk-format qcow2 --container-format bare --file cirros-0.3.2-x86_64-disk.img
Request returned failure status.
403 Forbidden
Attribute 'file' is read-only.
    (HTTP 403)

Same command from v1 API , works fine.

Version-Release number of selected component (if applicable):
RHEL7
python-glanceclient-0.12.0-1.el7ost.noarch
python-glance-2014.1-2.el7ost.noarch
openstack-glance-2014.1-2.el7ost.noarch

How reproducible:
Every time

Steps to Reproduce:
1. # glance --os-image-api-version 2 image-create ... --file <file>

Actual results: Failed to create image, error:
Request returned failure status.
403 forbidden

Attribute 'file' is read-only.
    (HTTP 403)

Expected results:
Image should be created successfully.

Revision history for this message
Tzach Shefi (tshefi) wrote :

Forgot to attach api.log

Revision history for this message
Flavio Percoco (flaper87) wrote :

This is indeed a bug in the clientlibrary. Specifically, it seems that the image_create function is not processing the `file` parameter at all. This causes the parameter to be sent to the server.

Changed in python-glanceclient:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Cindy Pallares (cindy-pallaresq)
Revision history for this message
Michal Dulko (michal-dulko-f) wrote :

Shouldn't image-upload be used for this purpose instead of image-create?

Revision history for this message
Tzach Shefi (tshefi) wrote :

That would make some sense, I agree, but there is no such command :)

Glance's image-create is the correct command used to create "upload" images.
I may be wrong but never heard about glance image-upload command before.

Answer based on Glance command guide:
http://docs.openstack.org/user-guide/content/glance_commands.html

Note Glance image-download is a valid command used to download, or rather copy, images to files , it's the opposite of image-create.

Revision history for this message
Stuart McLaren (stuart-mclaren) wrote :

There is an image-upload command:

$ ./.tox/py27/bin/glance --os-image-api-version 2 help image-upload
usage: glance image-upload [--file <FILE>] [--size <IMAGE_SIZE>] [--progress]
                           <IMAGE_ID>

Upload data for a specific image x.

Positional arguments:
  <IMAGE_ID> ID of image to upload data to.

Optional arguments:
  --file <FILE> Local file that contains disk image to be uploaded.
                       Alternatively, images can be passed to the client via
                       stdin.
  --size <IMAGE_SIZE> Size in bytes of image to be uploaded. Default is to
                       get size from provided data object but this is
                       supported in case where size cannot be inferred.
  --progress Show upload progress bar.

but having the v2 create do both the image create and data upload would be more user friendly than having to run two commands.

Revision history for this message
Erno Kuvaja (jokke) wrote :

Cindy,

Are you working on this? If you have nothing ready, I'll look into it.

Revision history for this message
Cindy Pallares (cpallares) wrote :

@Erno, yes I starterd working on this. Will update the patch soon, sorry about the delay!

Revision history for this message
Erno Kuvaja (jokke) wrote :

@Cindy, I uploaded patch to fix this bug. Please have a look https://review.openstack.org/#/c/128347/

Changed in python-glanceclient:
assignee: Cindy Pallares (cindy-pallaresq) → nobody
Erno Kuvaja (jokke)
Changed in python-glanceclient:
assignee: nobody → Erno Kuvaja (jokke)
Changed in python-glanceclient:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-glanceclient (master)

Reviewed: https://review.openstack.org/128347
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=8e02b2a64145719dd2bcd870983be53dc4330e30
Submitter: Jenkins
Branch: master

commit 8e02b2a64145719dd2bcd870983be53dc4330e30
Author: Erno Kuvaja <email address hidden>
Date: Tue Oct 14 16:23:45 2014 +0000

    Allow --file in image-create with v2 Image API

    Allows passing --file and --progress to glance image-create with Image API v2.

    if --file is present the image-create effectively calls image-upload with the
    newly created image's id and the '--file' + '--progress' paramaters. The image
    metadata will be printed after the upload call instead of after creation.

    In a case argumented file does not exist the image will not be created and
    error will be printed instead.

    DocImpact
    Closes-Bug: #1324067

    Change-Id: I5d41fb2bbeb4e56213ae8696b84bf96b749414f8

Changed in python-glanceclient:
status: In Progress → Fix Committed
Louis Taylor (kragniz)
Changed in python-glanceclient:
milestone: none → v0.15.0
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.