Metadata widget doesn't handle default values for numeric and boolean fields

Bug #1404888 reported by Kamil Rykowski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
Kamil Rykowski

Bug Description

Metadata widget doesn't handle well default values for metadefinition properties from Glance which type is set to: integer, number and boolean. For now on it works only with string properties.

To reproduce this issue follow these steps:
1. Go to the "metadef_properties" table located in Glance database.
2. Update "json_schema" field of any record (e.g. "os_shutdown_timeout") and put there "default" key with some integer value (e.g. 10).

Field "json_schema" before update:

{
    "minimum": 0,
    "type": "integer",
    "description": "Some description.",
    "title": "Shutdown timeout"
}

After update:
{
    "minimum": 0,
    "type": "integer",
    "description": "Some description.",
    "title": "Shutdown timeout",
    "default: 10
}

3. Go to the Horizon /admin/images/ page and choose any image which doesn't have "os_shutdown_timeout" property defined yet.
4. Open "Update Metadata" form and pick the "Shutdown timeout" property. As you can see it has empty input, with no default value filled.

Same steps can be repeated for number and boolean properties to check that no default value is shown to the user. Default value is prompted only for string properties.

Tags: metadef
Changed in horizon:
assignee: nobody → Kamil Rykowski (kamil-rykowski)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Revision history for this message
Wu Hong Guang (whg) wrote :

Testing on patch , the os_shutdown_timeout still is empty even the default is 30 in the glance database

Revision history for this message
Wu Hong Guang (whg) wrote :

Testing on patch 2 , the os_shutdown_timeout still is empty even the default is 30 in the glance database

Revision history for this message
Kamil Rykowski (kamil-rykowski) wrote :

Hi Wu Hong Guang,

Strange thing. Could you paste me your current json_schema field for os_shutdown_timeout record?

Revision history for this message
Travis Tripp (travis-tripp) wrote :

Another way to test without going to DB. Looks like a lot of steps, but can be done via horizon.

1) Go to Admin --> Metatadata Definitions

2) Click on Shutdown Behavior

3) Copy contents to buffer

4) Go back to Admin --> Metadata Defintions

5) Uncheck protected on Shutdown Behavior

6) Delete Shutdown Behavior

7) Click Import

8) Use direct input

9) Paste clipboard, modify default in JSON

10) Import

11) Write a blueprint to support editing metadata values

Revision history for this message
Travis Tripp (travis-tripp) wrote :

Simple method. Just copy the below and then go to admin --> Metadata Definitions --> Import Namespace.

{
    "namespace": "OS::SampleMetadefs",
    "display_name": "Sample Metadefs",
    "description": "Sample metadata definitions for testing",
    "visibility": "public",
    "protected": false,
    "resource_type_associations": [
        {
            "name": "OS::Nova::Flavor",
            "prefix": "sample_"
        },
        {
            "name": "OS::Nova::Instance",
            "prefix": "sample_"
        },
                {
            "name": "OS::Glance::Image",
            "prefix": "sample_"
        },
        {
            "name": "OS::Nova::Aggregate",
            "prefix": "sample_"
        },
        {
            "name": "OS::Cinder::Volume",
            "properties_target": "image",
            "prefix": "sample_"
        }
    ],
    "properties": {
        "boolean": {
            "title": "boolean",
            "description": "",
            "type": "boolean",
            "default": true
        },
        "integer": {
            "title": "integer",
            "description": "integer 1 to 10",
            "type": "integer",
            "default": 7,
            "minimum": 1,
            "maximum": 10
        },
        "string_pattern": {
            "title": "String 0-9 pattern",
            "description": "String 0-9",
            "type": "integer",
            "pattern": "[0-9]*",
            "default": "foo"
        },
        "string_enum": {
            "title": "string_enum",
            "description": "string_enum",
            "type": "string",
            "enum": [
                "string1",
                "defaultString",
                "string3"
            ],
            "default": "defaultString"
        },
        "number": {
            "title": "number",
            "description": "number 0 to 10",
            "type": "integer",
            "default": 5.5,
            "minimum": 0,
            "maximum": 10
        },"array": {
            "title": "array",
            "description": "array",
            "type": "array",
            "items": {
                "type": "string",
                "enum": [
                    "1",
                    "2",
                    "3",
                    "4",
                    "5"
                ]
            }
        }
    }
}

Changed in horizon:
assignee: Kamil Rykowski (kamil-rykowski) → Szymon Wróblewski (bluex)
Changed in horizon:
assignee: Szymon Wróblewski (bluex) → Kamil Rykowski (kamil-rykowski)
Changed in horizon:
assignee: Kamil Rykowski (kamil-rykowski) → Szymon Wróblewski (bluex)
Changed in horizon:
assignee: Szymon Wróblewski (bluex) → Kamil Rykowski (kamil-rykowski)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/143444
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=aaf7e02be3048cbe36bcb3cdaa009d56534c3217
Submitter: Jenkins
Branch: master

commit aaf7e02be3048cbe36bcb3cdaa009d56534c3217
Author: Kamil Rykowski <email address hidden>
Date: Mon Dec 22 15:03:20 2014 +0100

    Metadata widget support for default values

    Metadata widget doesn't handle default values for glance meta definition
    properties which type is one of the following: integer, number or
    boolean. Currently it supports only string properties.
    This change provides a fix for auto-filling default value when new
    property is being added to the resource.

    Change-Id: Ib8616cefaa09d21d226d9c568287d4d23a3a4afe
    Closes-Bug: #1404888
    Closes-Bug: #1413731

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
milestone: none → kilo-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-2 → 2015.1.0
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.