metadata definition property show should handle type specific prefix

Bug #1367564 reported by Travis Tripp
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance
Fix Released
Medium
Unassigned
Glance Client
Invalid
Medium
Unassigned

Bug Description

metadata definition property show should handle type specific prefix

The metadata definitions API supports listing namespaces by resource type. For example, you can list only namespaces applicable to images by specifying OS::Glance::Image

The API also support showing namespace properties for a specific resource type. The API will automatically prepend any prefix specific to that resource type. For example, in the OS::Compute::VirtCPUTopology namespace, the properties will come back with "hw_" prepended.

However, if you then ask the API to show the property with the prefix, it will return a "not found" error. To actually see the details of the property, you have to know the base property (without the prefix). It would be nice if the API would attempt to auto-resolve any automatically prefixed properties when showing a property.

This is evident from the command line. If you look at the below interactions, you will see the namespaces listed, then limited to a particular resource type, then the properties shown for the namespace, and then a failure to show the property using the automatically prepended prefix.

* Apologize for formatting.

$ glance --os-image-api-version 2 md-namespace-list
+------------------------------------+
| namespace |
+------------------------------------+
| OS::Compute::VMware |
| OS::Compute::XenAPI |
| OS::Compute::Quota |
| OS::Compute::Libvirt |
| OS::Compute::Hypervisor |
| OS::Compute::Watchdog |
| OS::Compute::HostCapabilities |
| OS::Compute::Trust |
| OS::Compute::VirtCPUTopology |
| OS::Glance:CommonImageProperties |
| OS::Compute::RandomNumberGenerator |
+------------------------------------+

$ glance --os-image-api-version 2 md-namespace-list --resource-type OS::Glance::Image
+------------------------------+
| namespace |
+------------------------------+
| OS::Compute::VMware |
| OS::Compute::XenAPI |
| OS::Compute::Libvirt |
| OS::Compute::Hypervisor |
| OS::Compute::Watchdog |
| OS::Compute::VirtCPUTopology |
+------------------------------+

$ glance --os-image-api-version 2 md-namespace-show OS::Compute::VirtCPUTopology --resource-type OS::Glance::Image
+----------------------------+----------------------------------------------------------------------------------+
| Property | Value |
+----------------------------+----------------------------------------------------------------------------------+
| created_at | 2014-09-10T02:55:40Z |
| description | This provides the preferred socket/core/thread counts for the virtual CPU |
| | instance exposed to guests. This enables the ability to avoid hitting |
| | limitations on vCPU topologies that OS vendors place on their products. See |
| | also: http://git.openstack.org/cgit/openstack/nova-specs/tree/specs/juno/virt- |
| | driver-vcpu-topology.rst |
| display_name | Virtual CPU Topology |
| namespace | OS::Compute::VirtCPUTopology |
| owner | admin |
| properties | ["hw_cpu_cores", "hw_cpu_sockets", "hw_cpu_maxsockets", "hw_cpu_threads", |
| | "hw_cpu_maxcores", "hw_cpu_maxthreads"] |
| protected | True |
| resource_type_associations | ["OS::Glance::Image", "OS::Cinder::Volume", "OS::Nova::Flavor"] |
| schema | /v2/schemas/metadefs/namespace |
| visibility | public |
+----------------------------+----------------------------------------------------------------------------------+

ttripp@ubuntu:/opt/stack/glance$ glance --os-image-api-version 2 md-property-show OS::Compute::VirtCPUTopology hw_cpu_cores
Request returned failure status 404.
<html>
 <head>
  <title>404 Not Found</title>
 </head>
 <body>
  <h1>404 Not Found</h1>
  Could not find property hw_cpu_cores<br /><br />

 </body>
</html> (HTTP 404)

ttripp@ubuntu:/opt/stack/glance$ glance --os-image-api-version 2 md-property-show OS::Compute::VirtCPUTopology cpu_cores
+-------------+---------------------------------------------------+
| Property | Value |
+-------------+---------------------------------------------------+
| description | Preferred number of cores to expose to the guest. |
| name | cpu_cores |
| title | vCPU Cores |
| type | integer |
+-------------+---------------------------------------------------+

