if(configTarget.getDatastore() != null) for (int i = 0; i < configTarget.getDatastore().length; i++) VirtualMachineDatastoreInfo vdsInfo = configTarget.getDatastore()[i]; DatastoreSummary dsSummary = vdsInfo.getDatastore(); if (dsSummary.isAccessible())
if(configTarget.getDatastore() != null) for (int i = 0; i < configTarget.getDatastore().length; i++) VirtualMachineDatastoreInfo vdsInfo = configTarget.getDatastore()[i]; DatastoreSummary dsSummary = vdsInfo.getDatastore(); if (dsSummary.isAccessible())
static DatastoreSummary findDatastoreSummary(VirtualMachine vm, String dsName) throws Exception { DatastoreSummary dsSum = null; VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime(); EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser(); ManagedObjectReference hmor = vmRuntimeInfo.getHost(); if(hmor == null) { System.out.println("No Datastore found"); return null; } ConfigTarget configTarget = envBrowser.queryConfigTarget(new HostSystem(vm.getServerConnection(), hmor)); VirtualMachineDatastoreInfo[] dis = configTarget.getDatastore(); for (int i=0; dis!=null && i<dis.length; i++) { dsSum = dis[i].getDatastore(); if (dsSum.isAccessible() && dsName.equals(dsSum.getName())) { break; } } return dsSum; }
static DatastoreSummary findDatastoreSummary(VirtualMachine vm, String dsName) throws Exception { DatastoreSummary dsSum = null; VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime(); EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser(); ManagedObjectReference hmor = vmRuntimeInfo.getHost(); if(hmor == null) { System.out.println("No Datastore found"); return null; } ConfigTarget configTarget = envBrowser.queryConfigTarget(new HostSystem(vm.getServerConnection(), hmor)); VirtualMachineDatastoreInfo[] dis = configTarget.getDatastore(); for (int i=0; dis!=null && i<dis.length; i++) { dsSum = dis[i].getDatastore(); if (dsSum.isAccessible() && dsName.equals(dsSum.getName())) { break; } } return dsSum; }
ManagedObjectReference cloneHostMor = getMorHost(vmInputs.getCloneHost(), connectionResources, vmMor); ConfigTarget configTarget = getHostConfigTarget(connectionResources, cloneHostMor); List<VirtualMachineDatastoreInfo> dataStoreInfoList = configTarget.getDatastore(); for (VirtualMachineDatastoreInfo dataStoreInfo : dataStoreInfoList) { if (vmInputs.getCloneDataStore().equals(dataStoreInfo.getDatastore().getName())) {
private VirtualMachineConfigSpec createVmConfigSpec(ConnectionResources connectionResources, VmInputs vmInputs) throws Exception { ConfigTarget configTarget = new VmUtils().getHostConfigTarget(connectionResources, connectionResources.getHostMor()); List<VirtualMachineDatastoreInfo> dataStoresList = configTarget.getDatastore(); String dataStoreName = vmInputs.getDataStore();