Use Tempest-lib's aggregate client
Aggregate service client has been migrated to tempest-lib-
Ia20fd3914aa6e5ac829bfd3fb88bb4f654958b53
Now Tempest-lib provides this client as stable interface so Tempest
should start using this from lib and remove its own copy.
Also remove other files for this client like response schema, unit tests.
This commits makes Tempest to use aggregate client from Tempest-lib.
Change-Id: I238c688beff26f63e804ebe86101205eb2c0c57c
Depends-on: I516d4119fd200c79a8be4598cbb0d732344e8b75
diff --git a/tempest/api_schema/response/compute/v2_1/aggregates.py b/tempest/api_schema/response/compute/v2_1/aggregates.py
deleted file mode 100644
index 1a9fe41..0000000
--- a/tempest/api_schema/response/compute/v2_1/aggregates.py
+++ /dev/null
@@ -1,92 +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
-
-# create-aggregate api doesn't have 'hosts' and 'metadata' attributes.
-aggregate_for_create = {
- 'type': 'object',
- 'properties': {
- 'availability_zone': {'type': ['string', 'null']},
- 'created_at': {'type': 'string'},
- 'deleted': {'type': 'boolean'},
- 'deleted_at': {'type': ['string', 'null']},
- 'id': {'type': 'integer'},
- 'name': {'type': 'string'},
- 'updated_at': {'type': ['string', 'null']}
- },
- 'additionalProperties': False,
- 'required': ['availability_zone', 'created_at', 'deleted',
- 'deleted_at', 'id', 'name', 'updated_at'],
-}
-
-common_aggregate_info = copy.deepcopy(aggregate_for_create)
-common_aggregate_info['properties'].update({
- 'hosts': {'type': 'array'},
- 'metadata': {'type': 'object'}
-})
-common_aggregate_info['required'].extend(['hosts', 'metadata'])
-
-list_aggregates = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'aggregates': {
- 'type': 'array',
- 'items': common_aggregate_info
- }
- },
- 'additionalProperties': False,
- 'required': ['aggregates'],
- }
-}
-
-get_aggregate = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'aggregate': common_aggregate_info
- },
- 'additionalProperties': False,
- 'required': ['aggregate'],
- }
-}
-
-aggregate_set_metadata = get_aggregate
-# The 'updated_at' attribute of 'update_aggregate' can't be null.
-update_aggregate = copy.deepcopy(get_aggregate)
-update_aggregate['response_body']['properties']['aggregate']['properties'][
- 'updated_at'] = {
- 'type': 'string'
- }
-
-delete_aggregate = {
- 'status_code': [200]
-}
-
-create_aggregate = {
- 'status_code': [200],
- 'response_body': {
- 'type': 'object',
- 'properties': {
- 'aggregate': aggregate_for_create
- },
- 'additionalProperties': False,
- 'required': ['aggregate'],
- }
-}
-
-aggregate_add_remove_host = get_aggregate
diff --git a/tempest/clients.py b/tempest/clients.py
index cffdc3f..276f7eb 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -17,6 +17,7 @@
from oslo_log import log as logging
from tempest_lib.services.compute.agents_client import AgentsClient
+from tempest_lib.services.compute.aggregates_client import AggregatesClient
from tempest_lib.services.identity.v2.token_client import TokenClient
from tempest_lib.services.identity.v3.token_client import V3TokenClient
@@ -28,8 +29,6 @@
from tempest.services.baremetal.v1.json.baremetal_client import \
BaremetalClient
from tempest.services import botoclients
-from tempest.services.compute.json.aggregates_client import \
- AggregatesClient
from tempest.services.compute.json.availability_zone_client import \
AvailabilityZoneClient
from tempest.services.compute.json.baremetal_nodes_client import \
diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py
deleted file mode 100644
index c9895db..0000000
--- a/tempest/services/compute/json/aggregates_client.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2013 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.
-
-from oslo_serialization import jsonutils as json
-from tempest_lib import exceptions as lib_exc
-
-from tempest.api_schema.response.compute.v2_1 import aggregates as schema
-from tempest.common import service_client
-
-
-class AggregatesClient(service_client.ServiceClient):
-
- def list_aggregates(self):
- """Get aggregate list."""
- resp, body = self.get("os-aggregates")
- body = json.loads(body)
- self.validate_response(schema.list_aggregates, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def show_aggregate(self, aggregate_id):
- """Get details of the given aggregate."""
- resp, body = self.get("os-aggregates/%s" % aggregate_id)
- body = json.loads(body)
- self.validate_response(schema.get_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def create_aggregate(self, **kwargs):
- """Creates a new aggregate."""
- post_body = json.dumps({'aggregate': kwargs})
- resp, body = self.post('os-aggregates', post_body)
-
- body = json.loads(body)
- self.validate_response(schema.create_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def update_aggregate(self, aggregate_id, **kwargs):
- """Update a aggregate."""
- put_body = json.dumps({'aggregate': kwargs})
- resp, body = self.put('os-aggregates/%s' % aggregate_id, put_body)
-
- body = json.loads(body)
- self.validate_response(schema.update_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def delete_aggregate(self, aggregate_id):
- """Deletes the given aggregate."""
- resp, body = self.delete("os-aggregates/%s" % aggregate_id)
- self.validate_response(schema.delete_aggregate, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def is_resource_deleted(self, id):
- try:
- self.show_aggregate(id)
- except lib_exc.NotFound:
- return True
- return False
-
- @property
- def resource_type(self):
- """Returns the primary type of resource this client works with."""
- return 'aggregate'
-
- def add_host(self, aggregate_id, **kwargs):
- """Adds a host to the given aggregate."""
- post_body = json.dumps({'add_host': kwargs})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_add_remove_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def remove_host(self, aggregate_id, **kwargs):
- """Removes a host from the given aggregate."""
- post_body = json.dumps({'remove_host': kwargs})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_add_remove_host, resp, body)
- return service_client.ResponseBody(resp, body)
-
- def set_metadata(self, aggregate_id, **kwargs):
- """Replaces the aggregate's existing metadata with new metadata."""
- post_body = json.dumps({'set_metadata': kwargs})
- resp, body = self.post('os-aggregates/%s/action' % aggregate_id,
- post_body)
- body = json.loads(body)
- self.validate_response(schema.aggregate_set_metadata, resp, body)
- return service_client.ResponseBody(resp, body)
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index e4228a7..4244616 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -17,7 +17,6 @@
import six
from tempest.services.baremetal.v1.json import baremetal_client
-from tempest.services.compute.json import aggregates_client
from tempest.services.compute.json import availability_zone_client
from tempest.services.compute.json import certificates_client
from tempest.services.compute.json import extensions_client
@@ -108,7 +107,6 @@
def test_service_client_creations_with_specified_args(self, mock_init):
test_clients = [
baremetal_client.BaremetalClient,
- aggregates_client.AggregatesClient,
availability_zone_client.AvailabilityZoneClient,
certificates_client.CertificatesClient,
extensions_client.ExtensionsClient,
diff --git a/tempest/tests/services/compute/test_aggregates_client.py b/tempest/tests/services/compute/test_aggregates_client.py
deleted file mode 100644
index e92b76b..0000000
--- a/tempest/tests/services/compute/test_aggregates_client.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Copyright 2015 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.
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import aggregates_client
-from tempest.tests.services.compute import base
-
-
-class TestAggregatesClient(base.BaseComputeServiceTest):
- FAKE_SHOW_AGGREGATE = {
- "aggregate":
- {
- "name": "hoge",
- "availability_zone": None,
- "deleted": False,
- "created_at":
- "2015-07-16T03:07:32.000000",
- "updated_at": None,
- "hosts": [],
- "deleted_at": None,
- "id": 1,
- "metadata": {}
- }
- }
-
- FAKE_CREATE_AGGREGATE = {
- "aggregate":
- {
- "name": u'\xf4',
- "availability_zone": None,
- "deleted": False,
- "created_at": "2015-07-21T04:11:18.000000",
- "updated_at": None,
- "deleted_at": None,
- "id": 1
- }
- }
-
- FAKE_UPDATE_AGGREGATE = {
- "aggregate":
- {
- "name": u'\xe9',
- "availability_zone": None,
- "deleted": False,
- "created_at": "2015-07-16T03:07:32.000000",
- "updated_at": "2015-07-23T05:16:29.000000",
- "hosts": [],
- "deleted_at": None,
- "id": 1,
- "metadata": {}
- }
- }
-
- def setUp(self):
- super(TestAggregatesClient, self).setUp()
- fake_auth = fake_auth_provider.FakeAuthProvider()
- self.client = aggregates_client.AggregatesClient(
- fake_auth, 'compute', 'regionOne')
-
- def _test_list_aggregates(self, bytes_body=False):
- self.check_service_client_function(
- self.client.list_aggregates,
- 'tempest.common.service_client.ServiceClient.get',
- {"aggregates": []},
- bytes_body)
-
- def test_list_aggregates_with_str_body(self):
- self._test_list_aggregates()
-
- def test_list_aggregates_with_bytes_body(self):
- self._test_list_aggregates(bytes_body=True)
-
- def _test_show_aggregate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.show_aggregate,
- 'tempest.common.service_client.ServiceClient.get',
- self.FAKE_SHOW_AGGREGATE,
- bytes_body,
- aggregate_id=1)
-
- def test_show_aggregate_with_str_body(self):
- self._test_show_aggregate()
-
- def test_show_aggregate_with_bytes_body(self):
- self._test_show_aggregate(bytes_body=True)
-
- def _test_create_aggregate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.create_aggregate,
- 'tempest.common.service_client.ServiceClient.post',
- self.FAKE_CREATE_AGGREGATE,
- bytes_body,
- name='hoge')
-
- def test_create_aggregate_with_str_body(self):
- self._test_create_aggregate()
-
- def test_create_aggregate_with_bytes_body(self):
- self._test_create_aggregate(bytes_body=True)
-
- def test_delete_aggregate(self):
- self.check_service_client_function(
- self.client.delete_aggregate,
- 'tempest.common.service_client.ServiceClient.delete',
- {}, aggregate_id="1")
-
- def _test_update_aggregate(self, bytes_body=False):
- self.check_service_client_function(
- self.client.update_aggregate,
- 'tempest.common.service_client.ServiceClient.put',
- self.FAKE_UPDATE_AGGREGATE,
- bytes_body,
- aggregate_id=1)
-
- def test_update_aggregate_with_str_body(self):
- self._test_update_aggregate()
-
- def test_update_aggregate_with_bytes_body(self):
- self._test_update_aggregate(bytes_body=True)