mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 14369: remove host entry when destroy CPVM/SSVM instances
status 14369: resolved fixed
This commit is contained in:
parent
4a9155df1b
commit
29c61e6341
@ -1332,7 +1332,18 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
public boolean destroyProxy(long vmId) {
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId);
|
||||
try {
|
||||
return _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
//expunge the vm
|
||||
boolean result = _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
if (result) {
|
||||
HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterIdToDeployIn(), proxy.getHostName(),
|
||||
Host.Type.ConsoleProxy);
|
||||
if (host != null) {
|
||||
s_logger.debug("Removing host entry for proxy id=" + vmId);
|
||||
result = result && _hostDao.remove(host.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + proxy, e);
|
||||
return false;
|
||||
|
||||
@ -68,5 +68,7 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
||||
|
||||
boolean updateResourceState(ResourceState oldState, ResourceState.Event event, ResourceState newState, Host vo);
|
||||
|
||||
HostVO findByGuid(String guid);
|
||||
HostVO findByGuid(String guid);
|
||||
|
||||
HostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
protected final SearchBuilder<HostVO> UnmanagedApplianceSearch;
|
||||
protected final SearchBuilder<HostVO> MaintenanceCountSearch;
|
||||
protected final SearchBuilder<HostVO> ClusterStatusSearch;
|
||||
protected final SearchBuilder<HostVO> ConsoleProxyHostSearch;
|
||||
protected final SearchBuilder<HostVO> TypeNameZoneSearch;
|
||||
protected final SearchBuilder<HostVO> AvailHypevisorInZone;
|
||||
|
||||
protected final SearchBuilder<HostVO> DirectConnectSearch;
|
||||
@ -187,10 +187,11 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
ClusterStatusSearch.and("status", ClusterStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
ClusterStatusSearch.done();
|
||||
|
||||
ConsoleProxyHostSearch = createSearchBuilder();
|
||||
ConsoleProxyHostSearch.and("name", ConsoleProxyHostSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
ConsoleProxyHostSearch.and("type", ConsoleProxyHostSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
ConsoleProxyHostSearch.done();
|
||||
TypeNameZoneSearch = createSearchBuilder();
|
||||
TypeNameZoneSearch.and("name", TypeNameZoneSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
TypeNameZoneSearch.and("type", TypeNameZoneSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
TypeNameZoneSearch.and("zoneId", TypeNameZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
TypeNameZoneSearch.done();
|
||||
|
||||
PodSearch = createSearchBuilder();
|
||||
PodSearch.and("pod", PodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
@ -705,5 +706,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO findByTypeNameAndZoneId(long zoneId, String name, Host.Type type) {
|
||||
SearchCriteria<HostVO> sc = TypeNameZoneSearch.create();
|
||||
sc.setParameters("type", type);
|
||||
sc.setParameters("name", name);
|
||||
sc.setParameters("zoneId", zoneId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -974,7 +974,17 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId);
|
||||
|
||||
try {
|
||||
return _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
boolean result = _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
if (result) {
|
||||
HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterIdToDeployIn(), ssvm.getHostName(),
|
||||
Host.Type.SecondaryStorageVM);
|
||||
if (host != null) {
|
||||
s_logger.debug("Removing host entry for ssvm id=" + vmId);
|
||||
result = result && _hostDao.remove(host.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + ssvm, e);
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user