{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/vic/pulls/comments/67044093","id":67044093,"diff_hunk":"@@ -0,0 +1,143 @@\n+// Copyright 2016 VMware, Inc. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//    http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package main\n+\n+import (\n+\t\"encoding/hex\"\n+\t\"fmt\"\n+\t\"log\"\n+\t\"math/rand\"\n+\t\"net\"\n+\t\"net/http\"\n+\t\"net/rpc\"\n+\n+\t\"github.com/vmware/vic/lib/portlayer/exec2\"\n+\t\"github.com/vmware/vic/lib/portlayer/exec2/remote\"\n+)\n+\n+type PortLayerRPCServer struct {\n+}\n+\n+// A Handle can be anything, so this takes advantage of that by creating a sparse handle\n+// to send to the client and using that sparse handle as a key in a hashtable which points to\n+// rich handles created by the HandleFactory\n+type SparseHandle exec2.Handle\n+\n+var lcTarget exec2.ContainerLifecycle\n+\n+//var lcQuery exec2.ContainerQuery\n+var handles map[SparseHandle]exec2.Handle\n+\n+func init() {\n+\tpl := &exec2.PortLayerVsphere{}\n+\tpl.Init(nil, &exec2.BasicHandleFactory{})\n+\tlcTarget = pl\n+\t//lcQuery = lcTarget\n+\thandles = make(map[SparseHandle]exec2.Handle)\n+}\n+\n+func main() {\n+\trpcServer := new(PortLayerRPCServer)\n+\trpc.Register(rpcServer)\n+\trpc.HandleHTTP()\n+\tl, e := net.Listen(\"tcp\", \":1234\")\n+\tif e != nil {\n+\t\tlog.Fatal(\"listen error:\", e)\n+\t}\n+\tfmt.Println(\"Server listening\")\n+\thttp.Serve(l, nil)\n+}\n+\n+// A sparse handle is simply a random string\n+func newSparseHandle() SparseHandle {\n+\tb := make([]byte, 16)\n+\trand.Read(b)\n+\treturn SparseHandle(hex.EncodeToString(b))\n+}\n+\n+func createSparseHandle(handle exec2.Handle) SparseHandle {\n+\tkey := newSparseHandle()\n+\thandles[key] = handle\n+\treturn key\n+}\n+\n+func resolveSparseHandle(handle SparseHandle) exec2.Handle {\n+\treturn handles[handle]\n+}\n+\n+func refreshHandle(result *exec2.Handle, oldHandle SparseHandle, newHandle exec2.Handle, err error) error {\n+\t*result = createSparseHandle(newHandle)\n+\tdelete(handles, oldHandle)\n+\treturn err\n+}\n+\n+func (*PortLayerRPCServer) CreateContainer(args remote.CreateArgs, result *exec2.Handle) error {\n+\thandle, err := lcTarget.CreateContainer(args.Name)\n+\t*result = createSparseHandle(handle)\n+\treturn err\n+}\n+\n+func (*PortLayerRPCServer) GetHandle(cid exec2.ID, result *exec2.Handle) error {\n+\thandle, err := lcTarget.GetHandle(cid)\n+\t*result = createSparseHandle(handle)\n+\treturn err\n+}\n+\n+func (*PortLayerRPCServer) CopyTo(args remote.CopyToArgs, result *exec2.Handle) error {\n+\thandle := resolveSparseHandle(args.Handle)\n+\tnewHandle, err := lcTarget.CopyTo(handle,\n+\t\targs.TargetDir, args.Filename, args.Data)","path":"lib/portlayer/exec2/remote/server/portlayer_rpc_server.go","position":101,"original_position":101,"commit_id":"02d6909626c10e74e893f2a783d4a30441c64a21","original_commit_id":"02d6909626c10e74e893f2a783d4a30441c64a21","user":{"login":"caglar10ur","id":205498,"avatar_url":"https://avatars.githubusercontent.com/u/205498?v=3","gravatar_id":"","url":"https://api.github.com/users/caglar10ur","html_url":"https://github.com/caglar10ur","followers_url":"https://api.github.com/users/caglar10ur/followers","following_url":"https://api.github.com/users/caglar10ur/following{/other_user}","gists_url":"https://api.github.com/users/caglar10ur/gists{/gist_id}","starred_url":"https://api.github.com/users/caglar10ur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caglar10ur/subscriptions","organizations_url":"https://api.github.com/users/caglar10ur/orgs","repos_url":"https://api.github.com/users/caglar10ur/repos","events_url":"https://api.github.com/users/caglar10ur/events{/privacy}","received_events_url":"https://api.github.com/users/caglar10ur/received_events","type":"User","site_admin":false},"body":"Don't break lines like that, we all have retina or 4K displays :)","created_at":"2016-06-14T19:53:52Z","updated_at":"2016-06-14T19:53:52Z","html_url":"https://github.com/vmware/vic/pull/1092#discussion_r67044093","pull_request_url":"https://api.github.com/repos/vmware/vic/pulls/1092","_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments/67044093"},"html":{"href":"https://github.com/vmware/vic/pull/1092#discussion_r67044093"},"pull_request":{"href":"https://api.github.com/repos/vmware/vic/pulls/1092"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/vic/pulls/1092","id":73665654,"html_url":"https://github.com/vmware/vic/pull/1092","diff_url":"https://github.com/vmware/vic/pull/1092.diff","patch_url":"https://github.com/vmware/vic/pull/1092.patch","issue_url":"https://api.github.com/repos/vmware/vic/issues/1092","number":1092,"state":"open","locked":false,"title":"WIP: Initial draft PortLayer exec API","user":{"login":"corrieb","id":1699842,"avatar_url":"https://avatars.githubusercontent.com/u/1699842?v=3","gravatar_id":"","url":"https://api.github.com/users/corrieb","html_url":"https://github.com/corrieb","followers_url":"https://api.github.com/users/corrieb/followers","following_url":"https://api.github.com/users/corrieb/following{/other_user}","gists_url":"https://api.github.com/users/corrieb/gists{/gist_id}","starred_url":"https://api.github.com/users/corrieb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corrieb/subscriptions","organizations_url":"https://api.github.com/users/corrieb/orgs","repos_url":"https://api.github.com/users/corrieb/repos","events_url":"https://api.github.com/users/corrieb/events{/privacy}","received_events_url":"https://api.github.com/users/corrieb/received_events","type":"User","site_admin":false},"body":"Partial work towards #1043\r\n\r\nExperimental RPC code to demonstrate sparse handles\r\nExperimental minimal vSphere implementation code\r\n\r\nCurrently exists entirely in isolation and I'm looking for review comments on the API, not the code that backs it:\r\n\r\nexecution.go\r\ncontainer.go\r\nid.go\r\nhandle.go\r\n\r\nThe design for the API has been to facilitate many of the design goals in #1043. \r\n\r\n[skip-ci]\r\n","created_at":"2016-06-14T00:53:42Z","updated_at":"2016-06-14T19:53:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0e8a34ac068c24adbaaf114c46c32066f98b9116","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vmware/vic/pulls/1092/commits","review_comments_url":"https://api.github.com/repos/vmware/vic/pulls/1092/comments","review_comment_url":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/vic/issues/1092/comments","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/02d6909626c10e74e893f2a783d4a30441c64a21","head":{"label":"corrieb:1043","ref":"1043","sha":"02d6909626c10e74e893f2a783d4a30441c64a21","user":{"login":"corrieb","id":1699842,"avatar_url":"https://avatars.githubusercontent.com/u/1699842?v=3","gravatar_id":"","url":"https://api.github.com/users/corrieb","html_url":"https://github.com/corrieb","followers_url":"https://api.github.com/users/corrieb/followers","following_url":"https://api.github.com/users/corrieb/following{/other_user}","gists_url":"https://api.github.com/users/corrieb/gists{/gist_id}","starred_url":"https://api.github.com/users/corrieb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corrieb/subscriptions","organizations_url":"https://api.github.com/users/corrieb/orgs","repos_url":"https://api.github.com/users/corrieb/repos","events_url":"https://api.github.com/users/corrieb/events{/privacy}","received_events_url":"https://api.github.com/users/corrieb/received_events","type":"User","site_admin":false},"repo":{"id":61079275,"name":"vic","full_name":"corrieb/vic","owner":{"login":"corrieb","id":1699842,"avatar_url":"https://avatars.githubusercontent.com/u/1699842?v=3","gravatar_id":"","url":"https://api.github.com/users/corrieb","html_url":"https://github.com/corrieb","followers_url":"https://api.github.com/users/corrieb/followers","following_url":"https://api.github.com/users/corrieb/following{/other_user}","gists_url":"https://api.github.com/users/corrieb/gists{/gist_id}","starred_url":"https://api.github.com/users/corrieb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corrieb/subscriptions","organizations_url":"https://api.github.com/users/corrieb/orgs","repos_url":"https://api.github.com/users/corrieb/repos","events_url":"https://api.github.com/users/corrieb/events{/privacy}","received_events_url":"https://api.github.com/users/corrieb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/corrieb/vic","description":"Integrated containers on vSphere","fork":true,"url":"https://api.github.com/repos/corrieb/vic","forks_url":"https://api.github.com/repos/corrieb/vic/forks","keys_url":"https://api.github.com/repos/corrieb/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/corrieb/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/corrieb/vic/teams","hooks_url":"https://api.github.com/repos/corrieb/vic/hooks","issue_events_url":"https://api.github.com/repos/corrieb/vic/issues/events{/number}","events_url":"https://api.github.com/repos/corrieb/vic/events","assignees_url":"https://api.github.com/repos/corrieb/vic/assignees{/user}","branches_url":"https://api.github.com/repos/corrieb/vic/branches{/branch}","tags_url":"https://api.github.com/repos/corrieb/vic/tags","blobs_url":"https://api.github.com/repos/corrieb/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/corrieb/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/corrieb/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/corrieb/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/corrieb/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/corrieb/vic/languages","stargazers_url":"https://api.github.com/repos/corrieb/vic/stargazers","contributors_url":"https://api.github.com/repos/corrieb/vic/contributors","subscribers_url":"https://api.github.com/repos/corrieb/vic/subscribers","subscription_url":"https://api.github.com/repos/corrieb/vic/subscription","commits_url":"https://api.github.com/repos/corrieb/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/corrieb/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/corrieb/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/corrieb/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/corrieb/vic/contents/{+path}","compare_url":"https://api.github.com/repos/corrieb/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/corrieb/vic/merges","archive_url":"https://api.github.com/repos/corrieb/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/corrieb/vic/downloads","issues_url":"https://api.github.com/repos/corrieb/vic/issues{/number}","pulls_url":"https://api.github.com/repos/corrieb/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/corrieb/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/corrieb/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/corrieb/vic/labels{/name}","releases_url":"https://api.github.com/repos/corrieb/vic/releases{/id}","deployments_url":"https://api.github.com/repos/corrieb/vic/deployments","created_at":"2016-06-14T00:37:37Z","updated_at":"2016-06-14T00:38:48Z","pushed_at":"2016-06-14T15:25:48Z","git_url":"git://github.com/corrieb/vic.git","ssh_url":"git@github.com:corrieb/vic.git","clone_url":"https://github.com/corrieb/vic.git","svn_url":"https://github.com/corrieb/vic","homepage":null,"size":19502,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vmware:master","ref":"master","sha":"dfcf326b7ec1b6ad500a54702edfa8c85ae37ee1","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":49597898,"name":"vic","full_name":"vmware/vic","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/vic","description":"Integrated containers on vSphere","fork":false,"url":"https://api.github.com/repos/vmware/vic","forks_url":"https://api.github.com/repos/vmware/vic/forks","keys_url":"https://api.github.com/repos/vmware/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/vic/teams","hooks_url":"https://api.github.com/repos/vmware/vic/hooks","issue_events_url":"https://api.github.com/repos/vmware/vic/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/vic/events","assignees_url":"https://api.github.com/repos/vmware/vic/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/vic/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/vic/tags","blobs_url":"https://api.github.com/repos/vmware/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/vic/languages","stargazers_url":"https://api.github.com/repos/vmware/vic/stargazers","contributors_url":"https://api.github.com/repos/vmware/vic/contributors","subscribers_url":"https://api.github.com/repos/vmware/vic/subscribers","subscription_url":"https://api.github.com/repos/vmware/vic/subscription","commits_url":"https://api.github.com/repos/vmware/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/vic/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/vic/merges","archive_url":"https://api.github.com/repos/vmware/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/vic/downloads","issues_url":"https://api.github.com/repos/vmware/vic/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/vic/labels{/name}","releases_url":"https://api.github.com/repos/vmware/vic/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/vic/deployments","created_at":"2016-01-13T19:53:57Z","updated_at":"2016-06-10T18:46:47Z","pushed_at":"2016-06-14T18:28:22Z","git_url":"git://github.com/vmware/vic.git","ssh_url":"git@github.com:vmware/vic.git","clone_url":"https://github.com/vmware/vic.git","svn_url":"https://github.com/vmware/vic","homepage":null,"size":61885,"stargazers_count":89,"watchers_count":89,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":35,"mirror_url":null,"open_issues_count":408,"forks":35,"open_issues":408,"watchers":89,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/1092"},"html":{"href":"https://github.com/vmware/vic/pull/1092"},"issue":{"href":"https://api.github.com/repos/vmware/vic/issues/1092"},"comments":{"href":"https://api.github.com/repos/vmware/vic/issues/1092/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/vic/pulls/1092/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/vic/pulls/1092/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/vic/statuses/02d6909626c10e74e893f2a783d4a30441c64a21"}}}}
{"actor":{"display_login":"caglar10ur"}}