weizhouapache commented on a change in pull request #5977:
URL: https://github.com/apache/cloudstack/pull/5977#discussion_r812971911
##########
File path:
engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
##########
@@ -142,11 +192,63 @@ public boolean hostDisconnected(long hostId, long poolId)
{
@Override
public boolean hostAboutToBeRemoved(long hostId) {
+ // send host the cleanup persistent network resources
+ HostVO host = hostDao.findById(hostId);
+ if (host == null) {
+ s_logger.warn("Host with id " + hostId + " can't be found");
+ return false;
+ }
+
+ List<NetworkVO> allPersistentNetworks =
networkDao.getAllPersistentNetworksFromZone(host.getDataCenterId()); // find
zoneId of host
+ for (NetworkVO persistentNetworkVO : allPersistentNetworks) {
+ NetworkOfferingVO networkOfferingVO =
networkOfferingDao.findById(persistentNetworkVO.getNetworkOfferingId());
+ CleanupPersistentNetworkResourceCommand cleanupCmd =
+ new
CleanupPersistentNetworkResourceCommand(createNicTOFromNetworkAndOffering(persistentNetworkVO,
networkOfferingVO, host));
+ Answer answer = agentMgr.easySend(hostId, cleanupCmd);
+ if (answer == null) {
+ s_logger.error("Unable to get answer to the cleanup persistent
network command " + persistentNetworkVO.getId());
+ continue;
+ }
+ if (!answer.getResult()) {
+ String msg = String.format("Unable to cleanup persistent
network resources from network %d on the host %d", persistentNetworkVO.getId(),
hostId);
+ s_logger.error(msg);
+ }
+ }
return true;
}
@Override
public boolean hostRemoved(long hostId, long clusterId) {
return true;
}
+
+ @Override
+ public boolean hostEnabled(long hostId) {
+ HostVO host = hostDao.findById(hostId);
+ if (host == null) {
+ s_logger.warn(String.format("Host with id %d can't be found",
hostId));
+ return false;
+ }
+ setupPersistentNetwork(host);
+ return true;
+ }
+
+ private void setupPersistentNetwork(HostVO host) {
Review comment:
@Pearl1594
can you explain a bit what's the benifit of this feature ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]