mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed NPE on volume creation from snapshot (#6839)
Co-authored-by: João Jandre <joao@scclouds.com.br>
This commit is contained in:
parent
13d22c2f54
commit
14937e1adb
@ -18,6 +18,7 @@ package com.cloud.deploy;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -117,4 +118,10 @@ public class DataCenterDeployment implements DeploymentPlan {
|
||||
return migrationPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "_dcId", "_podId", "_clusterId", "_poolId", "_hostid", "_physicalNetworkId",
|
||||
"migrationPlan");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -86,7 +86,10 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return _vm.toString();
|
||||
if (_vm != null) {
|
||||
return _vm.toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -374,15 +374,15 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
||||
if (storagePool.isPresent()) {
|
||||
storage = (StoragePool)this.dataStoreMgr.getDataStore(storagePool.get().getId(), DataStoreRole.Primary);
|
||||
s_logger.debug(String.format("VM [%s] has a preferred storage pool [%s]. Volume Orchestrator found this storage using Storage Pool Allocator [%s] and will"
|
||||
+ " use it.", vm, storage, allocator));
|
||||
+ " use it.", vm, storage, allocator.getClass().getSimpleName()));
|
||||
} else {
|
||||
storage = (StoragePool)dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
|
||||
s_logger.debug(String.format("VM [%s] does not have a preferred storage pool or it cannot be used. Volume Orchestrator will use the available Storage Pool"
|
||||
+ " [%s], which was discovered using Storage Pool Allocator [%s].", vm, storage, allocator));
|
||||
+ " [%s], which was discovered using Storage Pool Allocator [%s].", vm, storage, allocator.getClass().getSimpleName()));
|
||||
}
|
||||
return storage;
|
||||
}
|
||||
s_logger.debug(String.format("Could not find any available Storage Pool using Storage Pool Allocator [%s].", allocator));
|
||||
s_logger.debug(String.format("Could not find any available Storage Pool using Storage Pool Allocator [%s].", allocator.getClass().getSimpleName()));
|
||||
}
|
||||
s_logger.info("Volume Orchestrator could not find any available Storage Pool.");
|
||||
return null;
|
||||
|
||||
@ -19,6 +19,7 @@ package org.apache.cloudstack.storage.allocator;
|
||||
import java.math.BigDecimal;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -389,4 +390,9 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
|
||||
+ "deployment plan [%s]. Returning up to [%d] and bypassStorageTypeCheck [%s].", this.getClass().getSimpleName(), dskCh, vmProfile, plan, returnUpTo, bypassStorageTypeCheck));
|
||||
}
|
||||
|
||||
protected void logEndOfSearch(List<StoragePool> storagePoolList) {
|
||||
s_logger.debug(String.format("%s is returning [%s] suitable storage pools [%s].", this.getClass().getSimpleName(), storagePoolList.size(),
|
||||
Arrays.toString(storagePoolList.toArray())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class ClusterScopeStoragePoolAllocator extends AbstractStoragePoolAllocat
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.debug(String.format("ClusterScopeStoragePoolAllocator is returning [%s] suitable storage pools [%s].", suitablePools.size(), suitablePools));
|
||||
logEndOfSearch(suitablePools);
|
||||
|
||||
return suitablePools;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator {
|
||||
avoid.addPool(pool.getId());
|
||||
}
|
||||
}
|
||||
s_logger.debug(String.format("LocalStoragePoolAllocator returning [%s] suitable storage pools [%s].", suitablePools.size(), suitablePools));
|
||||
logEndOfSearch(suitablePools);
|
||||
|
||||
return suitablePools;
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator {
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGGER.debug(String.format("ZoneWideStoragePoolAllocator is returning [%s] suitable storage pools [%s].", suitablePools.size(), suitablePools));
|
||||
logEndOfSearch(suitablePools);
|
||||
|
||||
return suitablePools;
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
|
||||
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.to.DataObjectType;
|
||||
@ -464,4 +465,9 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "name", "uuid");
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class RandomStoragePoolAllocator extends AbstractStoragePoolAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.debug(String.format("RandomStoragePoolAllocator is returning [%s] suitable storage pools [%s].", suitablePools.size(), suitablePools));
|
||||
logEndOfSearch(suitablePools);
|
||||
|
||||
return suitablePools;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user