Quantcast
Channel: VMware Communities : All Content - vSphere Management SDK
Viewing all articles
Browse latest Browse all 1860

Error while Provisioning a VM on Datastore Cluster

$
0
0

Hi, I'm trying to create virtual machine on datastore cluster using  Java API, however I'm getting the following error on the invocation of  "RecommendDatastores" method

 

"A general system error occurred: optional value not set"

 

I'm  not sure what am I missing here, api is not returning the clear  message/error, it seems very ambigous message, how do I know which value  is not set?

Following is the code snippet I'm trying with.

 

 

 

               //This is the storage pod where I want to create a VM

               ManagedObjectReference storagePod = new ManagedObjectReference();
               storagePod.set_value("group-p303");
               storagePod.setType("StoragePod");
              
               StorageDrsVmConfigInfo vmconfigInfo = new StorageDrsVmConfigInfo();
               vmconfigInfo.setBehavior(StorageDrsPodConfigInfoBehavior._automated);
              
               VmPodConfigForPlacement vmPodConfig = new VmPodConfigForPlacement();
               vmPodConfig.setStoragePod(storagePod);
               vmPodConfig.setVmConfig(vmconfigInfo);
              

               //Storage Pod Sslection spec
               StorageDrsPodSelectionSpec storageSelSpec = new StorageDrsPodSelectionSpec();
               storageSelSpec.setStoragePod(storagePod);
               storageSelSpec.setInitialVmConfig(new VmPodConfigForPlacement[]{vmPodConfig});
              


               //Storage Placement spec              
               StoragePlacementSpec placementSpec = new StoragePlacementSpec();
               placementSpec.setConfigSpec(spec);
               placementSpec.setPodSelectionSpec(storageSelSpec);
               placementSpec.setType(StoragePlacementSpecPlacementType._create);
               placementSpec.setFolder(vmFolderMor);
               placementSpec.setHost(hostMOR);
               placementSpec.setResourcePool(poolMOR);                 
              
                 StoragePlacementResult placementRes =  service.recommendDatastores(sic.getStorageResourceManager(),  placementSpec);
                task =  service.applyStorageDrsRecommendationToPod_Task(sic.getStorageResourceManager(),  storagePod/*Storage POD MOR*/,  placementRes.getRecommendations(0).getKey());

I read  through the API documentation, for me it looks like whatever is required  is being set.My virtual machine spec has the VMName and its file info  set. I'm not sure what is missing here, could some one help to find out.

 

In  the above snippet "vmconfigInfo" and "vmPodConfig" are set later in the  hopes to resolve the issue, however no luck. Appreciate any quick help.

 

Thanks,

Parash


Viewing all articles
Browse latest Browse all 1860

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>