diff --git a/engine/schema/src/com/cloud/host/dao/HostTagsDao.java b/engine/schema/src/com/cloud/host/dao/HostTagsDao.java index 8901716ddfd..c811de93e76 100644 --- a/engine/schema/src/com/cloud/host/dao/HostTagsDao.java +++ b/engine/schema/src/com/cloud/host/dao/HostTagsDao.java @@ -29,4 +29,6 @@ public interface HostTagsDao extends GenericDao { List getDistinctImplicitHostTags(List hostIds, String[] implicitHostTags); + void deleteTags(long hostId); + } diff --git a/engine/schema/src/com/cloud/host/dao/HostTagsDaoImpl.java b/engine/schema/src/com/cloud/host/dao/HostTagsDaoImpl.java index 7e8615a26ad..e275e04cc29 100644 --- a/engine/schema/src/com/cloud/host/dao/HostTagsDaoImpl.java +++ b/engine/schema/src/com/cloud/host/dao/HostTagsDaoImpl.java @@ -71,6 +71,16 @@ public class HostTagsDaoImpl extends GenericDaoBase implements return customSearch(sc, null); } + @Override + public void deleteTags(long hostId) { + TransactionLegacy txn = TransactionLegacy.currentTxn(); + txn.start(); + SearchCriteria sc = HostSearch.create(); + sc.setParameters("hostId", hostId); + expunge(sc); + txn.commit(); + } + @Override public void persist(long hostId, List hostTags) { TransactionLegacy txn = TransactionLegacy.currentTxn(); diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 588778313d7..5cc2d3613a0 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -847,8 +847,11 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, // delete host details _hostDetailsDao.deleteDetails(hostId); - // if host is GPU enabled, delete GPU entries - _hostGpuGroupsDao.deleteGpuEntries(hostId); + // if host is GPU enabled, delete GPU entries + _hostGpuGroupsDao.deleteGpuEntries(hostId); + + // delete host tags + _hostTagsDao.deleteTags(hostId); host.setGuid(null); Long clusterId = host.getClusterId();