Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError thrown while creating client by "_create_client() " method #2

Open
dineshbhor opened this issue Jul 21, 2017 · 2 comments
Open

Comments

@dineshbhor
Copy link
Contributor

After fixing the issue [1] if you try to execute actions registered by mistral-actions the "_create_client() " method from mistral_actions.openstack.py gives TypeError.

Steps:
1] Fix the issue [1]
2] Try to execute any action registered by mistral-actions
ex: mistral run-action int32bit.nova.servers.assert_status input.json

input.json:
{
"server_id": "1229b18b-120b-4382-87c3-c56f55f5b22e"
}

Observed traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/server.py", line 160, in _process_incoming
    res = self.dispatcher.dispatch(message)
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 213, in dispatch
    return self._do_dispatch(endpoint, method, ctxt, args)
  File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 183, in _do_dispatch
    result = func(ctxt, **new_args)
 File "/opt/stack/mistral/mistral/engine/engine_server.py", line 128, in start_action
    **params
  File "/opt/stack/mistral/mistral/engine/action_queue.py", line 74, in decorate
    res = func(*args, **kw)
  File "/opt/stack/mistral/mistral/engine/default_engine.py", line 63, in start_action
    is_action_sync = action.is_sync(action_input)
  File "/opt/stack/mistral/mistral/engine/actions.py", line 276, in is_sync
    a = a_m.get_action_class(self.action_def.name)(**input_dict)
  File "/usr/local/lib/python2.7/dist-packages/mistral_actions/nova/servers.py", line 13, in __init__
    super(AssertStatus, self).__init__('nova')
  File "/usr/local/lib/python2.7/dist-packages/mistral_actions/openstack.py", line 8, in __init__
    self.client = self._get_client()
  File "/usr/local/lib/python2.7/dist-packages/mistral_actions/openstack.py", line 14, in _get_client
    return getattr(action_obj, '_create_client')()
TypeError: _create_client() takes exactly 2 arguments (1 given)

This issue can be fixed by providing mistral context to _create_client() method like below:

diff --git a/mistral_actions/openstack.py b/mistral_actions/openstack.py
index d6cd2dd..1432c52 100644
--- a/mistral_actions/openstack.py
+++ b/mistral_actions/openstack.py
@@ -1,5 +1,6 @@
 from mistral.actions.base import Action as action_base
 from mistral.actions.openstack import actions as os_actions
+from mistral import context


 class OpenstackBase(action_base):
@@ -11,6 +12,6 @@ class OpenstackBase(action_base):
         action_obj = getattr(os_actions, "%sAction" % self.service)()
         # New version use _create_client()
         if hasattr(action_obj, '_create_client'):
-            return getattr(action_obj, '_create_client')()
+            return getattr(action_obj, '_create_client')(context.ctx())
         # Fallback to _get_client()
         return action_obj._get_client()

[1] #1

@int32bit
Copy link
Owner

Thanks @dineshbhor, look forward to your PR.

@dineshbhor
Copy link
Contributor Author

Hi @int32bit Please see my PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants