{"action":"created","comment":{"url":"https://api.github.com/repos/fog/fog-vsphere/pulls/comments/44939272","id":44939272,"diff_hunk":"@@ -581,31 +587,57 @@ def vm_clone(options = {})\n                                                             :template => false)\n \n           # Perform the actual Clone Task\n-          task = vm_mob_ref.CloneVM_Task(:folder => dest_folder,\n+          # Clone VM on a storage pod\n+          if options.key?('storage_pod')\n+            raise ArgumentError, \"need to use at least vsphere revision 5.0 or greater to use storage pods\" unless @vsphere_rev.to_f >= 5\n+            pod_spec     = RbVmomi::VIM::StorageDrsPodSelectionSpec.new(\n+              :storagePod => get_raw_storage_pod(options['storage_pod'], options['datacenter']),\n+            )\n+            storage_spec = RbVmomi::VIM::StoragePlacementSpec.new(\n+              :type => 'clone',\n+              :folder => dest_folder,\n+              :resourcePool => resource_pool,\n+              :podSelectionSpec => pod_spec,\n+              :cloneSpec => clone_spec,\n+              :cloneName => options['name'],\n+              :vm => vm_mob_ref,\n+            )\n+            srm = @connection.serviceContent.storageResourceManager\n+            result = srm.RecommendDatastores(:storageSpec => storage_spec)\n+\n+            # if result array contains recommendation, we can apply it\n+            if key = result.recommendations.first.key\n+              task = srm.ApplyStorageDrsRecommendation_Task(:key => [key])\n+              result = task.wait_for_completion\n+              new_vm = result.vm\n+            end\n+          else\n+            task = vm_mob_ref.CloneVM_Task(:folder => dest_folder,\n                                          :name => options['name'],\n                                          :spec => clone_spec)\n-          # Waiting for the VM to complete allows us to get the VirtulMachine\n-          # object of the new machine when it's done.  It is HIGHLY recommended\n-          # to set 'wait' => true if your app wants to wait.  Otherwise, you're\n-          # going to have to reload the server model over and over which\n-          # generates a lot of time consuming API calls to vmware.\n-          if options.fetch('wait', true) then\n-            # REVISIT: It would be awesome to call a block passed to this\n-            # request to notify the application how far along in the process we\n-            # are.  I'm thinking of updating a progress bar, etc...\n-            new_vm = task.wait_for_completion\n-          else\n-            tries = 0\n-            new_vm = begin\n-              # Try and find the new VM (folder.find is quite efficient)\n-              dest_folder.find(options['name'], RbVmomi::VIM::VirtualMachine) or raise Fog::Vsphere::Errors::NotFound\n-            rescue Fog::Vsphere::Errors::NotFound\n-              tries += 1\n-              if tries <= 10 then\n-                sleep 15\n-                retry\n+            # Waiting for the VM to complete allows us to get the VirtulMachine\n+            # object of the new machine when it's done.  It is HIGHLY recommended\n+            # to set 'wait' => true if your app wants to wait.  Otherwise, you're\n+            # going to have to reload the server model over and over which\n+            # generates a lot of time consuming API calls to vmware.\n+            if options.fetch('wait', true) then\n+              # REVISIT: It would be awesome to call a block passed to this\n+              # request to notify the application how far along in the process we\n+              # are.  I'm thinking of updating a progress bar, etc...\n+              new_vm = task.wait_for_completion\n+            else\n+              tries = 0\n+              new_vm = begin\n+                # Try and find the new VM (folder.find is quite efficient)\n+                dest_folder.find(options['name'], RbVmomi::VIM::VirtualMachine) or raise Fog::Vsphere::Errors::NotFound\n+              rescue Fog::Vsphere::Errors::NotFound\n+                tries += 1\n+                if tries <= 10 then\n+                  sleep 15\n+                  retry\n+                end\n+                nil","path":"lib/fog/vsphere/requests/compute/vm_clone.rb","position":106,"original_position":106,"commit_id":"01fd936155732ce7b6e631d00a3507db51513dc4","original_commit_id":"01fd936155732ce7b6e631d00a3507db51513dc4","user":{"login":"plribeiro3000","id":672952,"avatar_url":"https://avatars.githubusercontent.com/u/672952?v=3","gravatar_id":"","url":"https://api.github.com/users/plribeiro3000","html_url":"https://github.com/plribeiro3000","followers_url":"https://api.github.com/users/plribeiro3000/followers","following_url":"https://api.github.com/users/plribeiro3000/following{/other_user}","gists_url":"https://api.github.com/users/plribeiro3000/gists{/gist_id}","starred_url":"https://api.github.com/users/plribeiro3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plribeiro3000/subscriptions","organizations_url":"https://api.github.com/users/plribeiro3000/orgs","repos_url":"https://api.github.com/users/plribeiro3000/repos","events_url":"https://api.github.com/users/plribeiro3000/events{/privacy}","received_events_url":"https://api.github.com/users/plribeiro3000/received_events","type":"User","site_admin":false},"body":"I think you could use Fog [`wait_for`](https://github.com/fog/fog-core/blob/master/lib/fog/core/wait_for.rb#L2) here.","created_at":"2015-11-16T15:49:35Z","updated_at":"2015-11-16T15:49:35Z","html_url":"https://github.com/fog/fog-vsphere/pull/6#discussion_r44939272","pull_request_url":"https://api.github.com/repos/fog/fog-vsphere/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/fog/fog-vsphere/pulls/comments/44939272"},"html":{"href":"https://github.com/fog/fog-vsphere/pull/6#discussion_r44939272"},"pull_request":{"href":"https://api.github.com/repos/fog/fog-vsphere/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/fog/fog-vsphere/pulls/6","id":50824535,"html_url":"https://github.com/fog/fog-vsphere/pull/6","diff_url":"https://github.com/fog/fog-vsphere/pull/6.diff","patch_url":"https://github.com/fog/fog-vsphere/pull/6.patch","issue_url":"https://api.github.com/repos/fog/fog-vsphere/issues/6","number":6,"state":"open","locked":false,"title":"implement storage pods","user":{"login":"timogoebel","id":4107560,"avatar_url":"https://avatars.githubusercontent.com/u/4107560?v=3","gravatar_id":"","url":"https://api.github.com/users/timogoebel","html_url":"https://github.com/timogoebel","followers_url":"https://api.github.com/users/timogoebel/followers","following_url":"https://api.github.com/users/timogoebel/following{/other_user}","gists_url":"https://api.github.com/users/timogoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/timogoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timogoebel/subscriptions","organizations_url":"https://api.github.com/users/timogoebel/orgs","repos_url":"https://api.github.com/users/timogoebel/repos","events_url":"https://api.github.com/users/timogoebel/events{/privacy}","received_events_url":"https://api.github.com/users/timogoebel/received_events","type":"User","site_admin":false},"body":"This PR adds storage pods (datastore clusters) to fog. You can create a new vm or clone an existing one.","created_at":"2015-11-16T15:34:12Z","updated_at":"2015-11-16T15:49:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f55337d3f8e19f417daa56a734fecc2cbedb9c86","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fog/fog-vsphere/pulls/6/commits","review_comments_url":"https://api.github.com/repos/fog/fog-vsphere/pulls/6/comments","review_comment_url":"https://api.github.com/repos/fog/fog-vsphere/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fog/fog-vsphere/issues/6/comments","statuses_url":"https://api.github.com/repos/fog/fog-vsphere/statuses/01fd936155732ce7b6e631d00a3507db51513dc4","head":{"label":"timogoebel:feature_storage_pods","ref":"feature_storage_pods","sha":"01fd936155732ce7b6e631d00a3507db51513dc4","user":{"login":"timogoebel","id":4107560,"avatar_url":"https://avatars.githubusercontent.com/u/4107560?v=3","gravatar_id":"","url":"https://api.github.com/users/timogoebel","html_url":"https://github.com/timogoebel","followers_url":"https://api.github.com/users/timogoebel/followers","following_url":"https://api.github.com/users/timogoebel/following{/other_user}","gists_url":"https://api.github.com/users/timogoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/timogoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timogoebel/subscriptions","organizations_url":"https://api.github.com/users/timogoebel/orgs","repos_url":"https://api.github.com/users/timogoebel/repos","events_url":"https://api.github.com/users/timogoebel/events{/privacy}","received_events_url":"https://api.github.com/users/timogoebel/received_events","type":"User","site_admin":false},"repo":{"id":46260681,"name":"fog-vsphere","full_name":"timogoebel/fog-vsphere","owner":{"login":"timogoebel","id":4107560,"avatar_url":"https://avatars.githubusercontent.com/u/4107560?v=3","gravatar_id":"","url":"https://api.github.com/users/timogoebel","html_url":"https://github.com/timogoebel","followers_url":"https://api.github.com/users/timogoebel/followers","following_url":"https://api.github.com/users/timogoebel/following{/other_user}","gists_url":"https://api.github.com/users/timogoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/timogoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timogoebel/subscriptions","organizations_url":"https://api.github.com/users/timogoebel/orgs","repos_url":"https://api.github.com/users/timogoebel/repos","events_url":"https://api.github.com/users/timogoebel/events{/privacy}","received_events_url":"https://api.github.com/users/timogoebel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timogoebel/fog-vsphere","description":"Fog for vSphere","fork":true,"url":"https://api.github.com/repos/timogoebel/fog-vsphere","forks_url":"https://api.github.com/repos/timogoebel/fog-vsphere/forks","keys_url":"https://api.github.com/repos/timogoebel/fog-vsphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timogoebel/fog-vsphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timogoebel/fog-vsphere/teams","hooks_url":"https://api.github.com/repos/timogoebel/fog-vsphere/hooks","issue_events_url":"https://api.github.com/repos/timogoebel/fog-vsphere/issues/events{/number}","events_url":"https://api.github.com/repos/timogoebel/fog-vsphere/events","assignees_url":"https://api.github.com/repos/timogoebel/fog-vsphere/assignees{/user}","branches_url":"https://api.github.com/repos/timogoebel/fog-vsphere/branches{/branch}","tags_url":"https://api.github.com/repos/timogoebel/fog-vsphere/tags","blobs_url":"https://api.github.com/repos/timogoebel/fog-vsphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timogoebel/fog-vsphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timogoebel/fog-vsphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/timogoebel/fog-vsphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timogoebel/fog-vsphere/statuses/{sha}","languages_url":"https://api.github.com/repos/timogoebel/fog-vsphere/languages","stargazers_url":"https://api.github.com/repos/timogoebel/fog-vsphere/stargazers","contributors_url":"https://api.github.com/repos/timogoebel/fog-vsphere/contributors","subscribers_url":"https://api.github.com/repos/timogoebel/fog-vsphere/subscribers","subscription_url":"https://api.github.com/repos/timogoebel/fog-vsphere/subscription","commits_url":"https://api.github.com/repos/timogoebel/fog-vsphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/timogoebel/fog-vsphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/timogoebel/fog-vsphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/timogoebel/fog-vsphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/timogoebel/fog-vsphere/contents/{+path}","compare_url":"https://api.github.com/repos/timogoebel/fog-vsphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timogoebel/fog-vsphere/merges","archive_url":"https://api.github.com/repos/timogoebel/fog-vsphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timogoebel/fog-vsphere/downloads","issues_url":"https://api.github.com/repos/timogoebel/fog-vsphere/issues{/number}","pulls_url":"https://api.github.com/repos/timogoebel/fog-vsphere/pulls{/number}","milestones_url":"https://api.github.com/repos/timogoebel/fog-vsphere/milestones{/number}","notifications_url":"https://api.github.com/repos/timogoebel/fog-vsphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timogoebel/fog-vsphere/labels{/name}","releases_url":"https://api.github.com/repos/timogoebel/fog-vsphere/releases{/id}","created_at":"2015-11-16T08:08:05Z","updated_at":"2015-11-16T08:08:06Z","pushed_at":"2015-11-16T15:35:32Z","git_url":"git://github.com/timogoebel/fog-vsphere.git","ssh_url":"git@github.com:timogoebel/fog-vsphere.git","clone_url":"https://github.com/timogoebel/fog-vsphere.git","svn_url":"https://github.com/timogoebel/fog-vsphere","homepage":null,"size":192,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"fog:master","ref":"master","sha":"76cff0c7b970a15e7b5609840c9106e73ea40fe6","user":{"login":"fog","id":991149,"avatar_url":"https://avatars.githubusercontent.com/u/991149?v=3","gravatar_id":"","url":"https://api.github.com/users/fog","html_url":"https://github.com/fog","followers_url":"https://api.github.com/users/fog/followers","following_url":"https://api.github.com/users/fog/following{/other_user}","gists_url":"https://api.github.com/users/fog/gists{/gist_id}","starred_url":"https://api.github.com/users/fog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fog/subscriptions","organizations_url":"https://api.github.com/users/fog/orgs","repos_url":"https://api.github.com/users/fog/repos","events_url":"https://api.github.com/users/fog/events{/privacy}","received_events_url":"https://api.github.com/users/fog/received_events","type":"Organization","site_admin":false},"repo":{"id":45206013,"name":"fog-vsphere","full_name":"fog/fog-vsphere","owner":{"login":"fog","id":991149,"avatar_url":"https://avatars.githubusercontent.com/u/991149?v=3","gravatar_id":"","url":"https://api.github.com/users/fog","html_url":"https://github.com/fog","followers_url":"https://api.github.com/users/fog/followers","following_url":"https://api.github.com/users/fog/following{/other_user}","gists_url":"https://api.github.com/users/fog/gists{/gist_id}","starred_url":"https://api.github.com/users/fog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fog/subscriptions","organizations_url":"https://api.github.com/users/fog/orgs","repos_url":"https://api.github.com/users/fog/repos","events_url":"https://api.github.com/users/fog/events{/privacy}","received_events_url":"https://api.github.com/users/fog/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fog/fog-vsphere","description":"Fog for vSphere","fork":false,"url":"https://api.github.com/repos/fog/fog-vsphere","forks_url":"https://api.github.com/repos/fog/fog-vsphere/forks","keys_url":"https://api.github.com/repos/fog/fog-vsphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fog/fog-vsphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fog/fog-vsphere/teams","hooks_url":"https://api.github.com/repos/fog/fog-vsphere/hooks","issue_events_url":"https://api.github.com/repos/fog/fog-vsphere/issues/events{/number}","events_url":"https://api.github.com/repos/fog/fog-vsphere/events","assignees_url":"https://api.github.com/repos/fog/fog-vsphere/assignees{/user}","branches_url":"https://api.github.com/repos/fog/fog-vsphere/branches{/branch}","tags_url":"https://api.github.com/repos/fog/fog-vsphere/tags","blobs_url":"https://api.github.com/repos/fog/fog-vsphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fog/fog-vsphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fog/fog-vsphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/fog/fog-vsphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fog/fog-vsphere/statuses/{sha}","languages_url":"https://api.github.com/repos/fog/fog-vsphere/languages","stargazers_url":"https://api.github.com/repos/fog/fog-vsphere/stargazers","contributors_url":"https://api.github.com/repos/fog/fog-vsphere/contributors","subscribers_url":"https://api.github.com/repos/fog/fog-vsphere/subscribers","subscription_url":"https://api.github.com/repos/fog/fog-vsphere/subscription","commits_url":"https://api.github.com/repos/fog/fog-vsphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/fog/fog-vsphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/fog/fog-vsphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/fog/fog-vsphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/fog/fog-vsphere/contents/{+path}","compare_url":"https://api.github.com/repos/fog/fog-vsphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fog/fog-vsphere/merges","archive_url":"https://api.github.com/repos/fog/fog-vsphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fog/fog-vsphere/downloads","issues_url":"https://api.github.com/repos/fog/fog-vsphere/issues{/number}","pulls_url":"https://api.github.com/repos/fog/fog-vsphere/pulls{/number}","milestones_url":"https://api.github.com/repos/fog/fog-vsphere/milestones{/number}","notifications_url":"https://api.github.com/repos/fog/fog-vsphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fog/fog-vsphere/labels{/name}","releases_url":"https://api.github.com/repos/fog/fog-vsphere/releases{/id}","created_at":"2015-10-29T19:35:37Z","updated_at":"2015-11-06T07:41:41Z","pushed_at":"2015-11-16T15:35:32Z","git_url":"git://github.com/fog/fog-vsphere.git","ssh_url":"git@github.com:fog/fog-vsphere.git","clone_url":"https://github.com/fog/fog-vsphere.git","svn_url":"https://github.com/fog/fog-vsphere","homepage":null,"size":192,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fog/fog-vsphere/pulls/6"},"html":{"href":"https://github.com/fog/fog-vsphere/pull/6"},"issue":{"href":"https://api.github.com/repos/fog/fog-vsphere/issues/6"},"comments":{"href":"https://api.github.com/repos/fog/fog-vsphere/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/fog/fog-vsphere/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/fog/fog-vsphere/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fog/fog-vsphere/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/fog/fog-vsphere/statuses/01fd936155732ce7b6e631d00a3507db51513dc4"}}}}