Add *locked* field in server response

Closes-Bug: #1717405
Change-Id: I946879f9505b0fc91e1726b61b5ee235427ac0e0
This commit is contained in:
liusheng 2017-09-15 10:36:51 +08:00
parent 5949568d06
commit 244f31f88c
9 changed files with 15 additions and 3 deletions

View File

@ -427,7 +427,7 @@ links:
type: array
lock_state:
description: |
The request to lock/unlock servers.
The lock state of a server.
in: body
required: true
type: boolean

View File

@ -17,6 +17,7 @@
}
],
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"locked": false,
"created_at": "2016-09-27T02:37:21.966342+00:00",
"launched_at": "2016-09-27T02:39:21.966342+00:00",
"updated_at": null,

View File

@ -14,6 +14,7 @@
"power_state": "power on",
"project_id": "c18e8a1a870d4c08a0b51ced6e0b6459",
"status": "error",
"locked": false,
"fault": {
"code": 500,
"message": "fault message",

View File

@ -29,6 +29,7 @@
"swap_mb": 40960
},
"power_state": "power on",
"locked": false,
"project_id": "c18e8a1a870d4c08a0b51ced6e0b6459",
"status": "building",
"launched_at" : null,

View File

@ -31,6 +31,7 @@
"swap_mb": 40960
},
"power_state": "power on",
"locked": false,
"project_id": "c18e8a1a870d4c08a0b51ced6e0b6459",
"status": "building",
"updated_at": "2016-10-17T04:12:44+00:00",

View File

@ -17,6 +17,7 @@
}
],
"uuid": "7de2859d-ec6d-42c7-bb86-9d630ba5ac94",
"locked": false,
"created_at": "2016-09-27T02:37:21.966342+00:00",
"launched_at": "2016-09-27T02:39:21.966342+00:00",
"updated_at": null,

View File

@ -75,6 +75,7 @@ Response
- affinity_zone: affinity_zone
- key_name: key_name
- partitions: partitions
- locked: lock_state
**Example Create Server: JSON response**
@ -229,6 +230,7 @@ Response
- affinity_zone: affinity_zone
- key_name: key_name
- partitions: partitions
- locked: lock_state
**Example Detailed list of Servers: JSON response**
@ -284,6 +286,7 @@ Response
- affinity_zone: affinity_zone
- key_name: key_name
- partitions: partitions
- locked: lock_state
**Example Server Details: JSON response**
@ -347,6 +350,7 @@ Response
- affinity_zone: affinity_zone
- key_name: key_name
- partitions: partitions
- locked: lock_state
**Example Update Server: JSON response**

View File

@ -462,6 +462,9 @@ class Server(base.APIBase):
partitions = types.jsontype
"""The partitions of the server"""
locked = types.boolean
"""Represent the current lock state of the server"""
def __init__(self, **kwargs):
super(Server, self).__init__(**kwargs)
self.fields = []
@ -513,7 +516,7 @@ class ServerPatchType(types.JsonPatchType):
'/power_state', '/availability_zone',
'/flavor_uuid', '/image_uuid', '/addresses',
'/launched_at', '/affinity_zone', '/key_name',
'/partitions', '/fault', '/node']
'/partitions', '/fault', '/node', '/locked']
class ServerCollection(base.APIBase):

View File

@ -206,7 +206,7 @@ class TestServers(v1_test.APITestV1):
resps = self.get_json('/servers/detail',
headers=headers)['servers']
self.assertEqual(4, len(resps))
self.assertEqual(18, len(resps[0].keys()))
self.assertEqual(19, len(resps[0].keys()))
self.assertEqual('test_server_0', resps[0]['name'])
self.assertEqual('just test server 0', resps[0]['description'])
self.assertEqual('building', resps[0]['status'])