A part of network's name will be lost

Asked by Dong Liu

I use the latest code of Grizzly, and create a network. The name of network is longer then 255 characters.
Then I list networks, the name of network has only 255 characters.
This is my request:
{
  "network":
  {
    "name": "test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
  }
}

And this is list network responce:
{
    "networks": [
        {
            "status": "ACTIVE",
            "subnets": [],
            "name": "test12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901",
            "provider:physical_network": "physnet1",
            "admin_state_up": true,
            "tenant_id": "6fbe9263116a4b68818cf1edce16bc4f",
            "provider:network_type": "vlan",
            "router:external": false,
            "shared": false,
            "id": "40a59f54-d8c0-432c-a2ef-6a8151348054",
            "provider:segmentation_id": 54
        }
    ]
}

The name lost 9 characters.

I found the code in /quantum/db/models_v2.py

class Network(model_base.BASEV2, HasId, HasTenant):
    """Represents a v2 quantum network."""
    name = sa.Column(sa.String(255))
    ports = orm.relationship(Port, backref='networks')
    subnets = orm.relationship(Subnet, backref='networks')
    status = sa.Column(sa.String(16))
    admin_state_up = sa.Column(sa.Boolean)
    shared = sa.Column(sa.Boolean)

It defines ths name's limit is 255 characters. But there is no parameter check when create network.

Question information

Language:
English Edit question
Status:
Solved
For:
neutron Edit question
Assignee:
No assignee Edit question
Solved by:
Aaron Rosen
Solved:
Last query:
Last reply:
Revision history for this message
Best Aaron Rosen (arosen) said :
#1

looks like it gets truncated. The api layer should probably raise an exception if >255 chars.

Revision history for this message
Dong Liu (liudong78) said :
#2

Thanks Aaron Rosen, that solved my question.