mirror of https://github.com/apache/cloudstack.git
Compare commits
9 Commits
b15959e1b4
...
334d9c102e
| Author | SHA1 | Date |
|---|---|---|
|
|
334d9c102e | |
|
|
bce3e54a7e | |
|
|
6a9835904c | |
|
|
6846619a6f | |
|
|
d1eb2822d9 | |
|
|
b0e586afde | |
|
|
36f7cda780 | |
|
|
3fc135638c | |
|
|
15c1be46e6 |
|
|
@ -78,6 +78,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID,
|
||||
type = CommandType.STRING,
|
||||
length = 4096,
|
||||
description = "The ID of the containing domain(s) as comma separated string, public for public offerings")
|
||||
private String domainIds;
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ public class UpdateDiskOfferingCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.STRING,
|
||||
description = "The ID of the containing zone(s) as comma separated string, all for all zones offerings",
|
||||
length = 4096,
|
||||
since = "4.13")
|
||||
private String zoneIds;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.STRING,
|
||||
description = "The ID of the containing zone(s) as comma separated string, all for all zones offerings",
|
||||
length = 4096,
|
||||
since = "4.13")
|
||||
private String zoneIds;
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.ZONE_ID,
|
||||
type = CommandType.STRING,
|
||||
description = "The ID of the containing zone(s) as comma separated string, all for all zones offerings",
|
||||
length = 4096,
|
||||
since = "4.13")
|
||||
private String zoneIds;
|
||||
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ public interface TemplateManager {
|
|||
|
||||
TemplateType validateTemplateType(BaseCmd cmd, boolean isAdmin, boolean isCrossZones);
|
||||
|
||||
DataStore verifyHeuristicRulesForZone(VMTemplateVO template, Long zoneId);
|
||||
|
||||
List<DatadiskTO> getTemplateDisksOnImageStore(VirtualMachineTemplate template, DataStoreRole role, String configurationId);
|
||||
|
||||
static Boolean getValidateUrlIsResolvableBeforeRegisteringTemplateValue() {
|
||||
|
|
|
|||
|
|
@ -31,4 +31,6 @@ public interface VMScheduledJobDao extends GenericDao<VMScheduledJobVO, Long> {
|
|||
int expungeJobsForSchedules(List<Long> scheduleId, Date dateAfter);
|
||||
|
||||
int expungeJobsBefore(Date currentTimestamp);
|
||||
|
||||
VMScheduledJobVO findByScheduleAndTimestamp(long scheduleId, Date scheduledTimestamp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ public class VMScheduledJobDaoImpl extends GenericDaoBase<VMScheduledJobVO, Long
|
|||
|
||||
private final SearchBuilder<VMScheduledJobVO> expungeJobForScheduleSearch;
|
||||
|
||||
private final SearchBuilder<VMScheduledJobVO> scheduleAndTimestampSearch;
|
||||
|
||||
static final String SCHEDULED_TIMESTAMP = "scheduled_timestamp";
|
||||
|
||||
static final String VM_SCHEDULE_ID = "vm_schedule_id";
|
||||
|
|
@ -58,6 +60,11 @@ public class VMScheduledJobDaoImpl extends GenericDaoBase<VMScheduledJobVO, Long
|
|||
expungeJobForScheduleSearch.and(VM_SCHEDULE_ID, expungeJobForScheduleSearch.entity().getVmScheduleId(), SearchCriteria.Op.IN);
|
||||
expungeJobForScheduleSearch.and(SCHEDULED_TIMESTAMP, expungeJobForScheduleSearch.entity().getScheduledTime(), SearchCriteria.Op.GTEQ);
|
||||
expungeJobForScheduleSearch.done();
|
||||
|
||||
scheduleAndTimestampSearch = createSearchBuilder();
|
||||
scheduleAndTimestampSearch.and(VM_SCHEDULE_ID, scheduleAndTimestampSearch.entity().getVmScheduleId(), SearchCriteria.Op.EQ);
|
||||
scheduleAndTimestampSearch.and(SCHEDULED_TIMESTAMP, scheduleAndTimestampSearch.entity().getScheduledTime(), SearchCriteria.Op.EQ);
|
||||
scheduleAndTimestampSearch.done();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -92,4 +99,12 @@ public class VMScheduledJobDaoImpl extends GenericDaoBase<VMScheduledJobVO, Long
|
|||
sc.setParameters(SCHEDULED_TIMESTAMP, date);
|
||||
return expunge(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMScheduledJobVO findByScheduleAndTimestamp(long scheduleId, Date scheduledTimestamp) {
|
||||
SearchCriteria<VMScheduledJobVO> sc = scheduleAndTimestampSearch.create();
|
||||
sc.setParameters(VM_SCHEDULE_ID, scheduleId);
|
||||
sc.setParameters(SCHEDULED_TIMESTAMP, scheduledTimestamp);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,23 +290,43 @@ public class TemplateServiceImpl implements TemplateService {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean isSkipTemplateStoreDownload(VMTemplateVO template, Long zoneId) {
|
||||
protected boolean shouldDownloadTemplateToStore(VMTemplateVO template, DataStore store) {
|
||||
Long zoneId = store.getScope().getScopeId();
|
||||
DataStore directedStore = _tmpltMgr.verifyHeuristicRulesForZone(template, zoneId);
|
||||
if (directedStore != null && store.getId() != directedStore.getId()) {
|
||||
logger.info("Template [{}] will not be download to image store [{}], as a heuristic rule is directing it to another store.",
|
||||
template.getUniqueName(), store.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (template.isPublicTemplate()) {
|
||||
return false;
|
||||
}
|
||||
if (template.isFeatured()) {
|
||||
return false;
|
||||
}
|
||||
if (TemplateType.SYSTEM.equals(template.getTemplateType())) {
|
||||
return false;
|
||||
}
|
||||
if (zoneId != null && _vmTemplateStoreDao.findByTemplateZone(template.getId(), zoneId, DataStoreRole.Image) == null) {
|
||||
logger.debug("Template {} is not present on any image store for the zone ID: {}, its download cannot be skipped", template, zoneId);
|
||||
return false;
|
||||
}
|
||||
logger.debug("Download of template [{}] to image store [{}] cannot be skipped, as it is public.", template.getUniqueName(),
|
||||
store.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (template.isFeatured()) {
|
||||
logger.debug("Download of template [{}] to image store [{}] cannot be skipped, as it is featured.", template.getUniqueName(),
|
||||
store.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TemplateType.SYSTEM.equals(template.getTemplateType())) {
|
||||
logger.debug("Download of template [{}] to image store [{}] cannot be skipped, as it is a system VM template.",
|
||||
template.getUniqueName(),store.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (zoneId != null && _vmTemplateStoreDao.findByTemplateZone(template.getId(), zoneId, DataStoreRole.Image) == null) {
|
||||
logger.debug("Download of template [{}] to image store [{}] cannot be skipped, as it is not present on any image store of zone [{}].",
|
||||
template.getUniqueName(), store.getName(), zoneId);
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.info("Skipping download of template [{}] to image store [{}].", template.getUniqueName(), store.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTemplateSync(DataStore store) {
|
||||
if (store == null) {
|
||||
|
|
@ -531,8 +551,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||
// download.
|
||||
for (VMTemplateVO tmplt : toBeDownloaded) {
|
||||
// if this is private template, skip sync to a new image store
|
||||
if (isSkipTemplateStoreDownload(tmplt, zoneId)) {
|
||||
logger.info("Skip sync downloading private template {} to a new image store", tmplt);
|
||||
if (!shouldDownloadTemplateToStore(tmplt, store)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.cloudstack.storage.image;
|
||||
|
||||
import com.cloud.storage.template.TemplateProp;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import org.apache.cloudstack.engine.orchestration.service.StorageOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
|
||||
|
|
@ -70,6 +71,9 @@ public class TemplateServiceImplTest {
|
|||
@Mock
|
||||
TemplateObject templateInfoMock;
|
||||
|
||||
@Mock
|
||||
DataStore dataStoreMock;
|
||||
|
||||
@Mock
|
||||
DataStore sourceStoreMock;
|
||||
|
||||
|
|
@ -82,6 +86,9 @@ public class TemplateServiceImplTest {
|
|||
@Mock
|
||||
StorageOrchestrationService storageOrchestrator;
|
||||
|
||||
@Mock
|
||||
TemplateManager templateManagerMock;
|
||||
|
||||
Map<String, TemplateProp> templatesInSourceStore = new HashMap<>();
|
||||
|
||||
@Before
|
||||
|
|
@ -96,45 +103,45 @@ public class TemplateServiceImplTest {
|
|||
Mockito.doReturn(null).when(templateService).listTemplate(destStoreMock);
|
||||
Mockito.doReturn("install-path").when(templateInfoMock).getInstallPath();
|
||||
Mockito.doReturn(templateInfoMock).when(templateDataFactoryMock).getTemplate(2L, sourceStoreMock);
|
||||
Mockito.doReturn(3L).when(dataStoreMock).getId();
|
||||
Mockito.doReturn(zoneScopeMock).when(dataStoreMock).getScope();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSkipTemplateStoreDownloadPublicTemplate() {
|
||||
VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class);
|
||||
Mockito.when(templateVO.isPublicTemplate()).thenReturn(true);
|
||||
Assert.assertFalse(templateService.isSkipTemplateStoreDownload(templateVO, 1L));
|
||||
public void shouldDownloadTemplateToStoreTestSkipsTemplateDirectedToAnotherStorage() {
|
||||
DataStore destinedStore = Mockito.mock(DataStore.class);
|
||||
Mockito.doReturn(dataStoreMock.getId() + 1L).when(destinedStore).getId();
|
||||
Mockito.when(templateManagerMock.verifyHeuristicRulesForZone(tmpltMock, zoneScopeMock.getScopeId())).thenReturn(destinedStore);
|
||||
Assert.assertFalse(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSkipTemplateStoreDownloadFeaturedTemplate() {
|
||||
VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class);
|
||||
Mockito.when(templateVO.isFeatured()).thenReturn(true);
|
||||
Assert.assertFalse(templateService.isSkipTemplateStoreDownload(templateVO, 1L));
|
||||
public void shouldDownloadTemplateToStoreTestDownloadsPublicTemplate() {
|
||||
Mockito.when(tmpltMock.isPublicTemplate()).thenReturn(true);
|
||||
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSkipTemplateStoreDownloadSystemTemplate() {
|
||||
VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class);
|
||||
Mockito.when(templateVO.getTemplateType()).thenReturn(Storage.TemplateType.SYSTEM);
|
||||
Assert.assertFalse(templateService.isSkipTemplateStoreDownload(templateVO, 1L));
|
||||
public void shouldDownloadTemplateToStoreTestDownloadsFeaturedTemplate() {
|
||||
Mockito.when(tmpltMock.isFeatured()).thenReturn(true);
|
||||
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSkipTemplateStoreDownloadPrivateNoRefTemplate() {
|
||||
VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class);
|
||||
long id = 1L;
|
||||
Mockito.when(templateVO.getId()).thenReturn(id);
|
||||
Mockito.when(templateDataStoreDao.findByTemplateZone(id, id, DataStoreRole.Image)).thenReturn(null);
|
||||
Assert.assertFalse(templateService.isSkipTemplateStoreDownload(templateVO, id));
|
||||
public void shouldDownloadTemplateToStoreTestDownloadsSystemTemplate() {
|
||||
Mockito.when(tmpltMock.getTemplateType()).thenReturn(Storage.TemplateType.SYSTEM);
|
||||
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsSkipTemplateStoreDownloadPrivateExistingTemplate() {
|
||||
VMTemplateVO templateVO = Mockito.mock(VMTemplateVO.class);
|
||||
long id = 1L;
|
||||
Mockito.when(templateVO.getId()).thenReturn(id);
|
||||
Mockito.when(templateDataStoreDao.findByTemplateZone(id, id, DataStoreRole.Image)).thenReturn(Mockito.mock(TemplateDataStoreVO.class));
|
||||
Assert.assertTrue(templateService.isSkipTemplateStoreDownload(templateVO, id));
|
||||
public void shouldDownloadTemplateToStoreTestDownloadsPrivateNoRefTemplate() {
|
||||
Assert.assertTrue(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDownloadTemplateToStoreTestSkipsPrivateExistingTemplate() {
|
||||
Mockito.when(templateDataStoreDao.findByTemplateZone(tmpltMock.getId(), zoneScopeMock.getScopeId(), DataStoreRole.Image)).thenReturn(Mockito.mock(TemplateDataStoreVO.class));
|
||||
Assert.assertFalse(templateService.shouldDownloadTemplateToStore(tmpltMock, dataStoreMock));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
|||
import org.apache.cloudstack.framework.async.AsyncRpcContext;
|
||||
import org.apache.cloudstack.framework.messagebus.MessageBus;
|
||||
import org.apache.cloudstack.framework.messagebus.PublishScope;
|
||||
import org.apache.cloudstack.secstorage.heuristics.HeuristicType;
|
||||
import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
|
|
@ -308,7 +307,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
|
||||
|
||||
for (long zoneId : zonesIds) {
|
||||
DataStore imageStore = verifyHeuristicRulesForZone(template, zoneId);
|
||||
DataStore imageStore = templateMgr.verifyHeuristicRulesForZone(template, zoneId);
|
||||
|
||||
if (imageStore == null) {
|
||||
List<DataStore> imageStores = getImageStoresThrowsExceptionIfNotFound(zoneId, profile);
|
||||
|
|
@ -327,16 +326,6 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
return imageStores;
|
||||
}
|
||||
|
||||
protected DataStore verifyHeuristicRulesForZone(VMTemplateVO template, Long zoneId) {
|
||||
HeuristicType heuristicType;
|
||||
if (ImageFormat.ISO.equals(template.getFormat())) {
|
||||
heuristicType = HeuristicType.ISO;
|
||||
} else {
|
||||
heuristicType = HeuristicType.TEMPLATE;
|
||||
}
|
||||
return heuristicRuleHelper.getImageStoreIfThereIsHeuristicRule(zoneId, heuristicType, template);
|
||||
}
|
||||
|
||||
protected void standardImageStoreAllocation(List<DataStore> imageStores, VMTemplateVO template) {
|
||||
Set<Long> zoneSet = new HashSet<Long>();
|
||||
Collections.shuffle(imageStores);
|
||||
|
|
@ -432,7 +421,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||
}
|
||||
|
||||
Long zoneId = zoneIdList.get(0);
|
||||
DataStore imageStore = verifyHeuristicRulesForZone(template, zoneId);
|
||||
DataStore imageStore = templateMgr.verifyHeuristicRulesForZone(template, zoneId);
|
||||
List<TemplateOrVolumePostUploadCommand> payloads = new LinkedList<>();
|
||||
|
||||
if (imageStore == null) {
|
||||
|
|
|
|||
|
|
@ -2347,6 +2347,17 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
|||
return templateType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataStore verifyHeuristicRulesForZone(VMTemplateVO template, Long zoneId) {
|
||||
HeuristicType heuristicType;
|
||||
if (ImageFormat.ISO.equals(template.getFormat())) {
|
||||
heuristicType = HeuristicType.ISO;
|
||||
} else {
|
||||
heuristicType = HeuristicType.TEMPLATE;
|
||||
}
|
||||
return heuristicRuleHelper.getImageStoreIfThereIsHeuristicRule(zoneId, heuristicType, template);
|
||||
}
|
||||
|
||||
void validateDetails(VMTemplateVO template, Map<String, String> details) {
|
||||
if (MapUtils.isEmpty(details)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -162,7 +162,13 @@ public class VMSchedulerImpl extends ManagerBase implements VMScheduler, Configu
|
|||
}
|
||||
|
||||
Date scheduledDateTime = Date.from(ts.toInstant());
|
||||
VMScheduledJobVO scheduledJob = new VMScheduledJobVO(vmSchedule.getVmId(), vmSchedule.getId(), vmSchedule.getAction(), scheduledDateTime);
|
||||
VMScheduledJobVO scheduledJob = vmScheduledJobDao.findByScheduleAndTimestamp(vmSchedule.getId(), scheduledDateTime);
|
||||
if (scheduledJob != null) {
|
||||
logger.trace("Job is already scheduled for schedule {} at {}", vmSchedule, scheduledDateTime);
|
||||
return scheduledDateTime;
|
||||
}
|
||||
|
||||
scheduledJob = new VMScheduledJobVO(vmSchedule.getVmId(), vmSchedule.getId(), vmSchedule.getAction(), scheduledDateTime);
|
||||
try {
|
||||
vmScheduledJobDao.persist(scheduledJob);
|
||||
ActionEventUtils.onScheduledActionEvent(User.UID_SYSTEM, vm.getAccountId(), actionEventMap.get(vmSchedule.getAction()),
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
|||
import org.apache.cloudstack.framework.events.Event;
|
||||
import org.apache.cloudstack.framework.events.EventDistributor;
|
||||
import org.apache.cloudstack.framework.messagebus.MessageBus;
|
||||
import org.apache.cloudstack.secstorage.heuristics.HeuristicType;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
import org.apache.cloudstack.storage.heuristics.HeuristicRuleHelper;
|
||||
|
|
@ -339,7 +338,7 @@ public class HypervisorTemplateAdapterTest {
|
|||
|
||||
Mockito.when(templateProfileMock.getZoneIdList()).thenReturn(zoneIds);
|
||||
Mockito.doReturn(null).when(_adapter).getImageStoresThrowsExceptionIfNotFound(Mockito.any(Long.class), Mockito.any(TemplateProfile.class));
|
||||
Mockito.doReturn(null).when(_adapter).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
|
||||
Mockito.doReturn(null).when(_templateMgr).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
|
||||
Mockito.doNothing().when(_adapter).standardImageStoreAllocation(Mockito.isNull(), Mockito.any(VMTemplateVO.class));
|
||||
|
||||
_adapter.createTemplateWithinZones(templateProfileMock, vmTemplateVOMock);
|
||||
|
|
@ -355,7 +354,7 @@ public class HypervisorTemplateAdapterTest {
|
|||
|
||||
Mockito.when(templateProfileMock.getZoneIdList()).thenReturn(zoneIds);
|
||||
Mockito.doReturn(null).when(_adapter).getImageStoresThrowsExceptionIfNotFound(Mockito.any(Long.class), Mockito.any(TemplateProfile.class));
|
||||
Mockito.doReturn(null).when(_adapter).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
|
||||
Mockito.doReturn(null).when(_templateMgr).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
|
||||
Mockito.doNothing().when(_adapter).standardImageStoreAllocation(Mockito.isNull(), Mockito.any(VMTemplateVO.class));
|
||||
|
||||
_adapter.createTemplateWithinZones(templateProfileMock, vmTemplateVOMock);
|
||||
|
|
@ -371,7 +370,7 @@ public class HypervisorTemplateAdapterTest {
|
|||
List<Long> zoneIds = List.of(1L);
|
||||
|
||||
Mockito.when(templateProfileMock.getZoneIdList()).thenReturn(zoneIds);
|
||||
Mockito.doReturn(dataStoreMock).when(_adapter).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
|
||||
Mockito.doReturn(dataStoreMock).when(_templateMgr).verifyHeuristicRulesForZone(Mockito.any(VMTemplateVO.class), Mockito.anyLong());
|
||||
Mockito.doNothing().when(_adapter).validateSecondaryStorageAndCreateTemplate(Mockito.any(List.class), Mockito.any(VMTemplateVO.class), Mockito.isNull());
|
||||
|
||||
_adapter.createTemplateWithinZones(templateProfileMock, vmTemplateVOMock);
|
||||
|
|
@ -409,26 +408,6 @@ public class HypervisorTemplateAdapterTest {
|
|||
_adapter.getImageStoresThrowsExceptionIfNotFound(zoneId, templateProfileMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyHeuristicRulesForZoneTestTemplateIsISOFormatShouldCheckForISOHeuristicType() {
|
||||
VMTemplateVO vmTemplateVOMock = Mockito.mock(VMTemplateVO.class);
|
||||
|
||||
Mockito.when(vmTemplateVOMock.getFormat()).thenReturn(ImageFormat.ISO);
|
||||
_adapter.verifyHeuristicRulesForZone(vmTemplateVOMock, 1L);
|
||||
|
||||
Mockito.verify(heuristicRuleHelperMock, Mockito.times(1)).getImageStoreIfThereIsHeuristicRule(1L, HeuristicType.ISO, vmTemplateVOMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyHeuristicRulesForZoneTestTemplateNotISOFormatShouldCheckForTemplateHeuristicType() {
|
||||
VMTemplateVO vmTemplateVOMock = Mockito.mock(VMTemplateVO.class);
|
||||
|
||||
Mockito.when(vmTemplateVOMock.getFormat()).thenReturn(ImageFormat.QCOW2);
|
||||
_adapter.verifyHeuristicRulesForZone(vmTemplateVOMock, 1L);
|
||||
|
||||
Mockito.verify(heuristicRuleHelperMock, Mockito.times(1)).getImageStoreIfThereIsHeuristicRule(1L, HeuristicType.TEMPLATE, vmTemplateVOMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isZoneAndImageStoreAvailableTestZoneIdIsNullShouldReturnFalse() {
|
||||
DataStore dataStoreMock = Mockito.mock(DataStore.class);
|
||||
|
|
|
|||
|
|
@ -750,6 +750,26 @@ public class TemplateManagerImplTest {
|
|||
Assert.assertNull(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyHeuristicRulesForZoneTestTemplateIsISOFormatShouldCheckForISOHeuristicType() {
|
||||
VMTemplateVO vmTemplateVOMock = Mockito.mock(VMTemplateVO.class);
|
||||
|
||||
Mockito.when(vmTemplateVOMock.getFormat()).thenReturn(Storage.ImageFormat.ISO);
|
||||
templateManager.verifyHeuristicRulesForZone(vmTemplateVOMock, 1L);
|
||||
|
||||
Mockito.verify(heuristicRuleHelperMock, Mockito.times(1)).getImageStoreIfThereIsHeuristicRule(1L, HeuristicType.ISO, vmTemplateVOMock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyHeuristicRulesForZoneTestTemplateNotISOFormatShouldCheckForTemplateHeuristicType() {
|
||||
VMTemplateVO vmTemplateVOMock = Mockito.mock(VMTemplateVO.class);
|
||||
|
||||
Mockito.when(vmTemplateVOMock.getFormat()).thenReturn(Storage.ImageFormat.QCOW2);
|
||||
templateManager.verifyHeuristicRulesForZone(vmTemplateVOMock, 1L);
|
||||
|
||||
Mockito.verify(heuristicRuleHelperMock, Mockito.times(1)).getImageStoreIfThereIsHeuristicRule(1L, HeuristicType.TEMPLATE, vmTemplateVOMock);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackageClasses = {TemplateManagerImpl.class},
|
||||
includeFilters = {@ComponentScan.Filter(value = TestConfiguration.Library.class, type = FilterType.CUSTOM)},
|
||||
|
|
|
|||
|
|
@ -218,18 +218,19 @@ export const notifierPlugin = {
|
|||
if (error.response.status) {
|
||||
msg = `${i18n.global.t('message.request.failed')} (${error.response.status})`
|
||||
}
|
||||
if (error.message) {
|
||||
desc = error.message
|
||||
}
|
||||
if (error.response.headers && 'x-description' in error.response.headers) {
|
||||
if (error.response.headers?.['x-description']) {
|
||||
desc = error.response.headers['x-description']
|
||||
}
|
||||
if (desc === '' && error.response.data) {
|
||||
} else if (error.response.data) {
|
||||
const responseKey = _.findKey(error.response.data, 'errortext')
|
||||
if (responseKey) {
|
||||
desc = error.response.data[responseKey].errortext
|
||||
} else if (typeof error.response.data === 'string') {
|
||||
desc = error.response.data
|
||||
}
|
||||
}
|
||||
if (!desc && error.message) {
|
||||
desc = error.message
|
||||
}
|
||||
}
|
||||
let countNotify = store.getters.countNotify
|
||||
countNotify++
|
||||
|
|
|
|||
|
|
@ -638,11 +638,7 @@ export default {
|
|||
this.$emit('refresh-data')
|
||||
this.closeAction()
|
||||
}).catch(e => {
|
||||
this.$notification.error({
|
||||
message: this.$t('message.upload.failed'),
|
||||
description: `${this.$t('message.upload.template.failed.description')} - ${e}`,
|
||||
duration: 0
|
||||
})
|
||||
this.$notifyError(e)
|
||||
})
|
||||
},
|
||||
fetchCustomHypervisorName () {
|
||||
|
|
|
|||
Loading…
Reference in New Issue