CLOUDSTACK-7859: Host tags are not getting removed in cloud.host_tags table when a Host is deleted from CS.

This commit is contained in:
Sanjay Tripathi 2014-11-07 16:55:50 +05:30
parent 7c5bc4ae7e
commit 330bd2748e
3 changed files with 17 additions and 2 deletions

View File

@ -29,4 +29,6 @@ public interface HostTagsDao extends GenericDao<HostTagVO, Long> {
List<String> getDistinctImplicitHostTags(List<Long> hostIds, String[] implicitHostTags);
void deleteTags(long hostId);
}

View File

@ -71,6 +71,16 @@ public class HostTagsDaoImpl extends GenericDaoBase<HostTagVO, Long> implements
return customSearch(sc, null);
}
@Override
public void deleteTags(long hostId) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SearchCriteria<HostTagVO> sc = HostSearch.create();
sc.setParameters("hostId", hostId);
expunge(sc);
txn.commit();
}
@Override
public void persist(long hostId, List<String> hostTags) {
TransactionLegacy txn = TransactionLegacy.currentTxn();

View File

@ -850,6 +850,9 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
// if host is GPU enabled, delete GPU entries
_hostGpuGroupsDao.deleteGpuEntries(hostId);
// delete host tags
_hostTagsDao.deleteTags(hostId);
host.setGuid(null);
Long clusterId = host.getClusterId();
host.setClusterId(null);