{"action":"created","issue":{"url":"https://api.github.com/repos/vmware/pyvmomi/issues/213","labels_url":"https://api.github.com/repos/vmware/pyvmomi/issues/213/labels{/name}","comments_url":"https://api.github.com/repos/vmware/pyvmomi/issues/213/comments","events_url":"https://api.github.com/repos/vmware/pyvmomi/issues/213/events","html_url":"https://github.com/vmware/pyvmomi/issues/213","id":57226221,"number":213,"title":"Create VM by using StorageDRS","user":{"login":"jm66","id":2047620,"avatar_url":"https://avatars.githubusercontent.com/u/2047620?v=3","gravatar_id":"","url":"https://api.github.com/users/jm66","html_url":"https://github.com/jm66","followers_url":"https://api.github.com/users/jm66/followers","following_url":"https://api.github.com/users/jm66/following{/other_user}","gists_url":"https://api.github.com/users/jm66/gists{/gist_id}","starred_url":"https://api.github.com/users/jm66/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jm66/subscriptions","organizations_url":"https://api.github.com/users/jm66/orgs","repos_url":"https://api.github.com/users/jm66/repos","events_url":"https://api.github.com/users/jm66/events{/privacy}","received_events_url":"https://api.github.com/users/jm66/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-10T19:46:14Z","updated_at":"2015-02-11T21:05:01Z","closed_at":"2015-02-11T20:48:22Z","body":"Hi guys,\r\n\r\nI've been trying to create a VM using Storage DRS, and while I don't get the VM created, vCenter crashes. I'm currently analyzing the vC logs but wanted to ask you guys if I'm doing it right. Here's what I've done so far assuming the following:\r\n- A full VM config Spec tested with vim.Folder.CreateVM_Task. This means that the config spec object is working and there are no errors.\r\n- A valid datastore cluster name and the function get_dscluster gets the corresponding object for the datastore cluster\r\n- A valid target folder (vim.Folder) object\r\n- A valid resource pool object (vim.ClusterComputeResource.resourcePool)\r\n\r\n``` python\r\ndef create_vm_sdrs(content, si, dsc_name, folder, vm_config_spec, resource_pool):\r\n\r\n    # make an empty pod selection spec, then customize it\r\n    podsel = vim.storageDrs.PodSelectionSpec()\r\n    pod = get_dscluster(content, dsc_name)\r\n    podsel.storagePod = pod\r\n\r\n    # make an empty storage placement spec, then customize it\r\n    storagespec = vim.storageDrs.StoragePlacementSpec()\r\n    storagespec.podSelectionSpec = podsel\r\n    storagespec.type = 'create'\r\n    storagespec.folder = folder\r\n    storagespec.resourcePool = resource_pool\r\n    storagespec.configSpec = vm_config_spec\r\n\r\n    # recommended datastores\r\n    rec = content.storageResourceManager.RecommendDatastores(storageSpec=storagespec)\r\n\r\n    # recommendation key\r\n    rec_key = rec.recommendations[0].key\r\n\r\n    task = content.storageResourceManager.ApplyStorageDrsRecommendation_Task(rec_key)\r\n    tasks.wait_for_tasks(si, [task])\r\n```\r\nAny help on this is greatly appreciated.\r\n\r\nThanks,\r\nJM"},"comment":{"url":"https://api.github.com/repos/vmware/pyvmomi/issues/comments/73964486","html_url":"https://github.com/vmware/pyvmomi/issues/213#issuecomment-73964486","issue_url":"https://api.github.com/repos/vmware/pyvmomi/issues/213","id":73964486,"user":{"login":"jm66","id":2047620,"avatar_url":"https://avatars.githubusercontent.com/u/2047620?v=3","gravatar_id":"","url":"https://api.github.com/users/jm66","html_url":"https://github.com/jm66","followers_url":"https://api.github.com/users/jm66/followers","following_url":"https://api.github.com/users/jm66/following{/other_user}","gists_url":"https://api.github.com/users/jm66/gists{/gist_id}","starred_url":"https://api.github.com/users/jm66/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jm66/subscriptions","organizations_url":"https://api.github.com/users/jm66/orgs","repos_url":"https://api.github.com/users/jm66/repos","events_url":"https://api.github.com/users/jm66/events{/privacy}","received_events_url":"https://api.github.com/users/jm66/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T21:05:01Z","updated_at":"2015-02-11T21:05:01Z","body":"hey @hartsock, thanks for your response. I wrote the code based on William Lam's post and it was very useful. I will review it once more and see if I'm missing something.\r\n\r\nWith respect to the initializers, I followed your recommendation:\r\n``` python\r\n    rec = content.storageResourceManager.RecommendDatastores()\r\n    rec.storageSpec = storagespec\r\n```\r\nBut got the following:\r\n```\r\n    rec = content.storageResourceManager.RecommendDatastores()\r\n  File \"build/bdist.macosx-10.9-x86_64/egg/pyVmomi/VmomiSupport.py\", line 566, in <lambda>\r\n  File \"build/bdist.macosx-10.9-x86_64/egg/pyVmomi/VmomiSupport.py\", line 374, in _InvokeMethod\r\n  File \"build/bdist.macosx-10.9-x86_64/egg/pyVmomi/VmomiSupport.py\", line 892, in CheckField\r\nTypeError: Required field \"storageSpec\" not provided (not @optional)\r\n```\r\nLooking at https://github.com/vmware/pyvmomi/blob/master/docs/vim/StorageResourceManager.rst it seems that it ```RecommendDatastores``` needs to be initialized with ```storageSpec``` set to ```storagespec``` in my case."}}