{"action":"created","comment":{"url":"https://api.github.com/repos/mitchellh/packer/pulls/comments/35597405","id":35597405,"diff_hunk":"@@ -155,7 +156,34 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {\n \treturn multistep.ActionContinue\n }\n \n-func (s *stepCreateVMX) Cleanup(multistep.StateBag) {\n+func (s *stepCreateVMX) Cleanup(state multistep.StateBag) {\n+\tdriver := state.Get(\"driver\").(vmwcommon.Driver)\n+\tconfig := state.Get(\"config\").(*Config)\n+\tui := state.Get(\"ui\").(packer.Ui)\n+\n+\tui.Say(\"Unregistering and deleting virtual machine...\")\n+\tvar err error = nil\n+\tfor i := 0; i < 5; i++ {\n+\t\trunning, err := driver.IsRunning(config.VMXTemplatePath)\n+\t\tif err == nil {\n+\t\t\tif running {\n+\t\t\t\terr = driver.Stop(config.VMXTemplatePath)\n+\t\t\t}\n+\t\t}\n+\t\tif err == nil {","path":"builder/vmware/iso/step_create_vmx.go","position":27,"original_position":27,"commit_id":"5cf5dac918ccaa3e9e923dd8a16eb8f28cab4b97","original_commit_id":"5cf5dac918ccaa3e9e923dd8a16eb8f28cab4b97","user":{"login":"pecigonzalo","id":9908105,"avatar_url":"https://avatars.githubusercontent.com/u/9908105?v=3","gravatar_id":"","url":"https://api.github.com/users/pecigonzalo","html_url":"https://github.com/pecigonzalo","followers_url":"https://api.github.com/users/pecigonzalo/followers","following_url":"https://api.github.com/users/pecigonzalo/following{/other_user}","gists_url":"https://api.github.com/users/pecigonzalo/gists{/gist_id}","starred_url":"https://api.github.com/users/pecigonzalo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pecigonzalo/subscriptions","organizations_url":"https://api.github.com/users/pecigonzalo/orgs","repos_url":"https://api.github.com/users/pecigonzalo/repos","events_url":"https://api.github.com/users/pecigonzalo/events{/privacy}","received_events_url":"https://api.github.com/users/pecigonzalo/received_events","type":"User","site_admin":false},"body":"I dont know if i understand correctly, you mean like this:\r\n```\r\nrunning, err := driver.IsRunning(config.VMXTemplatePath)\r\n\t\tif err == nil && running {\r\n\t\t\t\terr = driver.Stop(config.VMXTemplatePath)\r\n\t\t}\r\n\t\tif err == nil {\r\n\t\t\ttime.Sleep(5 * time.Second * time.Duration(i))\r\n\t\t\terr = driver.Delete(config.VMXTemplatePath)\r\n\t\t\tif err == nil {\r\n\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n```","created_at":"2015-07-27T22:54:50Z","updated_at":"2015-07-27T22:54:50Z","html_url":"https://github.com/mitchellh/packer/pull/2506#discussion_r35597405","pull_request_url":"https://api.github.com/repos/mitchellh/packer/pulls/2506","_links":{"self":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/comments/35597405"},"html":{"href":"https://github.com/mitchellh/packer/pull/2506#discussion_r35597405"},"pull_request":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/2506"}}},"pull_request":{"url":"https://api.github.com/repos/mitchellh/packer/pulls/2506","id":40863268,"html_url":"https://github.com/mitchellh/packer/pull/2506","diff_url":"https://github.com/mitchellh/packer/pull/2506.diff","patch_url":"https://github.com/mitchellh/packer/pull/2506.patch","issue_url":"https://api.github.com/repos/mitchellh/packer/issues/2506","number":2506,"state":"open","locked":false,"title":"Fix VMWare often not removing files properly when terminated","user":{"login":"pecigonzalo","id":9908105,"avatar_url":"https://avatars.githubusercontent.com/u/9908105?v=3","gravatar_id":"","url":"https://api.github.com/users/pecigonzalo","html_url":"https://github.com/pecigonzalo","followers_url":"https://api.github.com/users/pecigonzalo/followers","following_url":"https://api.github.com/users/pecigonzalo/following{/other_user}","gists_url":"https://api.github.com/users/pecigonzalo/gists{/gist_id}","starred_url":"https://api.github.com/users/pecigonzalo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pecigonzalo/subscriptions","organizations_url":"https://api.github.com/users/pecigonzalo/orgs","repos_url":"https://api.github.com/users/pecigonzalo/repos","events_url":"https://api.github.com/users/pecigonzalo/events{/privacy}","received_events_url":"https://api.github.com/users/pecigonzalo/received_events","type":"User","site_admin":false},"body":"Ref: #2452\r\n\r\nThe VMWare builder sometimes does not delete the files/vm correctly when terminated in the middle of the run, or terminated due to error and cant connect to the VM to shutdown. \r\nThis is due to it not issuing a force terminate command for cleanup like virtualbox does.\r\n\r\nThis is still WIP, added the pull request for visibility and if anyone can contribute.\r\n\r\n","created_at":"2015-07-27T00:47:31Z","updated_at":"2015-07-27T22:54:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4a1c4c029b6a28a9f541eb83d14e714a02228529","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mitchellh/packer/pulls/2506/commits","review_comments_url":"https://api.github.com/repos/mitchellh/packer/pulls/2506/comments","review_comment_url":"https://api.github.com/repos/mitchellh/packer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitchellh/packer/issues/2506/comments","statuses_url":"https://api.github.com/repos/mitchellh/packer/statuses/5cf5dac918ccaa3e9e923dd8a16eb8f28cab4b97","head":{"label":"pecigonzalo:f-vmware-fix_stop_cleanup","ref":"f-vmware-fix_stop_cleanup","sha":"5cf5dac918ccaa3e9e923dd8a16eb8f28cab4b97","user":{"login":"pecigonzalo","id":9908105,"avatar_url":"https://avatars.githubusercontent.com/u/9908105?v=3","gravatar_id":"","url":"https://api.github.com/users/pecigonzalo","html_url":"https://github.com/pecigonzalo","followers_url":"https://api.github.com/users/pecigonzalo/followers","following_url":"https://api.github.com/users/pecigonzalo/following{/other_user}","gists_url":"https://api.github.com/users/pecigonzalo/gists{/gist_id}","starred_url":"https://api.github.com/users/pecigonzalo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pecigonzalo/subscriptions","organizations_url":"https://api.github.com/users/pecigonzalo/orgs","repos_url":"https://api.github.com/users/pecigonzalo/repos","events_url":"https://api.github.com/users/pecigonzalo/events{/privacy}","received_events_url":"https://api.github.com/users/pecigonzalo/received_events","type":"User","site_admin":false},"repo":{"id":37836867,"name":"packer","full_name":"pecigonzalo/packer","owner":{"login":"pecigonzalo","id":9908105,"avatar_url":"https://avatars.githubusercontent.com/u/9908105?v=3","gravatar_id":"","url":"https://api.github.com/users/pecigonzalo","html_url":"https://github.com/pecigonzalo","followers_url":"https://api.github.com/users/pecigonzalo/followers","following_url":"https://api.github.com/users/pecigonzalo/following{/other_user}","gists_url":"https://api.github.com/users/pecigonzalo/gists{/gist_id}","starred_url":"https://api.github.com/users/pecigonzalo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pecigonzalo/subscriptions","organizations_url":"https://api.github.com/users/pecigonzalo/orgs","repos_url":"https://api.github.com/users/pecigonzalo/repos","events_url":"https://api.github.com/users/pecigonzalo/events{/privacy}","received_events_url":"https://api.github.com/users/pecigonzalo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pecigonzalo/packer","description":"Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.","fork":true,"url":"https://api.github.com/repos/pecigonzalo/packer","forks_url":"https://api.github.com/repos/pecigonzalo/packer/forks","keys_url":"https://api.github.com/repos/pecigonzalo/packer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pecigonzalo/packer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pecigonzalo/packer/teams","hooks_url":"https://api.github.com/repos/pecigonzalo/packer/hooks","issue_events_url":"https://api.github.com/repos/pecigonzalo/packer/issues/events{/number}","events_url":"https://api.github.com/repos/pecigonzalo/packer/events","assignees_url":"https://api.github.com/repos/pecigonzalo/packer/assignees{/user}","branches_url":"https://api.github.com/repos/pecigonzalo/packer/branches{/branch}","tags_url":"https://api.github.com/repos/pecigonzalo/packer/tags","blobs_url":"https://api.github.com/repos/pecigonzalo/packer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pecigonzalo/packer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pecigonzalo/packer/git/refs{/sha}","trees_url":"https://api.github.com/repos/pecigonzalo/packer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pecigonzalo/packer/statuses/{sha}","languages_url":"https://api.github.com/repos/pecigonzalo/packer/languages","stargazers_url":"https://api.github.com/repos/pecigonzalo/packer/stargazers","contributors_url":"https://api.github.com/repos/pecigonzalo/packer/contributors","subscribers_url":"https://api.github.com/repos/pecigonzalo/packer/subscribers","subscription_url":"https://api.github.com/repos/pecigonzalo/packer/subscription","commits_url":"https://api.github.com/repos/pecigonzalo/packer/commits{/sha}","git_commits_url":"https://api.github.com/repos/pecigonzalo/packer/git/commits{/sha}","comments_url":"https://api.github.com/repos/pecigonzalo/packer/comments{/number}","issue_comment_url":"https://api.github.com/repos/pecigonzalo/packer/issues/comments{/number}","contents_url":"https://api.github.com/repos/pecigonzalo/packer/contents/{+path}","compare_url":"https://api.github.com/repos/pecigonzalo/packer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pecigonzalo/packer/merges","archive_url":"https://api.github.com/repos/pecigonzalo/packer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pecigonzalo/packer/downloads","issues_url":"https://api.github.com/repos/pecigonzalo/packer/issues{/number}","pulls_url":"https://api.github.com/repos/pecigonzalo/packer/pulls{/number}","milestones_url":"https://api.github.com/repos/pecigonzalo/packer/milestones{/number}","notifications_url":"https://api.github.com/repos/pecigonzalo/packer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pecigonzalo/packer/labels{/name}","releases_url":"https://api.github.com/repos/pecigonzalo/packer/releases{/id}","created_at":"2015-06-22T04:07:22Z","updated_at":"2015-06-22T04:07:24Z","pushed_at":"2015-07-27T04:32:01Z","git_url":"git://github.com/pecigonzalo/packer.git","ssh_url":"git@github.com:pecigonzalo/packer.git","clone_url":"https://github.com/pecigonzalo/packer.git","svn_url":"https://github.com/pecigonzalo/packer","homepage":"http://www.packer.io","size":9774,"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":"mitchellh:master","ref":"master","sha":"ef873ba210efde9e92c11fc89c712bd632de7bf8","user":{"login":"mitchellh","id":1299,"avatar_url":"https://avatars.githubusercontent.com/u/1299?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellh","html_url":"https://github.com/mitchellh","followers_url":"https://api.github.com/users/mitchellh/followers","following_url":"https://api.github.com/users/mitchellh/following{/other_user}","gists_url":"https://api.github.com/users/mitchellh/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellh/subscriptions","organizations_url":"https://api.github.com/users/mitchellh/orgs","repos_url":"https://api.github.com/users/mitchellh/repos","events_url":"https://api.github.com/users/mitchellh/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellh/received_events","type":"User","site_admin":false},"repo":{"id":8966356,"name":"packer","full_name":"mitchellh/packer","owner":{"login":"mitchellh","id":1299,"avatar_url":"https://avatars.githubusercontent.com/u/1299?v=3","gravatar_id":"","url":"https://api.github.com/users/mitchellh","html_url":"https://github.com/mitchellh","followers_url":"https://api.github.com/users/mitchellh/followers","following_url":"https://api.github.com/users/mitchellh/following{/other_user}","gists_url":"https://api.github.com/users/mitchellh/gists{/gist_id}","starred_url":"https://api.github.com/users/mitchellh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitchellh/subscriptions","organizations_url":"https://api.github.com/users/mitchellh/orgs","repos_url":"https://api.github.com/users/mitchellh/repos","events_url":"https://api.github.com/users/mitchellh/events{/privacy}","received_events_url":"https://api.github.com/users/mitchellh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mitchellh/packer","description":"Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.","fork":false,"url":"https://api.github.com/repos/mitchellh/packer","forks_url":"https://api.github.com/repos/mitchellh/packer/forks","keys_url":"https://api.github.com/repos/mitchellh/packer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitchellh/packer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitchellh/packer/teams","hooks_url":"https://api.github.com/repos/mitchellh/packer/hooks","issue_events_url":"https://api.github.com/repos/mitchellh/packer/issues/events{/number}","events_url":"https://api.github.com/repos/mitchellh/packer/events","assignees_url":"https://api.github.com/repos/mitchellh/packer/assignees{/user}","branches_url":"https://api.github.com/repos/mitchellh/packer/branches{/branch}","tags_url":"https://api.github.com/repos/mitchellh/packer/tags","blobs_url":"https://api.github.com/repos/mitchellh/packer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitchellh/packer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitchellh/packer/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitchellh/packer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitchellh/packer/statuses/{sha}","languages_url":"https://api.github.com/repos/mitchellh/packer/languages","stargazers_url":"https://api.github.com/repos/mitchellh/packer/stargazers","contributors_url":"https://api.github.com/repos/mitchellh/packer/contributors","subscribers_url":"https://api.github.com/repos/mitchellh/packer/subscribers","subscription_url":"https://api.github.com/repos/mitchellh/packer/subscription","commits_url":"https://api.github.com/repos/mitchellh/packer/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitchellh/packer/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitchellh/packer/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitchellh/packer/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitchellh/packer/contents/{+path}","compare_url":"https://api.github.com/repos/mitchellh/packer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitchellh/packer/merges","archive_url":"https://api.github.com/repos/mitchellh/packer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitchellh/packer/downloads","issues_url":"https://api.github.com/repos/mitchellh/packer/issues{/number}","pulls_url":"https://api.github.com/repos/mitchellh/packer/pulls{/number}","milestones_url":"https://api.github.com/repos/mitchellh/packer/milestones{/number}","notifications_url":"https://api.github.com/repos/mitchellh/packer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitchellh/packer/labels{/name}","releases_url":"https://api.github.com/repos/mitchellh/packer/releases{/id}","created_at":"2013-03-23T05:43:03Z","updated_at":"2015-07-27T21:42:16Z","pushed_at":"2015-07-27T20:14:15Z","git_url":"git://github.com/mitchellh/packer.git","ssh_url":"git@github.com:mitchellh/packer.git","clone_url":"https://github.com/mitchellh/packer.git","svn_url":"https://github.com/mitchellh/packer","homepage":"http://www.packer.io","size":23652,"stargazers_count":4299,"watchers_count":4299,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":904,"mirror_url":null,"open_issues_count":193,"forks":904,"open_issues":193,"watchers":4299,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/2506"},"html":{"href":"https://github.com/mitchellh/packer/pull/2506"},"issue":{"href":"https://api.github.com/repos/mitchellh/packer/issues/2506"},"comments":{"href":"https://api.github.com/repos/mitchellh/packer/issues/2506/comments"},"review_comments":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/2506/comments"},"review_comment":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitchellh/packer/pulls/2506/commits"},"statuses":{"href":"https://api.github.com/repos/mitchellh/packer/statuses/5cf5dac918ccaa3e9e923dd8a16eb8f28cab4b97"}}}}