Python glance-client image-create validation error

Bug #1399782 reported by Diogo Monteiro
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance Client
Confirmed
Undecided
Feilong Wang

Bug Description

When using the python-glance client to create an image the schema validator fails when validating the locations object.

Basing from the format provided on the image schema:
{
    "properties": {
        "locations": {
            "items": {
                "required": ["url", "metadata"],
                "type": "object",
                "properties": {
                    "url": {
                        "type": "string",
                        "maxLength": 255
                    },
                    "metadata": {
                        "type": "object"
                    }
                }
            },
            "type": "array",
            "description": "A set of URLs to access the image file kept in external store"
        },
    }
}

The locations attribute is an array of objects containing two attributes, url and metadata, eg;
locations: [
  {
     url: 'image.url',
    metadata: {}
  }
]

However, when trying to set an image location the following validation error is raised:
glance --debug --os-image-api-version 2 image-create --locations "https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img"

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

On instance['locations'][0]:
    'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img'

During handling of the above exception, another exception occurred:

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 '['https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img']'. Reason: 'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img' 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'}

On instance['locations'][0]:
    'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/glanceclient/shell.py", line 620, in main
    args.func(client, args)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/glanceclient/v2/shell.py", line 68, in do_image_create
    image = gc.images.create(**fields)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/glanceclient/v2/images.py", line 156, in create
    raise TypeError(utils.exception_to_str(e))
TypeError: Unable to set 'locations' to '['https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img']'. Reason: 'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img' 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'}

On instance['locations'][0]:
    'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img'
Unable to set 'locations' to '['https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img']'. Reason: 'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img' 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'}

On instance['locations'][0]:
    'https://cloud-images.ubuntu.com/lucid/current/lucid-server-cloudimg-i386-disk1.img'

Feilong Wang (flwang)
Changed in glance:
assignee: nobody → Fei Long Wang (flwang)
Erno Kuvaja (jokke)
affects: glance → python-glanceclient
Changed in python-glanceclient:
status: New → Confirmed
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.