blob: e2e5c7b5ce626dd8d88e1dc6d0baac5edf87273e [file] [log] [blame]
Tony Yang3d5f1632013-06-06 14:17:57 +08001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 IBM Corporation.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18import json
19
20from tempest.common.rest_client import RestClient
21
22
23class HypervisorClientJSON(RestClient):
24
25 def __init__(self, config, username, password, auth_url, tenant_name=None):
26 super(HypervisorClientJSON, self).__init__(config, username,
27 password, auth_url,
28 tenant_name)
29 self.service = self.config.compute.catalog_type
30
31 def get_hypervisor_list(self):
32 """List hypervisors information."""
33 resp, body = self.get('os-hypervisors')
34 body = json.loads(body)
35 return resp, body['hypervisors']
36
37 def get_hypervisor_list_details(self):
38 """Show detailed hypervisors information."""
39 resp, body = self.get('os-hypervisors/detail')
40 body = json.loads(body)
41 return resp, body['hypervisors']
42
43 def get_hypervisor_show_details(self, hyper_id):
44 """Display the details of the specified hypervisor."""
45 resp, body = self.get('os-hypervisors/%s' % hyper_id)
46 body = json.loads(body)
47 return resp, body['hypervisor']
48
49 def get_hypervisor_servers(self, hyper_name):
50 """List instances belonging to the specified hypervisor."""
51 resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
52 body = json.loads(body)
53 return resp, body['hypervisors']
54
55 def get_hypervisor_stats(self):
56 """Get hypervisor statistics over all compute nodes."""
57 resp, body = self.get('os-hypervisors/statistics')
58 body = json.loads(body)
59 return resp, body['hypervisor_statistics']
60
61 def get_hypervisor_uptime(self, hyper_id):
62 """Display the uptime of the specified hypervisor."""
63 resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
64 body = json.loads(body)
65 return resp, body['hypervisor']