mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 5730: update dns of systemVms during zone update
This commit is contained in:
parent
acb23b6158
commit
fb99f95d7c
@ -215,8 +215,9 @@
|
||||
<dao name="IP Addresses configuration server" class="com.cloud.network.dao.IPAddressDaoImpl"/>
|
||||
<dao name="Datacenter IP Addresses configuration server" class="com.cloud.dc.dao.DataCenterIpAddressDaoImpl"/>
|
||||
<dao name="domain router" class="com.cloud.vm.dao.DomainRouterDaoImpl"/>
|
||||
<dao name="host zone configuration server" class="com.cloud.dc.dao.DataCenterDaoImpl">
|
||||
</dao>
|
||||
<dao name="host zone configuration server" class="com.cloud.dc.dao.DataCenterDaoImpl"/>
|
||||
<dao name="Console Proxy" class="com.cloud.vm.dao.ConsoleProxyDaoImpl"/>
|
||||
<dao name="Secondary Storage VM" class="com.cloud.vm.dao.SecondaryStorageVmDaoImpl"/>
|
||||
<dao name="host pod configuration server" class="com.cloud.dc.dao.HostPodDaoImpl">
|
||||
</dao>
|
||||
<dao name="PodVlanMap configuration server" class="com.cloud.dc.dao.PodVlanMapDaoImpl"/>
|
||||
|
||||
@ -80,4 +80,5 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long> {
|
||||
List<VMInstanceVO> listByHostIdTypes(long hostid, VirtualMachine.Type... types);
|
||||
|
||||
List<VMInstanceVO> listUpByHostIdTypes(long hostid, VirtualMachine.Type... types);
|
||||
List<VMInstanceVO> listByZoneIdAndType(long zoneId, VirtualMachine.Type type);
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
protected final SearchBuilder<VMInstanceVO> HostSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> LastHostSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> ZoneSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> ZoneVmTypeSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> ZoneTemplateNonExpungedSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> NameLikeSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> StateChangeSearch;
|
||||
@ -79,6 +80,11 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
ZoneSearch = createSearchBuilder();
|
||||
ZoneSearch.and("zone", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
ZoneSearch.done();
|
||||
|
||||
ZoneVmTypeSearch = createSearchBuilder();
|
||||
ZoneVmTypeSearch.and("zone", ZoneVmTypeSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
ZoneVmTypeSearch.and("type", ZoneVmTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
ZoneVmTypeSearch.done();
|
||||
|
||||
ZoneTemplateNonExpungedSearch = createSearchBuilder();
|
||||
ZoneTemplateNonExpungedSearch.and("zone", ZoneTemplateNonExpungedSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
@ -193,6 +199,15 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listByZoneIdAndType(long zoneId, VirtualMachine.Type type) {
|
||||
SearchCriteria<VMInstanceVO> sc = ZoneVmTypeSearch.create();
|
||||
sc.setParameters("zone", zoneId);
|
||||
sc.setParameters("type", type.toString());
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listNonExpungedByZoneAndTemplate(long zoneId, long templateId) {
|
||||
SearchCriteria<VMInstanceVO> sc = ZoneTemplateNonExpungedSearch.create();
|
||||
|
||||
@ -57,6 +57,7 @@ import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.SecondaryStorage;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.UserVO;
|
||||
@ -66,9 +67,14 @@ import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.ConsoleProxyVO;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
@Local(value={ConfigurationManager.class})
|
||||
@ -91,6 +97,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
@Inject AccountDao _accountDao;
|
||||
@Inject EventDao _eventDao;
|
||||
@Inject UserDao _userDao;
|
||||
@Inject ConsoleProxyDao _consoleDao;
|
||||
@Inject SecondaryStorageVmDao _secStorageDao;
|
||||
public boolean _premium;
|
||||
|
||||
@Override
|
||||
@ -665,13 +673,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
throw new InvalidParameterValueException("A zone with ID: " + zoneId + " does not exist.");
|
||||
}
|
||||
|
||||
// If DNS values are being changed, make sure there are no VMs in this zone
|
||||
if (dns1 != null || dns2 != null || internalDns1 != null || internalDns2 != null) {
|
||||
if (zoneHasVMs(zoneId)) {
|
||||
throw new InternalErrorException("The zone is not editable because there are VMs in the zone.");
|
||||
}
|
||||
}
|
||||
|
||||
// If the Vnet range is being changed, make sure there are no allocated VNets
|
||||
if (vnetRange != null) {
|
||||
if (zoneHasAllocatedVnets(zoneId)) {
|
||||
@ -679,22 +680,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
//To modify a zone, we need to make sure there are no domr's associated with it
|
||||
//1. List all the domain router objs
|
||||
//2. Check if any of these has the current data center associated
|
||||
//3. If yes, throw exception
|
||||
//4, If no, edit
|
||||
List<DomainRouterVO> allDomainRoutersAvailable = _domrDao.listAll();
|
||||
|
||||
for(DomainRouterVO domR : allDomainRoutersAvailable)
|
||||
{
|
||||
if(domR.getDataCenterId() == zoneId)
|
||||
{
|
||||
throw new InternalErrorException("The zone is not editable because there are domR's associated with the zone.");
|
||||
}
|
||||
}
|
||||
|
||||
//5. Reached here, hence editable
|
||||
|
||||
DataCenterVO zone = _zoneDao.findById(zoneId);
|
||||
String oldZoneName = zone.getName();
|
||||
@ -703,6 +688,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
newZoneName = oldZoneName;
|
||||
}
|
||||
|
||||
boolean dnsUpdate = false;
|
||||
|
||||
if(dns1 != null || dns2 != null){
|
||||
dnsUpdate = true;
|
||||
}
|
||||
|
||||
if (dns1 == null) {
|
||||
dns1 = zone.getDns1();
|
||||
}
|
||||
@ -742,6 +733,48 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
|
||||
_zoneDao.addVnet(zone.getId(), begin, end);
|
||||
}
|
||||
|
||||
if(dnsUpdate){
|
||||
|
||||
//Update dns for domRs in zone
|
||||
|
||||
List<DomainRouterVO> DomainRouters = _domrDao.listByDataCenter(zoneId);
|
||||
|
||||
for(DomainRouterVO domR : DomainRouters)
|
||||
{
|
||||
domR.setDns1(dns1);
|
||||
domR.setDns2(dns2);
|
||||
_domrDao.update(domR.getId(), domR);
|
||||
}
|
||||
|
||||
//Update dns for console proxies in zone
|
||||
List<VMInstanceVO> ConsoleProxies = _vmInstanceDao.listByZoneIdAndType(zoneId, VirtualMachine.Type.ConsoleProxy);
|
||||
|
||||
for(VMInstanceVO consoleVm : ConsoleProxies)
|
||||
{
|
||||
ConsoleProxyVO proxy = _consoleDao.findById(consoleVm.getId());
|
||||
if( proxy!= null ){
|
||||
proxy.setDns1(dns1);
|
||||
proxy.setDns2(dns2);
|
||||
_consoleDao.update(proxy.getId(), proxy);
|
||||
}
|
||||
}
|
||||
|
||||
//Update dns for secondary storage Vms in zone
|
||||
List<VMInstanceVO> storageVms = _vmInstanceDao.listByZoneIdAndType(zoneId, VirtualMachine.Type.SecondaryStorageVm);
|
||||
|
||||
for(VMInstanceVO storageVm : storageVms)
|
||||
{
|
||||
SecondaryStorageVmVO secStorageVm = _secStorageDao.findById(storageVm.getId());
|
||||
if( secStorageVm!= null ){
|
||||
secStorageVm.setDns1(dns1);
|
||||
secStorageVm.setDns2(dns2);
|
||||
_secStorageDao.update(secStorageVm.getId(), secStorageVm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_ZONE_EDIT, "Successfully edited zone with name: " + zone.getName() + ".", "dcId=" + zone.getId(), "dns1=" + dns1, "dns2=" + dns2, "internalDns1=" + internalDns1, "internalDns2=" + internalDns2, "vnetRange=" + vnetRange, "guestCidr=" + guestCidr);
|
||||
|
||||
return zone;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user