Verify list_instance_action attributes of Nova API

This patch adds the JSON schema for Nova V2 & V3 list_instance_actions
API response and validate the response with added JSON schema
to block the backward incompatibility change in the future.

The response body of list_instance_actions V2 API is below:

{
    "instanceActions": [
        {
            "action": "reboot",
            "instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
            "request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
            "user_id": "789",
            "project_id": "147",
            "start_time": "2012-12-05 00:00:00.000000",
            "message": ""
        }
    ]
}

The response body of list_instance_actions V3 API is below:

{
    "server_actions": [
        {
            "action": "reboot",
            "server_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
            "request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
            "user_id": "789",
            "project_id": "147",
            "start_time": "2012-12-05T00:00:00.000000",
            "message": ""
        }
    ]
}

Partially implements blueprint nova-api-attribute-test

Change-Id: I81a21a4ec0522318fd20c3db3e534fdcea7b8715
This commit is contained in:
Ghanshyam 2014-04-07 17:27:41 +09:00
parent 1fdc484cb4
commit 2996609f29
5 changed files with 53 additions and 0 deletions

View File

@ -165,3 +165,17 @@ get_console_output = {
'required': ['output']
}
}
common_instance_actions = {
'type': 'object',
'properties': {
'action': {'type': 'string'},
'request_id': {'type': 'string'},
'user_id': {'type': 'string'},
'project_id': {'type': 'string'},
'start_time': {'type': 'string'},
'message': {'type': ['string', 'null']}
},
'required': ['action', 'request_id', 'user_id', 'project_id',
'start_time', 'message']
}

View File

@ -177,3 +177,22 @@ create_get_server_group = {
delete_server_group = {
'status_code': [204]
}
instance_actions_object = copy.deepcopy(servers.common_instance_actions)
instance_actions_object[
'properties'].update({'instance_uuid': {'type': 'string'}})
instance_actions_object['required'].extend(['instance_uuid'])
list_instance_actions = {
'status_code': [200],
'response_body': {
'type': 'object',
'properties': {
'instanceActions': {
'type': 'array',
'items': instance_actions_object
}
},
'required': ['instanceActions']
}
}

View File

@ -99,3 +99,21 @@ list_addresses = {
update_server_metadata = copy.deepcopy(servers.update_server_metadata)
# V3 API's response status_code is 201
update_server_metadata['status_code'] = [201]
server_actions_object = copy.deepcopy(servers.common_instance_actions)
server_actions_object['properties'].update({'server_uuid': {'type': 'string'}})
server_actions_object['required'].extend(['server_uuid'])
list_server_actions = {
'status_code': [200],
'response_body': {
'type': 'object',
'properties': {
'server_actions': {
'type': 'array',
'items': server_actions_object
}
},
'required': ['server_actions']
}
}

View File

@ -463,6 +463,7 @@ class ServersClientJSON(rest_client.RestClient):
resp, body = self.get("servers/%s/os-instance-actions" %
str(server_id))
body = json.loads(body)
self.validate_response(schema.list_instance_actions, resp, body)
return resp, body['instanceActions']
def get_instance_action(self, server_id, request_id):

View File

@ -461,6 +461,7 @@ class ServersV3ClientJSON(rest_client.RestClient):
resp, body = self.get("servers/%s/os-server-actions" %
str(server_id))
body = json.loads(body)
self.validate_response(schema.list_server_actions, resp, body)
return resp, body['server_actions']
def get_server_action(self, server_id, request_id):