Fix clustering profile type miss list operation

This patch fix clustering profile type ops error, Senlin
and senlinclient has support list 'op', but openstacksdk
not exist profile type list 'op', Add openstacksdk support
profile type list 'op'.

Senlinclient merge support profile type list 'op' link:
https://review.openstack.org/#/c/492047/

Closes-Bug: 1777454

Change-Id: I4e2a1ef6ceb34fbef2c4191582956e5556f4eb0e
Signed-off-by: Yuanbin.Chen <cybing4@gmail.com>
This commit is contained in:
Yuanbin.Chen
2018-06-19 14:17:03 +08:00
parent 07d3828860
commit 1423fc7dde
4 changed files with 44 additions and 0 deletions

View File

@@ -1155,3 +1155,17 @@ class Proxy(proxy.Proxy):
:class:`~openstack.clustering.v1.service.Service`
"""
return self._list(_service.Service, paginated=False, **query)
def list_profile_type_operations(self, profile_type):
"""Get the operation about a profile type.
:param profile_type: The name of the profile_type to retrieve or an
object of :class:`~openstack.clustering.v1.profile_type.ProfileType`.
:returns: A :class:`~openstack.clustering.v1.profile_type.ProfileType`
object.
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
profile_type matching the name could be found.
"""
obj = self._get_resource(_profile_type.ProfileType, profile_type)
return obj.type_ops(self)

View File

@@ -12,6 +12,7 @@
from openstack.clustering import clustering_service
from openstack import resource
from openstack import utils
class ProfileType(resource.Resource):
@@ -31,3 +32,8 @@ class ProfileType(resource.Resource):
schema = resource.Body('schema')
#: The support status of the profile type
support_status = resource.Body('support_status')
def type_ops(self, session):
url = utils.urljoin(self.base_path, self.id, 'ops')
resp = session.get(url)
return resp.json()

View File

@@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from openstack.tests.unit import base
from openstack.clustering.v1 import profile_type
@@ -46,3 +47,14 @@ class TestProfileType(base.TestCase):
self.assertEqual(FAKE['name'], sot.name)
self.assertEqual(FAKE['schema'], sot.schema)
self.assertEqual(FAKE['support_status'], sot.support_status)
def test_ops(self):
sot = profile_type.ProfileType(**FAKE)
resp = mock.Mock()
resp.json = mock.Mock(return_value='')
sess = mock.Mock()
sess.get = mock.Mock(return_value=resp)
self.assertEqual('', sot.type_ops(sess))
url = 'profile-types/%s/ops' % sot.id
sess.get.assert_called_once_with(url)

View File

@@ -576,3 +576,15 @@ class TestClusterProxy(test_proxy_base.TestProxyBase):
self.proxy.wait_for_delete(mock_resource, 1, 2)
mock_wait.assert_called_once_with(self.proxy, mock_resource, 1, 2)
@deprecation.fail_if_not_removed
@mock.patch.object(proxy_base.Proxy, '_get_resource')
def test_profile_type_ops(self, mock_get):
mock_profile = profile_type.ProfileType.new(id='FAKE_PROFILE')
mock_get.return_value = mock_profile
self._verify(
"openstack.clustering.v1.profile_type.ProfileType.type_ops",
self.proxy.list_profile_type_operations,
method_args=["FAKE_PROFILE"])
mock_get.assert_called_once_with(profile_type.ProfileType,
"FAKE_PROFILE")