diff --git a/tempest/api_schema/response/compute/v2_1/hypervisors.py b/tempest/api_schema/response/compute/v2_1/hypervisors.py deleted file mode 100644 index 05901b6131..0000000000 --- a/tempest/api_schema/response/compute/v2_1/hypervisors.py +++ /dev/null @@ -1,195 +0,0 @@ -# Copyright 2014 NEC Corporation. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import copy - -from tempest.api_schema.response.compute.v2_1 import parameter_types - -get_hypervisor_statistics = { - 'status_code': [200], - 'response_body': { - 'type': 'object', - 'properties': { - 'hypervisor_statistics': { - 'type': 'object', - 'properties': { - 'count': {'type': 'integer'}, - 'current_workload': {'type': 'integer'}, - 'disk_available_least': {'type': ['integer', 'null']}, - 'free_disk_gb': {'type': 'integer'}, - 'free_ram_mb': {'type': 'integer'}, - 'local_gb': {'type': 'integer'}, - 'local_gb_used': {'type': 'integer'}, - 'memory_mb': {'type': 'integer'}, - 'memory_mb_used': {'type': 'integer'}, - 'running_vms': {'type': 'integer'}, - 'vcpus': {'type': 'integer'}, - 'vcpus_used': {'type': 'integer'} - }, - 'additionalProperties': False, - 'required': ['count', 'current_workload', - 'disk_available_least', 'free_disk_gb', - 'free_ram_mb', 'local_gb', 'local_gb_used', - 'memory_mb', 'memory_mb_used', 'running_vms', - 'vcpus', 'vcpus_used'] - } - }, - 'additionalProperties': False, - 'required': ['hypervisor_statistics'] - } -} - - -hypervisor_detail = { - 'type': 'object', - 'properties': { - 'status': {'type': 'string'}, - 'state': {'type': 'string'}, - 'cpu_info': {'type': 'string'}, - 'current_workload': {'type': 'integer'}, - 'disk_available_least': {'type': ['integer', 'null']}, - 'host_ip': parameter_types.ip_address, - 'free_disk_gb': {'type': 'integer'}, - 'free_ram_mb': {'type': 'integer'}, - 'hypervisor_hostname': {'type': 'string'}, - 'hypervisor_type': {'type': 'string'}, - 'hypervisor_version': {'type': 'integer'}, - 'id': {'type': ['integer', 'string']}, - 'local_gb': {'type': 'integer'}, - 'local_gb_used': {'type': 'integer'}, - 'memory_mb': {'type': 'integer'}, - 'memory_mb_used': {'type': 'integer'}, - 'running_vms': {'type': 'integer'}, - 'service': { - 'type': 'object', - 'properties': { - 'host': {'type': 'string'}, - 'id': {'type': ['integer', 'string']}, - 'disabled_reason': {'type': ['string', 'null']} - }, - 'additionalProperties': False, - 'required': ['host', 'id'] - }, - 'vcpus': {'type': 'integer'}, - 'vcpus_used': {'type': 'integer'} - }, - 'additionalProperties': False, - # NOTE: When loading os-hypervisor-status extension, - # a response contains status and state. So these params - # should not be required. - 'required': ['cpu_info', 'current_workload', - 'disk_available_least', 'host_ip', - 'free_disk_gb', 'free_ram_mb', - 'hypervisor_hostname', 'hypervisor_type', - 'hypervisor_version', 'id', 'local_gb', - 'local_gb_used', 'memory_mb', 'memory_mb_used', - 'running_vms', 'service', 'vcpus', 'vcpus_used'] -} - -list_hypervisors_detail = { - 'status_code': [200], - 'response_body': { - 'type': 'object', - 'properties': { - 'hypervisors': { - 'type': 'array', - 'items': hypervisor_detail - } - }, - 'additionalProperties': False, - 'required': ['hypervisors'] - } -} - -get_hypervisor = { - 'status_code': [200], - 'response_body': { - 'type': 'object', - 'properties': { - 'hypervisor': hypervisor_detail - }, - 'additionalProperties': False, - 'required': ['hypervisor'] - } -} - -list_search_hypervisors = { - 'status_code': [200], - 'response_body': { - 'type': 'object', - 'properties': { - 'hypervisors': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'status': {'type': 'string'}, - 'state': {'type': 'string'}, - 'id': {'type': ['integer', 'string']}, - 'hypervisor_hostname': {'type': 'string'} - }, - 'additionalProperties': False, - # NOTE: When loading os-hypervisor-status extension, - # a response contains status and state. So these params - # should not be required. - 'required': ['id', 'hypervisor_hostname'] - } - } - }, - 'additionalProperties': False, - 'required': ['hypervisors'] - } -} - -get_hypervisor_uptime = { - 'status_code': [200], - 'response_body': { - 'type': 'object', - 'properties': { - 'hypervisor': { - 'type': 'object', - 'properties': { - 'status': {'type': 'string'}, - 'state': {'type': 'string'}, - 'id': {'type': ['integer', 'string']}, - 'hypervisor_hostname': {'type': 'string'}, - 'uptime': {'type': 'string'} - }, - 'additionalProperties': False, - # NOTE: When loading os-hypervisor-status extension, - # a response contains status and state. So these params - # should not be required. - 'required': ['id', 'hypervisor_hostname', 'uptime'] - } - }, - 'additionalProperties': False, - 'required': ['hypervisor'] - } -} - -get_hypervisors_servers = copy.deepcopy(list_search_hypervisors) -get_hypervisors_servers['response_body']['properties']['hypervisors']['items'][ - 'properties']['servers'] = { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'uuid': {'type': 'string'}, - 'name': {'type': 'string'} - }, - 'additionalProperties': False, - } - } -# In V2 API, if there is no servers (VM) on the Hypervisor host then 'servers' -# attribute will not be present in response body So it is not 'required'. diff --git a/tempest/clients.py b/tempest/clients.py index 6c33e376a0..7832e910b8 100644 --- a/tempest/clients.py +++ b/tempest/clients.py @@ -33,6 +33,8 @@ from tempest_lib.services.compute.floating_ip_pools_client import \ from tempest_lib.services.compute.floating_ips_bulk_client import \ FloatingIPsBulkClient from tempest_lib.services.compute.hosts_client import HostsClient +from tempest_lib.services.compute.hypervisor_client import \ + HypervisorClient from tempest_lib.services.identity.v2.token_client import TokenClient from tempest_lib.services.identity.v3.token_client import V3TokenClient @@ -46,8 +48,6 @@ from tempest.services.baremetal.v1.json.baremetal_client import \ from tempest.services import botoclients from tempest.services.compute.json.floating_ips_client import \ FloatingIPsClient -from tempest.services.compute.json.hypervisor_client import \ - HypervisorClient from tempest.services.compute.json.images_client import ImagesClient from tempest.services.compute.json.instance_usage_audit_log_client import \ InstanceUsagesAuditLogClient diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py deleted file mode 100644 index ba06f23e98..0000000000 --- a/tempest/services/compute/json/hypervisor_client.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright 2013 IBM Corporation. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_serialization import jsonutils as json - -from tempest.api_schema.response.compute.v2_1 import hypervisors as schema -from tempest.common import service_client - - -class HypervisorClient(service_client.ServiceClient): - - def list_hypervisors(self, detail=False): - """List hypervisors information.""" - url = 'os-hypervisors' - _schema = schema.list_search_hypervisors - if detail: - url += '/detail' - _schema = schema.list_hypervisors_detail - - resp, body = self.get(url) - body = json.loads(body) - self.validate_response(_schema, resp, body) - return service_client.ResponseBody(resp, body) - - def show_hypervisor(self, hypervisor_id): - """Display the details of the specified hypervisor.""" - resp, body = self.get('os-hypervisors/%s' % hypervisor_id) - body = json.loads(body) - self.validate_response(schema.get_hypervisor, resp, body) - return service_client.ResponseBody(resp, body) - - def list_servers_on_hypervisor(self, hypervisor_name): - """List instances belonging to the specified hypervisor.""" - resp, body = self.get('os-hypervisors/%s/servers' % hypervisor_name) - body = json.loads(body) - self.validate_response(schema.get_hypervisors_servers, resp, body) - return service_client.ResponseBody(resp, body) - - def show_hypervisor_statistics(self): - """Get hypervisor statistics over all compute nodes.""" - resp, body = self.get('os-hypervisors/statistics') - body = json.loads(body) - self.validate_response(schema.get_hypervisor_statistics, resp, body) - return service_client.ResponseBody(resp, body) - - def show_hypervisor_uptime(self, hypervisor_id): - """Display the uptime of the specified hypervisor.""" - resp, body = self.get('os-hypervisors/%s/uptime' % hypervisor_id) - body = json.loads(body) - self.validate_response(schema.get_hypervisor_uptime, resp, body) - return service_client.ResponseBody(resp, body) - - def search_hypervisor(self, hypervisor_name): - """Search specified hypervisor.""" - resp, body = self.get('os-hypervisors/%s/search' % hypervisor_name) - body = json.loads(body) - self.validate_response(schema.list_search_hypervisors, resp, body) - return service_client.ResponseBody(resp, body) diff --git a/tempest/tests/services/compute/test_hypervisor_client.py b/tempest/tests/services/compute/test_hypervisor_client.py deleted file mode 100644 index 441e7e6348..0000000000 --- a/tempest/tests/services/compute/test_hypervisor_client.py +++ /dev/null @@ -1,167 +0,0 @@ -# Copyright 2015 IBM Corp. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from tempest.services.compute.json import hypervisor_client -from tempest.tests import fake_auth_provider -from tempest.tests.services.compute import base - - -class TestHypervisorClient(base.BaseComputeServiceTest): - - hypervisor_id = "1" - hypervisor_name = "hyper.hostname.com" - - def setUp(self): - super(TestHypervisorClient, self).setUp() - fake_auth = fake_auth_provider.FakeAuthProvider() - self.client = hypervisor_client.HypervisorClient( - fake_auth, 'compute', 'regionOne') - - def test_list_hypervisor_str_body(self): - self._test_list_hypervisor(bytes_body=False) - - def test_list_hypervisor_byte_body(self): - self._test_list_hypervisor(bytes_body=True) - - def _test_list_hypervisor(self, bytes_body=False): - expected = {"hypervisors": [{ - "id": 1, - "hypervisor_hostname": "hypervisor1.hostname.com"}, - { - "id": 2, - "hypervisor_hostname": "hypervisor2.hostname.com"}]} - self.check_service_client_function( - self.client.list_hypervisors, - 'tempest.common.service_client.ServiceClient.get', - expected, bytes_body) - - def test_show_hypervisor_str_body(self): - self._test_show_hypervisor(bytes_body=False) - - def test_show_hypervisor_byte_body(self): - self._test_show_hypervisor(bytes_body=True) - - def _test_show_hypervisor(self, bytes_body=False): - expected = {"hypervisor": { - "cpu_info": "?", - "current_workload": 0, - "disk_available_least": 1, - "host_ip": "10.10.10.10", - "free_disk_gb": 1028, - "free_ram_mb": 7680, - "hypervisor_hostname": "fake-mini", - "hypervisor_type": "fake", - "hypervisor_version": 1, - "id": 1, - "local_gb": 1028, - "local_gb_used": 0, - "memory_mb": 8192, - "memory_mb_used": 512, - "running_vms": 0, - "service": { - "host": "fake_host", - "id": 2}, - "vcpus": 1, - "vcpus_used": 0}} - self.check_service_client_function( - self.client.show_hypervisor, - 'tempest.common.service_client.ServiceClient.get', - expected, bytes_body, - hypervisor_id=self.hypervisor_id) - - def test_list_servers_on_hypervisor_str_body(self): - self._test_list_servers_on_hypervisor(bytes_body=False) - - def test_list_servers_on_hypervisor_byte_body(self): - self._test_list_servers_on_hypervisor(bytes_body=True) - - def _test_list_servers_on_hypervisor(self, bytes_body=False): - expected = {"hypervisors": [{ - "id": 1, - "hypervisor_hostname": "hyper.hostname.com", - "servers": [{ - "uuid": "e1ae8fc4-b72d-4c2f-a427-30dd420b6277", - "name": "instance-00000001"}, - { - "uuid": "e1ae8fc4-b72d-4c2f-a427-30dd42066666", - "name": "instance-00000002"} - ]} - ]} - self.check_service_client_function( - self.client.list_servers_on_hypervisor, - 'tempest.common.service_client.ServiceClient.get', - expected, bytes_body, - hypervisor_name=self.hypervisor_name) - - def test_show_hypervisor_statistics_str_body(self): - self._test_show_hypervisor_statistics(bytes_body=False) - - def test_show_hypervisor_statistics_byte_body(self): - self._test_show_hypervisor_statistics(bytes_body=True) - - def _test_show_hypervisor_statistics(self, bytes_body=False): - expected = { - "hypervisor_statistics": { - "count": 1, - "current_workload": 0, - "disk_available_least": 0, - "free_disk_gb": 1028, - "free_ram_mb": 7680, - "local_gb": 1028, - "local_gb_used": 0, - "memory_mb": 8192, - "memory_mb_used": 512, - "running_vms": 0, - "vcpus": 1, - "vcpus_used": 0}} - self.check_service_client_function( - self.client.show_hypervisor_statistics, - 'tempest.common.service_client.ServiceClient.get', - expected, bytes_body) - - def test_show_hypervisor_uptime_str_body(self): - self._test_show_hypervisor_uptime(bytes_body=False) - - def test_show_hypervisor_uptime_byte_body(self): - self._test_show_hypervisor_uptime(bytes_body=True) - - def _test_show_hypervisor_uptime(self, bytes_body=False): - expected = { - "hypervisor": { - "hypervisor_hostname": "fake-mini", - "id": 1, - "uptime": (" 08:32:11 up 93 days, 18:25, 12 users, " - " load average: 0.20, 0.12, 0.14") - }} - self.check_service_client_function( - self.client.show_hypervisor_uptime, - 'tempest.common.service_client.ServiceClient.get', - expected, bytes_body, - hypervisor_id=self.hypervisor_id) - - def test_search_hypervisor_str_body(self): - self._test_search_hypervisor(bytes_body=False) - - def test_search_hypervisor_byte_body(self): - self._test_search_hypervisor(bytes_body=True) - - def _test_search_hypervisor(self, bytes_body=False): - expected = {"hypervisors": [{ - "id": 2, - "hypervisor_hostname": "hyper.hostname.com"}]} - self.check_service_client_function( - self.client.search_hypervisor, - 'tempest.common.service_client.ServiceClient.get', - expected, bytes_body, - hypervisor_name=self.hypervisor_name)