phallur
Contributor
Contributor

Error while Provisioning a VM on Datastore Cluster

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

0 Kudos
7 Replies
lamw
Community Manager
Community Manager

Take a look at this blog post (http://www.virtuallyghetto.com/2012/03/vm-provisioning-on-datastore-clusters.html) which goes through the steps for provisioning to a Datastore Cluster, it also contains a full working sample script written using the vSphere SDK for Perl which uses the vSphere API methods and you can convert that to your Java program to test the basic functionality and then add additional params such as ResourcePool/etc.

phallur
Contributor
Contributor

Lamw, Thanks for the reply! I followed that link and converted it into java code. By looking at the API documentation came to know that the createVM task for RecommendDatastores expects hostMor, ResourcePool and VmFolder, so providing that info. Could you please have a look at the java code and let me know if you can find any errors?

Thanks,

Parash

0 Kudos
phallur
Contributor
Contributor

I'm past the above error, I had to set few more optional parameters in VirtualMachineConfigSpec. Howeever I now see the error on the VC while applying storage DRS recommendation. Attached is the error message.

The error message on the VC is

"Apply a Storage DRS recommendation A specified parameter was not correct.key"

Does this mean that the recommendation key provided by "recommendDatastores" method is not right?

0 Kudos
phallur
Contributor
Contributor

I'm getting the following exception

Caused by: com.vmware.vim25.InvalidArgument: (no message available) sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) java.lang.reflect.Constructor.newInstance(Unknown Source) java.lang.Class.newInstance0(Unknown Source) java.lang.Class.newInstance(Unknown Source) org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:104) org.apache.axis.encoding.ser.BeanDeserializer.<init>(BeanDeserializer.java:90) com.vmware.vim25.InvalidArgument.getDeserializer(InvalidArgument.java:124) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) java.lang.reflect.Method.invoke(Unknown Source) org.apache.axis.encoding.ser.BaseDeserializerFactory.getSpecialized(BaseDeserializerFactory.java:154) org.apache.axis.encoding.ser.BaseDeserializerFactory.getDeserializerAs(BaseDeserializerFactory.java:84) org.apache.axis.encoding.DeserializationContext.getDeserializer(DeserializationContext.java:464) org.apache.axis.encoding.DeserializationContext.getDeserializerForType(DeserializationContext.java:547) org.apache.axis.encoding.ser.BeanDeserializer.getDeserializer(BeanDeserializer.java:514) org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:286) org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035) org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165) org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141) org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236) org.apache.axis.message.RPCElement.getParams(RPCElement.java:384) org.apache.axis.client.Call.invoke(Call.java:2467) org.apache.axis.client.Call.invoke(Call.java:2366) org.apache.axis.client.Call.invoke(Call.java:1812) com.vmware.vim25.VimBindingStub.retrieveProperties(VimBindingStub.java:44531)

Error message is : "Task completed with an error. A specified parameter was not correct.  key"

Isn't this strange, the key being used to apply the storage recommendation is returned from the API itself. Every time I run the workflow the key generated is differrent. I'm stuck here and appreciate any pointers from the experts in this community?

0 Kudos
phallur
Contributor
Contributor

So, I had raised the support ticket for this issue. Given that datastore cluster apis are still experimental in 5.0, following is what I heard from VMware support team.

"Yes, Experimental API's are not guaranteed to work.  These APIs are subject to change and hence it is usually suggested to not  use them in production environment."

And on the timeline of when they would be getting fully functional API, following is the answer

"Currently there is no time line fixed for the fix of this API, but tentatively it will be some time in 2013."

0 Kudos
bntr
Contributor
Contributor

applyStorageDrsRecommendation_Task should be used instead of

applyStorageDrsRecommendationToPod_Task

0 Kudos
ssuter
Contributor
Contributor

phallur,

I know it's been a while, but can you share details on the "additional optional parameters in VirtualMachineConfigSpec" you had to set? I've been trying for hours now to figure out why I am getting the "optional value not set" error.

0 Kudos