{"action":"created","comment":{"url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/comments/30510699","id":30510699,"diff_hunk":"@@ -0,0 +1,128 @@\n+#!/usr/bin/env python\n+\n+# Project Clearwater - IMS in the Cloud\n+# Copyright (C) 2015 Metaswitch Networks Ltd\n+#\n+# This program is free software: you can redistribute it and/or modify it\n+# under the terms of the GNU General Public License as published by the\n+# Free Software Foundation, either version 3 of the License, or (at your\n+# option) any later version, along with the \"Special Exception\" for use of\n+# the program along with SSL, set forth below. This program is distributed\n+# in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n+# A PARTICULAR PURPOSE.  See the GNU General Public License for more\n+# details. You should have received a copy of the GNU General Public\n+# License along with this program.  If not, see\n+# <http://www.gnu.org/licenses/>.\n+#\n+# The author can be reached by email at clearwater@metaswitch.com or by\n+# post at Metaswitch Networks Ltd, 100 Church St, Enfield EN2 6BQ, UK\n+#\n+# Special Exception\n+# Metaswitch Networks Ltd  grants you permission to copy, modify,\n+# propagate, and distribute a work formed by combining OpenSSL with The\n+# Software, or a work derivative of such a combination, even if such\n+# copying, modification, propagation, or distribution would otherwise\n+# violate the terms of the GPL. You must comply with the GPL in all\n+# respects for all of the code used other than OpenSSL.\n+# \"OpenSSL\" means OpenSSL toolkit software distributed by the OpenSSL\n+# Project and licensed under the OpenSSL Licenses, or a work based on such\n+# software and licensed under the OpenSSL Licenses.\n+# \"OpenSSL Licenses\" means the OpenSSL License and Original SSLeay License\n+# under which the OpenSSL Project distributes the OpenSSL toolkit software,\n+# as those licenses appear in the file LICENSE-OPENSSL.\n+\n+\"\"\"Clearwater Config Manager\n+\n+Usage:\n+  main.py --local-ip=IP [--foreground] [--log-level=LVL] [--log-directory=DIR]\n+          [--pidfile=FILE]\n+\n+Options:\n+  -h --help                   Show this screen.\n+  --local-ip=IP               IP address\n+  --foreground                Don't daemonise\n+  --log-level=LVL             Level to log at, 0-4 [default: 3]\n+  --log-directory=DIR         Directory to log to [default: ./]\n+  --pidfile=FILE              Pidfile to write [default: ./config-manager.pid]\n+\n+\"\"\"\n+\n+from docopt import docopt\n+\n+from metaswitch.common import logging_config, utils\n+from metaswitch.clearwater.config_manager.plugin_loader \\\n+    import load_plugins_in_dir\n+from metaswitch.clearwater.config_manager.etcd_synchronizer \\\n+    import EtcdSynchronizer\n+from metaswitch.clearwater.config_manager.alarms \\\n+    import ConfigAlarm\n+import logging\n+import os\n+from threading import Thread\n+import signal\n+\n+_log = logging.getLogger(\"metaswitch.clearwater.config_manager.main\")\n+\n+LOG_LEVELS = {'0': logging.CRITICAL,\n+              '1': logging.ERROR,\n+              '2': logging.WARNING,\n+              '3': logging.INFO,\n+              '4': logging.DEBUG}\n+\n+\n+def install_sigquit_handler(plugins):\n+    def sigquit_handler(sig, stack):\n+        _log.debug(\"Handling SIGQUIT\")\n+    signal.signal(signal.SIGQUIT, sigquit_handler)\n+\n+\n+def main(args):\n+    arguments = docopt(__doc__, argv=args)\n+\n+    local_ip = arguments['--local-ip']\n+    log_dir = arguments['--log-directory']\n+    log_level = LOG_LEVELS.get(arguments['--log-level'], logging.DEBUG)\n+\n+    stdout_err_log = os.path.join(log_dir, \"config-manager.output.log\")\n+\n+    if not arguments['--foreground']:\n+        utils.daemonize(stdout_err_log)\n+\n+    logging_config.configure_logging(log_level, log_dir, \"config-manager\")\n+    utils.install_sigusr1_handler(\"config-manager\")\n+\n+    # Drop a pidfile.\n+    pid = os.getpid()\n+    with open(arguments['--pidfile'], \"w\") as pidfile:\n+        pidfile.write(str(pid) + \"\\n\")\n+\n+    plugins_dir = \"/usr/share/clearwater/clearwater-config-manager/plugins/\"\n+    plugins = load_plugins_in_dir(plugins_dir, local_ip)\n+    plugins.sort(key=lambda x: x.key())\n+    synchronizers = []\n+    threads = []\n+\n+    files = map(lambda p: p.file(), plugins)\n+    alarm = ConfigAlarm(files)\n+\n+    for plugin in plugins:\n+        syncer = EtcdSynchronizer(plugin, alarm)\n+        thread = Thread(target=syncer.main)\n+        thread.start()\n+\n+        synchronizers.append(syncer)\n+        threads.append(thread)\n+        _log.info(\"Loaded plugin %s\" % plugin)\n+\n+    install_sigquit_handler(synchronizers)\n+\n+    for thread in threads:\n+        while thread.isAlive():\n+            thread.join(1)\n+\n+    _log.info(\"Clearwater Configuration Manager shutting down\")\n+\n+if __name__ == '__main__':","path":"src/metaswitch/clearwater/config_manager/main.py","position":126,"original_position":126,"commit_id":"51155c1f26f7d9083202856e0c7df0a32a128b87","original_commit_id":"51155c1f26f7d9083202856e0c7df0a32a128b87","user":{"login":"AlexHockey","id":4903205,"avatar_url":"https://avatars.githubusercontent.com/u/4903205?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexHockey","html_url":"https://github.com/AlexHockey","followers_url":"https://api.github.com/users/AlexHockey/followers","following_url":"https://api.github.com/users/AlexHockey/following{/other_user}","gists_url":"https://api.github.com/users/AlexHockey/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexHockey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexHockey/subscriptions","organizations_url":"https://api.github.com/users/AlexHockey/orgs","repos_url":"https://api.github.com/users/AlexHockey/repos","events_url":"https://api.github.com/users/AlexHockey/events{/privacy}","received_events_url":"https://api.github.com/users/AlexHockey/received_events","type":"User","site_admin":false},"body":"You don't need this and the wrapper script (and having both runs the risk of being confusing as a developer might update one but not the other). ","created_at":"2015-05-18T14:15:37Z","updated_at":"2015-05-18T14:15:37Z","html_url":"https://github.com/Metaswitch/clearwater-etcd/pull/24#discussion_r30510699","pull_request_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/comments/30510699"},"html":{"href":"https://github.com/Metaswitch/clearwater-etcd/pull/24#discussion_r30510699"},"pull_request":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24","id":35595348,"html_url":"https://github.com/Metaswitch/clearwater-etcd/pull/24","diff_url":"https://github.com/Metaswitch/clearwater-etcd/pull/24.diff","patch_url":"https://github.com/Metaswitch/clearwater-etcd/pull/24.patch","issue_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/24","number":24,"state":"open","locked":false,"title":"Reviewer Alex - Config manager","user":{"login":"bossmc","id":1073983,"avatar_url":"https://avatars.githubusercontent.com/u/1073983?v=3","gravatar_id":"","url":"https://api.github.com/users/bossmc","html_url":"https://github.com/bossmc","followers_url":"https://api.github.com/users/bossmc/followers","following_url":"https://api.github.com/users/bossmc/following{/other_user}","gists_url":"https://api.github.com/users/bossmc/gists{/gist_id}","starred_url":"https://api.github.com/users/bossmc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bossmc/subscriptions","organizations_url":"https://api.github.com/users/bossmc/orgs","repos_url":"https://api.github.com/users/bossmc/repos","events_url":"https://api.github.com/users/bossmc/events{/privacy}","received_events_url":"https://api.github.com/users/bossmc/received_events","type":"User","site_admin":false},"body":"Alex, can you please review my Config Manager?  I've tested live (snooping logs to check for alarms)","created_at":"2015-05-17T23:22:42Z","updated_at":"2015-05-18T14:15:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59bf9f4704901fb1d085cb4f6d142bcaf28feb59","assignee":{"login":"AlexHockey","id":4903205,"avatar_url":"https://avatars.githubusercontent.com/u/4903205?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexHockey","html_url":"https://github.com/AlexHockey","followers_url":"https://api.github.com/users/AlexHockey/followers","following_url":"https://api.github.com/users/AlexHockey/following{/other_user}","gists_url":"https://api.github.com/users/AlexHockey/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexHockey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexHockey/subscriptions","organizations_url":"https://api.github.com/users/AlexHockey/orgs","repos_url":"https://api.github.com/users/AlexHockey/repos","events_url":"https://api.github.com/users/AlexHockey/events{/privacy}","received_events_url":"https://api.github.com/users/AlexHockey/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24/commits","review_comments_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24/comments","review_comment_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/24/comments","statuses_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/statuses/51155c1f26f7d9083202856e0c7df0a32a128b87","head":{"label":"Metaswitch:config-manager","ref":"config-manager","sha":"51155c1f26f7d9083202856e0c7df0a32a128b87","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":34358654,"name":"clearwater-etcd","full_name":"Metaswitch/clearwater-etcd","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/clearwater-etcd","description":"Wrappers around etcd for ease of integration into Project Clearwater","fork":false,"url":"https://api.github.com/repos/Metaswitch/clearwater-etcd","forks_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/forks","keys_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/teams","hooks_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/events","assignees_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/tags","blobs_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/subscription","commits_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/merges","archive_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/downloads","issues_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/releases{/id}","created_at":"2015-04-22T00:03:08Z","updated_at":"2015-05-11T10:20:37Z","pushed_at":"2015-05-18T12:50:49Z","git_url":"git://github.com/Metaswitch/clearwater-etcd.git","ssh_url":"git@github.com:Metaswitch/clearwater-etcd.git","clone_url":"https://github.com/Metaswitch/clearwater-etcd.git","svn_url":"https://github.com/Metaswitch/clearwater-etcd","homepage":null,"size":3871,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"Metaswitch:master","ref":"master","sha":"21395db5e99dc0881c1b78bb5ebb876ff9cc763b","user":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"repo":{"id":34358654,"name":"clearwater-etcd","full_name":"Metaswitch/clearwater-etcd","owner":{"login":"Metaswitch","id":453759,"avatar_url":"https://avatars.githubusercontent.com/u/453759?v=3","gravatar_id":"","url":"https://api.github.com/users/Metaswitch","html_url":"https://github.com/Metaswitch","followers_url":"https://api.github.com/users/Metaswitch/followers","following_url":"https://api.github.com/users/Metaswitch/following{/other_user}","gists_url":"https://api.github.com/users/Metaswitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Metaswitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Metaswitch/subscriptions","organizations_url":"https://api.github.com/users/Metaswitch/orgs","repos_url":"https://api.github.com/users/Metaswitch/repos","events_url":"https://api.github.com/users/Metaswitch/events{/privacy}","received_events_url":"https://api.github.com/users/Metaswitch/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Metaswitch/clearwater-etcd","description":"Wrappers around etcd for ease of integration into Project Clearwater","fork":false,"url":"https://api.github.com/repos/Metaswitch/clearwater-etcd","forks_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/forks","keys_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/teams","hooks_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/hooks","issue_events_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/events{/number}","events_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/events","assignees_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/assignees{/user}","branches_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/branches{/branch}","tags_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/tags","blobs_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/statuses/{sha}","languages_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/languages","stargazers_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/stargazers","contributors_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/contributors","subscribers_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/subscribers","subscription_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/subscription","commits_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/contents/{+path}","compare_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/merges","archive_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/downloads","issues_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues{/number}","pulls_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls{/number}","milestones_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/milestones{/number}","notifications_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/labels{/name}","releases_url":"https://api.github.com/repos/Metaswitch/clearwater-etcd/releases{/id}","created_at":"2015-04-22T00:03:08Z","updated_at":"2015-05-11T10:20:37Z","pushed_at":"2015-05-18T12:50:49Z","git_url":"git://github.com/Metaswitch/clearwater-etcd.git","ssh_url":"git@github.com:Metaswitch/clearwater-etcd.git","clone_url":"https://github.com/Metaswitch/clearwater-etcd.git","svn_url":"https://github.com/Metaswitch/clearwater-etcd","homepage":null,"size":3871,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24"},"html":{"href":"https://github.com/Metaswitch/clearwater-etcd/pull/24"},"issue":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/24"},"comments":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/Metaswitch/clearwater-etcd/statuses/51155c1f26f7d9083202856e0c7df0a32a128b87"}}}}