Merge "services: Introduce a cinder v3 attachments client"

This commit is contained in:
Zuul 2020-03-22 01:50:45 +00:00 committed by Gerrit Code Review
commit 6e79824135
5 changed files with 93 additions and 9 deletions

View File

@ -0,0 +1,8 @@
---
features:
- |
A new attachments client library has been introduced for the volume
service.
Initially only the show_attachment API is provided. This API requires a
minimum volume API microversion of ``3.27``.

View File

@ -263,6 +263,8 @@ class Manager(clients.ServiceClients):
self.volume_v3.MessagesClient())
self.volume_versions_client_latest = (
self.volume_v3.VersionsClient())
self.attachments_client_latest = (
self.volume_v3.AttachmentsClient())
# TODO(gmann): Below alias for service clients have been
# deprecated and will be removed in future. Start using the alias

View File

@ -11,6 +11,7 @@
# 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.services.volume.v3.attachments_client import AttachmentsClient
from tempest.lib.services.volume.v3.availability_zone_client \
import AvailabilityZoneClient
from tempest.lib.services.volume.v3.backups_client import BackupsClient
@ -43,12 +44,11 @@ from tempest.lib.services.volume.v3.versions_client import VersionsClient
from tempest.lib.services.volume.v3.volume_manage_client import \
VolumeManageClient
from tempest.lib.services.volume.v3.volumes_client import VolumesClient
__all__ = ['AvailabilityZoneClient', 'BackupsClient', 'BaseClient',
'CapabilitiesClient', 'EncryptionTypesClient', 'ExtensionsClient',
'GroupSnapshotsClient', 'GroupTypesClient', 'GroupsClient',
'HostsClient', 'LimitsClient', 'MessagesClient', 'QosSpecsClient',
'QuotaClassesClient', 'QuotasClient', 'SchedulerStatsClient',
'ServicesClient', 'SnapshotManageClient', 'SnapshotsClient',
'TransfersClient', 'TypesClient', 'VersionsClient',
'VolumeManageClient', 'VolumesClient']
__all__ = ['AttachmentsClient', 'AvailabilityZoneClient', 'BackupsClient',
'BaseClient', 'CapabilitiesClient', 'EncryptionTypesClient',
'ExtensionsClient', 'GroupSnapshotsClient', 'GroupTypesClient',
'GroupsClient', 'HostsClient', 'LimitsClient', 'MessagesClient',
'QosSpecsClient', 'QuotaClassesClient', 'QuotasClient',
'SchedulerStatsClient', 'ServicesClient', 'SnapshotManageClient',
'SnapshotsClient', 'TransfersClient', 'TypesClient',
'VersionsClient', 'VolumeManageClient', 'VolumesClient']

View File

@ -0,0 +1,28 @@
# 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.common import rest_client
from tempest.lib.services.volume import base_client
class AttachmentsClient(base_client.BaseClient):
"""Client class to send CRUD attachment V3 API requests"""
def show_attachment(self, attachment_id):
"""Show volume attachment."""
url = "attachments/%s" % (attachment_id)
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)

View File

@ -0,0 +1,46 @@
# 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.services.volume.v3 import attachments_client
from tempest.tests.lib import fake_auth_provider
from tempest.tests.lib.services import base
from oslo_utils.fixture import uuidsentinel as uuids
class TestAttachmentsClient(base.BaseServiceTest):
FAKE_ATTACHMENT_INFO = {
"attachment": {
"status": "attaching",
"detached_at": "2015-09-16T09:28:52.000000",
"connection_info": {},
"attached_at": "2015-09-16T09:28:52.000000",
"attach_mode": "ro",
"instance": uuids.instance_id,
"volume_id": uuids.volume_id,
"id": uuids.id,
}
}
def setUp(self):
super(TestAttachmentsClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.client = attachments_client.AttachmentsClient(fake_auth,
'volume',
'regionOne')
def test_show_attachment(self):
self.check_service_client_function(
self.client.show_attachment,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_ATTACHMENT_INFO, attachment_id=uuids.id)