{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/kubernetes/pulls/comments/102616621","pull_request_review_id":23374618,"id":102616621,"diff_hunk":"@@ -400,108 +339,79 @@ func getVirtualMachineManagedObjectReference(ctx context.Context, c *govmomi.Cli\n \treturn nil\n }\n \n-// Returns names of running VMs inside VM folder.\n-func getInstances(ctx context.Context, cfg *VSphereConfig, c *govmomi.Client, filter string) ([]string, error) {\n-\tf := find.NewFinder(c.Client, true)\n-\tdc, err := f.Datacenter(ctx, cfg.Global.Datacenter)\n-\tif err != nil {\n-\t\treturn nil, err\n-\t}\n-\n-\tf.SetDatacenter(dc)\n-\n-\tvmRegex := cfg.Global.WorkingDir + filter\n-\n-\t//TODO: get all vms inside subfolders\n-\tvms, err := f.VirtualMachineList(ctx, vmRegex)\n-\tif err != nil {\n-\t\treturn nil, err\n-\t}\n-\n-\tvar vmRef []types.ManagedObjectReference\n-\tfor _, vm := range vms {\n-\t\tvmRef = append(vmRef, vm.Reference())\n-\t}\n-\n-\tpc := property.DefaultCollector(c.Client)\n+// Instances returns an implementation of Instances for vSphere.\n+func (vs *VSphere) Instances() (cloudprovider.Instances, bool) {\n+\treturn vs, true\n+}\n \n-\tvar vmt []mo.VirtualMachine\n-\terr = pc.Retrieve(ctx, vmRef, []string{\"name\", \"summary\"}, &vmt)\n-\tif err != nil {\n-\t\treturn nil, err\n-\t}\n+// NodeAddresses is an implementation of Instances.NodeAddresses.\n+func (vs *VSphere) NodeAddresses(nodeName k8stypes.NodeName) ([]v1.NodeAddress, error) {\n+\taddrs := []v1.NodeAddress{}\n \n-\tvar vmList []string\n-\tfor _, vm := range vmt {\n-\t\tif vm.Summary.Runtime.PowerState == ActivePowerState {\n-\t\t\tvmList = append(vmList, vm.Name)\n-\t\t} else if vm.Summary.Config.Template == false {\n-\t\t\tglog.Warningf(\"VM %s, is not in %s state\", vm.Name, ActivePowerState)\n+\tif vs.localInstanceID == nodeNameToVMName(nodeName) {\n+\t\t/* Get local IP addresses if node is local node */\n+\t\tifaces, err := net.Interfaces()\n+\t\tif err != nil {\n+\t\t\tglog.Errorf(\"net.Interfaces() failed for NodeAddresses - %v\", err)\n+\t\t\treturn nil, err\n \t\t}\n-\t}\n-\treturn vmList, nil\n-}\n-\n-type Instances struct {\n-\tclient          *govmomi.Client\n-\tcfg             *VSphereConfig\n-\tlocalInstanceID string\n-}\n \n-// Instances returns an implementation of Instances for vSphere.\n-func (vs *VSphere) Instances() (cloudprovider.Instances, bool) {\n-\t// Ensure client is logged in and session is valid\n-\terr := vSphereLogin(context.TODO(), vs)\n-\tif err != nil {\n-\t\tglog.Errorf(\"Failed to login into vCenter - %v\", err)\n-\t\treturn nil, false\n+\t\tfor _, i := range ifaces {\n+\t\t\tlocalAddrs, err := i.Addrs()\n+\t\t\tif err != nil {\n+\t\t\t\tglog.Warningf(\"Failed to extract addresses for NodeAddresses - %v\", err)\n+\t\t\t} else {\n+\t\t\t\tfor _, addr := range localAddrs {\n+\t\t\t\t\tif ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n+\t\t\t\t\t\tif ipnet.IP.To4() != nil {\n+\t\t\t\t\t\t\t// Filter external IP by MAC address OUIs from vCenter and from ESX\n+\t\t\t\t\t\t\tvar addressType v1.NodeAddressType\n+\t\t\t\t\t\t\tif strings.HasPrefix(i.HardwareAddr.String(), MAC_OUI_VC) ||\n+\t\t\t\t\t\t\t\tstrings.HasPrefix(i.HardwareAddr.String(), MAC_OUI_ESX) {\n+\t\t\t\t\t\t\t\taddressType = v1.NodeExternalIP\n+\t\t\t\t\t\t\t} else {\n+\t\t\t\t\t\t\t\taddressType = v1.NodeInternalIP\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\tv1.AddToNodeAddresses(&addrs,\n+\t\t\t\t\t\t\t\tv1.NodeAddress{\n+\t\t\t\t\t\t\t\t\tType:    addressType,\n+\t\t\t\t\t\t\t\t\tAddress: ipnet.IP.String(),\n+\t\t\t\t\t\t\t\t},\n+\t\t\t\t\t\t\t)\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\treturn addrs, nil\n \t}\n-\treturn &Instances{vs.client, vs.cfg, vs.localInstanceID}, true\n-}\n \n-// List returns names of VMs (inside vm folder) by applying filter and which are currently running.\n-func (vs *VSphere) list(filter string) ([]k8stypes.NodeName, error) {","path":"pkg/cloudprovider/providers/vsphere/vsphere.go","position":230,"original_position":230,"commit_id":"594432feade98414461b76eb3ac8a564e6038674","original_commit_id":"594432feade98414461b76eb3ac8a564e6038674","user":{"login":"BaluDontu","id":22899615,"avatar_url":"https://avatars.githubusercontent.com/u/22899615?v=3","gravatar_id":"","url":"https://api.github.com/users/BaluDontu","html_url":"https://github.com/BaluDontu","followers_url":"https://api.github.com/users/BaluDontu/followers","following_url":"https://api.github.com/users/BaluDontu/following{/other_user}","gists_url":"https://api.github.com/users/BaluDontu/gists{/gist_id}","starred_url":"https://api.github.com/users/BaluDontu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BaluDontu/subscriptions","organizations_url":"https://api.github.com/users/BaluDontu/orgs","repos_url":"https://api.github.com/users/BaluDontu/repos","events_url":"https://api.github.com/users/BaluDontu/events{/privacy}","received_events_url":"https://api.github.com/users/BaluDontu/received_events","type":"User","site_admin":false},"body":"Is this an unused function? I don't see any references in original codE?","created_at":"2017-02-23T01:07:07Z","updated_at":"2017-02-23T01:13:36Z","html_url":"https://github.com/vmware/kubernetes/pull/104#discussion_r102616621","pull_request_url":"https://api.github.com/repos/vmware/kubernetes/pulls/104","_links":{"self":{"href":"https://api.github.com/repos/vmware/kubernetes/pulls/comments/102616621"},"html":{"href":"https://github.com/vmware/kubernetes/pull/104#discussion_r102616621"},"pull_request":{"href":"https://api.github.com/repos/vmware/kubernetes/pulls/104"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/kubernetes/pulls/104","id":107509451,"html_url":"https://github.com/vmware/kubernetes/pull/104","diff_url":"https://github.com/vmware/kubernetes/pull/104.diff","patch_url":"https://github.com/vmware/kubernetes/pull/104.patch","issue_url":"https://api.github.com/repos/vmware/kubernetes/issues/104","number":104,"state":"open","locked":false,"title":"Remove login info on workers for vsphere cloud provider.","user":{"login":"luomiao","id":8987721,"avatar_url":"https://avatars.githubusercontent.com/u/8987721?v=3","gravatar_id":"","url":"https://api.github.com/users/luomiao","html_url":"https://github.com/luomiao","followers_url":"https://api.github.com/users/luomiao/followers","following_url":"https://api.github.com/users/luomiao/following{/other_user}","gists_url":"https://api.github.com/users/luomiao/gists{/gist_id}","starred_url":"https://api.github.com/users/luomiao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luomiao/subscriptions","organizations_url":"https://api.github.com/users/luomiao/orgs","repos_url":"https://api.github.com/users/luomiao/repos","events_url":"https://api.github.com/users/luomiao/events{/privacy}","received_events_url":"https://api.github.com/users/luomiao/received_events","type":"User","site_admin":false},"body":"Remove the dependency of login information on worker nodes for vsphere cloud provider:\r\n1. VM Name is required to be set in the cloud provider configuration file. Corresponding update in kube-anywhere is needed.\r\n2. Remove the requirement of login for Instance functions when querying local node information.\r\n3. Remove the List function implementation since this function is already removed from Instance's interface.\r\n\r\n\r\n","created_at":"2017-02-22T22:07:02Z","updated_at":"2017-02-23T01:13:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0382d9ffc29c42bc3edfd9ed362aa3e6542546f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/kubernetes/pulls/104/commits","review_comments_url":"https://api.github.com/repos/vmware/kubernetes/pulls/104/comments","review_comment_url":"https://api.github.com/repos/vmware/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/kubernetes/issues/104/comments","statuses_url":"https://api.github.com/repos/vmware/kubernetes/statuses/594432feade98414461b76eb3ac8a564e6038674","head":{"label":"luomiao:vsphere-remove-loginInfo-on-workers","ref":"vsphere-remove-loginInfo-on-workers","sha":"594432feade98414461b76eb3ac8a564e6038674","user":{"login":"luomiao","id":8987721,"avatar_url":"https://avatars.githubusercontent.com/u/8987721?v=3","gravatar_id":"","url":"https://api.github.com/users/luomiao","html_url":"https://github.com/luomiao","followers_url":"https://api.github.com/users/luomiao/followers","following_url":"https://api.github.com/users/luomiao/following{/other_user}","gists_url":"https://api.github.com/users/luomiao/gists{/gist_id}","starred_url":"https://api.github.com/users/luomiao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luomiao/subscriptions","organizations_url":"https://api.github.com/users/luomiao/orgs","repos_url":"https://api.github.com/users/luomiao/repos","events_url":"https://api.github.com/users/luomiao/events{/privacy}","received_events_url":"https://api.github.com/users/luomiao/received_events","type":"User","site_admin":false},"repo":{"id":67172599,"name":"kubernetes","full_name":"luomiao/kubernetes","owner":{"login":"luomiao","id":8987721,"avatar_url":"https://avatars.githubusercontent.com/u/8987721?v=3","gravatar_id":"","url":"https://api.github.com/users/luomiao","html_url":"https://github.com/luomiao","followers_url":"https://api.github.com/users/luomiao/followers","following_url":"https://api.github.com/users/luomiao/following{/other_user}","gists_url":"https://api.github.com/users/luomiao/gists{/gist_id}","starred_url":"https://api.github.com/users/luomiao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luomiao/subscriptions","organizations_url":"https://api.github.com/users/luomiao/orgs","repos_url":"https://api.github.com/users/luomiao/repos","events_url":"https://api.github.com/users/luomiao/events{/privacy}","received_events_url":"https://api.github.com/users/luomiao/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/luomiao/kubernetes","description":"Production-Grade Container Scheduling and Management","fork":true,"url":"https://api.github.com/repos/luomiao/kubernetes","forks_url":"https://api.github.com/repos/luomiao/kubernetes/forks","keys_url":"https://api.github.com/repos/luomiao/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luomiao/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luomiao/kubernetes/teams","hooks_url":"https://api.github.com/repos/luomiao/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/luomiao/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/luomiao/kubernetes/events","assignees_url":"https://api.github.com/repos/luomiao/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/luomiao/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/luomiao/kubernetes/tags","blobs_url":"https://api.github.com/repos/luomiao/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luomiao/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luomiao/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/luomiao/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luomiao/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/luomiao/kubernetes/languages","stargazers_url":"https://api.github.com/repos/luomiao/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/luomiao/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/luomiao/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/luomiao/kubernetes/subscription","commits_url":"https://api.github.com/repos/luomiao/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/luomiao/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/luomiao/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/luomiao/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/luomiao/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/luomiao/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luomiao/kubernetes/merges","archive_url":"https://api.github.com/repos/luomiao/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luomiao/kubernetes/downloads","issues_url":"https://api.github.com/repos/luomiao/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/luomiao/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/luomiao/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/luomiao/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luomiao/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/luomiao/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/luomiao/kubernetes/deployments","created_at":"2016-09-01T23:07:37Z","updated_at":"2016-09-01T23:08:09Z","pushed_at":"2017-02-22T22:01:58Z","git_url":"git://github.com/luomiao/kubernetes.git","ssh_url":"git@github.com:luomiao/kubernetes.git","clone_url":"https://github.com/luomiao/kubernetes.git","svn_url":"https://github.com/luomiao/kubernetes","homepage":"http://kubernetes.io","size":405295,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vmware:vsphere-remove-loginInfo-on-workers","ref":"vsphere-remove-loginInfo-on-workers","sha":"e43e663a5329739ce5bad8f274ab1a985ad1c784","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":49536898,"name":"kubernetes","full_name":"vmware/kubernetes","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/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/vmware/kubernetes","forks_url":"https://api.github.com/repos/vmware/kubernetes/forks","keys_url":"https://api.github.com/repos/vmware/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/kubernetes/teams","hooks_url":"https://api.github.com/repos/vmware/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/vmware/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/kubernetes/events","assignees_url":"https://api.github.com/repos/vmware/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/kubernetes/tags","blobs_url":"https://api.github.com/repos/vmware/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/kubernetes/languages","stargazers_url":"https://api.github.com/repos/vmware/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/vmware/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/vmware/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/vmware/kubernetes/subscription","commits_url":"https://api.github.com/repos/vmware/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/kubernetes/merges","archive_url":"https://api.github.com/repos/vmware/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/kubernetes/downloads","issues_url":"https://api.github.com/repos/vmware/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/vmware/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/kubernetes/deployments","created_at":"2016-01-12T23:58:29Z","updated_at":"2017-01-25T00:24:09Z","pushed_at":"2017-02-23T01:00:48Z","git_url":"git://github.com/vmware/kubernetes.git","ssh_url":"git@github.com:vmware/kubernetes.git","clone_url":"https://github.com/vmware/kubernetes.git","svn_url":"https://github.com/vmware/kubernetes","homepage":"http://kubernetes.io","size":411788,"stargazers_count":9,"watchers_count":9,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":49,"forks":6,"open_issues":49,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/kubernetes/pulls/104"},"html":{"href":"https://github.com/vmware/kubernetes/pull/104"},"issue":{"href":"https://api.github.com/repos/vmware/kubernetes/issues/104"},"comments":{"href":"https://api.github.com/repos/vmware/kubernetes/issues/104/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/kubernetes/pulls/104/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/kubernetes/pulls/104/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/kubernetes/statuses/594432feade98414461b76eb3ac8a564e6038674"}}}}
{"actor":{"display_login":"BaluDontu"}}