flavor name with only white spaces should return 400 error

Bug #1237611 reported by Tushar Patil
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Abhijeet Malawade

Bug Description

When user passes only white spaces to flavor name, it creates flavor successfully. Since name is a mandatory parameter, it should restrict user from passing white spaces. Also leading and trailing white spaces should be removed before saving it to the backend similar to the instance name.

{
    "flavor": {
        "name": " "
        "ram": 1024,
        "vcpus": 2,
        "disk": 10,
        "id": "10",
        "os-flavor-access:is_public": false
    }
}

For example
name = " " #not allowed
name = "extra large" #allowed
name = " extra large " #allowed, but leading and trailing white spaces will be trimmed before saving it to the backend.

Actual output: HTTP/1.1 200 OK
Expected output: HTTP/1.1 400 Bad Request

Tags: ntt
Tushar Patil (tpatil)
tags: added: ntt
Changed in nova:
assignee: nobody → Abhijeet Malawade (abhijeet-malawade)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Tushar Patil (tpatil)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/50875
Committed: http://github.com/openstack/nova/commit/831e6013544326e32a1e252917301618c9ea7626
Submitter: Jenkins
Branch: master

commit 831e6013544326e32a1e252917301618c9ea7626
Author: Abhijeet Malawade <email address hidden>
Date: Thu Oct 10 00:00:07 2013 -0700

    Flavor name should not contain only white spaces

    Returns 400 Bad request instead of 200 Ok if flavor name
    contains only whitespaces.
    Flavor name containing any leading and trailing whitespaces will be
    trimmed before validation and before saving it to the backend.

    Added unit test cases for both v2 and v3 api's. For v3 api instead of
    stubbing flavors 'create' method stubbed db's 'flavor_create' method.
    Also removed redundant code of stubbing 'flavor_create' method.

    For example
    name = " " #not allowed
    name = "extra large" #allowed
    name = " extra large " #allowed, but leading and trailing whitespaces
                             #will be trimmed (same as instance name)

    Closes-Bug: #1237611

    Change-Id: Ie68be299030a878a752dbfdcdfe5094f8427598a

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.1
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.