Merge "Add namespace properties client and tests"
This commit is contained in:
commit
ab0066b260
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
As in the [doc]:
|
||||
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html,
|
||||
there are some apis are not included, add them.
|
||||
|
||||
* namespace_properties_client(v2)
|
||||
|
|
@ -141,6 +141,7 @@ class BaseV2ImageTest(BaseImageTest):
|
|||
cls.client = cls.os.image_client_v2
|
||||
cls.namespaces_client = cls.os.namespaces_client
|
||||
cls.resource_types_client = cls.os.resource_types_client
|
||||
cls.namespace_properties_client = cls.os.namespace_properties_client
|
||||
cls.schemas_client = cls.os.schemas_client
|
||||
|
||||
def create_namespace(cls, namespace_name=None, visibility='public',
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# 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.api.image import base
|
||||
from tempest.common.utils import data_utils
|
||||
from tempest import test
|
||||
|
||||
|
||||
class MetadataNamespacePropertiesTest(base.BaseV2ImageTest):
|
||||
"""Test the Metadata definition namespace property basic functionality"""
|
||||
|
||||
@test.idempotent_id('b1a3765e-3a5d-4f6d-a3a7-3ca3476ae768')
|
||||
def test_basic_meta_def_namespace_property(self):
|
||||
# Get the available resource types and use one resource_type
|
||||
body = self.resource_types_client.list_resource_types()
|
||||
resource_name = body['resource_types'][0]['name']
|
||||
enum = ["xen", "qemu", "kvm", "lxc", "uml", "vmware", "hyperv"]
|
||||
# Create a namespace
|
||||
namespace = self.create_namespace()
|
||||
# Create resource type association
|
||||
body = self.resource_types_client.create_resource_type_association(
|
||||
namespace['namespace'], name=resource_name)
|
||||
# Create a property
|
||||
property_title = data_utils.rand_name('property')
|
||||
body = self.namespace_properties_client.create_namespace_property(
|
||||
namespace=namespace['namespace'], title=property_title,
|
||||
name=resource_name, type="string", enum=enum)
|
||||
self.assertEqual(property_title, body['title'])
|
||||
# Show namespace property
|
||||
body = self.namespace_properties_client.show_namespace_properties(
|
||||
namespace['namespace'], resource_name)
|
||||
self.assertEqual(resource_name, body['name'])
|
||||
# Update namespace property
|
||||
update_property_title = data_utils.rand_name('update-property')
|
||||
body = self.namespace_properties_client.update_namespace_properties(
|
||||
namespace['namespace'], resource_name,
|
||||
title=update_property_title, type="string",
|
||||
enum=enum, name=resource_name)
|
||||
self.assertEqual(update_property_title, body['title'])
|
||||
# Delete namespace property
|
||||
self.namespace_properties_client.delete_namespace_property(
|
||||
namespace['namespace'], resource_name)
|
||||
# List namespace properties and validate deletion
|
||||
namespace_property = [
|
||||
namespace_property['title'] for namespace_property in
|
||||
self.namespace_properties_client.list_namespace_properties(
|
||||
namespace['namespace'])['properties']]
|
||||
self.assertNotIn(update_property_title, namespace_property)
|
|
@ -141,6 +141,8 @@ class Manager(clients.ServiceClients):
|
|||
self.namespaces_client = self.image_v2.NamespacesClient()
|
||||
self.resource_types_client = self.image_v2.ResourceTypesClient()
|
||||
self.schemas_client = self.image_v2.SchemasClient()
|
||||
self.namespace_properties_client = \
|
||||
self.image_v2.NamespacePropertiesClient()
|
||||
|
||||
def _set_compute_clients(self):
|
||||
self.agents_client = self.compute.AgentsClient()
|
||||
|
|
|
@ -15,10 +15,12 @@
|
|||
from tempest.lib.services.image.v2.image_members_client import \
|
||||
ImageMembersClient
|
||||
from tempest.lib.services.image.v2.images_client import ImagesClient
|
||||
from tempest.lib.services.image.v2.namespace_properties_client import \
|
||||
NamespacePropertiesClient
|
||||
from tempest.lib.services.image.v2.namespaces_client import NamespacesClient
|
||||
from tempest.lib.services.image.v2.resource_types_client import \
|
||||
ResourceTypesClient
|
||||
from tempest.lib.services.image.v2.schemas_client import SchemasClient
|
||||
|
||||
__all__ = ['ImageMembersClient', 'ImagesClient', 'NamespacesClient',
|
||||
'ResourceTypesClient', 'SchemasClient']
|
||||
__all__ = ['ImageMembersClient', 'ImagesClient', 'NamespacePropertiesClient',
|
||||
'NamespacesClient', 'ResourceTypesClient', 'SchemasClient']
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
# Copyright 2016 EasyStack.
|
||||
# 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
|
||||
|
||||
|
||||
class NamespacePropertiesClient(rest_client.RestClient):
|
||||
api_version = "v2"
|
||||
|
||||
def list_namespace_properties(self, namespace):
|
||||
"""Lists property definitions in a namespace.
|
||||
|
||||
For a full list of available parameters, please refer to the official
|
||||
API reference:
|
||||
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html#list-properties
|
||||
"""
|
||||
url = 'metadefs/namespaces/%s/properties' % namespace
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def create_namespace_property(self, namespace, **kwargs):
|
||||
"""Creates a property definition in a namespace.
|
||||
|
||||
For a full list of available parameters, please refer to the official
|
||||
API reference:
|
||||
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html#create-property
|
||||
"""
|
||||
url = 'metadefs/namespaces/%s/properties' % namespace
|
||||
data = json.dumps(kwargs)
|
||||
resp, body = self.post(url, data)
|
||||
self.expected_success(201, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def show_namespace_properties(self, namespace, property_name):
|
||||
"""Shows the definition for a property.
|
||||
|
||||
For a full list of available parameters, please refer to the official
|
||||
API reference:
|
||||
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html#show-property-definition
|
||||
"""
|
||||
url = 'metadefs/namespaces/%s/properties/%s' % (namespace,
|
||||
property_name)
|
||||
resp, body = self.get(url)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def update_namespace_properties(self, namespace, property_name, **kwargs):
|
||||
"""Updates a property definition.
|
||||
|
||||
For a full list of available parameters, please refer to the official
|
||||
API reference:
|
||||
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html#update-property-definition
|
||||
"""
|
||||
url = 'metadefs/namespaces/%s/properties/%s' % (namespace,
|
||||
property_name)
|
||||
data = json.dumps(kwargs)
|
||||
resp, body = self.put(url, data)
|
||||
self.expected_success(200, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
||||
def delete_namespace_property(self, namespace, property_name):
|
||||
"""Removes a property definition from a namespace.
|
||||
|
||||
For a full list of available parameters, please refer to the official
|
||||
API reference:
|
||||
http://developer.openstack.org/api-ref/image/v2/metadefs-index.html#remove-property-definition
|
||||
"""
|
||||
url = 'metadefs/namespaces/%s/properties/%s' % (namespace,
|
||||
property_name)
|
||||
resp, _ = self.delete(url)
|
||||
self.expected_success(204, resp.status)
|
||||
return rest_client.ResponseBody(resp)
|
Loading…
Reference in New Issue