Get rid of normalization in orchestration CL
Stop using normalization in the orchestration cloud layer methods. Change-Id: I9c674242f6da87923fc8a4adc9a2428030094f00
This commit is contained in:
parent
b23de23ee7
commit
f34ea0d13f
@ -15,7 +15,6 @@
|
|||||||
# openstack.resource.Resource.list and openstack.resource2.Resource.list
|
# openstack.resource.Resource.list and openstack.resource2.Resource.list
|
||||||
import types # noqa
|
import types # noqa
|
||||||
|
|
||||||
from openstack.cloud import _normalize
|
|
||||||
from openstack.cloud import _utils
|
from openstack.cloud import _utils
|
||||||
from openstack.cloud import exc
|
from openstack.cloud import exc
|
||||||
from openstack.orchestration.util import event_utils
|
from openstack.orchestration.util import event_utils
|
||||||
@ -30,7 +29,7 @@ def _no_pending_stacks(stacks):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class OrchestrationCloudMixin(_normalize.Normalizer):
|
class OrchestrationCloudMixin:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _orchestration_client(self):
|
def _orchestration_client(self):
|
||||||
@ -213,13 +212,13 @@ class OrchestrationCloudMixin(_normalize.Normalizer):
|
|||||||
"""List all stacks.
|
"""List all stacks.
|
||||||
|
|
||||||
:param dict query: Query parameters to limit stacks.
|
:param dict query: Query parameters to limit stacks.
|
||||||
:returns: a list of ``munch.Munch`` containing the stack description.
|
:returns: a list of :class:`openstack.orchestration.v1.stack.Stack`
|
||||||
|
objects containing the stack description.
|
||||||
|
|
||||||
:raises: ``OpenStackCloudException`` if something goes wrong during the
|
:raises: ``OpenStackCloudException`` if something goes wrong during the
|
||||||
OpenStack API call.
|
OpenStack API call.
|
||||||
"""
|
"""
|
||||||
data = self.orchestration.stacks(**query)
|
return list(self.orchestration.stacks(**query))
|
||||||
return self._normalize_stacks(data)
|
|
||||||
|
|
||||||
def get_stack(self, name_or_id, filters=None, resolve_outputs=True):
|
def get_stack(self, name_or_id, filters=None, resolve_outputs=True):
|
||||||
"""Get exactly one stack.
|
"""Get exactly one stack.
|
||||||
@ -230,7 +229,8 @@ class OrchestrationCloudMixin(_normalize.Normalizer):
|
|||||||
:param resolve_outputs: If True, then outputs for this
|
:param resolve_outputs: If True, then outputs for this
|
||||||
stack will be resolved
|
stack will be resolved
|
||||||
|
|
||||||
:returns: a ``munch.Munch`` containing the stack description
|
:returns: a :class:`openstack.orchestration.v1.stack.Stack`
|
||||||
|
containing the stack description
|
||||||
|
|
||||||
:raises: ``OpenStackCloudException`` if something goes wrong during the
|
:raises: ``OpenStackCloudException`` if something goes wrong during the
|
||||||
OpenStack API call or if multiple matches are found.
|
OpenStack API call or if multiple matches are found.
|
||||||
@ -248,7 +248,6 @@ class OrchestrationCloudMixin(_normalize.Normalizer):
|
|||||||
return []
|
return []
|
||||||
except exc.OpenStackCloudURINotFound:
|
except exc.OpenStackCloudURINotFound:
|
||||||
return []
|
return []
|
||||||
stack = self._normalize_stack(stack)
|
|
||||||
return _utils._filter_list([stack], name_or_id, filters)
|
return _utils._filter_list([stack], name_or_id, filters)
|
||||||
|
|
||||||
return _utils._get_entity(
|
return _utils._get_entity(
|
||||||
|
@ -29,6 +29,11 @@ class TestStack(base.TestCase):
|
|||||||
self.stack_tag = self.getUniqueString('tag')
|
self.stack_tag = self.getUniqueString('tag')
|
||||||
self.stack = fakes.make_fake_stack(self.stack_id, self.stack_name)
|
self.stack = fakes.make_fake_stack(self.stack_id, self.stack_name)
|
||||||
|
|
||||||
|
def _compare_stacks(self, exp, real):
|
||||||
|
self.assertDictEqual(
|
||||||
|
stack.Stack(**exp).to_dict(computed=False),
|
||||||
|
real.to_dict(computed=False))
|
||||||
|
|
||||||
def test_list_stacks(self):
|
def test_list_stacks(self):
|
||||||
fake_stacks = [
|
fake_stacks = [
|
||||||
self.stack,
|
self.stack,
|
||||||
@ -43,10 +48,7 @@ class TestStack(base.TestCase):
|
|||||||
json={"stacks": fake_stacks}),
|
json={"stacks": fake_stacks}),
|
||||||
])
|
])
|
||||||
stacks = self.cloud.list_stacks()
|
stacks = self.cloud.list_stacks()
|
||||||
self.assertEqual(
|
[self._compare_stacks(b, a) for a, b in zip(stacks, fake_stacks)]
|
||||||
[f.toDict() for f in self.cloud._normalize_stacks(
|
|
||||||
stack.Stack(**st) for st in fake_stacks)],
|
|
||||||
[f.toDict() for f in stacks])
|
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -67,10 +69,7 @@ class TestStack(base.TestCase):
|
|||||||
json={"stacks": fake_stacks}),
|
json={"stacks": fake_stacks}),
|
||||||
])
|
])
|
||||||
stacks = self.cloud.list_stacks(name='a', status='b')
|
stacks = self.cloud.list_stacks(name='a', status='b')
|
||||||
self.assertEqual(
|
[self._compare_stacks(b, a) for a, b in zip(stacks, fake_stacks)]
|
||||||
[f.toDict() for f in self.cloud._normalize_stacks(
|
|
||||||
stack.Stack(**st) for st in fake_stacks)],
|
|
||||||
[f.toDict() for f in stacks])
|
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -100,10 +99,7 @@ class TestStack(base.TestCase):
|
|||||||
json={"stacks": fake_stacks}),
|
json={"stacks": fake_stacks}),
|
||||||
])
|
])
|
||||||
stacks = self.cloud.search_stacks()
|
stacks = self.cloud.search_stacks()
|
||||||
self.assertEqual(
|
[self._compare_stacks(b, a) for a, b in zip(stacks, fake_stacks)]
|
||||||
self.cloud._normalize_stacks(
|
|
||||||
stack.Stack(**st) for st in fake_stacks),
|
|
||||||
stacks)
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_search_stacks_filters(self):
|
def test_search_stacks_filters(self):
|
||||||
@ -122,10 +118,7 @@ class TestStack(base.TestCase):
|
|||||||
])
|
])
|
||||||
filters = {'status': 'FAILED'}
|
filters = {'status': 'FAILED'}
|
||||||
stacks = self.cloud.search_stacks(filters=filters)
|
stacks = self.cloud.search_stacks(filters=filters)
|
||||||
self.assertEqual(
|
[self._compare_stacks(b, a) for a, b in zip(stacks, fake_stacks)]
|
||||||
self.cloud._normalize_stacks(
|
|
||||||
stack.Stack(**st) for st in fake_stacks[1:]),
|
|
||||||
stacks)
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
def test_search_stacks_exception(self):
|
def test_search_stacks_exception(self):
|
||||||
@ -618,10 +611,9 @@ class TestStack(base.TestCase):
|
|||||||
|
|
||||||
res = self.cloud.get_stack(self.stack_name)
|
res = self.cloud.get_stack(self.stack_name)
|
||||||
self.assertIsNotNone(res)
|
self.assertIsNotNone(res)
|
||||||
self.assertEqual(self.stack['stack_name'], res['stack_name'])
|
|
||||||
self.assertEqual(self.stack['stack_name'], res['name'])
|
self.assertEqual(self.stack['stack_name'], res['name'])
|
||||||
self.assertEqual(self.stack['stack_status'], res['stack_status'])
|
self.assertEqual(self.stack['stack_status'], res['stack_status'])
|
||||||
self.assertEqual('COMPLETE', res['status'])
|
self.assertEqual('CREATE_COMPLETE', res['status'])
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
|
||||||
@ -647,10 +639,8 @@ class TestStack(base.TestCase):
|
|||||||
|
|
||||||
res = self.cloud.get_stack(self.stack_name)
|
res = self.cloud.get_stack(self.stack_name)
|
||||||
self.assertIsNotNone(res)
|
self.assertIsNotNone(res)
|
||||||
self.assertEqual(in_progress['stack_name'], res['stack_name'])
|
self.assertEqual(in_progress['stack_name'], res.name)
|
||||||
self.assertEqual(in_progress['stack_name'], res['name'])
|
|
||||||
self.assertEqual(in_progress['stack_status'], res['stack_status'])
|
self.assertEqual(in_progress['stack_status'], res['stack_status'])
|
||||||
self.assertEqual('CREATE', res['action'])
|
self.assertEqual('CREATE_IN_PROGRESS', res['status'])
|
||||||
self.assertEqual('IN_PROGRESS', res['status'])
|
|
||||||
|
|
||||||
self.assert_calls()
|
self.assert_calls()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user