VMware Cloud Community
MDA1668
Contributor
Contributor

Wrong StorageCluster recommendation

Hi,

we are using the following script to create new VMs into a StorageCluster. This works quite good, as long as there are enough datastores with enough space for the new VM left. If only one datastore with enough space is left inside the storagecluster, the recommendation is often wrong and chooses a datastore too small for provisioning. Using the vCenter GUI the correct datastore is selected. Does anyone has an idea why VCO get the wrong recommendation?

Thanks

Stephan

var config = new VcVirtualMachineConfigSpec();

config.name = vmName;

config.version = "vmx-08";

config.guestId = "windows8Server64Guest";

config.numCPUs = 2;

config.memoryMB = 2 * 1024;

config.memoryHotAddEnabled = true;

config.cpuHotAddEnabled = true;

config.files = new VcVirtualMachineFileInfo();

config.files.vmPathName = "";

var devices = new Array();

devices.push( System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualScsiControllerConfigSpec( "sas" ) );

devices.push( System.getModule("com.xxx.eu.ServerAutomation").createVirtualDiskFlatVer2ConfigSpecForStoragePod(100,0,0,VcVirtualDiskMode.persistent, false) )

devices.push( System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualEthernetCardNetworkConfigSpecE1000(network));

var storageSpec = new VcStoragePlacementSpec();

config.deviceChange = devices;

storageSpec.configSpec = config;

storageSpec.type = "create";

storageSpec.podSelectionSpec = new VcStorageDrsPodSelectionSpec();

storageSpec.podSelectionSpec.initialVmConfig = new Array(new VcVmPodConfigForPlacement());

storageSpec.podSelectionSpec.initialVmConfig[0].storagePod = storagePodObj;

storageSpec.podSelectionSpec.initialVmConfig[0].vmConfig = new VcStorageDrsVmConfigInfo() ;

storageSpec.podSelectionSpec.initialVmConfig[0].vmConfig.intraVmAffinity = false;

storageSpec.podSelectionSpec.storagePod = storagePodObj;

storageSpec.resourcePool = resPool;

storageSpec.folder = folder;

vCenter = clusterObj.sdkConnection;

var managedObject = vCenter.storageResourceManager;

var placementResult = managedObject.recommendDatastores(storageSpec);

key = new Array();

key[0] = placementResult.recommendations[0].key;

task = managedObject.applyStorageDrsRecommendation_Task(key);

0 Kudos
1 Reply
kujeter
Enthusiast
Enthusiast

Sorry, I don't have an answer for your question but I'd love to see the code you have in com.xxx.eu.ServerAutomation").createVirtualDiskFlatVer2ConfigSpecForStoragePod. I'm wading through trying to provision new machines into sdrs clusters and am not making much headway.

0 Kudos