mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Exclude External hypervisor type during upgrade for System VM template checks (#11435)
* Exclude External hypervisor type during upgrade for System VM template checks
This commit is contained in:
parent
2c493d1933
commit
0b381d4270
@ -34,7 +34,7 @@ public interface ClusterDao extends GenericDao<ClusterVO, Long> {
|
||||
|
||||
List<HypervisorType> getAvailableHypervisorInZone(Long zoneId);
|
||||
|
||||
List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsArchAcrossClusters(Long zoneId);
|
||||
List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsAndArchExcludingExternalType(Long zoneId);
|
||||
|
||||
List<ClusterVO> listByDcHyType(long dcId, String hyType);
|
||||
|
||||
|
||||
@ -168,16 +168,26 @@ public class ClusterDaoImpl extends GenericDaoBase<ClusterVO, Long> implements C
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns distinct (HypervisorType, CPUArch) pairs from clusters in the given zone,
|
||||
* excluding clusters with {@link HypervisorType#External}.
|
||||
*
|
||||
* @param zoneId the zone ID to filter by, or {@code null} to include all zones
|
||||
* @return list of unique hypervisor type and CPU architecture pairs
|
||||
*/
|
||||
@Override
|
||||
public List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsArchAcrossClusters(Long zoneId) {
|
||||
public List<Pair<HypervisorType, CPU.CPUArch>> listDistinctHypervisorsAndArchExcludingExternalType(Long zoneId) {
|
||||
SearchBuilder<ClusterVO> sb = createSearchBuilder();
|
||||
sb.select(null, Func.DISTINCT_PAIR, sb.entity().getHypervisorType(), sb.entity().getArch());
|
||||
sb.and("zoneId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.NEQ);
|
||||
sb.done();
|
||||
SearchCriteria<ClusterVO> sc = sb.create();
|
||||
if (zoneId != null) {
|
||||
sc.setParameters("zoneId", zoneId);
|
||||
}
|
||||
sc.setParameters("hypervisorType", HypervisorType.External);
|
||||
|
||||
final List<ClusterVO> clusters = search(sc, null);
|
||||
return clusters.stream()
|
||||
.map(c -> new Pair<>(c.getHypervisorType(), c.getArch()))
|
||||
|
||||
@ -917,7 +917,7 @@ public class SystemVmTemplateRegistration {
|
||||
String nfsVersion = getNfsVersion(storeUrlAndId.second());
|
||||
mountStore(storeUrlAndId.first(), filePath, nfsVersion);
|
||||
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> hypervisorArchList =
|
||||
clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
|
||||
clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
|
||||
for (Pair<Hypervisor.HypervisorType, CPU.CPUArch> hypervisorArch : hypervisorArchList) {
|
||||
Hypervisor.HypervisorType hypervisorType = hypervisorArch.first();
|
||||
MetadataTemplateDetails templateDetails = getMetadataTemplateDetails(hypervisorType,
|
||||
@ -1065,7 +1065,7 @@ public class SystemVmTemplateRegistration {
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> hypervisorsInUse;
|
||||
try {
|
||||
hypervisorsInUse = clusterDao.listDistinctHypervisorsArchAcrossClusters(null);
|
||||
hypervisorsInUse = clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(null);
|
||||
} catch (final Exception e) {
|
||||
throw new CloudRuntimeException("Exception while getting hypervisor types from clusters", e);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class ClusterDaoImplTest {
|
||||
when(cluster2.getArch()).thenReturn(CPU.CPUArch.arm64);
|
||||
List<ClusterVO> dummyHosts = Arrays.asList(cluster1, cluster2);
|
||||
doReturn(dummyHosts).when(clusterDao).search(any(SearchCriteria.class), isNull());
|
||||
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
|
||||
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
|
||||
assertNotNull(result);
|
||||
assertEquals(2, result.size());
|
||||
assertEquals(Hypervisor.HypervisorType.XenServer, result.get(0).first());
|
||||
@ -109,7 +109,7 @@ public class ClusterDaoImplTest {
|
||||
when(cluster.getArch()).thenReturn(CPU.CPUArch.amd64);
|
||||
List<ClusterVO> dummyHosts = Collections.singletonList(cluster);
|
||||
doReturn(dummyHosts).when(clusterDao).search(any(SearchCriteria.class), isNull());
|
||||
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
|
||||
List<Pair<Hypervisor.HypervisorType, CPU.CPUArch>> result = clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
|
||||
assertNotNull(result);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(Hypervisor.HypervisorType.VMware, result.get(0).first());
|
||||
|
||||
@ -404,7 +404,7 @@ public class SystemVmTemplateRegistrationTest {
|
||||
Hypervisor.HypervisorType hypervisorType = Hypervisor.HypervisorType.KVM;
|
||||
CPU.CPUArch arch = CPU.CPUArch.getDefault();
|
||||
hypervisorArchList.add(new Pair<>(hypervisorType, arch));
|
||||
doReturn(hypervisorArchList).when(clusterDao).listDistinctHypervisorsArchAcrossClusters(zoneId);
|
||||
doReturn(hypervisorArchList).when(clusterDao).listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
|
||||
SystemVmTemplateRegistration.MetadataTemplateDetails details =
|
||||
Mockito.mock(SystemVmTemplateRegistration.MetadataTemplateDetails.class);
|
||||
String name = "existing";
|
||||
|
||||
@ -4029,7 +4029,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
DataStoreRole.Image, store.getId());
|
||||
if (CollectionUtils.isEmpty(stores)) {
|
||||
List<Pair<HypervisorType, CPU.CPUArch>> hypervisorTypes =
|
||||
_clusterDao.listDistinctHypervisorsArchAcrossClusters(zoneId);
|
||||
_clusterDao.listDistinctHypervisorsAndArchExcludingExternalType(zoneId);
|
||||
TransactionLegacy txn = TransactionLegacy.open("AutomaticTemplateRegister");
|
||||
SystemVmTemplateRegistration systemVmTemplateRegistration = new SystemVmTemplateRegistration();
|
||||
String filePath = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user