{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/28707579","id":28707579,"diff_hunk":"@@ -0,0 +1,183 @@\n+from pipes import quote as shell_quote\n+\n+from characteristic import attributes\n+\n+from eliot import Logger, Message\n+\n+from effect import (\n+    sync_performer, TypeDispatcher, ComposedDispatcher, Effect,\n+    )\n+from effect.twisted import (\n+    make_twisted_dispatcher,\n+)\n+from effect.twisted import (\n+    perform, deferred_performer)\n+from twisted.conch.endpoints import (\n+    SSHCommandClientEndpoint, _NewConnectionHelper, _ReadFile, ConsoleUI)\n+\n+from twisted.conch.client.knownhosts import KnownHostsFile\n+from twisted.internet import reactor\n+from twisted.internet.defer import Deferred, inlineCallbacks\n+from twisted.internet.endpoints import UNIXClientEndpoint, connectProtocol\n+from twisted.internet.error import ConnectionDone\n+from twisted.protocols.basic import LineOnlyReceiver\n+from twisted.python.filepath import FilePath\n+import os\n+\n+from flocker.testtools import loop_until\n+\n+from ._model import Run, Sudo, Put, Comment, RunRemotely\n+\n+from .._effect import dispatcher as base_dispatcher\n+\n+\n+logger = Logger()\n+\n+\n+@attributes([\n+    \"deferred\",\n+    \"context\",\n+])\n+class CommandProtocol(LineOnlyReceiver, object):\n+    \"\"\"\n+    Protocol that logs the lines of a remote command.\n+\n+    :ivar Deferred deferred: Deferred to fire when the command finishes\n+        If the command finished successfully, will fire with ``None``.\n+        Otherwise, errbacks with the reason.\n+    :ivar Message context: The eliot message context to log.\n+    \"\"\"\n+    delimiter = b'\\n'\n+\n+    def connectionMade(self):\n+        self.transport.disconnecting = False\n+\n+    def connectionLost(self, reason):\n+        if reason.check(ConnectionDone):\n+            self.deferred.callback(None)\n+        else:\n+            self.deferred.errback(reason)\n+\n+    def lineReceived(self, line):\n+        self.context.bind(\n+            message_type=\"flocker.provision.ssh:run:output\",\n+            line=line,\n+        ).write(logger)\n+\n+\n+@sync_performer\n+def perform_sudo(dispatcher, intent):\n+    \"\"\"\n+    See :py:class:`Sudo`.\n+    \"\"\"\n+    return Effect(Run(command='sudo ' + intent.command))\n+\n+\n+@sync_performer\n+def perform_put(dispatcher, intent):\n+    \"\"\"\n+    See :py:class:`Put`.\n+    \"\"\"\n+    return Effect(Run(command='printf %s > %s'\n+                              % (shell_quote(intent.content),\n+                                 shell_quote(intent.path))))\n+\n+\n+@sync_performer\n+def perform_comment(dispatcher, intent):\n+    \"\"\"\n+    See :py:class:`Comment`.\n+    \"\"\"\n+\n+\n+def get_ssh_dispatcher(connection, context):\n+    \"\"\"\n+    :ivar Message context: The eliot message context to log.\n+    :ivar connection: The SSH connection run commands on.\n+    \"\"\"\n+\n+    @deferred_performer\n+    def perform_run(dispatcher, intent):\n+        context.bind(\n+            message_type=\"flocker.provision.ssh:run\",\n+            command=intent.command,\n+        ).write(logger)\n+        endpoint = SSHCommandClientEndpoint.existingConnection(\n+            connection, intent.command)\n+        d = Deferred()\n+        connectProtocol(endpoint, CommandProtocol(\n+            deferred=d, context=context))\n+        return d\n+\n+    return TypeDispatcher({\n+        Run: perform_run,\n+        Sudo: perform_sudo,\n+        Put: perform_put,\n+        Comment: perform_comment,\n+    })\n+\n+\n+def get_connection_helper(address, username, port):\n+    \"\"\"\n+    Get a :class:`twisted.conch.endpoints._ISSHConnectionCreator` to connect to\n+    the given remote.\n+\n+    :param bytes address: The address of the remote host to connect to.\n+    :param bytes username: The user to connect as.\n+    :param int port: The port of the ssh server to connect to.\n+\n+    :return _ISSHConnectionCreator:\n+    \"\"\"\n+    try:\n+        agentEndpoint = UNIXClientEndpoint(\n+            reactor, os.environ[\"SSH_AUTH_SOCK\"])\n+    except KeyError:\n+        agentEndpoint = None\n+\n+    return _NewConnectionHelper(","path":"flocker/provision/_ssh/_conch.py","position":143,"original_position":137,"commit_id":"701c722b6e911fe056abd9cff9ec3af0eac3e629","original_commit_id":"82b22eef063692e41dbf7cd13a311cd35fe42a48","user":{"login":"exarkun","id":254565,"avatar_url":"https://avatars.githubusercontent.com/u/254565?v=3","gravatar_id":"","url":"https://api.github.com/users/exarkun","html_url":"https://github.com/exarkun","followers_url":"https://api.github.com/users/exarkun/followers","following_url":"https://api.github.com/users/exarkun/following{/other_user}","gists_url":"https://api.github.com/users/exarkun/gists{/gist_id}","starred_url":"https://api.github.com/users/exarkun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exarkun/subscriptions","organizations_url":"https://api.github.com/users/exarkun/orgs","repos_url":"https://api.github.com/users/exarkun/repos","events_url":"https://api.github.com/users/exarkun/events{/privacy}","received_events_url":"https://api.github.com/users/exarkun/received_events","type":"User","site_admin":false},"body":"Assuming that \"yet\" actually works in that sentence bothers me. :smile: \r\n\r\nThe extra process is entirely harmless.  Using a private API from another project is potentially harmful.","created_at":"2015-04-20T17:06:04Z","updated_at":"2015-04-20T17:06:04Z","html_url":"https://github.com/ClusterHQ/flocker/pull/1321#discussion_r28707579","pull_request_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321","_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/28707579"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/1321#discussion_r28707579"},"pull_request":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321","id":33650384,"html_url":"https://github.com/ClusterHQ/flocker/pull/1321","diff_url":"https://github.com/ClusterHQ/flocker/pull/1321.diff","patch_url":"https://github.com/ClusterHQ/flocker/pull/1321.patch","issue_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/1321","number":1321,"state":"open","locked":false,"title":"[FLOC-1674] Switch to conch","user":{"login":"tomprince","id":283816,"avatar_url":"https://avatars.githubusercontent.com/u/283816?v=3","gravatar_id":"","url":"https://api.github.com/users/tomprince","html_url":"https://github.com/tomprince","followers_url":"https://api.github.com/users/tomprince/followers","following_url":"https://api.github.com/users/tomprince/following{/other_user}","gists_url":"https://api.github.com/users/tomprince/gists{/gist_id}","starred_url":"https://api.github.com/users/tomprince/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomprince/subscriptions","organizations_url":"https://api.github.com/users/tomprince/orgs","repos_url":"https://api.github.com/users/tomprince/repos","events_url":"https://api.github.com/users/tomprince/events{/privacy}","received_events_url":"https://api.github.com/users/tomprince/received_events","type":"User","site_admin":false},"body":"https://clusterhq.atlassian.net/browse/FLOC-1674","created_at":"2015-04-20T09:55:41Z","updated_at":"2015-04-20T17:06:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a359814c0666dc53de80e804e11c24909cc8ef9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321/commits","review_comments_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321/comments","review_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/1321/comments","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/701c722b6e911fe056abd9cff9ec3af0eac3e629","head":{"label":"ClusterHQ:switch-to-conch-FLOC-1674","ref":"switch-to-conch-FLOC-1674","sha":"701c722b6e911fe056abd9cff9ec3af0eac3e629","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Easily manage Docker containers & their data","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-04-20T14:31:51Z","pushed_at":"2015-04-20T17:00:19Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":50595,"stargazers_count":1349,"watchers_count":1349,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":31,"forks":76,"open_issues":31,"watchers":1349,"default_branch":"master"}},"base":{"label":"ClusterHQ:master","ref":"master","sha":"70aa9a42dd8fd900e8d9b0630399dde5e00bab1a","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Easily manage Docker containers & their data","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-04-20T14:31:51Z","pushed_at":"2015-04-20T17:00:19Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":50595,"stargazers_count":1349,"watchers_count":1349,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":31,"forks":76,"open_issues":31,"watchers":1349,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/1321"},"issue":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/1321"},"comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/1321/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1321/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterHQ/flocker/statuses/701c722b6e911fe056abd9cff9ec3af0eac3e629"}}}}