Hi,
I am trying to create a virtual machine in a cluster using a storage pod cluster.
I am getting an error when calling the RecommendDatastores.
The error looks like this:
Internal Server Error Occured: optional value not set
I have no idea what is the value that is missing.
I wonder if you can you give me some pointers or some troubleshooting tips?
Are there any logs that may help?
Should I try to configure the server to use HTTP and spy the SOAP messages?
Code transcript for creating the virtual machine using storage DRS
private void createVMDRS()
{
_service = cb.getServiceConnectionV25()._service;
_sic = cb.getServiceConnectionV25().ServiceContent;
ManagedObjectReference dcmor = null;
ManagedObjectReference storagePodmor = null;
ManagedObjectReference computeResourcemor = null;
ManagedObjectReference resourcePoolmor = null;
ManagedObjectReference vmFoldermor = null;
// get the datacenter and the vm folder
String dcName = cb.get_option("datacentername");
if (!string.IsNullOrEmpty(dcName))
{
dcmor
= cb.getServiceUtilV25().GetDecendentMoRef(null, "Datacenter", dcName);
if (dcmor == null)
{
Console.WriteLine("Datacenter " + dcName + " not found.");
return;
}
else
{
//get the vm folder
ObjectContent[] objArray = cb.getServiceUtilV25().GetObjectProperties(_sic.propertyCollector, dcmor, new string[] { "vmFolder" });
if (objArray.Length > 0)
{
vmFoldermor = (ManagedObjectReference)objArray[0].propSet[0].val;
}
else
{
Console.WriteLine("vmfolder not found.");
return;
}
}
}
else
{
Console.WriteLine("datacentername user option is null or empty!");
return;
}
// get the storage pod
String storagePodName = cb.get_option("storagepodname");
if (!string.IsNullOrEmpty(storagePodName))
{
storagePodmor = cb.getServiceUtilV25().GetDecendentMoRef(dcmor, "StoragePod", storagePodName);
if (storagePodmor == null)
{
Console.WriteLine("StoragePod " + storagePodName + " not found");
return;
}
}
else
{
Console.WriteLine("storagepodname user option is null or empty!");
return;
}
// get the computeresourcename (cluster)
String computeResourceName = cb.get_option("computeresourcename");
if (!string.IsNullOrEmpty(computeResourceName))
{
computeResourcemor = cb.getServiceUtilV25().GetDecendentMoRef(dcmor, "ClusterComputeResource", computeResourceName);
if (computeResourcemor == null)
{
Console.WriteLine("ComputeResourceName " + computeResourceName + " not found");
return;
}
//get the resource pool
ObjectContent[] objArray = cb.getServiceUtilV25().GetObjectProperties(_sic.propertyCollector, computeResourcemor, new string[] {
"resourcePool" });
if (objArray.Length > 0)
{
resourcePoolmor = (ManagedObjectReference)objArray[0].propSet[0].val;
}
else
{
Console.WriteLine("ResourcePool not found");
return;
}
}
else
{
Console.WriteLine("computeresourcename user option is null or empty!");
return;
}
// For create machine
// the Folder, ConfigSpec, ResourcePool and HostSystem parameters are expected
// in the StoragePlacementSpec
StoragePlacementSpec storageSpec = new StoragePlacementSpec();
storageSpec.type = "create";
storageSpec.resourcePool = resourcePoolmor;
storageSpec.folder = vmFoldermor;
// Storage DRS
storageSpec.podSelectionSpec = new StorageDrsPodSelectionSpec();
//user selected SDRS pod for the vm
storageSpec.podSelectionSpec.storagePod = storagePodmor;
// podSelectionSpec.initialVMConfig
storageSpec.podSelectionSpec.initialVmConfig = new VmPodConfigForPlacement[1];
storageSpec.podSelectionSpec.initialVmConfig[0] = new VmPodConfigForPlacement();
storageSpec.podSelectionSpec.initialVmConfig[0].storagePod = storagePodmor;
storageSpec.podSelectionSpec.initialVmConfig[0].storagePod.type = "StoragePod";
storageSpec.podSelectionSpec.initialVmConfig[0].disk = new PodDiskLocator[1];
storageSpec.podSelectionSpec.initialVmConfig[0].disk[0] = new PodDiskLocator();
storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskId = -48;
storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo = new VirtualDiskFlatVer2BackingInfo();
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).fileName = "";
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).diskMode = "persistent";
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).thinProvisioned = true;
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).eagerlyScrub = false;
// configSpec
storageSpec.configSpec = new VirtualMachineConfigSpec();
storageSpec.configSpec.name = cb.get_option("vmname");
storageSpec.configSpec.version = "vmx-08";
storageSpec.configSpec.guestId = "windows7Server64Guest";
storageSpec.configSpec.files = new VirtualMachineFileInfo();
storageSpec.configSpec.files.vmPathName = "";
storageSpec.configSpec.numCPUs = 1;
storageSpec.configSpec.memoryMB = 1024;
storageSpec.configSpec.firmware = "bios";
// add devices to the machine
storageSpec.configSpec.deviceChange = new VirtualDeviceConfigSpec[5];
// add cd rom
storageSpec.configSpec.deviceChange[0] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[0].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[0].device = new VirtualCdrom();
storageSpec.configSpec.deviceChange[0].device.key = -44;
storageSpec.configSpec.deviceChange[0].device.backing = new VirtualCdromRemotePassthroughBackingInfo();
((VirtualCdromRemotePassthroughBackingInfo)storageSpec.configSpec.deviceChange[0].device.backing).deviceName = "";
((VirtualCdromRemotePassthroughBackingInfo)storageSpec.configSpec.deviceChange[0].device.backing).exclusive = false;
storageSpec.configSpec.deviceChange[0].device.connectable = new VirtualDeviceConnectInfo();
storageSpec.configSpec.deviceChange[0].device.connectable.startConnected = false;
storageSpec.configSpec.deviceChange[0].device.connectable.allowGuestControl = true;
storageSpec.configSpec.deviceChange[0].device.connectable.connected = false;
storageSpec.configSpec.deviceChange[0].device.controllerKey = 201;
storageSpec.configSpec.deviceChange[0].device.unitNumber = 0;
// add floppy
storageSpec.configSpec.deviceChange[1] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[1].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[1].device = new VirtualFloppy();
storageSpec.configSpec.deviceChange[1].device.key = -45;
storageSpec.configSpec.deviceChange[1].device.backing = new VirtualFloppyRemoteDeviceBackingInfo();
((VirtualFloppyRemoteDeviceBackingInfo)storageSpec.configSpec.deviceChange[1].device.backing).deviceName = "";
storageSpec.configSpec.deviceChange[1].device.connectable = new VirtualDeviceConnectInfo();
storageSpec.configSpec.deviceChange[1].device.connectable.startConnected = false;
storageSpec.configSpec.deviceChange[1].device.connectable.allowGuestControl = true;
storageSpec.configSpec.deviceChange[1].device.connectable.connected = false;
storageSpec.configSpec.deviceChange[2] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[2].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[2].device = new VirtualLsiLogicSASController();
storageSpec.configSpec.deviceChange[2].device.key = -46;
((VirtualLsiLogicSASController)storageSpec.configSpec.deviceChange[2].device).busNumber = 0;
((VirtualLsiLogicSASController)storageSpec.configSpec.deviceChange[2].device).sharedBus = VirtualSCSISharing.noSharing;
// add network
storageSpec.configSpec.deviceChange[3] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[3].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[3].device = new VirtualE1000();
storageSpec.configSpec.deviceChange[3].device.key = -47;
storageSpec.configSpec.deviceChange[3].device.backing = new VirtualEthernetCardNetworkBackingInfo();
((VirtualEthernetCardNetworkBackingInfo)storageSpec.configSpec.deviceChange[3].device.backing).deviceName = "VM Network SQA";
storageSpec.configSpec.deviceChange[3].device.connectable = new VirtualDeviceConnectInfo();
storageSpec.configSpec.deviceChange[3].device.connectable.startConnected = true;
storageSpec.configSpec.deviceChange[3].device.connectable.allowGuestControl = true;
storageSpec.configSpec.deviceChange[3].device.connectable.connected = true;
((VirtualE1000)storageSpec.configSpec.deviceChange[3].device).addressType = "generated";
((VirtualE1000)storageSpec.configSpec.deviceChange[3].device).wakeOnLanEnabled = true;
// add disk
storageSpec.configSpec.deviceChange[4] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[4].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[4].fileOperation = VirtualDeviceConfigSpecFileOperation.create;
storageSpec.configSpec.deviceChange[4].device = new VirtualDisk();
((VirtualDisk)storageSpec.configSpec.deviceChange[4].device).capacityInKB = 1048576;
storageSpec.configSpec.deviceChange[4].device.key = -48;
storageSpec.configSpec.deviceChange[4].device.controllerKey = -46;
storageSpec.configSpec.deviceChange[4].device.unitNumber = 0;
storageSpec.configSpec.deviceChange[4].device.backing = new VirtualDiskFlatVer2BackingInfo();
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).fileName = "";
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).diskMode = "persistent";
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).thinProvisioned = true;
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).eagerlyScrub = false;
// get recommened datastores call throws an error
// The error looks like this:
// Internal Server Error Occured: optional value not set
StoragePlacementResult storagePlacementRes = _service.RecommendDatastores(_sic.storageResourceManager, storageSpec);
if (storagePlacementRes.recommendations.Length > 0 )
{
string[] key = new String[1];
key[0] = storagePlacementRes.recommendations[0].key;
_service.ApplyStorageDrsRecommendation_Task(_sic.storageResourceManager, key);
}
return;
}
I am attaching a zip file with a small example.
I created the example by modifying the vm create example in SDK samples C#.
I tried a few variations of the example above.
I read in the documentation that I should specify the HostSystem.
1- I tried to add the HostSystem and I set it to reference the compute cluster.
When I do that I get an error that looks like this:
A specified parameter was not correct.
Storage DRS placement: target host vim.ClusterComputeResource:domain-c26 not connected to pod TestDatastoreCluster
2- I tried to add the HostSystem and I set it to reference an host in the cluster instead of the cluster.
When I do that I still get the error:
Internal Server Error Occured: optional value not set
Other ideas?
I tried using the same API RecommendDatastores and ApplyStorageDrsRecommendation_Task
to clone an existing machine using storage DRS. That worked fine. That example is also included in
the zipfile.
Thanks,
Teresa.