Tags: api metadef
Changed in glance:
assignee: nobody → Pawel Koniszewski (pawel-koniszewski)
status: New → In Progress
Revision history for this message
Pawel Koniszewski (pawel-koniszewski) wrote :

Travis,

I have analyzed things a bit here and I want to propose another solution which is clearer to me.

What you suggested is that after doing this:
glance --os-image-api-version 2 md-namespace-show OS::Compute::VirtCPUTopology --resource-type OS::Glance::Image

You want to do this:
glance --os-image-api-version 2 md-property-show OS::Compute::VirtCPUTopology hw_cpu_cores

The problem I see there is that such calls are inconsistent. In the first command you ask for namespace with specific resource type, but in another request you just want property without specifying resource type. I would say that 404 in this case is correct result.

Instead of resolving errors on the API side (possible name conflicts. a lot of DB calls to determine which property should be returned) my proposition is to add optional argument '--resource-type' to md_property_show command and extend API to handle such argument in URL. Previous calls changed to new way:

glance --os-image-api-version 2 md-namespace-show OS::Compute::VirtCPUTopology --resource-type OS::Glance::Image
glance --os-image-api-version 2 md-property-show OS::Compute::VirtCPUTopology --resource-type OS::Glance::Image hw_cpu_cores

This keeps consistency across every call, you can keep asking for properties associated to specific resource type the same way that you can do it with namespaces.

I will appreciate every comment, thanks!

Changed in python-glanceclient:
assignee: nobody → Pawel Koniszewski (pawel-koniszewski)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

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

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/121124

Changed in python-glanceclient:
status: New → In Progress
tags: added: metadef
Changed in glance:
assignee: Pawel Koniszewski (pawel-koniszewski) → Bartosz Fic (bartosz-fic)
Changed in python-glanceclient:
assignee: Pawel Koniszewski (pawel-koniszewski) → Bartosz Fic (bartosz-fic)
Thierry Carrez (ttx)
tags: added: juno-rc-potential
Changed in glance:
importance: Undecided → Medium
Changed in python-glanceclient:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)

Reviewed: https://review.openstack.org/121121
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=8b9f9836f8aadf98ff3bcc88de5622903625e7a0
Submitter: Jenkins
Branch: master

commit 8b9f9836f8aadf98ff3bcc88de5622903625e7a0
Author: Bartosz Fic <email address hidden>
Date: Wed Oct 8 10:47:31 2014 +0200

    GET property which name includes resource type prefix

    Currently GET call to API to retrieve property details ends with
    404 error when property name includes resource type prefix.
    This patch extends show method to take filters as a parameter.
    If 'resource_type' is included in filters then the prefix of included
    resource type is removed from property name. This enables user to look
    for property name starting with prefix that comes from associated
    resource type.

    Change-Id: I3c4d96fbc9ce15016631017bf76089c338ac3cdc
    Closes-Bug: #1367564
    DocImpact
    Co-Authored-By: Bartosz Fic <email address hidden>
    Co-Authored-By: Pawel Koniszewski <email address hidden>

Changed in glance:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in glance:
milestone: none → juno-rc2
tags: removed: juno-rc-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (proposed/juno)

Fix proposed to branch: proposed/juno
Review: https://review.openstack.org/127248

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (proposed/juno)

Reviewed: https://review.openstack.org/127248
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=6b0c7ed29ec1e716e704e19112d9ee24553faf19
Submitter: Jenkins
Branch: proposed/juno

