{"action":"created","comment":{"url":"https://api.github.com/repos/ceph/ceph/pulls/comments/46729459","id":46729459,"diff_hunk":"@@ -1667,6 +1667,39 @@ def read(self, key, length=8192, offset=0):\n             raise make_ex(ret, \"Ioctx.read(%s): failed to read %s\" % (self.name, key))\n         return ctypes.string_at(ret_buf, ret)\n \n+    @requires(('key', str_type), ('cls', str_type), ('method', str_type), ('data', bytes))\n+    def execute(self, key, cls, method, data, length=8192):\n+        \"\"\"\n+        Execute an OSD class method on an object.\n+\n+        :param key: name of the object\n+        :type key: str\n+        :param cls: name of the object class\n+        :type cls: str\n+        :param method: name of the method\n+        :type method: str\n+        :param data: input data\n+        :type data: bytes\n+        :param length: size of output buffer in bytes (default=8291)\n+        :type length: int\n+\n+        :raises: :class:`TypeError`\n+        :raises: :class:`Error`\n+        :returns: (ret, method output)\n+        \"\"\"\n+        self.require_ioctx_open()\n+        ret_buf = create_string_buffer(length)\n+        ret = run_in_thread(self.librados.rados_exec,\n+                (self.io, cstr(key), cstr(cls), cstr(method),\n+                    c_char_p(data), c_size_t(len(data)), ret_buf,\n+                    c_size_t(length)))\n+        if ret < 0:\n+            raise make_ex(ret, \"Ioctx.exec(%s): failed to exec %s:%s on %s\" %\n+                    (self.name, cls, method, key))\n+        # we return the exec return value as well as the full output buffer\n+        # because the interpretation of these are method dependent.\n+        return ret, ctypes.string_at(ret_buf, length)","path":"src/pybind/rados.py","position":35,"original_position":35,"commit_id":"23f4ec86e3c773f03fd45cadaa46f32b298b1442","original_commit_id":"23f4ec86e3c773f03fd45cadaa46f32b298b1442","user":{"login":"noahdesu","id":242417,"avatar_url":"https://avatars.githubusercontent.com/u/242417?v=3","gravatar_id":"","url":"https://api.github.com/users/noahdesu","html_url":"https://github.com/noahdesu","followers_url":"https://api.github.com/users/noahdesu/followers","following_url":"https://api.github.com/users/noahdesu/following{/other_user}","gists_url":"https://api.github.com/users/noahdesu/gists{/gist_id}","starred_url":"https://api.github.com/users/noahdesu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahdesu/subscriptions","organizations_url":"https://api.github.com/users/noahdesu/orgs","repos_url":"https://api.github.com/users/noahdesu/repos","events_url":"https://api.github.com/users/noahdesu/events{/privacy}","received_events_url":"https://api.github.com/users/noahdesu/received_events","type":"User","site_admin":false},"body":"if an object class returns a positive value and a zero-length buffer, then rados_exec() correctly handles that case by returning the positive value, but in this case the Python wrapper doesn't know if the return value should be interpreted as the length of the output. How about we return ret and perform the slice on behalf of the user. When object class method output is zero-length then the caller can discard the junk bytes that are returned?","created_at":"2015-12-04T20:38:25Z","updated_at":"2015-12-04T20:38:25Z","html_url":"https://github.com/ceph/ceph/pull/6795#discussion_r46729459","pull_request_url":"https://api.github.com/repos/ceph/ceph/pulls/6795","_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments/46729459"},"html":{"href":"https://github.com/ceph/ceph/pull/6795#discussion_r46729459"},"pull_request":{"href":"https://api.github.com/repos/ceph/ceph/pulls/6795"}}},"pull_request":{"url":"https://api.github.com/repos/ceph/ceph/pulls/6795","id":52622046,"html_url":"https://github.com/ceph/ceph/pull/6795","diff_url":"https://github.com/ceph/ceph/pull/6795.diff","patch_url":"https://github.com/ceph/ceph/pull/6795.patch","issue_url":"https://api.github.com/repos/ceph/ceph/issues/6795","number":6795,"state":"open","locked":false,"title":"pybind: support ioctx:exec","user":{"login":"noahdesu","id":242417,"avatar_url":"https://avatars.githubusercontent.com/u/242417?v=3","gravatar_id":"","url":"https://api.github.com/users/noahdesu","html_url":"https://github.com/noahdesu","followers_url":"https://api.github.com/users/noahdesu/followers","following_url":"https://api.github.com/users/noahdesu/following{/other_user}","gists_url":"https://api.github.com/users/noahdesu/gists{/gist_id}","starred_url":"https://api.github.com/users/noahdesu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noahdesu/subscriptions","organizations_url":"https://api.github.com/users/noahdesu/orgs","repos_url":"https://api.github.com/users/noahdesu/repos","events_url":"https://api.github.com/users/noahdesu/events{/privacy}","received_events_url":"https://api.github.com/users/noahdesu/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Noah Watkins <noahwatkins@gmail.com>","created_at":"2015-12-04T02:18:55Z","updated_at":"2015-12-04T20:38:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f6dbadedb1e5ac45f73989a39e754cf5a95ce662","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ceph/ceph/pulls/6795/commits","review_comments_url":"https://api.github.com/repos/ceph/ceph/pulls/6795/comments","review_comment_url":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ceph/ceph/issues/6795/comments","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/23f4ec86e3c773f03fd45cadaa46f32b298b1442","head":{"label":"ceph:pybind-rados-exec","ref":"pybind-rados-exec","sha":"23f4ec86e3c773f03fd45cadaa46f32b298b1442","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":2310495,"name":"ceph","full_name":"ceph/ceph","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":false,"url":"https://api.github.com/repos/ceph/ceph","forks_url":"https://api.github.com/repos/ceph/ceph/forks","keys_url":"https://api.github.com/repos/ceph/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph/teams","hooks_url":"https://api.github.com/repos/ceph/ceph/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph/events","assignees_url":"https://api.github.com/repos/ceph/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph/tags","blobs_url":"https://api.github.com/repos/ceph/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph/subscription","commits_url":"https://api.github.com/repos/ceph/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph/merges","archive_url":"https://api.github.com/repos/ceph/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph/downloads","issues_url":"https://api.github.com/repos/ceph/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph/releases{/id}","created_at":"2011-09-01T21:41:26Z","updated_at":"2015-12-03T17:26:10Z","pushed_at":"2015-12-04T20:13:27Z","git_url":"git://github.com/ceph/ceph.git","ssh_url":"git@github.com:ceph/ceph.git","clone_url":"https://github.com/ceph/ceph.git","svn_url":"https://github.com/ceph/ceph","homepage":"http://ceph.com","size":170293,"stargazers_count":1700,"watchers_count":1700,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1013,"mirror_url":null,"open_issues_count":232,"forks":1013,"open_issues":232,"watchers":1700,"default_branch":"master"}},"base":{"label":"ceph:master","ref":"master","sha":"014b8e25ea8b9a3d85001abfff589900d2955ff6","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":2310495,"name":"ceph","full_name":"ceph/ceph","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":false,"url":"https://api.github.com/repos/ceph/ceph","forks_url":"https://api.github.com/repos/ceph/ceph/forks","keys_url":"https://api.github.com/repos/ceph/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph/teams","hooks_url":"https://api.github.com/repos/ceph/ceph/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph/events","assignees_url":"https://api.github.com/repos/ceph/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph/tags","blobs_url":"https://api.github.com/repos/ceph/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph/subscription","commits_url":"https://api.github.com/repos/ceph/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph/merges","archive_url":"https://api.github.com/repos/ceph/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph/downloads","issues_url":"https://api.github.com/repos/ceph/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph/releases{/id}","created_at":"2011-09-01T21:41:26Z","updated_at":"2015-12-03T17:26:10Z","pushed_at":"2015-12-04T20:13:27Z","git_url":"git://github.com/ceph/ceph.git","ssh_url":"git@github.com:ceph/ceph.git","clone_url":"https://github.com/ceph/ceph.git","svn_url":"https://github.com/ceph/ceph","homepage":"http://ceph.com","size":170293,"stargazers_count":1700,"watchers_count":1700,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1013,"mirror_url":null,"open_issues_count":232,"forks":1013,"open_issues":232,"watchers":1700,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/6795"},"html":{"href":"https://github.com/ceph/ceph/pull/6795"},"issue":{"href":"https://api.github.com/repos/ceph/ceph/issues/6795"},"comments":{"href":"https://api.github.com/repos/ceph/ceph/issues/6795/comments"},"review_comments":{"href":"https://api.github.com/repos/ceph/ceph/pulls/6795/comments"},"review_comment":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ceph/ceph/pulls/6795/commits"},"statuses":{"href":"https://api.github.com/repos/ceph/ceph/statuses/23f4ec86e3c773f03fd45cadaa46f32b298b1442"}}}}