You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2019/10/17 19:51:15 UTC
[cloudstack] branch 4.13 updated: server: Do NOT cleanup dhcp and
dns when stop a vm (#3627)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.13
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.13 by this push:
new cc27095 server: Do NOT cleanup dhcp and dns when stop a vm (#3627)
cc27095 is described below
commit cc2709555472a8edcbc66737f78819824a9a869e
Author: Wei Zhou <w....@global.leaseweb.com>
AuthorDate: Thu Oct 17 21:50:55 2019 +0200
server: Do NOT cleanup dhcp and dns when stop a vm (#3627)
* server: Do NOT cleanup dhcp and dns when stop a vm
According comment in PR #3608, dhcp and dns entries are cleaned up only when a VM is expunged.
Revert part of commit 8fb388e9312b917a8f36c7d7e3f45985a95ce773.
* server: cleanup dns/dhcp entries in removeNic instead of finalizeExpunge
---
.../engine/orchestration/NetworkOrchestrator.java | 9 +++++++++
.../com/cloud/network/element/VirtualRouterElement.java | 1 -
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 14 --------------
3 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index 51b71d9..9e49148 100644
--- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -2014,6 +2014,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
for (final NicVO nic : nics) {
+ final NetworkVO network = _networksDao.findById(nic.getNetworkId());
+ if (network != null && network.getTrafficType() == TrafficType.Guest) {
+ final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
+ if (!Strings.isNullOrEmpty(nicIp)) {
+ NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
+ nicProfile.setId(nic.getId());
+ cleanupNicDhcpDnsEntry(network, vm, nicProfile);
+ }
+ }
removeNic(vm, nic);
}
}
diff --git a/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java b/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java
index aefa528..97a26d4 100644
--- a/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java
@@ -896,7 +896,6 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource, DnsServ
@Override
public boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
- removeDhcpEntry(network, nic, vm);
return true;
}
diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
index 2503b33..bb4246e 100644
--- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
@@ -312,7 +312,6 @@ import com.cloud.vm.dao.VMInstanceDao;
import com.cloud.vm.snapshot.VMSnapshotManager;
import com.cloud.vm.snapshot.VMSnapshotVO;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
-import com.google.common.base.Strings;
public class UserVmManagerImpl extends ManagerBase implements UserVmManager, VirtualMachineGuru, UserVmService, Configurable {
private static final Logger s_logger = Logger.getLogger(UserVmManagerImpl.class);
@@ -4479,19 +4478,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Override
public void finalizeExpunge(VirtualMachine vm) {
- final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
- final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
- for (final NicVO nic : nics) {
- final NetworkVO network = _networkDao.findById(nic.getNetworkId());
- if (network != null && network.getTrafficType() == TrafficType.Guest) {
- final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
- if (!Strings.isNullOrEmpty(nicIp)) {
- NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
- nicProfile.setId(nic.getId());
- _networkMgr.cleanupNicDhcpDnsEntry(network, profile, nicProfile);
- }
- }
- }
}
@Override