We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
znode - 'object is not iterable'
##### Issue Type:

Bug Report
##### Ansible Version:

```
$ ansible --version
ansible 2.1.0
  config file =
  configured module search path = Default w/o overrides
```
##### Ansible Configuration:

Default
##### Environment:
- Running from OSX
- Managing Centos7
##### Summary:

Attempting to add a znode to a remote Zookeeper server results in an `object not iterable` error.
##### Steps To Reproduce:

Run this playbook against a Zookeeper server.

``` yml

---
- hosts: 127.0.0.1
  connection: local
  gather_facts: no
  tasks:
    - action: znode hosts=[ZK_SERVER_ADDR]:2181 name=/mypath value=myvalue state=present
```
##### Expected Results:

I would expect a znode to be added to the Zookeeper server if it didn't exist, update the value if the value was different, and do nothing if the znode existed and required to updating.
##### Actual Results:

```
$ ansible-playbook -vvv znode-present-test.yml
No config file found; using defaults
 [WARNING]: provided hosts list is empty, only localhost is available

1 plays in znode-present-test.yml

PLAY ***************************************************************************

TASK [znode state=present hosts=[ZK_SERVER_ADDR]:2181 name=/mypath value=myvalue] **
task path: .../znode-present-test.yml:6
...
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "~/.ansible/tmp/ansible-tmp-1449761490.97-163319842606327/znode", line 2151, in <module>
    main()
  File "~/.ansible/tmp/ansible-tmp-1449761490.97-163319842606327/znode", line 126, in main
    result, result_dict = command_dict[command_type][method]
TypeError: 'instancemethod' object is not iterable

fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"hosts": "[ZK_SERVER_ADDR]:2181", "name": "/mypath", "state": "present", "value": "myvalue"}, "module_name": "znode"}, "parsed": false}

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=1
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `clustering/znode.py`
Content:
```
1 #!/usr/bin/python
2 # Copyright 2015 WP Engine, Inc. All rights reserved.
3 #
4 # This file is part of Ansible
5 #
6 # Ansible is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Ansible is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
18 
19 DOCUMENTATION = """
20 ---
21 module: znode
22 version_added: "2.0"
23 short_description: Create, delete, retrieve, and update znodes using ZooKeeper.
24 options:
25     hosts:
26         description:
27             - A list of ZooKeeper servers (format '[server]:[port]').
28         required: true
29     name:
30         description:
31             - The path of the znode.
32         required: true
33     value:
34         description:
35             - The value assigned to the znode.
36         default: None
37         required: false
38     op:
39         description:
40             - An operation to perform. Mutually exclusive with state.
41         default: None
42         required: false
43     state:
44         description:
45             - The state to enforce. Mutually exclusive with op.
46         default: None
47         required: false
48     timeout:
49         description:
50             - The amount of time to wait for a node to appear.
51         default: 300
52         required: false
53 requirements:
54     - kazoo >= 2.1
55     - python >= 2.6
56 author: "Trey Perry (@treyperry)"
57 """
58 
59 EXAMPLES = """
60 # Creating or updating a znode with a given value
61 - action: znode hosts=localhost:2181 name=/mypath value=myvalue state=present
62 
63 # Getting the value and stat structure for a znode
64 - action: znode hosts=localhost:2181 name=/mypath op=get
65 
66 # Listing a particular znode's children
67 - action: znode hosts=localhost:2181 name=/zookeeper op=list
68 
69 # Waiting 20 seconds for a znode to appear at path /mypath
70 - action: znode hosts=localhost:2181 name=/mypath op=wait timeout=20
71 
72 # Deleting a znode at path /mypath
73 - action: znode hosts=localhost:2181 name=/mypath state=absent
74 """
75 
76 try:
77     from kazoo.client import KazooClient
78     from kazoo.exceptions import NoNodeError, ZookeeperError
79     from kazoo.handlers.threading import KazooTimeoutError
80     KAZOO_INSTALLED = True
81 except ImportError:
82     KAZOO_INSTALLED = False
83 
84 
85 def main():
86     module = AnsibleModule(
87         argument_spec=dict(
88             hosts=dict(required=True, type='str'),
89             name=dict(required=True, type='str'),
90             value=dict(required=False, default=None, type='str'),
91             op=dict(required=False, default=None, choices=['get', 'wait', 'list']),
92             state=dict(choices=['present', 'absent']),
93             timeout=dict(required=False, default=300, type='int')
94         ),
95         supports_check_mode=False
96     )
97 
98     if not KAZOO_INSTALLED:
99         module.fail_json(msg='kazoo >= 2.1 is required to use this module. Use pip to install it.')
100 
101     check = check_params(module.params)
102     if not check['success']:
103         module.fail_json(msg=check['msg'])
104 
105     zoo = KazooCommandProxy(module)
106     try:
107         zoo.start()
108     except KazooTimeoutError:
109         module.fail_json(msg='The connection to the ZooKeeper ensemble timed out.')
110 
111     command_dict = {
112         'op': {
113             'get': zoo.get,
114             'list': zoo.list,
115             'wait': zoo.wait
116         },
117         'state': {
118             'present': zoo.present,
119             'absent': zoo.absent
120         }
121     }
122 
123     command_type = 'op' if 'op' in module.params and module.params['op'] is not None else 'state'
124     method = module.params[command_type]
125     result, result_dict = command_dict[command_type][method]
126     zoo.shutdown()
127 
128     if result:
129         module.exit_json(**result_dict)
130     else:
131         module.fail_json(**result_dict)
132 
133 
134 def check_params(params):
135     if not params['state'] and not params['op']:
136         return {'success': False, 'msg': 'Please define an operation (op) or a state.'}
137 
138     if params['state'] and params['op']:
139         return {'success': False, 'msg': 'Please choose an operation (op) or a state, but not both.'}
140 
141     return {'success': True}
142 
143 
144 class KazooCommandProxy():
145     def __init__(self, module):
146         self.module = module
147         self.zk = KazooClient(module.params['hosts'])
148 
149     def absent(self):
150         return self._absent(self.module.params['name'])
151 
152     def exists(self, znode):
153         return self.zk.exists(znode)
154 
155     def list(self):
156         children = self.zk.get_children(self.module.params['name'])
157         return True, {'count': len(children), 'items': children, 'msg': 'Retrieved znodes in path.',
158                       'znode': self.module.params['name']}
159 
160     def present(self):
161         return self._present(self.module.params['name'], self.module.params['value'])
162 
163     def get(self):
164         return self._get(self.module.params['name'])
165 
166     def shutdown(self):
167         self.zk.stop()
168         self.zk.close()
169 
170     def start(self):
171         self.zk.start()
172 
173     def wait(self):
174         return self._wait(self.module.params['name'], self.module.params['timeout'])
175 
176     def _absent(self, znode):
177         if self.exists(znode):
178             self.zk.delete(znode)
179             return True, {'changed': True, 'msg': 'The znode was deleted.'}
180         else:
181             return True, {'changed': False, 'msg': 'The znode does not exist.'}
182 
183     def _get(self, path):
184         if self.exists(path):
185             value, zstat = self.zk.get(path)
186             stat_dict = {}
187             for i in dir(zstat):
188                 if not i.startswith('_'):
189                     attr = getattr(zstat, i)
190                     if type(attr) in (int, str):
191                         stat_dict[i] = attr
192             result = True, {'msg': 'The node was retrieved.', 'znode': path, 'value': value,
193                             'stat': stat_dict}
194         else:
195             result = False, {'msg': 'The requested node does not exist.'}
196 
197         return result
198 
199     def _present(self, path, value):
200         if self.exists(path):
201             (current_value, zstat) = self.zk.get(path)
202             if value != current_value:
203                 self.zk.set(path, value)
204                 return True, {'changed': True, 'msg': 'Updated the znode value.', 'znode': path,
205                               'value': value}
206             else:
207                 return True, {'changed': False, 'msg': 'No changes were necessary.', 'znode': path, 'value': value}
208         else:
209             self.zk.create(path, value, makepath=True)
210             return True, {'changed': True, 'msg': 'Created a new znode.', 'znode': path, 'value': value}
211 
212     def _wait(self, path, timeout, interval=5):
213         lim = time.time() + timeout
214 
215         while time.time() < lim:
216             if self.exists(path):
217                 return True, {'msg': 'The node appeared before the configured timeout.',
218                               'znode': path, 'timeout': timeout}
219             else:
220                 time.sleep(interval)
221 
222         return False, {'msg': 'The node did not appear before the operation timed out.', 'timeout': timeout,
223                        'znode': path}
224 
225 from ansible.module_utils.basic import *
226 
227 main()
228 
229
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/clustering/znode.py b/clustering/znode.py
--- a/clustering/znode.py
+++ b/clustering/znode.py
@@ -122,7 +122,7 @@
 
     command_type = 'op' if 'op' in module.params and module.params['op'] is not None else 'state'
     method = module.params[command_type]
