Merge "Extracting generator objects returned by openstack actions"

This commit is contained in:
Jenkins 2015-10-16 10:27:15 +00:00 committed by Gerrit Code Review
commit ae0d5e9efe
2 changed files with 7 additions and 15 deletions

View File

@ -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

View File

@ -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)