{"action":"created","comment":{"url":"https://api.github.com/repos/kata-containers/runtime/pulls/comments/206954443","pull_request_review_id":142468458,"id":206954443,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjk1NDQ0Mw==","diff_hunk":"@@ -0,0 +1,214 @@\n+// Copyright (c) 2018 Huawei Corporation.\n+//\n+// SPDX-License-Identifier: Apache-2.0\n+//\n+\n+package main\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"os\"\n+\n+\t\"github.com/kata-containers/agent/protocols/grpc\"\n+\tvc \"github.com/kata-containers/runtime/virtcontainers\"\n+\t\"github.com/urfave/cli\"\n+)\n+\n+var networkCLICommand = cli.Command{\n+\tName:  \"network\",\n+\tUsage: \"manage interfaces and routes for container\",\n+\tSubcommands: []cli.Command{\n+\t\taddIfaceCommand,\n+\t\tdelIfaceCommand,\n+\t\tlistIfacesCommand,\n+\t\tupdateRoutesCommand,\n+\t\tlistRoutesCommand,\n+\t},\n+\tAction: func(context *cli.Context) error {\n+\t\treturn cli.ShowSubcommandHelp(context)\n+\t},\n+}\n+\n+var addIfaceCommand = cli.Command{\n+\tName:      \"add-iface\",\n+\tUsage:     \"add an interface to a container\",\n+\tArgsUsage: `add-iface <container-id> file or - for stdin`,\n+\tFlags:     []cli.Flag{},\n+\tAction: func(context *cli.Context) error {\n+\t\tif context.Args().Present() == false {\n+\t\t\treturn fmt.Errorf(\"missing container ID, should provide one\")\n+\t\t}\n+\t\tcontainerID := context.Args().First()\n+\t\tstatus, sandboxID, err := getExistingContainerInfo(containerID)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tcontainerID = status.ID\n+\t\t// container MUST be running\n+\t\tif status.State.State != vc.StateRunning {\n+\t\t\treturn fmt.Errorf(\"container %s is not running\", containerID)\n+\t\t}\n+\n+\t\tvar (\n+\t\t\tinf   *grpc.Interface\n+\t\t\tf     *os.File\n+\t\t\tinput = context.Args().Get(1)\n+\t\t)\n+\t\tif input == \"-\" {\n+\t\t\tf = os.Stdin\n+\t\t} else {\n+\t\t\tf, err = os.Open(input)\n+\t\t\tif err != nil {\n+\t\t\t\treturn err\n+\t\t\t}\n+\t\t\tdefer f.Close()\n+\t\t}\n+\t\tif err = json.NewDecoder(f).Decode(&inf); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\n+\t\tresultingInf, err := vci.AddInterface(sandboxID, inf)\n+\t\tfmt.Println(resultingInf)\n+\t\treturn err\n+\t},\n+}\n+\n+var delIfaceCommand = cli.Command{\n+\tName:      \"del-iface\",\n+\tUsage:     \"delete an interface from a container\",\n+\tArgsUsage: `del-iface <container-id> file or - for stdin`,\n+\tFlags:     []cli.Flag{},\n+\tAction: func(context *cli.Context) error {\n+\t\tif context.Args().Present() == false {\n+\t\t\treturn fmt.Errorf(\"missing container ID, should provide one\")\n+\t\t}\n+\t\tcontainerID := context.Args().First()\n+\t\tstatus, sandboxID, err := getExistingContainerInfo(containerID)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tcontainerID = status.ID\n+\t\t// container MUST be running\n+\t\tif status.State.State != vc.StateRunning {\n+\t\t\treturn fmt.Errorf(\"container %s is not running\", containerID)\n+\t\t}\n+\n+\t\tvar (\n+\t\t\tinf   *grpc.Interface\n+\t\t\tf     *os.File\n+\t\t\tinput = context.Args().Get(1)\n+\t\t)\n+\t\tif input == \"-\" {\n+\t\t\tf = os.Stdin\n+\t\t} else {\n+\t\t\tf, err = os.Open(input)\n+\t\t\tif err != nil {\n+\t\t\t\treturn err\n+\t\t\t}\n+\t\t\tdefer f.Close()\n+\t\t}\n+\t\tif err = json.NewDecoder(f).Decode(&inf); err != nil {\n+\t\t\treturn err\n+\t\t}\n+\n+\t\tresultingInf, err := vci.RemoveInterface(sandboxID, inf)\n+\t\tfmt.Println(resultingInf)","path":"cli/network.go","position":116,"original_position":116,"commit_id":"1ca40f3b17cd6fe687d7b10c1939e284ced3743c","original_commit_id":"1ca40f3b17cd6fe687d7b10c1939e284ced3743c","user":{"login":"devimc","id":13009432,"node_id":"MDQ6VXNlcjEzMDA5NDMy","avatar_url":"https://avatars0.githubusercontent.com/u/13009432?v=4","gravatar_id":"","url":"https://api.github.com/users/devimc","html_url":"https://github.com/devimc","followers_url":"https://api.github.com/users/devimc/followers","following_url":"https://api.github.com/users/devimc/following{/other_user}","gists_url":"https://api.github.com/users/devimc/gists{/gist_id}","starred_url":"https://api.github.com/users/devimc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devimc/subscriptions","organizations_url":"https://api.github.com/users/devimc/orgs","repos_url":"https://api.github.com/users/devimc/repos","events_url":"https://api.github.com/users/devimc/events{/privacy}","received_events_url":"https://api.github.com/users/devimc/received_events","type":"User","site_admin":false},"body":"Log","created_at":"2018-08-01T16:52:17Z","updated_at":"2018-08-01T16:52:17Z","html_url":"https://github.com/kata-containers/runtime/pull/287#discussion_r206954443","pull_request_url":"https://api.github.com/repos/kata-containers/runtime/pulls/287","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/comments/206954443"},"html":{"href":"https://github.com/kata-containers/runtime/pull/287#discussion_r206954443"},"pull_request":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/287"}}},"pull_request":{"url":"https://api.github.com/repos/kata-containers/runtime/pulls/287","id":186373891,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg2MzczODkx","html_url":"https://github.com/kata-containers/runtime/pull/287","diff_url":"https://github.com/kata-containers/runtime/pull/287.diff","patch_url":"https://github.com/kata-containers/runtime/pull/287.patch","issue_url":"https://api.github.com/repos/kata-containers/runtime/issues/287","number":287,"state":"open","locked":false,"title":"[WIP]api: add sanbox hotplug network ","user":{"login":"caoruidong","id":5561983,"node_id":"MDQ6VXNlcjU1NjE5ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/5561983?v=4","gravatar_id":"","url":"https://api.github.com/users/caoruidong","html_url":"https://github.com/caoruidong","followers_url":"https://api.github.com/users/caoruidong/followers","following_url":"https://api.github.com/users/caoruidong/following{/other_user}","gists_url":"https://api.github.com/users/caoruidong/gists{/gist_id}","starred_url":"https://api.github.com/users/caoruidong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caoruidong/subscriptions","organizations_url":"https://api.github.com/users/caoruidong/orgs","repos_url":"https://api.github.com/users/caoruidong/repos","events_url":"https://api.github.com/users/caoruidong/events{/privacy}","received_events_url":"https://api.github.com/users/caoruidong/received_events","type":"User","site_admin":false},"body":"Fixes #113\r\nRefactor generate interface and route, add network hotplug interface\r\n\r\nSigned-off-by: Ruidong Cao <caoruidong@huawei.com>","created_at":"2018-05-07T14:50:08Z","updated_at":"2018-08-01T16:52:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b522a9fe58e70240a4bb8888665210a70c2bd35d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":764364758,"node_id":"MDU6TGFiZWw3NjQzNjQ3NTg=","url":"https://api.github.com/repos/kata-containers/runtime/labels/do-not-merge","name":"do-not-merge","color":"b60205","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kata-containers/runtime/pulls/287/commits","review_comments_url":"https://api.github.com/repos/kata-containers/runtime/pulls/287/comments","review_comment_url":"https://api.github.com/repos/kata-containers/runtime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kata-containers/runtime/issues/287/comments","statuses_url":"https://api.github.com/repos/kata-containers/runtime/statuses/1ca40f3b17cd6fe687d7b10c1939e284ced3743c","head":{"label":"caoruidong:hotplug","ref":"hotplug","sha":"1ca40f3b17cd6fe687d7b10c1939e284ced3743c","user":{"login":"caoruidong","id":5561983,"node_id":"MDQ6VXNlcjU1NjE5ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/5561983?v=4","gravatar_id":"","url":"https://api.github.com/users/caoruidong","html_url":"https://github.com/caoruidong","followers_url":"https://api.github.com/users/caoruidong/followers","following_url":"https://api.github.com/users/caoruidong/following{/other_user}","gists_url":"https://api.github.com/users/caoruidong/gists{/gist_id}","starred_url":"https://api.github.com/users/caoruidong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caoruidong/subscriptions","organizations_url":"https://api.github.com/users/caoruidong/orgs","repos_url":"https://api.github.com/users/caoruidong/repos","events_url":"https://api.github.com/users/caoruidong/events{/privacy}","received_events_url":"https://api.github.com/users/caoruidong/received_events","type":"User","site_admin":false},"repo":{"id":127697056,"node_id":"MDEwOlJlcG9zaXRvcnkxMjc2OTcwNTY=","name":"runtime","full_name":"caoruidong/runtime","owner":{"login":"caoruidong","id":5561983,"node_id":"MDQ6VXNlcjU1NjE5ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/5561983?v=4","gravatar_id":"","url":"https://api.github.com/users/caoruidong","html_url":"https://github.com/caoruidong","followers_url":"https://api.github.com/users/caoruidong/followers","following_url":"https://api.github.com/users/caoruidong/following{/other_user}","gists_url":"https://api.github.com/users/caoruidong/gists{/gist_id}","starred_url":"https://api.github.com/users/caoruidong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caoruidong/subscriptions","organizations_url":"https://api.github.com/users/caoruidong/orgs","repos_url":"https://api.github.com/users/caoruidong/repos","events_url":"https://api.github.com/users/caoruidong/events{/privacy}","received_events_url":"https://api.github.com/users/caoruidong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caoruidong/runtime","description":"Kata Containers runtimes","fork":true,"url":"https://api.github.com/repos/caoruidong/runtime","forks_url":"https://api.github.com/repos/caoruidong/runtime/forks","keys_url":"https://api.github.com/repos/caoruidong/runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caoruidong/runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caoruidong/runtime/teams","hooks_url":"https://api.github.com/repos/caoruidong/runtime/hooks","issue_events_url":"https://api.github.com/repos/caoruidong/runtime/issues/events{/number}","events_url":"https://api.github.com/repos/caoruidong/runtime/events","assignees_url":"https://api.github.com/repos/caoruidong/runtime/assignees{/user}","branches_url":"https://api.github.com/repos/caoruidong/runtime/branches{/branch}","tags_url":"https://api.github.com/repos/caoruidong/runtime/tags","blobs_url":"https://api.github.com/repos/caoruidong/runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caoruidong/runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caoruidong/runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/caoruidong/runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caoruidong/runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/caoruidong/runtime/languages","stargazers_url":"https://api.github.com/repos/caoruidong/runtime/stargazers","contributors_url":"https://api.github.com/repos/caoruidong/runtime/contributors","subscribers_url":"https://api.github.com/repos/caoruidong/runtime/subscribers","subscription_url":"https://api.github.com/repos/caoruidong/runtime/subscription","commits_url":"https://api.github.com/repos/caoruidong/runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/caoruidong/runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/caoruidong/runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/caoruidong/runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/caoruidong/runtime/contents/{+path}","compare_url":"https://api.github.com/repos/caoruidong/runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caoruidong/runtime/merges","archive_url":"https://api.github.com/repos/caoruidong/runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caoruidong/runtime/downloads","issues_url":"https://api.github.com/repos/caoruidong/runtime/issues{/number}","pulls_url":"https://api.github.com/repos/caoruidong/runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/caoruidong/runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/caoruidong/runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caoruidong/runtime/labels{/name}","releases_url":"https://api.github.com/repos/caoruidong/runtime/releases{/id}","deployments_url":"https://api.github.com/repos/caoruidong/runtime/deployments","created_at":"2018-04-02T03:17:56Z","updated_at":"2018-06-20T02:01:04Z","pushed_at":"2018-08-01T07:54:46Z","git_url":"git://github.com/caoruidong/runtime.git","ssh_url":"git@github.com:caoruidong/runtime.git","clone_url":"https://github.com/caoruidong/runtime.git","svn_url":"https://github.com/caoruidong/runtime","homepage":"","size":4453,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kata-containers:master","ref":"master","sha":"1dae0560128934c0786b714274b9e8499dfab3cc","user":{"login":"kata-containers","id":33289952,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMjg5OTUy","avatar_url":"https://avatars3.githubusercontent.com/u/33289952?v=4","gravatar_id":"","url":"https://api.github.com/users/kata-containers","html_url":"https://github.com/kata-containers","followers_url":"https://api.github.com/users/kata-containers/followers","following_url":"https://api.github.com/users/kata-containers/following{/other_user}","gists_url":"https://api.github.com/users/kata-containers/gists{/gist_id}","starred_url":"https://api.github.com/users/kata-containers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kata-containers/subscriptions","organizations_url":"https://api.github.com/users/kata-containers/orgs","repos_url":"https://api.github.com/users/kata-containers/repos","events_url":"https://api.github.com/users/kata-containers/events{/privacy}","received_events_url":"https://api.github.com/users/kata-containers/received_events","type":"Organization","site_admin":false},"repo":{"id":110539997,"node_id":"MDEwOlJlcG9zaXRvcnkxMTA1Mzk5OTc=","name":"runtime","full_name":"kata-containers/runtime","owner":{"login":"kata-containers","id":33289952,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMjg5OTUy","avatar_url":"https://avatars3.githubusercontent.com/u/33289952?v=4","gravatar_id":"","url":"https://api.github.com/users/kata-containers","html_url":"https://github.com/kata-containers","followers_url":"https://api.github.com/users/kata-containers/followers","following_url":"https://api.github.com/users/kata-containers/following{/other_user}","gists_url":"https://api.github.com/users/kata-containers/gists{/gist_id}","starred_url":"https://api.github.com/users/kata-containers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kata-containers/subscriptions","organizations_url":"https://api.github.com/users/kata-containers/orgs","repos_url":"https://api.github.com/users/kata-containers/repos","events_url":"https://api.github.com/users/kata-containers/events{/privacy}","received_events_url":"https://api.github.com/users/kata-containers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kata-containers/runtime","description":"Kata Containers runtime","fork":false,"url":"https://api.github.com/repos/kata-containers/runtime","forks_url":"https://api.github.com/repos/kata-containers/runtime/forks","keys_url":"https://api.github.com/repos/kata-containers/runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kata-containers/runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kata-containers/runtime/teams","hooks_url":"https://api.github.com/repos/kata-containers/runtime/hooks","issue_events_url":"https://api.github.com/repos/kata-containers/runtime/issues/events{/number}","events_url":"https://api.github.com/repos/kata-containers/runtime/events","assignees_url":"https://api.github.com/repos/kata-containers/runtime/assignees{/user}","branches_url":"https://api.github.com/repos/kata-containers/runtime/branches{/branch}","tags_url":"https://api.github.com/repos/kata-containers/runtime/tags","blobs_url":"https://api.github.com/repos/kata-containers/runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kata-containers/runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kata-containers/runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/kata-containers/runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kata-containers/runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/kata-containers/runtime/languages","stargazers_url":"https://api.github.com/repos/kata-containers/runtime/stargazers","contributors_url":"https://api.github.com/repos/kata-containers/runtime/contributors","subscribers_url":"https://api.github.com/repos/kata-containers/runtime/subscribers","subscription_url":"https://api.github.com/repos/kata-containers/runtime/subscription","commits_url":"https://api.github.com/repos/kata-containers/runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/kata-containers/runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/kata-containers/runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/kata-containers/runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/kata-containers/runtime/contents/{+path}","compare_url":"https://api.github.com/repos/kata-containers/runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kata-containers/runtime/merges","archive_url":"https://api.github.com/repos/kata-containers/runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kata-containers/runtime/downloads","issues_url":"https://api.github.com/repos/kata-containers/runtime/issues{/number}","pulls_url":"https://api.github.com/repos/kata-containers/runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/kata-containers/runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/kata-containers/runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kata-containers/runtime/labels{/name}","releases_url":"https://api.github.com/repos/kata-containers/runtime/releases{/id}","deployments_url":"https://api.github.com/repos/kata-containers/runtime/deployments","created_at":"2017-11-13T11:29:03Z","updated_at":"2018-08-01T11:50:56Z","pushed_at":"2018-08-01T16:40:32Z","git_url":"git://github.com/kata-containers/runtime.git","ssh_url":"git@github.com:kata-containers/runtime.git","clone_url":"https://github.com/kata-containers/runtime.git","svn_url":"https://github.com/kata-containers/runtime","homepage":"","size":4465,"stargazers_count":416,"watchers_count":416,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":91,"mirror_url":null,"archived":false,"open_issues_count":121,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":91,"open_issues":121,"watchers":416,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/287"},"html":{"href":"https://github.com/kata-containers/runtime/pull/287"},"issue":{"href":"https://api.github.com/repos/kata-containers/runtime/issues/287"},"comments":{"href":"https://api.github.com/repos/kata-containers/runtime/issues/287/comments"},"review_comments":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/287/comments"},"review_comment":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/287/commits"},"statuses":{"href":"https://api.github.com/repos/kata-containers/runtime/statuses/1ca40f3b17cd6fe687d7b10c1939e284ced3743c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"devimc"}}