← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1399782] Re: Python glance-client image-create validation error

 

** Project changed: glance => python-glanceclient

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1399782

Title:
  Python glance-client image-create validation error

Status in Python client library for Glance:
  New

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'

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-glanceclient/+bug/1399782/+subscriptions


References