-    result, result_dict = command_dict[command_type][method]
+    result, result_dict = command_dict[command_type][method]()
     zoo.shutdown()
 
     if result:
@@ -225,4 +225,3 @@
 from ansible.module_utils.basic import *
 
 main()
-

{"golden_diff": "diff --git a/clustering/znode.py b/clustering/znode.py\n--- a/clustering/znode.py\n+++ b/clustering/znode.py\n@@ -122,7 +122,7 @@\n \n     command_type = 'op' if 'op' in module.params and module.params['op'] is not None else 'state'\n     method = module.params[command_type]\n-    result, result_dict = command_dict[command_type][method]\n+    result, result_dict = command_dict[command_type][method]()\n     zoo.shutdown()\n \n     if result:\n@@ -225,4 +225,3 @@\n from ansible.module_utils.basic import *\n \n main()\n-\n", "issue": "znode - 'object is not iterable'\n##### Issue Type:\n\nBug Report\n##### Ansible Version:\n\n```\n$ ansible --version\nansible 2.1.0\n  config file =\n  configured module search path = Default w/o overrides\n```\n##### Ansible Configuration:\n\nDefault\n##### Environment:\n- Running from OSX\n- Managing Centos7\n##### Summary:\n\nAttempting to add a znode to a remote Zookeeper server results in an `object not iterable` error.\n##### Steps To Reproduce:\n\nRun this playbook against a Zookeeper server.\n\n``` yml\n\n---\n- hosts: 127.0.0.1\n  connection: local\n  gather_facts: no\n  tasks:\n    - action: znode hosts=[ZK_SERVER_ADDR]:2181 name=/mypath value=myvalue state=present\n```\n##### Expected Results:\n\nI would expect a znode to be added to the Zookeeper server if it didn't exist, update the value if the value was different, and do nothing if the znode existed and required to updating.\n##### Actual Results:\n\n```\n$ ansible-playbook -vvv znode-present-test.yml\nNo config file found; using defaults\n [WARNING]: provided hosts list is empty, only localhost is available\n\n1 plays in znode-present-test.yml\n\nPLAY ***************************************************************************\n\nTASK [znode state=present hosts=[ZK_SERVER_ADDR]:2181 name=/mypath value=myvalue] **\ntask path: .../znode-present-test.yml:6\n...\nAn exception occurred during task execution. The full traceback is:\nTraceback (most recent call last):\n  File \"~/.ansible/tmp/ansible-tmp-1449761490.97-163319842606327/znode\", line 2151, in <module>\n    main()\n  File \"~/.ansible/tmp/ansible-tmp-1449761490.97-163319842606327/znode\", line 126, in main\n    result, result_dict = command_dict[command_type][method]\nTypeError: 'instancemethod' object is not iterable\n\nfatal: [127.0.0.1]: FAILED! => {\"changed\": false, \"failed\": true, \"invocation\": {\"module_args\": {\"hosts\": \"[ZK_SERVER_ADDR]:2181\", \"name\": \"/mypath\", \"state\": \"present\", \"value\": \"myvalue\"}, \"module_name\": \"znode\"}, \"parsed\": false}\n\nPLAY RECAP *********************************************************************\n127.0.0.1                  : ok=0    changed=0    unreachable=0    failed=1\n```\n\n", "before_files": [{"content": "#!/usr/bin/python\n# Copyright 2015 WP Engine, Inc. All rights reserved.\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n\nDOCUMENTATION = \"\"\"\n---\nmodule: znode\nversion_added: \"2.0\"\nshort_description: Create, delete, retrieve, and update znodes using ZooKeeper.\noptions:\n    hosts:\n        description:\n            - A list of ZooKeeper servers (format '[server]:[port]').\n        required: true\n    name:\n        description:\n            - The path of the znode.\n        required: true\n    value:\n        description:\n            - The value assigned to the znode.\n        default: None\n        required: false\n    op:\n        description:\n            - An operation to perform. Mutually exclusive with state.\n        default: None\n        required: false\n    state:\n        description:\n            - The state to enforce. Mutually exclusive with op.\n        default: None\n        required: false\n    timeout:\n        description:\n            - The amount of time to wait for a node to appear.\n        default: 300\n        required: false\nrequirements:\n    - kazoo >= 2.1\n    - python >= 2.6\nauthor: \"Trey Perry (@treyperry)\"\n\"\"\"\n\nEXAMPLES = \"\"\"\n# Creating or updating a znode with a given value\n- action: znode hosts=localhost:2181 name=/mypath value=myvalue state=present\n\n# Getting the value and stat structure for a znode\n- action: znode hosts=localhost:2181 name=/mypath op=get\n\n# Listing a particular znode's children\n- action: znode hosts=localhost:2181 name=/zookeeper op=list\n\n# Waiting 20 seconds for a znode to appear at path /mypath\n- action: znode hosts=localhost:2181 name=/mypath op=wait timeout=20\n\n# Deleting a znode at path /mypath\n- action: znode hosts=localhost:2181 name=/mypath state=absent\n\"\"\"\n\ntry:\n    from kazoo.client import KazooClient\n    from kazoo.exceptions import NoNodeError, ZookeeperError\n    from kazoo.handlers.threading import KazooTimeoutError\n    KAZOO_INSTALLED = True\nexcept ImportError:\n    KAZOO_INSTALLED = False\n\n\ndef main():\n    module = AnsibleModule(\n        argument_spec=dict(\n            hosts=dict(required=True, type='str'),\n            name=dict(required=True, type='str'),\n            value=dict(required=False, default=None, type='str'),\n            op=dict(required=False, default=None, choices=['get', 'wait', 'list']),\n            state=dict(choices=['present', 'absent']),\n            timeout=dict(required=False, default=300, type='int')\n        ),\n        supports_check_mode=False\n    )\n\n    if not KAZOO_INSTALLED:\n        module.fail_json(msg='kazoo >= 2.1 is required to use this module. Use pip to install it.')\n\n    check = check_params(module.params)\n    if not check['success']:\n        module.fail_json(msg=check['msg'])\n\n    zoo = KazooCommandProxy(module)\n    try:\n        zoo.start()\n    except KazooTimeoutError:\n        module.fail_json(msg='The connection to the ZooKeeper ensemble timed out.')\n\n    command_dict = {\n        'op': {\n            'get': zoo.get,\n            'list': zoo.list,\n            'wait': zoo.wait\n        },\n        'state': {\n            'present': zoo.present,\n            'absent': zoo.absent\n        }\n    }\n\n    command_type = 'op' if 'op' in module.params and module.params['op'] is not None else 'state'\n    method = module.params[command_type]\n    result, result_dict = command_dict[command_type][method]\n    zoo.shutdown()\n\n    if result:\n        module.exit_json(**result_dict)\n    else:\n        module.fail_json(**result_dict)\n\n\ndef check_params(params):\n    if not params['state'] and not params['op']:\n        return {'success': False, 'msg': 'Please define an operation (op) or a state.'}\n\n    if params['state'] and params['op']:\n        return {'success': False, 'msg': 'Please choose an operation (op) or a state, but not both.'}\n\n    return {'success': True}\n\n\nclass KazooCommandProxy():\n    def __init__(self, module):\n        self.module = module\n        self.zk = KazooClient(module.params['hosts'])\n\n    def absent(self):\n        return self._absent(self.module.params['name'])\n\n    def exists(self, znode):\n        return self.zk.exists(znode)\n\n    def list(self):\n        children = self.zk.get_children(self.module.params['name'])\n        return True, {'count': len(children), 'items': children, 'msg': 'Retrieved znodes in path.',\n                      'znode': self.module.params['name']}\n\n    def present(self):\n        return self._present(self.module.params['name'], self.module.params['value'])\n\n    def get(self):\n        return self._get(self.module.params['name'])\n\n    def shutdown(self):\n        self.zk.stop()\n        self.zk.close()\n\n    def start(self):\n        self.zk.start()\n\n    def wait(self):\n        return self._wait(self.module.params['name'], self.module.params['timeout'])\n\n    def _absent(self, znode):\n        if self.exists(znode):\n            self.zk.delete(znode)\n            return True, {'changed': True, 'msg': 'The znode was deleted.'}\n        else:\n            return True, {'changed': False, 'msg': 'The znode does not exist.'}\n\n    def _get(self, path):\n        if self.exists(path):\n            value, zstat = self.zk.get(path)\n            stat_dict = {}\n            for i in dir(zstat):\n                if not i.startswith('_'):\n                    attr = getattr(zstat, i)\n                    if type(attr) in (int, str):\n                        stat_dict[i] = attr\n            result = True, {'msg': 'The node was retrieved.', 'znode': path, 'value': value,\n                            'stat': stat_dict}\n        else:\n            result = False, {'msg': 'The requested node does not exist.'}\n\n        return result\n\n    def _present(self, path, value):\n        if self.exists(path):\n            (current_value, zstat) = self.zk.get(path)\n            if value != current_value:\n                self.zk.set(path, value)\n                return True, {'changed': True, 'msg': 'Updated the znode value.', 'znode': path,\n                              'value': value}\n            else:\n                return True, {'changed': False, 'msg': 'No changes were necessary.', 'znode': path, 'value': value}\n        else:\n            self.zk.create(path, value, makepath=True)\n            return True, {'changed': True, 'msg': 'Created a new znode.', 'znode': path, 'value': value}\n\n    def _wait(self, path, timeout, interval=5):\n        lim = time.time() + timeout\n\n        while time.time() < lim:\n            if self.exists(path):\n                return True, {'msg': 'The node appeared before the configured timeout.',\n                              'znode': path, 'timeout': timeout}\n            else:\n                time.sleep(interval)\n\n        return False, {'msg': 'The node did not appear before the operation timed out.', 'timeout': timeout,\n                       'znode': path}\n\nfrom ansible.module_utils.basic import *\n\nmain()\n\n", "path": "clustering/znode.py"}], "after_files": [{"content": "#!/usr/bin/python\n# Copyright 2015 WP Engine, Inc. All rights reserved.\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n\nDOCUMENTATION = \"\"\"\n---\nmodule: znode\nversion_added: \"2.0\"\nshort_description: Create, delete, retrieve, and update znodes using ZooKeeper.\noptions:\n    hosts:\n        description:\n            - A list of ZooKeeper servers (format '[server]:[port]').\n        required: true\n    name:\n        description:\n            - The path of the znode.\n        required: true\n    value:\n        description:\n            - The value assigned to the znode.\n        default: None\n        required: false\n    op:\n        description:\n            - An operation to perform. Mutually exclusive with state.\n        default: None\n        required: false\n    state:\n        description:\n            - The state to enforce. Mutually exclusive with op.\n        default: None\n        required: false\n    timeout:\n        description:\n            - The amount of time to wait for a node to appear.\n        default: 300\n        required: false\nrequirements:\n    - kazoo >= 2.1\n    - python >= 2.6\nauthor: \"Trey Perry (@treyperry)\"\n\"\"\"\n\nEXAMPLES = \"\"\"\n# Creating or updating a znode with a given value\n- action: znode hosts=localhost:2181 name=/mypath value=myvalue state=present\n\n# Getting the value and stat structure for a znode\n- action: znode hosts=localhost:2181 name=/mypath op=get\n\n# Listing a particular znode's children\n- action: znode hosts=localhost:2181 name=/zookeeper op=list\n\n# Waiting 20 seconds for a znode to appear at path /mypath\n- action: znode hosts=localhost:2181 name=/mypath op=wait timeout=20\n\n# Deleting a znode at path /mypath\n- action: znode hosts=localhost:2181 name=/mypath state=absent\n\"\"\"\n\ntry:\n    from kazoo.client import KazooClient\n    from kazoo.exceptions import NoNodeError, ZookeeperError\n    from kazoo.handlers.threading import KazooTimeoutError\n    KAZOO_INSTALLED = True\nexcept ImportError:\n    KAZOO_INSTALLED = False\n\n\ndef main():\n    module = AnsibleModule(\n        argument_spec=dict(\n            hosts=dict(required=True, type='str'),\n            name=dict(required=True, type='str'),\n            value=dict(required=False, default=None, type='str'),\n            op=dict(required=False, default=None, choices=['get', 'wait', 'list']),\n            state=dict(choices=['present', 'absent']),\n            timeout=dict(required=False, default=300, type='int')\n        ),\n        supports_check_mode=False\n    )\n\n    if not KAZOO_INSTALLED:\n        module.fail_json(msg='kazoo >= 2.1 is required to use this module. Use pip to install it.')\n\n    check = check_params(module.params)\n    if not check['success']:\n        module.fail_json(msg=check['msg'])\n\n    zoo = KazooCommandProxy(module)\n    try:\n        zoo.start()\n    except KazooTimeoutError:\n        module.fail_json(msg='The connection to the ZooKeeper ensemble timed out.')\n\n    command_dict = {\n        'op': {\n            'get': zoo.get,\n            'list': zoo.list,\n            'wait': zoo.wait\n        },\n        'state': {\n            'present': zoo.present,\n            'absent': zoo.absent\n        }\n    }\n\n    command_type = 'op' if 'op' in module.params and module.params['op'] is not None else 'state'\n    method = module.params[command_type]\n    result, result_dict = command_dict[command_type][method]()\n    zoo.shutdown()\n\n    if result:\n        module.exit_json(**result_dict)\n    else:\n        module.fail_json(**result_dict)\n\n\ndef check_params(params):\n    if not params['state'] and not params['op']:\n        return {'success': False, 'msg': 'Please define an operation (op) or a state.'}\n\n    if params['state'] and params['op']:\n        return {'success': False, 'msg': 'Please choose an operation (op) or a state, but not both.'}\n\n    return {'success': True}\n\n\nclass KazooCommandProxy():\n    def __init__(self, module):\n        self.module = module\n        self.zk = KazooClient(module.params['hosts'])\n\n    def absent(self):\n        return self._absent(self.module.params['name'])\n\n    def exists(self, znode):\n        return self.zk.exists(znode)\n\n    def list(self):\n        children = self.zk.get_children(self.module.params['name'])\n        return True, {'count': len(children), 'items': children, 'msg': 'Retrieved znodes in path.',\n                      'znode': self.module.params['name']}\n\n    def present(self):\n        return self._present(self.module.params['name'], self.module.params['value'])\n\n    def get(self):\n        return self._get(self.module.params['name'])\n\n    def shutdown(self):\n        self.zk.stop()\n        self.zk.close()\n\n    def start(self):\n        self.zk.start()\n\n    def wait(self):\n        return self._wait(self.module.params['name'], self.module.params['timeout'])\n\n    def _absent(self, znode):\n        if self.exists(znode):\n            self.zk.delete(znode)\n            return True, {'changed': True, 'msg': 'The znode was deleted.'}\n        else:\n            return True, {'changed': False, 'msg': 'The znode does not exist.'}\n\n    def _get(self, path):\n        if self.exists(path):\n            value, zstat = self.zk.get(path)\n            stat_dict = {}\n            for i in dir(zstat):\n                if not i.startswith('_'):\n                    attr = getattr(zstat, i)\n                    if type(attr) in (int, str):\n                        stat_dict[i] = attr\n            result = True, {'msg': 'The node was retrieved.', 'znode': path, 'value': value,\n                            'stat': stat_dict}\n        else:\n            result = False, {'msg': 'The requested node does not exist.'}\n\n        return result\n\n    def _present(self, path, value):\n        if self.exists(path):\n            (current_value, zstat) = self.zk.get(path)\n            if value != current_value:\n                self.zk.set(path, value)\n                return True, {'changed': True, 'msg': 'Updated the znode value.', 'znode': path,\n                              'value': value}\n            else:\n                return True, {'changed': False, 'msg': 'No changes were necessary.', 'znode': path, 'value': value}\n        else:\n            self.zk.create(path, value, makepath=True)\n            return True, {'changed': True, 'msg': 'Created a new znode.', 'znode': path, 'value': value}\n\n    def _wait(self, path, timeout, interval=5):\n        lim = time.time() + timeout\n\n        while time.time() < lim:\n            if self.exists(path):\n                return True, {'msg': 'The node appeared before the configured timeout.',\n                              'znode': path, 'timeout': timeout}\n            else:\n                time.sleep(interval)\n\n        return False, {'msg': 'The node did not appear before the operation timed out.', 'timeout': timeout,\n                       'znode': path}\n\nfrom ansible.module_utils.basic import *\n\nmain()\n", "path": "clustering/znode.py"}]}