Merge "Add list resource provider usage"
This commit is contained in:
commit
1053ecca53
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``placement`` API usage method for evaluating resource class
|
||||
utilization of the resource provider. The following API call is available
|
||||
for tempest from now in the resource_providers_client:
|
||||
|
||||
* GET /resource_providers/{uuid}/usages
|
@ -26,6 +26,7 @@ class ResourceProvidersClient(base_placement_client.BasePlacementClient):
|
||||
* resource providers
|
||||
* resource provider inventories
|
||||
* resource provider aggregates
|
||||
* resource provider usages
|
||||
"""
|
||||
|
||||
def list_resource_providers(self, **params):
|
||||
@ -69,6 +70,19 @@ class ResourceProvidersClient(base_placement_client.BasePlacementClient):
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_resource_provider_usages(self, rp_uuid):
|
||||
"""List resource provider usages.
|
||||
|
||||
For full list of available parameters, please refer to the official
|
||||
API reference:
|
||||
https://docs.openstack.org/api-ref/placement/#list-resource-provider-usages
|
||||
"""
|
||||
url = '/resource_providers/%s/usages' % rp_uuid
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def list_resource_provider_aggregates(self, rp_uuid):
|
||||
"""List resource provider aggregates.
|
||||
|
||||
|
@ -85,6 +85,14 @@ class TestResourceProvidersClient(base.BaseServiceTest):
|
||||
},
|
||||
"resource_provider_generation": 1
|
||||
}
|
||||
FAKE_RESOURCE_PROVIDER_USAGES = {
|
||||
"usages": {
|
||||
"VCPU": 2,
|
||||
"MEMORY_MB": 1024,
|
||||
"DISK_GB": 10
|
||||
},
|
||||
"resource_provider_generation": 3
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestResourceProvidersClient, self).setUp()
|
||||
@ -180,3 +188,19 @@ class TestResourceProvidersClient(base.BaseServiceTest):
|
||||
|
||||
def test_list_resource_provider_aggregates_with_bytes_body(self):
|
||||
self._test_list_resource_provider_aggregates(bytes_body=True)
|
||||
|
||||
def _test_list_resource_provider_usages(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_resource_provider_usages,
|
||||
'tempest.lib.common.rest_client.RestClient.get',
|
||||
self.FAKE_RESOURCE_PROVIDER_USAGES,
|
||||
to_utf=bytes_body,
|
||||
status=200,
|
||||
rp_uuid=self.FAKE_RESOURCE_PROVIDER_UUID
|
||||
)
|
||||
|
||||
def test_show_resource_provider_usages_with_str_body(self):
|
||||
self._test_list_resource_provider_inventories()
|
||||
|
||||
def test_show_resource_provider_usages_with_with_bytes_body(self):
|
||||
self._test_list_resource_provider_inventories(bytes_body=True)
|
||||
|
Loading…
Reference in New Issue
Block a user