mirror of https://github.com/apache/cloudstack.git
Handle import unmanaged VM into CloudStack to support any type of datastore
This commit is contained in:
parent
c11dc337be
commit
04d400f055
|
|
@ -299,7 +299,6 @@ import com.vmware.vim25.VirtualVmxnet2;
|
|||
import com.vmware.vim25.VirtualVmxnet3;
|
||||
import com.vmware.vim25.VmConfigInfo;
|
||||
import com.vmware.vim25.VmConfigSpec;
|
||||
import com.vmware.vim25.VmfsDatastoreInfo;
|
||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchPvlanSpec;
|
||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
||||
import org.apache.cloudstack.storage.command.CopyCommand;
|
||||
|
|
@ -7000,14 +6999,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
instanceDisk.setDatastorePath(dsInfo.getNas().getRemotePath());
|
||||
instanceDisk.setDatastoreType(dsInfo.getNas().getType());
|
||||
}
|
||||
} else if (info instanceof VmfsDatastoreInfo) {
|
||||
VmfsDatastoreInfo dsInfo = (VmfsDatastoreInfo) info;
|
||||
instanceDisk.setDatastoreName(dsInfo.getVmfs().getName());
|
||||
instanceDisk.setDatastoreType(dsInfo.getVmfs().getType());
|
||||
} else {
|
||||
String msg = String.format("Unmanaged instance disk: %s is on unsupported datastore %s", instanceDisk.getDiskId(), info.getClass().getSimpleName());
|
||||
s_logger.error(msg);
|
||||
throw new Exception(msg);
|
||||
instanceDisk.setDatastoreName(info.getName());
|
||||
}
|
||||
}
|
||||
s_logger.info(vmMo.getName() + " " + disk.getDeviceInfo().getLabel() + " " + disk.getDeviceInfo().getSummary() + " " + disk.getDiskObjectId() + " " + disk.getCapacityInKB() + " " + instanceDisk.getController());
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ import com.cloud.service.ServiceOfferingVO;
|
|||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.storage.GuestOSHypervisor;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
|
|
@ -491,23 +490,20 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
|||
final String dsPath = disk.getDatastorePath();
|
||||
final String dsType = disk.getDatastoreType();
|
||||
final String dsName = disk.getDatastoreName();
|
||||
if (dsType.equals(Storage.StoragePoolType.VMFS.toString())) {
|
||||
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolsByCluster(cluster.getId());
|
||||
pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId()));
|
||||
if (dsType != null) {
|
||||
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(dsHost, dsPath);
|
||||
for (StoragePool pool : pools) {
|
||||
if (pool.getPoolType() != Storage.StoragePoolType.VMFS) {
|
||||
continue;
|
||||
}
|
||||
if (pool.getPath().endsWith(dsName)) {
|
||||
if (pool.getDataCenterId() == zone.getId() &&
|
||||
(pool.getClusterId() == null || pool.getClusterId().equals(cluster.getId()))) {
|
||||
storagePool = pool;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolByHostPath(dsHost, dsPath);
|
||||
List<StoragePoolVO> pools = primaryDataStoreDao.listPoolsByCluster(cluster.getId());
|
||||
pools.addAll(primaryDataStoreDao.listByDataCenterId(zone.getId()));
|
||||
for (StoragePool pool : pools) {
|
||||
if (pool.getDataCenterId() == zone.getId() &&
|
||||
(pool.getClusterId() == null || pool.getClusterId().equals(cluster.getId()))) {
|
||||
if (pool.getPath().endsWith(dsName)) {
|
||||
storagePool = pool;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue