Failing to create image using glance endpoint version 2

Bug #1399778 reported by Diogo Monteiro
28
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Medium
Feilong Wang
Nominated for Kilo by Erno Kuvaja

Bug Description

Not able to create an image utilizing the glance service REST api version 2
I've tried a few different approaches

#1 Using the python-glance client

Running:
glance --debug --os-image-api-version 2 image-create --locations "https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img"

Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/glanceclient/v2/images.py", line 154, in create
    setattr(image, key, value)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/warlock/model.py", line 75, in __setattr__
    self.__setitem__(key, value)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/warlock/model.py", line 50, in __setitem__
    raise exceptions.InvalidOperation(msg)
warlock.exceptions.InvalidOperation: Unable to set 'locations' to '['{', 'url:', 'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img,', 'metadata:', '{}', '}']'. Reason: '{' is not of type 'object'

Failed validating 'type' in schema['properties']['locations']['items']:
    {'properties': {'metadata': {'type': 'object'},
                    'url': {'maxLength': 255, 'type': 'string'}},
     'required': ['url', 'metadata'],
     'type': 'object'}

#2 Adding a location to an existing image using python-glance client

Running:
glance --debug --os-image-api-version 2 location-add bf9e453a-8aef-4806-9afe-9546694f814b --url "https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img"

Exception:
The administrator has disabled API access to image locations

#3 Sending curl requests directly to glance's version 2 endpoints

Running:
Node.js app using request lib

"requestOptions": {
    "url": "http://controller01.qa.cloud:9292/v2/images",
    "json": true,
    "headers": {
      "X-Auth-Project-Id": "2136a657f30c4f65895dd95164f4dda6",
      "X-Auth-Token": "ba36f4becfa04740bd524a37404ae29f"
    },
    "timeout": 10000,
    "strictSSL": false,
    "body": {
      "name": "cdos-template6001",
      "container_format": "ovf",
      "disk_format": "raw",
      "min_ram": 1,
      "min_disk": 10,
      "locations": [
        {
          "url": "https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img",
          "metadata": {}
        }
      ]
    }

request.post(requestOptions, callback);

Exception:
403 Forbidden\n\nAttribute 'locations' is reserved.\n\n

Can anybody confirm if the glance version 2 image-create REST endpoint even works?
If it does how to consume the API, any docs?

Feilong Wang (flwang)
Changed in glance:
assignee: nobody → Fei Long Wang (flwang)
Feilong Wang (flwang)
Changed in glance:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Feilong Wang (flwang) wrote :

Sorry for the late response. Let me explain the 3 cases.

#1 the format you're using for locations is invalid. But that's your fault, it's because current code can't parse a string to dict

#2 you need to add a config 'show_multiple_locations = True' in your glance-api.conf

#3 current, 'locations' is a reserved attribute, see https://github.com/openstack/glance/blob/master/glance/domain/__init__.py#L56

But FWIW, we need a fix in glance client to disable the locations parameter. Please let me know if you have any questions.

Revision history for this message
Feilong Wang (flwang) wrote :

btw, I just tested the #2, it works for me.

Feilong Wang (flwang)
affects: glance → python-glanceclient
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/172395

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/172395
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=c73026634cc4bef7e648bb1e82bde29d6b737af2
Submitter: Jenkins
Branch: master

commit c73026634cc4bef7e648bb1e82bde29d6b737af2
Author: Fei Long Wang <email address hidden>
Date: Sat Apr 11 00:02:17 2015 +1200

    Omit 'locations' as image-create parameter

    Based on current implementation, locations is reserved
    attribute, so it should not be a parameter for image
    create.

    Closes-Bug: #1399778

    Change-Id: Ie51e52157e905fdecf736125be0dac87b1a966ec

Changed in python-glanceclient:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-glanceclient (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/199534

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

Reviewed: https://review.openstack.org/199534
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=28dc1da28843ac4e3a524746e5fc9e8e5f87fcbd
Submitter: Jenkins
Branch: stable/kilo

commit 28dc1da28843ac4e3a524746e5fc9e8e5f87fcbd
Author: Fei Long Wang <email address hidden>
Date: Sat Apr 11 00:02:17 2015 +1200

    Omit 'locations' as image-create parameter

    Based on current implementation, locations is reserved
    attribute, so it should not be a parameter for image
    create.

    Closes-Bug: #1399778

    Change-Id: Ie51e52157e905fdecf736125be0dac87b1a966ec
    (cherry picked from commit c73026634cc4bef7e648bb1e82bde29d6b737af2)

tags: added: in-stable-kilo
Changed in python-glanceclient:
milestone: none → 1.0.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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