Я хочу создать диск в VMware. Я могу создать диск, указав хранилище данных, но когда хранилище DRS включено, я хочу создать диск в кластере хранилища данных без указания хранилища данных.
Я создаю StorageDrsPodSelectionSpec и StoragePlacementSpec, но каждый раз получаю какое-то исключение.
PodDiskLocator diskLocator1 = new PodDiskLocator();
diskLocator1.setDiskId(-1);
VmPodConfigForPlacement podConf = new VmPodConfigForPlacement();
PodDiskLocator[] podDiskLocators = new PodDiskLocator[1];
podDiskLocators[0] = diskLocator1;
podConf.setDisk(podDiskLocators);
podConf.setStoragePod(storagePodMOR.getMOR());
PodDiskLocator[] locators = new PodDiskLocator[1];
locators[0] = diskLocator1;
podConf.setDisk(locators);
VmPodConfigForPlacement[] vmPodConfigForPlacements = new VmPodConfigForPlacement[1];
vmPodConfigForPlacements[0] = podConf;
StorageDrsPodSelectionSpec podSelSpec = new StorageDrsPodSelectionSpec();
podSelSpec.setInitialVmConfig(vmPodConfigForPlacements);
//podSelSpec.setStoragePod(storagePodMOR.getMOR());
StoragePlacementSpec storagePlacementSpec = new StoragePlacementSpec();
storagePlacementSpec.setVm(vmMOR);
storagePlacementSpec.setPodSelectionSpec(podSelSpec);
storagePlacementSpec.setType(StoragePlacementSpecPlacementType.reconfigure.name());
storagePlacementSpec.setConfigSpec(getVmConfigSpec(virtualMachine));
storagePlacementSpec.setVm(vmMOR);
StorageResourceManager storageResourceManager = new StorageResourceManager(serviceInstance.getServerConnection(),
serviceInstance.getServiceContent().getStorageResourceManager());
StoragePlacementResult storagePlacementResult = storageResourceManager.recommendDatastores(storagePlacementSpec);
System.out.println("Found recommendations...");
ClusterRecommendation clusterRecommendation = storagePlacementResult.getRecommendations()[0];
String[] keys = {clusterRecommendation.getKey()};
storageResourceManager.applyStorageDrsRecommendation_Task(keys);
Я получаю ниже исключения.
com.vmware.vim25.InvalidArgument: A specified parameter was not correct: StoragePlacementSpec.podSelectionSpec and configSpec
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at com.vmware.vim25.ws.XmlGenDom.fromXml(XmlGenDom.java:253)
at com.vmware.vim25.ws.XmlGenDom.parseSoapFault(XmlGenDom.java:151)
at com.vmware.vim25.ws.XmlGenDom.fromXML(XmlGenDom.java:109)
at com.vmware.vim25.ws.SoapClient.unMarshall(SoapClient.java:253)
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:96)
at com.vmware.vim25.ws.VimStub.recommendDatastores(VimStub.java:1894)
at com.vmware.vim25.mo.StorageResourceManager.recommendDatastores(StorageResourceManager.java:93)
at vmware.storage.drs.VmwareAddDiskTest.applyStorageDRS(VmwareAddDiskTest.java:93)
at vmware.storage.drs.VmwareAddDiskTest.apply(VmwareAddDiskTest.java:57)
at vmware.storage.drs.VmwareAddDiskTest.main(VmwareAddDiskTest.java:36)