{"action":"created","comment":{"url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/comments/140487631","pull_request_review_id":64570702,"id":140487631,"diff_hunk":"@@ -85,35 +85,69 @@ func (c *Controller) GetNetwork(tenantName, networkName string) (*types.VirtualN\n \treturn net, nil\n }\n \n-func (c *Controller) GetIpamSubnet(net *types.VirtualNetwork) (*types.IpamSubnetType, error) {\n+// GetIpamSubnet returns IPAM subnet of specified virtual network with specified CIDR.\n+// If virtual network has only one subnet, CIDR is ignored.\n+func (c *Controller) GetIpamSubnet(net *types.VirtualNetwork, CIDR string) (\n+\t*types.IpamSubnetType, error) {\n+\n+\tif strings.HasPrefix(CIDR, \"0.0.0.0\") {\n+\t\t// this means that the user didn't provide a subnet\n+\t\tCIDR = \"\"\n+\t}\n+\n \tipamReferences, err := net.GetNetworkIpamRefs()\n \tif err != nil {\n \t\tlog.Errorf(\"Failed to get ipam references: %v\", err)\n \t\treturn nil, err\n \t}\n-\tif len(ipamReferences) == 0 {\n-\t\terr = errors.New(\"Ipam references list is empty\")\n-\t\tlog.Error(err)\n-\t\treturn nil, err\n+\n+\tvar allIpamSubnets []types.IpamSubnetType\n+\tfor _, ref := range ipamReferences {\n+\t\tattribute := ref.Attr\n+\t\tipamSubnets := attribute.(types.VnSubnetsType).IpamSubnets\n+\t\tfor _, ipamSubnet := range ipamSubnets {\n+\t\t\tallIpamSubnets = append(allIpamSubnets, ipamSubnet)\n+\t\t}\n \t}\n-\tattribute := ipamReferences[0].Attr\n-\tipamSubnets := attribute.(types.VnSubnetsType).IpamSubnets\n-\tif len(ipamSubnets) == 0 {\n-\t\terr = errors.New(\"Ipam subnets list is empty\")\n+\n+\tif len(allIpamSubnets) == 0 {\n+\t\terr = errors.New(\"No Ipam subnets found\")\n \t\tlog.Error(err)\n \t\treturn nil, err\n \t}\n-\treturn &ipamSubnets[0], nil\n-}\n \n-func (c *Controller) GetDefaultGatewayIp(net *types.VirtualNetwork) (string, error) {\n-\tsubnet, err := c.GetIpamSubnet(net)\n-\tif err != nil {\n-\t\treturn \"\", err\n+\tif CIDR == \"\" {\n+\t\tif len(allIpamSubnets) > 1 {\n+\t\t\terr = errors.New(\"Didn't specify subnet CIDR and there are multiple Contrail subnets\")\n+\t\t\tlog.Error(err)\n+\t\t\treturn nil, err\n+\t\t}\n+\t\t// return the one and only subnet\n+\t\treturn &allIpamSubnets[0], nil\n+\t}\n+\n+\t// there are multiple subnets to choose from\n+\tfor _, ipam := range allIpamSubnets {\n+\n+\t\tthisCIDR := fmt.Sprintf(\"%s/%v\", ipam.Subnet.IpPrefix,\n+\t\t\tipam.Subnet.IpPrefixLen)\n+\n+\t\tif CIDR != \"\" {","path":"controller/controller.go","position":76,"original_position":76,"commit_id":"d366c51f1b33f3ae9ed78bec9e9a66b8f9bf529a","original_commit_id":"d366c51f1b33f3ae9ed78bec9e9a66b8f9bf529a","user":{"login":"PawelMarchewkaCodiLime","id":31847731,"avatar_url":"https://avatars1.githubusercontent.com/u/31847731?v=4","gravatar_id":"","url":"https://api.github.com/users/PawelMarchewkaCodiLime","html_url":"https://github.com/PawelMarchewkaCodiLime","followers_url":"https://api.github.com/users/PawelMarchewkaCodiLime/followers","following_url":"https://api.github.com/users/PawelMarchewkaCodiLime/following{/other_user}","gists_url":"https://api.github.com/users/PawelMarchewkaCodiLime/gists{/gist_id}","starred_url":"https://api.github.com/users/PawelMarchewkaCodiLime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PawelMarchewkaCodiLime/subscriptions","organizations_url":"https://api.github.com/users/PawelMarchewkaCodiLime/orgs","repos_url":"https://api.github.com/users/PawelMarchewkaCodiLime/repos","events_url":"https://api.github.com/users/PawelMarchewkaCodiLime/events{/privacy}","received_events_url":"https://api.github.com/users/PawelMarchewkaCodiLime/received_events","type":"User","site_admin":false},"body":"I think CIDR can't be equal here to \"\", because of the 'if statement above. Am I right ?","created_at":"2017-09-22T13:04:45Z","updated_at":"2017-09-22T13:18:38Z","html_url":"https://github.com/codilime/contrail-windows-docker/pull/39#discussion_r140487631","pull_request_url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/comments/140487631"},"html":{"href":"https://github.com/codilime/contrail-windows-docker/pull/39#discussion_r140487631"},"pull_request":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39","id":105941007,"html_url":"https://github.com/codilime/contrail-windows-docker/pull/39","diff_url":"https://github.com/codilime/contrail-windows-docker/pull/39.diff","patch_url":"https://github.com/codilime/contrail-windows-docker/pull/39.patch","issue_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/39","number":39,"state":"open","locked":false,"title":"[WIP] JW-189 handle multiple subnets","user":{"login":"m-kostrzewa","id":9220158,"avatar_url":"https://avatars3.githubusercontent.com/u/9220158?v=4","gravatar_id":"","url":"https://api.github.com/users/m-kostrzewa","html_url":"https://github.com/m-kostrzewa","followers_url":"https://api.github.com/users/m-kostrzewa/followers","following_url":"https://api.github.com/users/m-kostrzewa/following{/other_user}","gists_url":"https://api.github.com/users/m-kostrzewa/gists{/gist_id}","starred_url":"https://api.github.com/users/m-kostrzewa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-kostrzewa/subscriptions","organizations_url":"https://api.github.com/users/m-kostrzewa/orgs","repos_url":"https://api.github.com/users/m-kostrzewa/repos","events_url":"https://api.github.com/users/m-kostrzewa/events{/privacy}","received_events_url":"https://api.github.com/users/m-kostrzewa/received_events","type":"User","site_admin":false},"body":"**WIP, do not merge**\r\n\r\nThis PR allows the user to specify which contrail subnet (network can have multiple subnets) should be used as the subnet in docker and hns.\r\n\r\nIf contrail network has only one subnet, then everything is as it used to be. If it has multiple, user needs to specify it using ```--subnet``` parameter of ```docker network create``` command.\r\n\r\nRight now, since it's kinda hard to modify HNS networks to accomodate multiple subnets (it can be done only upon creation AFAIK), we will use a single HNS network (and single Docker network) per single Contrail subnet. ","created_at":"2017-02-13T17:29:31Z","updated_at":"2017-09-22T13:18:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1c80c9d92f546f8cbfe6f2e88bc4114de51c473","assignee":{"login":"jablonskim","id":6965522,"avatar_url":"https://avatars0.githubusercontent.com/u/6965522?v=4","gravatar_id":"","url":"https://api.github.com/users/jablonskim","html_url":"https://github.com/jablonskim","followers_url":"https://api.github.com/users/jablonskim/followers","following_url":"https://api.github.com/users/jablonskim/following{/other_user}","gists_url":"https://api.github.com/users/jablonskim/gists{/gist_id}","starred_url":"https://api.github.com/users/jablonskim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jablonskim/subscriptions","organizations_url":"https://api.github.com/users/jablonskim/orgs","repos_url":"https://api.github.com/users/jablonskim/repos","events_url":"https://api.github.com/users/jablonskim/events{/privacy}","received_events_url":"https://api.github.com/users/jablonskim/received_events","type":"User","site_admin":false},"assignees":[{"login":"jablonskim","id":6965522,"avatar_url":"https://avatars0.githubusercontent.com/u/6965522?v=4","gravatar_id":"","url":"https://api.github.com/users/jablonskim","html_url":"https://github.com/jablonskim","followers_url":"https://api.github.com/users/jablonskim/followers","following_url":"https://api.github.com/users/jablonskim/following{/other_user}","gists_url":"https://api.github.com/users/jablonskim/gists{/gist_id}","starred_url":"https://api.github.com/users/jablonskim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jablonskim/subscriptions","organizations_url":"https://api.github.com/users/jablonskim/orgs","repos_url":"https://api.github.com/users/jablonskim/repos","events_url":"https://api.github.com/users/jablonskim/events{/privacy}","received_events_url":"https://api.github.com/users/jablonskim/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"sodar","id":1798621,"avatar_url":"https://avatars1.githubusercontent.com/u/1798621?v=4","gravatar_id":"","url":"https://api.github.com/users/sodar","html_url":"https://github.com/sodar","followers_url":"https://api.github.com/users/sodar/followers","following_url":"https://api.github.com/users/sodar/following{/other_user}","gists_url":"https://api.github.com/users/sodar/gists{/gist_id}","starred_url":"https://api.github.com/users/sodar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sodar/subscriptions","organizations_url":"https://api.github.com/users/sodar/orgs","repos_url":"https://api.github.com/users/sodar/repos","events_url":"https://api.github.com/users/sodar/events{/privacy}","received_events_url":"https://api.github.com/users/sodar/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39/commits","review_comments_url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39/comments","review_comment_url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/39/comments","statuses_url":"https://api.github.com/repos/codilime/contrail-windows-docker/statuses/d366c51f1b33f3ae9ed78bec9e9a66b8f9bf529a","head":{"label":"codilime:JW-189_multiple_subnets","ref":"JW-189_multiple_subnets","sha":"d366c51f1b33f3ae9ed78bec9e9a66b8f9bf529a","user":{"login":"codilime","id":2143695,"avatar_url":"https://avatars1.githubusercontent.com/u/2143695?v=4","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"repo":{"id":75595436,"name":"contrail-windows-docker","full_name":"codilime/contrail-windows-docker","owner":{"login":"codilime","id":2143695,"avatar_url":"https://avatars1.githubusercontent.com/u/2143695?v=4","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codilime/contrail-windows-docker","description":null,"fork":false,"url":"https://api.github.com/repos/codilime/contrail-windows-docker","forks_url":"https://api.github.com/repos/codilime/contrail-windows-docker/forks","keys_url":"https://api.github.com/repos/codilime/contrail-windows-docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codilime/contrail-windows-docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codilime/contrail-windows-docker/teams","hooks_url":"https://api.github.com/repos/codilime/contrail-windows-docker/hooks","issue_events_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/events{/number}","events_url":"https://api.github.com/repos/codilime/contrail-windows-docker/events","assignees_url":"https://api.github.com/repos/codilime/contrail-windows-docker/assignees{/user}","branches_url":"https://api.github.com/repos/codilime/contrail-windows-docker/branches{/branch}","tags_url":"https://api.github.com/repos/codilime/contrail-windows-docker/tags","blobs_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codilime/contrail-windows-docker/statuses/{sha}","languages_url":"https://api.github.com/repos/codilime/contrail-windows-docker/languages","stargazers_url":"https://api.github.com/repos/codilime/contrail-windows-docker/stargazers","contributors_url":"https://api.github.com/repos/codilime/contrail-windows-docker/contributors","subscribers_url":"https://api.github.com/repos/codilime/contrail-windows-docker/subscribers","subscription_url":"https://api.github.com/repos/codilime/contrail-windows-docker/subscription","commits_url":"https://api.github.com/repos/codilime/contrail-windows-docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/codilime/contrail-windows-docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/codilime/contrail-windows-docker/contents/{+path}","compare_url":"https://api.github.com/repos/codilime/contrail-windows-docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codilime/contrail-windows-docker/merges","archive_url":"https://api.github.com/repos/codilime/contrail-windows-docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codilime/contrail-windows-docker/downloads","issues_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues{/number}","pulls_url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls{/number}","milestones_url":"https://api.github.com/repos/codilime/contrail-windows-docker/milestones{/number}","notifications_url":"https://api.github.com/repos/codilime/contrail-windows-docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codilime/contrail-windows-docker/labels{/name}","releases_url":"https://api.github.com/repos/codilime/contrail-windows-docker/releases{/id}","deployments_url":"https://api.github.com/repos/codilime/contrail-windows-docker/deployments","created_at":"2016-12-05T06:25:36Z","updated_at":"2016-12-06T12:40:13Z","pushed_at":"2017-09-20T09:39:17Z","git_url":"git://github.com/codilime/contrail-windows-docker.git","ssh_url":"git@github.com:codilime/contrail-windows-docker.git","clone_url":"https://github.com/codilime/contrail-windows-docker.git","svn_url":"https://github.com/codilime/contrail-windows-docker","homepage":null,"size":4446,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"codilime:master","ref":"master","sha":"1a3e139525db374e22eb2b10c23db00a71506225","user":{"login":"codilime","id":2143695,"avatar_url":"https://avatars1.githubusercontent.com/u/2143695?v=4","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"repo":{"id":75595436,"name":"contrail-windows-docker","full_name":"codilime/contrail-windows-docker","owner":{"login":"codilime","id":2143695,"avatar_url":"https://avatars1.githubusercontent.com/u/2143695?v=4","gravatar_id":"","url":"https://api.github.com/users/codilime","html_url":"https://github.com/codilime","followers_url":"https://api.github.com/users/codilime/followers","following_url":"https://api.github.com/users/codilime/following{/other_user}","gists_url":"https://api.github.com/users/codilime/gists{/gist_id}","starred_url":"https://api.github.com/users/codilime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codilime/subscriptions","organizations_url":"https://api.github.com/users/codilime/orgs","repos_url":"https://api.github.com/users/codilime/repos","events_url":"https://api.github.com/users/codilime/events{/privacy}","received_events_url":"https://api.github.com/users/codilime/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codilime/contrail-windows-docker","description":null,"fork":false,"url":"https://api.github.com/repos/codilime/contrail-windows-docker","forks_url":"https://api.github.com/repos/codilime/contrail-windows-docker/forks","keys_url":"https://api.github.com/repos/codilime/contrail-windows-docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codilime/contrail-windows-docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codilime/contrail-windows-docker/teams","hooks_url":"https://api.github.com/repos/codilime/contrail-windows-docker/hooks","issue_events_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/events{/number}","events_url":"https://api.github.com/repos/codilime/contrail-windows-docker/events","assignees_url":"https://api.github.com/repos/codilime/contrail-windows-docker/assignees{/user}","branches_url":"https://api.github.com/repos/codilime/contrail-windows-docker/branches{/branch}","tags_url":"https://api.github.com/repos/codilime/contrail-windows-docker/tags","blobs_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codilime/contrail-windows-docker/statuses/{sha}","languages_url":"https://api.github.com/repos/codilime/contrail-windows-docker/languages","stargazers_url":"https://api.github.com/repos/codilime/contrail-windows-docker/stargazers","contributors_url":"https://api.github.com/repos/codilime/contrail-windows-docker/contributors","subscribers_url":"https://api.github.com/repos/codilime/contrail-windows-docker/subscribers","subscription_url":"https://api.github.com/repos/codilime/contrail-windows-docker/subscription","commits_url":"https://api.github.com/repos/codilime/contrail-windows-docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/codilime/contrail-windows-docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/codilime/contrail-windows-docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/codilime/contrail-windows-docker/contents/{+path}","compare_url":"https://api.github.com/repos/codilime/contrail-windows-docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codilime/contrail-windows-docker/merges","archive_url":"https://api.github.com/repos/codilime/contrail-windows-docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codilime/contrail-windows-docker/downloads","issues_url":"https://api.github.com/repos/codilime/contrail-windows-docker/issues{/number}","pulls_url":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls{/number}","milestones_url":"https://api.github.com/repos/codilime/contrail-windows-docker/milestones{/number}","notifications_url":"https://api.github.com/repos/codilime/contrail-windows-docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codilime/contrail-windows-docker/labels{/name}","releases_url":"https://api.github.com/repos/codilime/contrail-windows-docker/releases{/id}","deployments_url":"https://api.github.com/repos/codilime/contrail-windows-docker/deployments","created_at":"2016-12-05T06:25:36Z","updated_at":"2016-12-06T12:40:13Z","pushed_at":"2017-09-20T09:39:17Z","git_url":"git://github.com/codilime/contrail-windows-docker.git","ssh_url":"git@github.com:codilime/contrail-windows-docker.git","clone_url":"https://github.com/codilime/contrail-windows-docker.git","svn_url":"https://github.com/codilime/contrail-windows-docker","homepage":null,"size":4446,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39"},"html":{"href":"https://github.com/codilime/contrail-windows-docker/pull/39"},"issue":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/39"},"comments":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/codilime/contrail-windows-docker/statuses/d366c51f1b33f3ae9ed78bec9e9a66b8f9bf529a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"PawelMarchewkaCodiLime"}}