From e0a9347ebc3e7a0ad2d267f63a2d8691a65985d0 Mon Sep 17 00:00:00 2001
From: Szymon Konefal <szymon.konefal@gmail.com>
Date: Fri, 19 Aug 2016 15:13:31 +0200
Subject: [PATCH] Remove Kazoo dependency and Kolla Zookeeper helper

Related-Bug: #1577194

Change-Id: Idad2a78d3b4251a321c1a05b435bff4625d5fe56
---
 docker/kolla-toolbox/Dockerfile.j2      |  2 +-
 docker/kolla-toolbox/kolla_zookeeper.py | 68 -------------------------
 docker/openstack-base/Dockerfile.j2     |  1 -
 kolla/common/config.py                  |  2 +-
 4 files changed, 2 insertions(+), 71 deletions(-)
 delete mode 100644 docker/kolla-toolbox/kolla_zookeeper.py

diff --git a/docker/kolla-toolbox/Dockerfile.j2 b/docker/kolla-toolbox/Dockerfile.j2
index a983df7981..43f6cf6acc 100644
--- a/docker/kolla-toolbox/Dockerfile.j2
+++ b/docker/kolla-toolbox/Dockerfile.j2
@@ -60,7 +60,7 @@ RUN useradd -m --user-group ansible --groups kolla \
     && echo 'localhost ansible_connection=local' > /etc/ansible/hosts \
     && sed -i 's|  "identity_api_version": "2.0",|  "identity_api_version": "3",|' {{ os_client_config }}
 
-COPY find_disks.py kolla_keystone_service.py kolla_keystone_user.py kolla_sanity.py kolla_zookeeper.py /usr/share/ansible/
+COPY find_disks.py kolla_keystone_service.py kolla_keystone_user.py kolla_sanity.py /usr/share/ansible/
 COPY ansible.cfg /home/ansible/.ansible.cfg
 
 COPY ansible_sudoers /etc/sudoers.d/ansible_sudoers
diff --git a/docker/kolla-toolbox/kolla_zookeeper.py b/docker/kolla-toolbox/kolla_zookeeper.py
deleted file mode 100644
index 3142c0f5a9..0000000000
--- a/docker/kolla-toolbox/kolla_zookeeper.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/python
-
-#    Copyright 2015 Mirantis, Inc.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import contextlib
-import traceback
-
-import kazoo.client
-import kazoo.exceptions
-
-
-@contextlib.contextmanager
-def zk_connection(zk_host, zk_port):
-    zk = kazoo.client.KazooClient(hosts='{}:{}'.format(zk_host, zk_port))
-    zk.start()
-    yield zk
-    zk.stop()
-
-
-def main():
-    module = AnsibleModule(
-        argument_spec=dict(
-            zk_host=dict(required=True, type='str'),
-            zk_port=dict(required=True, type='str'),
-            path=dict(required=True, type='str'),
-            value=dict(required=False, default=None, type='str')
-        )
-    )
-
-    try:
-        zk_host = module.params.pop('zk_host')
-        zk_port = module.params.pop('zk_port')
-        path = module.params.pop('path')
-        value = module.params.pop('value')
-
-        changed = False
-        with zk_connection(zk_host, zk_port) as zk:
-            try:
-                zk.get(path)
-            except kazoo.exceptions.NoNodeError:
-                if value is None:
-                    zk.create(path, makepath=True)
-                else:
-                    zk.create(path, value=value.encode(), makepath=True)
-                changed = True
-
-        module.exit_json(changed=changed)
-    except Exception:
-        module.exit_json(failed=True, changed=True,
-                         msg=repr(traceback.format_exc()))
-
-
-# import module snippets
-from ansible.module_utils.basic import *  # noqa
-if __name__ == '__main__':
-    main()
diff --git a/docker/openstack-base/Dockerfile.j2 b/docker/openstack-base/Dockerfile.j2
index 9b58097864..6471d3621b 100644
--- a/docker/openstack-base/Dockerfile.j2
+++ b/docker/openstack-base/Dockerfile.j2
@@ -264,7 +264,6 @@ RUN ln -s openstack-base-source/* /requirements \
         jsonpatch \
         jsonpointer \
         jsonschema \
-        kazoo \
         keystoneauth1 \
         keystonemiddleware \
         kombu \
diff --git a/kolla/common/config.py b/kolla/common/config.py
index 2f5c436730..38e94f27e7 100644
--- a/kolla/common/config.py
+++ b/kolla/common/config.py
@@ -45,7 +45,7 @@ _PROFILE_OPTS = [
                 help='Main images'),
     cfg.ListOpt('aux',
                 default=['aodh', 'designate', 'gnocchi', 'ironic',
-                         'magnum', 'mistral', 'trove,' 'zaqar', 'zookeeper',
+                         'magnum', 'mistral', 'trove,' 'zaqar',
                          'congress'],
                 help='Aux Images'),
     cfg.ListOpt('default',