commit 6b0c7ed29ec1e716e704e19112d9ee24553faf19
Author: Bartosz Fic <email address hidden>
Date: Wed Oct 8 10:47:31 2014 +0200

    GET property which name includes resource type prefix

    Currently GET call to API to retrieve property details ends with
    404 error when property name includes resource type prefix.
    This patch extends show method to take filters as a parameter.
    If 'resource_type' is included in filters then the prefix of included
    resource type is removed from property name. This enables user to look
    for property name starting with prefix that comes from associated
    resource type.

    Change-Id: I3c4d96fbc9ce15016631017bf76089c338ac3cdc
    Closes-Bug: #1367564
    DocImpact
    Co-Authored-By: Bartosz Fic <email address hidden>
    Co-Authored-By: Pawel Koniszewski <email address hidden>

Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in glance:
milestone: juno-rc2 → 2014.2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glance (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to glance (master)
Download full text (14.4 KiB)

Reviewed: https://review.openstack.org/128928
Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=858cd9d4fdf32b4cc52e02ec771d01bfb463aa77
Submitter: Jenkins
Branch: master

commit 96e28428655aa7122ed74b045ff1bda1984255b1
Author: Nikhil Komawar <email address hidden>
Date: Tue Oct 14 13:09:48 2014 -0400

    Fix options and their groups - etc/glance-api.conf

    As per the docs at [0] , some of the options should have been moved
    around in the etc/glance-api.conf. This patch changes the conf file to:

        1. indicate new default values
        2. change the group of some of the configs in order to adhere to
           new groups as expected by the deployer.
        3. deprecated configs have been removed or replaced with new ones.

    [0] http://docs.openstack.org/trunk/config-reference/content/glance-conf-changes-master.html

    Fixes bug: 1380689

    Change-Id: I5b5ab96b050b502007e6660a7a613e252404d4e8

commit 9b176a278116849c8f7b7f4d9a987f37ec52779c
Author: Andy McCrae <email address hidden>
Date: Sat Oct 11 20:56:36 2014 +0100

    Adjust authentication.rst doc to reference "identity_uri"

    The "auth_port", "auth_host", and "auth_protocol" variables were
    deprecated in favour of a single "identity_uri" variable.

    * Adjust authentication.rst doc to reference "identity_uri"

    Change-Id: I48de53f21b8d767b276858ed274066015d765f0e
    Closes-Bug: #1361613

commit 08f83f543bc992ae8f2787fb405e58c33dadba73
Author: Jamie Lennox <email address hidden>
Date: Wed Aug 6 18:24:05 2014 +1000

    Use identity_uri instead of older fragments

    This has been the default option in middleware for a while now and we
    should recommend the default options.

    Change-Id: Ief347c897cf15ab4101936a56404e3a378021b15
    (cherry picked from commit e7110a9c6e0119b3d0c6f5cdb3b9675a82b76039)

commit c0d90a580f87dbbf71e3a5d5c1b5cf8d7c7245b2
Author: Stuart McLaren <email address hidden>
Date: Wed Jul 16 13:33:32 2014 +0000

    Prevent setting swift+config locations

    Forbid setting 'swift+config' locations in a similar
    manner to 'file' for security reasons; knowledge of
    the reference name should not be exploitable.

    Setting swift+config had been prevented when swift
    was the default store, this patch changes to forbid
    setting no matter which store is the default.

    As with change id I75af34145521f533dcd6f5fd7690f5a68f3b44b3
    this is v1 only for now.

    Change-Id: I62c4980bd5c2f3dd77fc40cd007bc1067eca63a4
    Closes-bug: 1334196

commit f259cac74d3e988b4012dcc2abd30091df27f5ce
Author: Wayne Okuma <email address hidden>
Date: Wed Oct 8 08:17:20 2014 -0700

    Metadef schema column name is a reserved word in MySQL

    The metadef_properties and metadef_objects tables both have
    a column named schema. Unfortunately, schema is a reserved word
    in some relational database products, including MySQL and PostgreSQL.
    The metadef_properties.schema and metadef_objects.schema
    columns should be renamed to a non reserved word.

    Conflicts:
     glance/db/sqlalchemy/metadata.py
     glance/tests/unit/test_m...

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-glanceclient (master)

Change abandoned by Pawel Koniszewski (<email address hidden>) on branch: master
Review: https://review.openstack.org/121124

Changed in python-glanceclient:
assignee: Bartosz Fic (bartosz-fic) → nobody
Changed in glance:
assignee: Bartosz Fic (bartosz-fic) → nobody
Revision history for this message
Ian Cordasco (icordasc) wrote :

It's no longer apparent that this is a glanceclient issue since it has been fixed in the Glance Metadef Service. Closing as invalid until it becomes apparent that this is a client issue as well.

Changed in python-glanceclient:
status: In Progress → Invalid
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.