Make 'device' optional in volume attach response schema

Volume attachment for server can return with no 'device' or as None
in response. It is optional on those APIs.

List and Show API does not include the 'device' in response if no
mountpoint for volume attachment.

{
    "volumeAttachments": [
        {
            "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
            "serverId": "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
            "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
        }
    ]
}

ref-240b3507e2/nova/api/openstack/compute/volumes.py (L223-L224)

Create API includes 'device' but with None value.
{
    "volumeAttachment": {
        "device": null,
        "id": "a26887c6-c47b-4654-abb5-dfadf7d3f803",
        "serverId": "0c92f3f6-c253-4c9b-bd43-e880a8d2eb0a",
        "volumeId": "a26887c6-c47b-4654-abb5-dfadf7d3f803"
    }
}

One example will be when server is in shelved offload state where server
is not on any host so there will not be any mountpoint for attached volume.

This commit makes that element optional in response schema too.

Change-Id: I377307bb92583f84c4fa147aa608ca27615f0f8b
Related-Bug: #1554440
This commit is contained in:
ghanshyam 2016-03-09 09:18:10 +09:00 committed by Ghanshyam Mann
parent a99aa9e30c
commit 0d560a9ce4
1 changed files with 3 additions and 2 deletions

View File

@ -267,12 +267,13 @@ common_attach_volume_info = {
'type': 'object',
'properties': {
'id': {'type': 'string'},
'device': {'type': 'string'},
'device': {'type': ['string', 'null']},
'volumeId': {'type': 'string'},
'serverId': {'type': ['integer', 'string']}
},
'additionalProperties': False,
'required': ['id', 'device', 'volumeId', 'serverId']
# 'device' is optional in response.
'required': ['id', 'volumeId', 'serverId']
}
attach_volume = {