Verify hypervisor uptime attributes of Nova API

This patch adds the JSON Schema for response of Nova V2 & V3
hypervisor uptime APIs ('os-hypervisors/<hyper_id>/uptime')
and validate the response with added JSON Schema to block
the backward incompatibility change in the future.

The response body of V2 & V3 hypervisor uptime APIs is same
& given below:

{
    "hypervisor": {
        "id": %(hypervisor_id)s,
        "hypervisor_hostname": "fake-mini",
        "uptime": " 08:32:11 up 93 days, 18:25, 12 users,
                  load average: 0.20, 0.12, 0.14"
    }
}

Partially implements blueprint nova-api-attribute-test

Change-Id: I163c50e0ad277ef8ed639363d5e53f66e9f9d4e4
This commit is contained in:
Ghanshyam 2014-03-28 09:48:38 +09:00
parent 8676fa6b5c
commit dd8ae35c10
3 changed files with 11 additions and 0 deletions

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
hypervisor_statistics = {
'status_code': [200],
'response_body': {
@ -186,3 +188,10 @@ common_hypervisors_info = {
'required': ['hypervisor']
}
}
hypervisor_uptime = copy.deepcopy(common_hypervisors_info)
hypervisor_uptime['response_body']['properties']['hypervisor'][
'properties']['uptime'] = {'type': 'string'}
hypervisor_uptime['response_body']['properties']['hypervisor'][
'required'] = ['id', 'hypervisor_hostname', 'uptime']

View File

@ -69,6 +69,7 @@ class HypervisorClientJSON(rest_client.RestClient):
"""Display the uptime of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
body = json.loads(body)
self.validate_response(common_schema.hypervisor_uptime, resp, body)
return resp, body['hypervisor']
def search_hypervisor(self, hyper_name):

View File

@ -67,6 +67,7 @@ class HypervisorV3ClientJSON(rest_client.RestClient):
"""Display the uptime of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
body = json.loads(body)
self.validate_response(common_schema.hypervisor_uptime, resp, body)
return resp, body['hypervisor']
def search_hypervisor(self, hyper_name):