services: Introduce a cinder v3 attachments client
This change adds a new attachment client to allow for CRUD operations against volume attachments as now exposed by the Cinder v3 API. Change-Id: I0171dc0a87800ad33c176c6b6540fbc3db025709
This commit is contained in:
parent
8877c4e891
commit
ec3ae5ea0e
@ -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``.
|
@ -263,6 +263,8 @@ class Manager(clients.ServiceClients):
|
|||||||
self.volume_v3.MessagesClient())
|
self.volume_v3.MessagesClient())
|
||||||
self.volume_versions_client_latest = (
|
self.volume_versions_client_latest = (
|
||||||
self.volume_v3.VersionsClient())
|
self.volume_v3.VersionsClient())
|
||||||
|
self.attachments_client_latest = (
|
||||||
|
self.volume_v3.AttachmentsClient())
|
||||||
|
|
||||||
# TODO(gmann): Below alias for service clients have been
|
# TODO(gmann): Below alias for service clients have been
|
||||||
# deprecated and will be removed in future. Start using the alias
|
# deprecated and will be removed in future. Start using the alias
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations under
|
# License for the specific language governing permissions and limitations under
|
||||||
# the License.
|
# the License.
|
||||||
|
from tempest.lib.services.volume.v3.attachments_client import AttachmentsClient
|
||||||
from tempest.lib.services.volume.v3.availability_zone_client \
|
from tempest.lib.services.volume.v3.availability_zone_client \
|
||||||
import AvailabilityZoneClient
|
import AvailabilityZoneClient
|
||||||
from tempest.lib.services.volume.v3.backups_client import BackupsClient
|
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 \
|
from tempest.lib.services.volume.v3.volume_manage_client import \
|
||||||
VolumeManageClient
|
VolumeManageClient
|
||||||
from tempest.lib.services.volume.v3.volumes_client import VolumesClient
|
from tempest.lib.services.volume.v3.volumes_client import VolumesClient
|
||||||
|
__all__ = ['AttachmentsClient', 'AvailabilityZoneClient', 'BackupsClient',
|
||||||
__all__ = ['AvailabilityZoneClient', 'BackupsClient', 'BaseClient',
|
'BaseClient', 'CapabilitiesClient', 'EncryptionTypesClient',
|
||||||
'CapabilitiesClient', 'EncryptionTypesClient', 'ExtensionsClient',
|
'ExtensionsClient', 'GroupSnapshotsClient', 'GroupTypesClient',
|
||||||
'GroupSnapshotsClient', 'GroupTypesClient', 'GroupsClient',
|
'GroupsClient', 'HostsClient', 'LimitsClient', 'MessagesClient',
|
||||||
'HostsClient', 'LimitsClient', 'MessagesClient', 'QosSpecsClient',
|
'QosSpecsClient', 'QuotaClassesClient', 'QuotasClient',
|
||||||
'QuotaClassesClient', 'QuotasClient', 'SchedulerStatsClient',
|
'SchedulerStatsClient', 'ServicesClient', 'SnapshotManageClient',
|
||||||
'ServicesClient', 'SnapshotManageClient', 'SnapshotsClient',
|
'SnapshotsClient', 'TransfersClient', 'TypesClient',
|
||||||
'TransfersClient', 'TypesClient', 'VersionsClient',
|
'VersionsClient', 'VolumeManageClient', 'VolumesClient']
|
||||||
'VolumeManageClient', 'VolumesClient']
|
|
||||||
|
28
tempest/lib/services/volume/v3/attachments_client.py
Normal file
28
tempest/lib/services/volume/v3/attachments_client.py
Normal 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)
|
@ -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)
|
Loading…
x
Reference in New Issue
Block a user