From d39a59f473d8fc7ed1705d03aa2fa96f0b65dc02 Mon Sep 17 00:00:00 2001 From: Renat Akhmerov Date: Fri, 16 Oct 2015 15:12:50 +0600 Subject: [PATCH] Extracting generator objects returned by openstack actions Change-Id: Ia2956295d4c9773b6203904699a2ae6ecf245348 --- mistral/actions/openstack/actions.py | 14 -------------- mistral/actions/openstack/base.py | 8 +++++++- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/mistral/actions/openstack/actions.py b/mistral/actions/openstack/actions.py index cbc0aaba..b99d78e6 100644 --- a/mistral/actions/openstack/actions.py +++ b/mistral/actions/openstack/actions.py @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import inspect - from cinderclient.v1 import client as cinderclient from glanceclient.v2 import client as glanceclient from heatclient.v1 import client as heatclient @@ -26,7 +24,6 @@ from oslo_log import log from mistral.actions.openstack import base from mistral import context -from mistral import exceptions as exc from mistral.utils.openstack import keystone as keystone_utils @@ -152,17 +149,6 @@ class HeatAction(base.OpenStackAction): def _get_fake_client(cls): return cls._client_class("") - def run(self): - try: - method = self._get_client_method(self._get_client()) - result = method(**self._kwargs_for_run) - if inspect.isgenerator(result): - return [v for v in result] - return result - except Exception as e: - raise exc.ActionException("%s failed: %s" - % (self.__class__.__name__, e)) - class NeutronAction(base.OpenStackAction): _client_class = neutronclient.Client diff --git a/mistral/actions/openstack/base.py b/mistral/actions/openstack/base.py index b0125170..ae091379 100644 --- a/mistral/actions/openstack/base.py +++ b/mistral/actions/openstack/base.py @@ -13,6 +13,7 @@ # limitations under the License. import abc +import inspect from mistral.actions import base from mistral import exceptions as exc @@ -69,7 +70,12 @@ class OpenStackAction(base.Action): try: method = self._get_client_method(self._get_client()) - return method(**self._kwargs_for_run) + result = method(**self._kwargs_for_run) + + if inspect.isgenerator(result): + return [v for v in result] + + return result except Exception as e: e_str = '%s: %s' % (type(e), e.message)