{"action":"created","comment":{"url":"https://api.github.com/repos/dmtucker/yaas/pulls/comments/42838259","id":42838259,"diff_hunk":"@@ -0,0 +1,105 @@\n+# coding: utf-8\n+\n+from __future__ import absolute_import\n+from __future__ import print_function\n+\n+import getpass\n+import inspect\n+import pprint\n+import requests\n+import sys\n+\n+from . import config\n+\n+\n+def command(parser, args):\n+    \"\"\" Interact with agent bootstrap requests. \"\"\"\n+    subparsers = parser.add_subparsers(dest='subcommand')\n+    subcommands = {\n+        'agents': _agents,\n+        'show': _show,\n+        }\n+    for name, fn in subcommands.items():\n+        subparsers.add_parser(name, help=inspect.getdoc(fn))\n+    subargs, extra = parser.parse_known_args(args)\n+    subcommands[subargs.subcommand](\n+        subparsers.choices[subargs.subcommand],\n+        extra)\n+\n+\n+def _agents(parser, args):\n+    \"\"\" Set up the agent on one or more hosts. \"\"\"\n+    parser.add_argument(\n+        '-k', '--ssh-key',\n+        required=True,\n+        help=\"Specify the private SSH key for a public SSH key on the hosts.\")\n+    parser.add_argument(\n+        '-u', '--user',\n+        default=getpass.getuser(),\n+        help=\"Specify the SSH user.\")\n+    parser.add_argument(\n+        '-r', '--userRunAs',\n+        help=\"Specify the SSH user.\")\n+    parser.add_argument(\n+        'host',\n+        nargs='+',\n+        help=\"Specify one or more hosts to bootstrap agents on.\")\n+    subargs, extra = parser.parse_known_args(args)\n+    request = {\n+        'hosts': subargs.host,\n+        'user': subargs.user,\n+    }\n+    if subargs.userRunAs is not None:\n+        request['userRunAs'] = subargs.userRunAs\n+    with open(subargs.ssh_key, 'r') as f:\n+        request['sshKey'] = f.read()\n+    response = requests.post(\n+        config.href('/api/v1/bootstrap'),\n+        json=request,\n+        **config.requests_opts())\n+    if config.args.raw:\n+        pprint.pprint(response.json())\n+        sys.exit(0)\n+    response.raise_for_status()\n+    res = response.json()\n+    print(\n+        'Request {id} {status} {log}'.format(\n+            id=res['requestId'],\n+            status=res['status'],\n+            log=res['log']))\n+\n+\n+def _show(parser, args):\n+    parser.add_argument(\n+        '-l', '--log',\n+        action='store_true', default=False,\n+        help=\"Show bootstrap logs.\")\n+    parser.add_argument(\n+        'id',\n+        nargs='+',\n+        help=\"Specify one or more bootstrap request IDs to show.\")\n+    subargs, extra = parser.parse_known_args(args)\n+    for req in subargs.id:\n+        response = requests.get(\n+            config.href('/api/v1/bootstrap/{requestId}'.format(requestId=req)),\n+            **config.requests_opts())\n+        if config.args.raw:\n+            pprint.pprint(response.json())\n+            continue","path":"yaas/bootstrap.py","position":88,"original_position":88,"commit_id":"b5064d0929958b36ab950a1c9bb6f9be83734853","original_commit_id":"b5064d0929958b36ab950a1c9bb6f9be83734853","user":{"login":"karth295","id":5653442,"avatar_url":"https://avatars.githubusercontent.com/u/5653442?v=3","gravatar_id":"","url":"https://api.github.com/users/karth295","html_url":"https://github.com/karth295","followers_url":"https://api.github.com/users/karth295/followers","following_url":"https://api.github.com/users/karth295/following{/other_user}","gists_url":"https://api.github.com/users/karth295/gists{/gist_id}","starred_url":"https://api.github.com/users/karth295/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karth295/subscriptions","organizations_url":"https://api.github.com/users/karth295/orgs","repos_url":"https://api.github.com/users/karth295/repos","events_url":"https://api.github.com/users/karth295/events{/privacy}","received_events_url":"https://api.github.com/users/karth295/received_events","type":"User","site_admin":false},"body":"Good idea with `continue`. We should make sure the other PR's do that too.","created_at":"2015-10-23T07:09:25Z","updated_at":"2015-10-23T07:09:25Z","html_url":"https://github.com/dmtucker/yaas/pull/16#discussion_r42838259","pull_request_url":"https://api.github.com/repos/dmtucker/yaas/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/dmtucker/yaas/pulls/comments/42838259"},"html":{"href":"https://github.com/dmtucker/yaas/pull/16#discussion_r42838259"},"pull_request":{"href":"https://api.github.com/repos/dmtucker/yaas/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/dmtucker/yaas/pulls/16","id":48422692,"html_url":"https://github.com/dmtucker/yaas/pull/16","diff_url":"https://github.com/dmtucker/yaas/pull/16.diff","patch_url":"https://github.com/dmtucker/yaas/pull/16.patch","issue_url":"https://api.github.com/repos/dmtucker/yaas/issues/16","number":16,"state":"open","locked":false,"title":"Implement bootstrap.","user":{"login":"dmtucker","id":1817814,"avatar_url":"https://avatars.githubusercontent.com/u/1817814?v=3","gravatar_id":"","url":"https://api.github.com/users/dmtucker","html_url":"https://github.com/dmtucker","followers_url":"https://api.github.com/users/dmtucker/followers","following_url":"https://api.github.com/users/dmtucker/following{/other_user}","gists_url":"https://api.github.com/users/dmtucker/gists{/gist_id}","starred_url":"https://api.github.com/users/dmtucker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmtucker/subscriptions","organizations_url":"https://api.github.com/users/dmtucker/orgs","repos_url":"https://api.github.com/users/dmtucker/repos","events_url":"https://api.github.com/users/dmtucker/events{/privacy}","received_events_url":"https://api.github.com/users/dmtucker/received_events","type":"User","site_admin":false},"body":"This has a weird behavior if you do not specify `--userRunAs` for bootstrapping Ambari 2 or greater, but it's not really our fault. Ambari shows success but hangs...","created_at":"2015-10-22T06:46:20Z","updated_at":"2015-10-23T07:09:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da9d49528495cb476577173b467dc019a0d309fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dmtucker/yaas/pulls/16/commits","review_comments_url":"https://api.github.com/repos/dmtucker/yaas/pulls/16/comments","review_comment_url":"https://api.github.com/repos/dmtucker/yaas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dmtucker/yaas/issues/16/comments","statuses_url":"https://api.github.com/repos/dmtucker/yaas/statuses/b5064d0929958b36ab950a1c9bb6f9be83734853","head":{"label":"dmtucker:bootstrap","ref":"bootstrap","sha":"b5064d0929958b36ab950a1c9bb6f9be83734853","user":{"login":"dmtucker","id":1817814,"avatar_url":"https://avatars.githubusercontent.com/u/1817814?v=3","gravatar_id":"","url":"https://api.github.com/users/dmtucker","html_url":"https://github.com/dmtucker","followers_url":"https://api.github.com/users/dmtucker/followers","following_url":"https://api.github.com/users/dmtucker/following{/other_user}","gists_url":"https://api.github.com/users/dmtucker/gists{/gist_id}","starred_url":"https://api.github.com/users/dmtucker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmtucker/subscriptions","organizations_url":"https://api.github.com/users/dmtucker/orgs","repos_url":"https://api.github.com/users/dmtucker/repos","events_url":"https://api.github.com/users/dmtucker/events{/privacy}","received_events_url":"https://api.github.com/users/dmtucker/received_events","type":"User","site_admin":false},"repo":{"id":42206165,"name":"yaas","full_name":"dmtucker/yaas","owner":{"login":"dmtucker","id":1817814,"avatar_url":"https://avatars.githubusercontent.com/u/1817814?v=3","gravatar_id":"","url":"https://api.github.com/users/dmtucker","html_url":"https://github.com/dmtucker","followers_url":"https://api.github.com/users/dmtucker/followers","following_url":"https://api.github.com/users/dmtucker/following{/other_user}","gists_url":"https://api.github.com/users/dmtucker/gists{/gist_id}","starred_url":"https://api.github.com/users/dmtucker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmtucker/subscriptions","organizations_url":"https://api.github.com/users/dmtucker/orgs","repos_url":"https://api.github.com/users/dmtucker/repos","events_url":"https://api.github.com/users/dmtucker/events{/privacy}","received_events_url":"https://api.github.com/users/dmtucker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmtucker/yaas","description":"Yet Another Ambari Shell","fork":false,"url":"https://api.github.com/repos/dmtucker/yaas","forks_url":"https://api.github.com/repos/dmtucker/yaas/forks","keys_url":"https://api.github.com/repos/dmtucker/yaas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmtucker/yaas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmtucker/yaas/teams","hooks_url":"https://api.github.com/repos/dmtucker/yaas/hooks","issue_events_url":"https://api.github.com/repos/dmtucker/yaas/issues/events{/number}","events_url":"https://api.github.com/repos/dmtucker/yaas/events","assignees_url":"https://api.github.com/repos/dmtucker/yaas/assignees{/user}","branches_url":"https://api.github.com/repos/dmtucker/yaas/branches{/branch}","tags_url":"https://api.github.com/repos/dmtucker/yaas/tags","blobs_url":"https://api.github.com/repos/dmtucker/yaas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmtucker/yaas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmtucker/yaas/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmtucker/yaas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmtucker/yaas/statuses/{sha}","languages_url":"https://api.github.com/repos/dmtucker/yaas/languages","stargazers_url":"https://api.github.com/repos/dmtucker/yaas/stargazers","contributors_url":"https://api.github.com/repos/dmtucker/yaas/contributors","subscribers_url":"https://api.github.com/repos/dmtucker/yaas/subscribers","subscription_url":"https://api.github.com/repos/dmtucker/yaas/subscription","commits_url":"https://api.github.com/repos/dmtucker/yaas/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmtucker/yaas/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmtucker/yaas/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmtucker/yaas/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmtucker/yaas/contents/{+path}","compare_url":"https://api.github.com/repos/dmtucker/yaas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmtucker/yaas/merges","archive_url":"https://api.github.com/repos/dmtucker/yaas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmtucker/yaas/downloads","issues_url":"https://api.github.com/repos/dmtucker/yaas/issues{/number}","pulls_url":"https://api.github.com/repos/dmtucker/yaas/pulls{/number}","milestones_url":"https://api.github.com/repos/dmtucker/yaas/milestones{/number}","notifications_url":"https://api.github.com/repos/dmtucker/yaas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmtucker/yaas/labels{/name}","releases_url":"https://api.github.com/repos/dmtucker/yaas/releases{/id}","created_at":"2015-09-09T21:37:25Z","updated_at":"2015-09-10T08:52:09Z","pushed_at":"2015-10-22T06:46:20Z","git_url":"git://github.com/dmtucker/yaas.git","ssh_url":"git@github.com:dmtucker/yaas.git","clone_url":"https://github.com/dmtucker/yaas.git","svn_url":"https://github.com/dmtucker/yaas","homepage":null,"size":722,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":4,"forks":2,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"dmtucker:master","ref":"master","sha":"4d0dab0b085fc00079f8dee00a188b2d64e14303","user":{"login":"dmtucker","id":1817814,"avatar_url":"https://avatars.githubusercontent.com/u/1817814?v=3","gravatar_id":"","url":"https://api.github.com/users/dmtucker","html_url":"https://github.com/dmtucker","followers_url":"https://api.github.com/users/dmtucker/followers","following_url":"https://api.github.com/users/dmtucker/following{/other_user}","gists_url":"https://api.github.com/users/dmtucker/gists{/gist_id}","starred_url":"https://api.github.com/users/dmtucker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmtucker/subscriptions","organizations_url":"https://api.github.com/users/dmtucker/orgs","repos_url":"https://api.github.com/users/dmtucker/repos","events_url":"https://api.github.com/users/dmtucker/events{/privacy}","received_events_url":"https://api.github.com/users/dmtucker/received_events","type":"User","site_admin":false},"repo":{"id":42206165,"name":"yaas","full_name":"dmtucker/yaas","owner":{"login":"dmtucker","id":1817814,"avatar_url":"https://avatars.githubusercontent.com/u/1817814?v=3","gravatar_id":"","url":"https://api.github.com/users/dmtucker","html_url":"https://github.com/dmtucker","followers_url":"https://api.github.com/users/dmtucker/followers","following_url":"https://api.github.com/users/dmtucker/following{/other_user}","gists_url":"https://api.github.com/users/dmtucker/gists{/gist_id}","starred_url":"https://api.github.com/users/dmtucker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmtucker/subscriptions","organizations_url":"https://api.github.com/users/dmtucker/orgs","repos_url":"https://api.github.com/users/dmtucker/repos","events_url":"https://api.github.com/users/dmtucker/events{/privacy}","received_events_url":"https://api.github.com/users/dmtucker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmtucker/yaas","description":"Yet Another Ambari Shell","fork":false,"url":"https://api.github.com/repos/dmtucker/yaas","forks_url":"https://api.github.com/repos/dmtucker/yaas/forks","keys_url":"https://api.github.com/repos/dmtucker/yaas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmtucker/yaas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmtucker/yaas/teams","hooks_url":"https://api.github.com/repos/dmtucker/yaas/hooks","issue_events_url":"https://api.github.com/repos/dmtucker/yaas/issues/events{/number}","events_url":"https://api.github.com/repos/dmtucker/yaas/events","assignees_url":"https://api.github.com/repos/dmtucker/yaas/assignees{/user}","branches_url":"https://api.github.com/repos/dmtucker/yaas/branches{/branch}","tags_url":"https://api.github.com/repos/dmtucker/yaas/tags","blobs_url":"https://api.github.com/repos/dmtucker/yaas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmtucker/yaas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmtucker/yaas/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmtucker/yaas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmtucker/yaas/statuses/{sha}","languages_url":"https://api.github.com/repos/dmtucker/yaas/languages","stargazers_url":"https://api.github.com/repos/dmtucker/yaas/stargazers","contributors_url":"https://api.github.com/repos/dmtucker/yaas/contributors","subscribers_url":"https://api.github.com/repos/dmtucker/yaas/subscribers","subscription_url":"https://api.github.com/repos/dmtucker/yaas/subscription","commits_url":"https://api.github.com/repos/dmtucker/yaas/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmtucker/yaas/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmtucker/yaas/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmtucker/yaas/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmtucker/yaas/contents/{+path}","compare_url":"https://api.github.com/repos/dmtucker/yaas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmtucker/yaas/merges","archive_url":"https://api.github.com/repos/dmtucker/yaas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmtucker/yaas/downloads","issues_url":"https://api.github.com/repos/dmtucker/yaas/issues{/number}","pulls_url":"https://api.github.com/repos/dmtucker/yaas/pulls{/number}","milestones_url":"https://api.github.com/repos/dmtucker/yaas/milestones{/number}","notifications_url":"https://api.github.com/repos/dmtucker/yaas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmtucker/yaas/labels{/name}","releases_url":"https://api.github.com/repos/dmtucker/yaas/releases{/id}","created_at":"2015-09-09T21:37:25Z","updated_at":"2015-09-10T08:52:09Z","pushed_at":"2015-10-22T06:46:20Z","git_url":"git://github.com/dmtucker/yaas.git","ssh_url":"git@github.com:dmtucker/yaas.git","clone_url":"https://github.com/dmtucker/yaas.git","svn_url":"https://github.com/dmtucker/yaas","homepage":null,"size":722,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":4,"forks":2,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dmtucker/yaas/pulls/16"},"html":{"href":"https://github.com/dmtucker/yaas/pull/16"},"issue":{"href":"https://api.github.com/repos/dmtucker/yaas/issues/16"},"comments":{"href":"https://api.github.com/repos/dmtucker/yaas/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/dmtucker/yaas/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/dmtucker/yaas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dmtucker/yaas/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/dmtucker/yaas/statuses/b5064d0929958b36ab950a1c9bb6f9be83734853"}}}}