Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public TemplateInfo getTemplate() {

void associateTemplateToZone(long templateId, Long zoneId);

void associateCrosszoneTemplatesToZone(long dcId);
void associateCrossZoneTemplatesToZone(long dcId);

AsyncCallFuture<TemplateApiResult> createDatadiskTemplateAsync(TemplateInfo parentTemplate, TemplateInfo dataDiskTemplate, String path, String diskId, long fileSize, boolean bootable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>, StateDao<

public List<VMTemplateVO> listAllActive();

List<VMTemplateVO> listAllCrossZoneTemplates();

public List<VMTemplateVO> listByState(VirtualMachineTemplate.State... states);

public List<VMTemplateVO> listByHypervisorType(List<HypervisorType> hyperTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
AllFieldsSearch.and("notDestroyed", AllFieldsSearch.entity().getState(), SearchCriteria.Op.NEQ);
AllFieldsSearch.and("updatedCount", AllFieldsSearch.entity().getUpdatedCount(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("crossZone", AllFieldsSearch.entity().isCrossZones(), SearchCriteria.Op.EQ);
AllFieldsSearch.done();

ParentTemplateIdSearch = createSearchBuilder();
Expand Down Expand Up @@ -571,6 +572,13 @@ public List<VMTemplateVO> listAllActive() {
return listBy(sc);
}

@Override
public List<VMTemplateVO> listAllCrossZoneTemplates() {
SearchCriteria<VMTemplateVO> sc = AllFieldsSearch.create();
sc.setParameters("crossZone", true);
return listBy(sc);
}

@Override
public List<VMTemplateVO> listByState(VirtualMachineTemplate.State... states) {
SearchCriteria<VMTemplateVO> sc = ActiveTmpltSearch.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,17 +881,15 @@ public void associateTemplateToZone(long templateId, Long zoneId) {

// update template_zone_ref for cross-zone template for newly added zone
@Override
public void associateCrosszoneTemplatesToZone(long dcId) {
public void associateCrossZoneTemplatesToZone(long dcId) {
VMTemplateZoneVO tmpltZone;

List<VMTemplateVO> allTemplates = _templateDao.listAll();
for (VMTemplateVO vt : allTemplates) {
if (vt.isCrossZones()) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
List<VMTemplateVO> crossZoneTemplates = _templateDao.listAllCrossZoneTemplates();
for (VMTemplateVO vt : crossZoneTemplates) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
Comment thread
vishesh92 marked this conversation as resolved.
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,12 @@ public void postDiscovery(List<HostVO> hosts, long msId) {
private void associateTemplatesToZone(long hostId, long dcId) {
VMTemplateZoneVO tmpltZone;

List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
for (VMTemplateVO vt : allTemplates) {
if (vt.isCrossZones()) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
List<VMTemplateVO> crossZoneTemplates = _vmTemplateDao.listAllCrossZoneTemplates();
for (VMTemplateVO vt : crossZoneTemplates) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.ConfigKey;
Expand Down Expand Up @@ -454,6 +455,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
@Inject
StorageManager _storageManager;
@Inject
TemplateService _templateService;
@Inject
ImageStoreDao _imageStoreDao;
@Inject
ImageStoreDetailsDao _imageStoreDetailsDao;
Expand Down Expand Up @@ -3157,6 +3160,12 @@ public DataCenterVO doInTransaction(final TransactionStatus status) {
// Create default system networks
createDefaultSystemNetworks(zone.getId());

// Associate cross zone templates with the Edge Zones here because they don't have SSVMs
// For Core zones, this happens when the SSVM starts up.
if (isEdge) {
_templateService.associateCrossZoneTemplatesToZone(zone.getId());
}

return zone;
}
});
Expand Down
16 changes: 7 additions & 9 deletions server/src/main/java/com/cloud/storage/StorageManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4232,7 +4232,6 @@ private void duplicateCacheStoreRecordsToRegionStore(long storeId) {
private void associateCrosszoneTemplatesToZone(Long zoneId) {
VMTemplateZoneVO tmpltZone;
Comment thread
vishesh92 marked this conversation as resolved.
Outdated
Comment thread
vishesh92 marked this conversation as resolved.
Outdated

List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
List<Long> dcIds = new ArrayList<>();
if (zoneId != null) {
dcIds.add(zoneId);
Expand All @@ -4245,14 +4244,13 @@ private void associateCrosszoneTemplatesToZone(Long zoneId) {
}
}

for (VMTemplateVO vt : allTemplates) {
if (vt.isCrossZones()) {
for (Long dcId : dcIds) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
List<VMTemplateVO> crossZoneTemplates = _vmTemplateDao.listAllCrossZoneTemplates();
for (VMTemplateVO vt : crossZoneTemplates) {
for (Long dcId : dcIds) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance)
}
_imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
// update template_zone_ref for cross-zone templates
_imageSrv.associateCrosszoneTemplatesToZone(agent.getDataCenterId());
_imageSrv.associateCrossZoneTemplatesToZone(agent.getDataCenterId());

}
/* This can be removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.messagebus.MessageBusBase;
Expand Down Expand Up @@ -223,6 +224,8 @@ public class ConfigurationManagerTest {
Ipv6GuestPrefixSubnetNetworkMapDao ipv6GuestPrefixSubnetNetworkMapDao;
@Mock
MessageBusBase messageBus;
@Mock
TemplateService _templateService;

VlanVO vlan = new VlanVO(Vlan.VlanType.VirtualNetwork, "vlantag", "vlangateway", "vlannetmask", 1L, "iprange", 1L, 1L, null, null, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,12 @@ public void postDiscovery(List<HostVO> hosts, long msId) {
private void associateTemplatesToZone(long hostId, long dcId) {
VMTemplateZoneVO tmpltZone;

List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
for (VMTemplateVO vt : allTemplates) {
if (vt.isCrossZones()) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
List<VMTemplateVO> crossZoneTemplates = _vmTemplateDao.listAllCrossZoneTemplates();
for (VMTemplateVO vt : crossZoneTemplates) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone);
}
}
}
Comment thread
vishesh92 marked this conversation as resolved.
Outdated
Expand Down
Loading