Add 'ProfileType' resource for senlin
This proposes a 'ProfileType' resource for senlin clustering service. Change-Id: I48b0934f6be500d7c9d12ba2643269aaa95988e8
This commit is contained in:
parent
7480a69a71
commit
0f3efa3ca0
|
@ -18,6 +18,7 @@ from openstack.cluster.v1 import event as _event
|
|||
from openstack.cluster.v1 import node as _node
|
||||
from openstack.cluster.v1 import policy as _policy
|
||||
from openstack.cluster.v1 import profile as _profile
|
||||
from openstack.cluster.v1 import profile_type as _profile_type
|
||||
from openstack import proxy
|
||||
from openstack import resource
|
||||
|
||||
|
@ -31,6 +32,27 @@ class Proxy(proxy.BaseProxy):
|
|||
"""
|
||||
return self._get(build_info.BuildInfo)
|
||||
|
||||
def profile_types(self, **query):
|
||||
"""Get a generator of profile types.
|
||||
|
||||
:returns: A generator of objects that are of type
|
||||
:class:`~openstack.cluster.v1.profile_type.ProfileType`
|
||||
"""
|
||||
return self._list(_profile_type.ProfileType, paginated=False, **query)
|
||||
|
||||
def get_profile_type(self, profile_type):
|
||||
"""Get the details about a profile_type.
|
||||
|
||||
:param name: The name of the profile_type to retrieve or an object of
|
||||
:class:`~openstack.cluster.v1.profile_type.ProfileType`.
|
||||
|
||||
:returns: A :class:`~openstack.cluster.v1.profile_type.ProfileType`
|
||||
object.
|
||||
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||
profile_type matching the name could be found.
|
||||
"""
|
||||
return self._get(_profile_type.ProfileType, profile_type)
|
||||
|
||||
def create_profile(self, **attrs):
|
||||
"""Create a new profile from attributes.
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# 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 openstack.cluster import cluster_service
|
||||
from openstack import resource
|
||||
|
||||
|
||||
class ProfileType(resource.Resource):
|
||||
id_attribute = 'name'
|
||||
resource_key = 'profile_type'
|
||||
resources_key = 'profile_types'
|
||||
base_path = '/profile-types'
|
||||
service = cluster_service.ClusterService()
|
||||
|
||||
# Capabilities
|
||||
allow_list = True
|
||||
allow_retrieve = True
|
||||
|
||||
# Properties
|
||||
#: Name of the profile type.
|
||||
name = resource.prop('name')
|
||||
#: The schema of the profile type.
|
||||
schema = resource.prop('schema')
|
|
@ -0,0 +1,42 @@
|
|||
# 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.
|
||||
|
||||
import testtools
|
||||
|
||||
from openstack.cluster.v1 import profile_type
|
||||
|
||||
|
||||
FAKE = {
|
||||
'name': 'FAKE_PROFILE_TYPE',
|
||||
'schema': {
|
||||
'foo': 'bar'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestProfileType(testtools.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
sot = profile_type.ProfileType()
|
||||
self.assertEqual('name', sot.id_attribute)
|
||||
self.assertEqual('profile_type', sot.resource_key)
|
||||
self.assertEqual('profile_types', sot.resources_key)
|
||||
self.assertEqual('/profile-types', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_instantiate(self):
|
||||
sot = profile_type.ProfileType(FAKE)
|
||||
self.assertEqual(FAKE['name'], sot.id)
|
||||
self.assertEqual(FAKE['name'], sot.name)
|
||||
self.assertEqual(FAKE['schema'], sot.schema)
|
|
@ -19,6 +19,7 @@ from openstack.cluster.v1 import event
|
|||
from openstack.cluster.v1 import node
|
||||
from openstack.cluster.v1 import policy
|
||||
from openstack.cluster.v1 import profile
|
||||
from openstack.cluster.v1 import profile_type
|
||||
from openstack.tests.unit import test_proxy_base
|
||||
|
||||
|
||||
|
@ -31,6 +32,15 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
|
|||
self.verify_get(self.proxy.get_build_info, build_info.BuildInfo,
|
||||
ignore_value=True)
|
||||
|
||||
def test_profile_types(self):
|
||||
self.verify_list(self.proxy.profile_types,
|
||||
profile_type.ProfileType,
|
||||
paginated=False)
|
||||
|
||||
def test_profile_type_get(self):
|
||||
self.verify_get(self.proxy.get_profile_type,
|
||||
profile_type.ProfileType)
|
||||
|
||||
def test_profile_create(self):
|
||||
self.verify_create(self.proxy.create_profile, profile.Profile)
|
||||
|
||||
|
|
Loading…
Reference in New Issue