Merge "Migrate V1 and V2 qos service to tempest lib"
This commit is contained in:
commit
39a4ae9de0
@ -7,6 +7,8 @@ features:
|
||||
any maintenance changes.
|
||||
|
||||
* encryption_types_client (v1)
|
||||
* qos_clients (v1)
|
||||
* qos_clients (v2)
|
||||
* snapshots_client (v1)
|
||||
* snapshots_client (v2)
|
||||
|
||||
|
@ -18,8 +18,13 @@ from tempest.lib.common import rest_client
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
|
||||
|
||||
class BaseQosSpecsClient(rest_client.RestClient):
|
||||
"""Client class to send CRUD QoS API requests"""
|
||||
class QosSpecsClient(rest_client.RestClient):
|
||||
"""Volume V1 QoS client.
|
||||
|
||||
Client class to send CRUD QoS API requests
|
||||
"""
|
||||
|
||||
api_version = "v1"
|
||||
|
||||
def is_resource_deleted(self, qos_id):
|
||||
try:
|
129
tempest/lib/services/volume/v2/qos_client.py
Normal file
129
tempest/lib/services/volume/v2/qos_client.py
Normal file
@ -0,0 +1,129 @@
|
||||
# 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.common import rest_client
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
|
||||
|
||||
class QosSpecsClient(rest_client.RestClient):
|
||||
"""Volume V2 QoS client.
|
||||
|
||||
Client class to send CRUD QoS API requests
|
||||
"""
|
||||
|
||||
api_version = "v2"
|
||||
|
||||
def is_resource_deleted(self, qos_id):
|
||||
try:
|
||||
self.show_qos(qos_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 'qos'
|
||||
|
||||
def create_qos(self, **kwargs):
|
||||
"""Create a QoS Specification.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-blockstorage-v2.html#createQoSSpec
|
||||
"""
|
||||
post_body = json.dumps({'qos_specs': kwargs})
|
||||
resp, body = self.post('qos-specs', post_body)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_qos(self, qos_id, force=False):
|
||||
"""Delete the specified QoS specification."""
|
||||
resp, body = self.delete(
|
||||
"qos-specs/%s?force=%s" % (qos_id, force))
|
||||
self.expected_success(202, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_qos(self):
|
||||
"""List all the QoS specifications created."""
|
||||
url = 'qos-specs'
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_qos(self, qos_id):
|
||||
"""Get the specified QoS specification."""
|
||||
url = "qos-specs/%s" % qos_id
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def set_qos_key(self, qos_id, **kwargs):
|
||||
"""Set the specified keys/values of QoS specification.
|
||||
|
||||
Available params: see http://developer.openstack.org/
|
||||
api-ref-blockstorage-v2.html#setQoSKey
|
||||
"""
|
||||
put_body = json.dumps({"qos_specs": kwargs})
|
||||
resp, body = self.put('qos-specs/%s' % qos_id, put_body)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def unset_qos_key(self, qos_id, keys):
|
||||
"""Unset the specified keys of QoS specification.
|
||||
|
||||
:param keys: keys to delete from the QoS specification.
|
||||
|
||||
TODO(jordanP): Add a link once LP #1524877 is fixed.
|
||||
"""
|
||||
put_body = json.dumps({'keys': keys})
|
||||
resp, body = self.put('qos-specs/%s/delete_keys' % qos_id, put_body)
|
||||
self.expected_success(202, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def associate_qos(self, qos_id, vol_type_id):
|
||||
"""Associate the specified QoS with specified volume-type."""
|
||||
url = "qos-specs/%s/associate" % qos_id
|
||||
url += "?vol_type_id=%s" % vol_type_id
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(202, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_association_qos(self, qos_id):
|
||||
"""Get the association of the specified QoS specification."""
|
||||
url = "qos-specs/%s/associations" % qos_id
|
||||
resp, body = self.get(url)
|
||||
body = json.loads(body)
|
||||
self.expected_success(200, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def disassociate_qos(self, qos_id, vol_type_id):
|
||||
"""Disassociate the specified QoS with specified volume-type."""
|
||||
url = "qos-specs/%s/disassociate" % qos_id
|
||||
url += "?vol_type_id=%s" % vol_type_id
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(202, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def disassociate_all_qos(self, qos_id):
|
||||
"""Disassociate the specified QoS with all associations."""
|
||||
url = "qos-specs/%s/disassociate_all" % qos_id
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(202, resp.status)
|
||||
return rest_client.ResponseBody(resp, body)
|
@ -18,15 +18,16 @@ from tempest.lib.services.volume.v1.encryption_types_client import \
|
||||
EncryptionTypesClient
|
||||
from tempest.lib.services.volume.v1.extensions_client import ExtensionsClient
|
||||
from tempest.lib.services.volume.v1.hosts_client import HostsClient
|
||||
from tempest.lib.services.volume.v1.qos_client import QosSpecsClient
|
||||
from tempest.lib.services.volume.v1.quotas_client import QuotasClient
|
||||
from tempest.lib.services.volume.v1.services_client import ServicesClient
|
||||
from tempest.lib.services.volume.v1.snapshots_client import SnapshotsClient
|
||||
from tempest.lib.services.volume.v1.types_client import TypesClient
|
||||
from tempest.services.volume.v1.json.backups_client import BackupsClient
|
||||
from tempest.services.volume.v1.json.qos_client import QosSpecsClient
|
||||
from tempest.services.volume.v1.json.volumes_client import VolumesClient
|
||||
|
||||
__all__ = ['AvailabilityZoneClient', 'EncryptionTypesClient',
|
||||
'ExtensionsClient', 'HostsClient', 'QuotasClient', 'ServicesClient',
|
||||
'SnapshotsClient', 'TypesClient', 'BackupsClient', 'QosSpecsClient',
|
||||
'ExtensionsClient', 'HostsClient', 'QuotasClient',
|
||||
'QosSpecsClient', 'ServicesClient',
|
||||
'SnapshotsClient', 'TypesClient', 'BackupsClient',
|
||||
'VolumesClient', ]
|
||||
|
@ -1,19 +0,0 @@
|
||||
# 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.services.volume.base import base_qos_client
|
||||
|
||||
|
||||
class QosSpecsClient(base_qos_client.BaseQosSpecsClient):
|
||||
"""Volume V1 QoS client."""
|
@ -16,6 +16,7 @@ from tempest.lib.services.volume.v2.availability_zone_client import \
|
||||
AvailabilityZoneClient
|
||||
from tempest.lib.services.volume.v2.extensions_client import ExtensionsClient
|
||||
from tempest.lib.services.volume.v2.hosts_client import HostsClient
|
||||
from tempest.lib.services.volume.v2.qos_client import QosSpecsClient
|
||||
from tempest.lib.services.volume.v2.quotas_client import QuotasClient
|
||||
from tempest.lib.services.volume.v2.services_client import ServicesClient
|
||||
from tempest.lib.services.volume.v2.snapshots_client import SnapshotsClient
|
||||
@ -23,10 +24,9 @@ from tempest.lib.services.volume.v2.types_client import TypesClient
|
||||
from tempest.services.volume.v2.json.backups_client import BackupsClient
|
||||
from tempest.services.volume.v2.json.encryption_types_client import \
|
||||
EncryptionTypesClient
|
||||
from tempest.services.volume.v2.json.qos_client import QosSpecsClient
|
||||
from tempest.services.volume.v2.json.volumes_client import VolumesClient
|
||||
|
||||
__all__ = ['AvailabilityZoneClient', 'ExtensionsClient', 'HostsClient',
|
||||
'QuotasClient', 'ServicesClient', 'SnapshotsClient', 'TypesClient',
|
||||
'BackupsClient', 'EncryptionTypesClient', 'QosSpecsClient',
|
||||
'VolumesClient', ]
|
||||
'QosSpecsClient', 'QuotasClient', 'ServicesClient',
|
||||
'SnapshotsClient', 'TypesClient', 'BackupsClient',
|
||||
'EncryptionTypesClient', 'VolumesClient', ]
|
||||
|
@ -1,19 +0,0 @@
|
||||
# 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.services.volume.base import base_qos_client
|
||||
|
||||
|
||||
class QosSpecsClient(base_qos_client.BaseQosSpecsClient):
|
||||
api_version = "v2"
|
Loading…
Reference in New Issue
Block a user