Import mistral python client directly

Python mistral client is now part of requirements.txt.
So this patch fixes mistral client plug-in and test
cases to use it directly.

Closes-bug:  #1477498

Change-Id: I334d0d7997000e7fb3e077930442838b7e0b0290
This commit is contained in:
Kanagaraj Manickam 2015-07-23 16:28:11 +05:30
parent 0084ae365d
commit b31f4f8bcb
6 changed files with 4 additions and 55 deletions

View File

@ -11,13 +11,11 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import importutils
from mistralclient.api import base as mistral_base
from mistralclient.api import client as mistral_client
from heat.engine.clients import client_plugin
mistral_base = importutils.try_import('mistralclient.api.base')
mistral_client = importutils.try_import('mistralclient.api.client')
class MistralClientPlugin(client_plugin.ClientPlugin):

View File

@ -13,7 +13,6 @@
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import clients
from heat.engine import properties
from heat.engine import resource
from heat.engine import support
@ -127,10 +126,3 @@ def resource_mapping():
return {
'OS::Mistral::CronTrigger': CronTrigger,
}
def available_resource_mapping():
if not clients.has_client(CronTrigger.default_client_name):
return {}
return resource_mapping()

View File

@ -18,7 +18,6 @@ import yaml
from heat.common import exception
from heat.common.i18n import _
from heat.engine import attributes
from heat.engine import clients
from heat.engine import constraints
from heat.engine import properties
from heat.engine import resource
@ -415,10 +414,3 @@ def resource_mapping():
return {
'OS::Mistral::Workflow': Workflow
}
def available_resource_mapping():
if not clients.has_client(Workflow.default_client_name):
return {}
return resource_mapping()

View File

@ -11,18 +11,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import importutils
import testtools
from heat.tests import common
from heat.tests import utils
mistral_client = importutils.try_import('mistralclient.api.base')
class MistralClientPluginTests(common.HeatTestCase):
@testtools.skipIf(mistral_client is None, 'Tests the mistral client')
def test_create(self):
context = utils.dummy_context()
plugin = context.clients.client_plugin('mistral')

View File

@ -12,21 +12,14 @@
# under the License.
import mock
from oslo_utils import importutils
import testtools
from heat.common import exception
from heat.common import template_format
from heat.engine import resources
from heat.engine.resources.openstack.mistral import cron_trigger
from heat.engine import scheduler
from heat.engine import stack as stack_parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils
mistral_client = importutils.try_import('mistralclient.api.base')
stack_template = '''
heat_template_version: 2013-05-23
@ -121,10 +114,3 @@ class MistralCronTriggerTest(common.HeatTestCase):
self.assertEqual((ct.DELETE, ct.COMPLETE), ct.state)
self.client.cron_triggers.delete.assert_called_once_with(
ct.resource_id)
@testtools.skipIf(mistral_client is not None,
'Tests mistral client not installed')
def test_no_client(self):
tmpl = template.Template((template_format.parse(stack_template)))
stack = stack_parser.Stack(utils.dummy_context(), 'foo', tmpl)
self.assertRaises(exception.ResourceTypeNotFound, stack.validate)

View File

@ -12,9 +12,9 @@
# under the License.
import mock
from oslo_utils import importutils
import six
import testtools
from mistralclient.api.v2 import executions
from heat.common import exception
from heat.common import template_format
@ -25,14 +25,10 @@ from heat.engine.resources.openstack.mistral import workflow
from heat.engine.resources import signal_responder
from heat.engine.resources import stack_user
from heat.engine import scheduler
from heat.engine import stack as stack_parser
from heat.engine import template
from heat.tests import common
from heat.tests import utils
mistral_client = importutils.try_import('mistralclient.api.base')
executions = importutils.try_import('mistralclient.api.v2.executions')
workflow_template = """
heat_template_version: 2013-05-23
resources:
@ -434,8 +430,6 @@ class TestMistralWorkflow(common.HeatTestCase):
"Signal data error: Unknown input 1")
self.assertEqual(error_message, six.text_type(err))
@testtools.skipIf(executions is None,
'Uses the actual mistral client')
def test_signal_and_delete_with_executions(self):
tmpl = template_format.parse(workflow_template_full)
stack = utils.parse_stack(tmpl)
@ -510,10 +504,3 @@ class TestMistralWorkflow(common.HeatTestCase):
execution = mock.Mock()
execution.id = '12345'
return execution
@testtools.skipIf(mistral_client is not None,
'Tests mistral client not installed')
def test_no_client(self):
tmpl = template.Template((template_format.parse(workflow_template)))
stack = stack_parser.Stack(utils.dummy_context(), 'foo', tmpl)
self.assertRaises(exception.ResourceTypeNotFound, stack.validate)