{"action":"created","comment":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/26488077","id":26488077,"diff_hunk":"@@ -0,0 +1,125 @@\n+# This file is part of VoltDB.\n+\n+# Copyright (C) 2008-2015 VoltDB Inc.\n+#\n+# This file contains original code and/or modifications of original code.\n+# Any modifications made by VoltDB Inc. are licensed under the following\n+# terms and conditions:\n+#\n+# Permission is hereby granted, free of charge, to any person obtaining\n+# a copy of this software and associated documentation files (the\n+# \"Software\"), to deal in the Software without restriction, including\n+# without limitation the rights to use, copy, modify, merge, publish,\n+# distribute, sublicense, and/or sell copies of the Software, and to\n+# permit persons to whom the Software is furnished to do so, subject to\n+# the following conditions:\n+#\n+# The above copyright notice and this permission notice shall be\n+# included in all copies or substantial portions of the Software.\n+\n+# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\n+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\n+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n+# OTHER DEALINGS IN THE SOFTWARE.\n+\n+# Stop a node. Written to easily support multiple, but configured for\n+# a single host for now.\n+\n+\n+class Host(dict):\n+\n+    def __init__(self, id, abort_func):\n+        self.id = id\n+        self.abort_func = abort_func\n+\n+    # Provide pseudo-attributes for dictionary items with error checking\n+    def __getattr__(self, name):\n+        try:\n+            return self[name]\n+        except IndexError:\n+            self.abort_func('Attribute \"%s\" not present for host.' % name)\n+\n+\n+class Hosts(object):\n+\n+    def __init__(self, abort_func):\n+        self.hosts_by_id = {}\n+        self.abort_func = abort_func\n+\n+    def update(self, host_id_raw, prop_name_raw, value):\n+        host_id = int(host_id_raw)\n+        prop_name = prop_name_raw.lower()\n+        self.hosts_by_id.setdefault(host_id, Host(host_id, self.abort_func))[prop_name] = value\n+\n+    def lookup(self, *host_names):\n+        \"\"\"\n+        Lookup host name(s) and return found and unused host objects,\n+        plus a list of the host names that are missing. The unused host\n+        list is arbitrarily ordered.\n+        \"\"\"\n+        found = []\n+        unused = []\n+        missing = set(host_names)\n+        for host in self.hosts_by_id.values():\n+            if host.hostname in host_names:\n+                found.append(host)\n+                missing.remove(host.hostname)\n+            else:\n+                unused.append(host)\n+        return found, unused, sorted(list(missing))\n+\n+\n+# To make it work with multiple hosts:\n+#   - set max_count to None in the argument definition\n+#   - change the lookup() call to hosts.lookup(*runner.opts.target_host)\n+#   - change message text to reflect the possibility of multiple targets.\n+@VOLT.Command(\n+    bundles = VOLT.AdminBundle(),\n+    description = 'Stop one host of a running VoltDB cluster.',\n+    arguments = (\n+        VOLT.StringArgument('target_host', 'the target HOST name or address',\n+                            min_count=1, max_count=1),\n+    ),\n+)\n+def stop(runner):\n+\n+    # Exec @SystemInformation to find out about the cluster.\n+    response = runner.call_proc('@SystemInformation',\n+                                [VOLT.FastSerializer.VOLTTYPE_STRING],\n+                                ['OVERVIEW'])\n+\n+    # Convert @SystemInformation results to objects.\n+    hosts = Hosts(runner.abort)\n+    for tuple in response.table(0).tuples():\n+        hosts.update(tuple[0], tuple[1], tuple[2])\n+\n+    # Look up the hosts specified as command line arguments.\n+    found, unused, missing = hosts.lookup(runner.opts.target_host)\n+    if len(missing) > 0:\n+        runner.abort('Host not found in cluster: %s' % ' '.join(missing))\n+    if len(unused) == 0:","path":"lib/python/voltcli/voltadmin.d/stop.py","position":103,"original_position":103,"commit_id":"db6181b1e08694c565bb6fe44a1dbc3532b43a4b","original_commit_id":"db6181b1e08694c565bb6fe44a1dbc3532b43a4b","user":{"login":"jhugg","id":634609,"avatar_url":"https://avatars.githubusercontent.com/u/634609?v=3","gravatar_id":"","url":"https://api.github.com/users/jhugg","html_url":"https://github.com/jhugg","followers_url":"https://api.github.com/users/jhugg/followers","following_url":"https://api.github.com/users/jhugg/following{/other_user}","gists_url":"https://api.github.com/users/jhugg/gists{/gist_id}","starred_url":"https://api.github.com/users/jhugg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhugg/subscriptions","organizations_url":"https://api.github.com/users/jhugg/orgs","repos_url":"https://api.github.com/users/jhugg/repos","events_url":"https://api.github.com/users/jhugg/events{/privacy}","received_events_url":"https://api.github.com/users/jhugg/received_events","type":"User","site_admin":false},"body":"Hmm... I guess in this case you have to pick a node to connect to... maybe you're right.","created_at":"2015-03-16T14:27:11Z","updated_at":"2015-03-16T14:27:11Z","html_url":"https://github.com/VoltDB/voltdb/pull/2135#discussion_r26488077","pull_request_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135","_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/26488077"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/2135#discussion_r26488077"},"pull_request":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135"}}},"pull_request":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135","id":31161049,"html_url":"https://github.com/VoltDB/voltdb/pull/2135","diff_url":"https://github.com/VoltDB/voltdb/pull/2135.diff","patch_url":"https://github.com/VoltDB/voltdb/pull/2135.patch","issue_url":"https://api.github.com/repos/VoltDB/voltdb/issues/2135","number":2135,"state":"open","locked":false,"title":"ENG-6125 voltadmin stop command","user":{"login":"wijjo","id":540458,"avatar_url":"https://avatars.githubusercontent.com/u/540458?v=3","gravatar_id":"","url":"https://api.github.com/users/wijjo","html_url":"https://github.com/wijjo","followers_url":"https://api.github.com/users/wijjo/followers","following_url":"https://api.github.com/users/wijjo/following{/other_user}","gists_url":"https://api.github.com/users/wijjo/gists{/gist_id}","starred_url":"https://api.github.com/users/wijjo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wijjo/subscriptions","organizations_url":"https://api.github.com/users/wijjo/orgs","repos_url":"https://api.github.com/users/wijjo/repos","events_url":"https://api.github.com/users/wijjo/events{/privacy}","received_events_url":"https://api.github.com/users/wijjo/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-13T20:29:17Z","updated_at":"2015-03-16T14:27:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47f1ff3e5eb44e65e274b3ce47b5f245215fbb89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135/commits","review_comments_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135/comments","review_comment_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/issues/2135/comments","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/db6181b1e08694c565bb6fe44a1dbc3532b43a4b","head":{"label":"VoltDB:notest-ENG-6125-voltadmin-stopnode","ref":"notest-ENG-6125-voltadmin-stopnode","sha":"db6181b1e08694c565bb6fe44a1dbc3532b43a4b","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","created_at":"2011-09-23T18:46:12Z","updated_at":"2015-03-16T14:06:42Z","pushed_at":"2015-03-16T14:06:44Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":593641,"stargazers_count":467,"watchers_count":467,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":134,"mirror_url":null,"open_issues_count":31,"forks":134,"open_issues":31,"watchers":467,"default_branch":"master"}},"base":{"label":"VoltDB:master","ref":"master","sha":"4c9b9dd5480cec117ceb51303f4e0c48461a5acb","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","created_at":"2011-09-23T18:46:12Z","updated_at":"2015-03-16T14:06:42Z","pushed_at":"2015-03-16T14:06:44Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":593641,"stargazers_count":467,"watchers_count":467,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":134,"mirror_url":null,"open_issues_count":31,"forks":134,"open_issues":31,"watchers":467,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/2135"},"issue":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/2135"},"comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/2135/comments"},"review_comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135/comments"},"review_comment":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2135/commits"},"statuses":{"href":"https://api.github.com/repos/VoltDB/voltdb/statuses/db6181b1e08694c565bb6fe44a1dbc3532b43a4b"}}}}