Skip to content

Commit cc27095

Browse files
ustcweizhouyadvr
authored andcommitted
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 8fb388e. * server: cleanup dns/dhcp entries in removeNic instead of finalizeExpunge
1 parent b853ebd commit cc27095

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,15 @@ public void cleanupNics(final VirtualMachineProfile vm) {
20142014

20152015
final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
20162016
for (final NicVO nic : nics) {
2017+
final NetworkVO network = _networksDao.findById(nic.getNetworkId());
2018+
if (network != null && network.getTrafficType() == TrafficType.Guest) {
2019+
final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
2020+
if (!Strings.isNullOrEmpty(nicIp)) {
2021+
NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
2022+
nicProfile.setId(nic.getId());
2023+
cleanupNicDhcpDnsEntry(network, vm, nicProfile);
2024+
}
2025+
}
20172026
removeNic(vm, nic);
20182027
}
20192028
}

server/src/main/java/com/cloud/network/element/VirtualRouterElement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,6 @@ public VirtualRouterProvider getCreatedElement(final long id) {
896896
@Override
897897
public boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context) throws ConcurrentOperationException,
898898
ResourceUnavailableException {
899-
removeDhcpEntry(network, nic, vm);
900899
return true;
901900
}
902901

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@
312312
import com.cloud.vm.snapshot.VMSnapshotManager;
313313
import com.cloud.vm.snapshot.VMSnapshotVO;
314314
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
315-
import com.google.common.base.Strings;
316315

317316
public class UserVmManagerImpl extends ManagerBase implements UserVmManager, VirtualMachineGuru, UserVmService, Configurable {
318317
private static final Logger s_logger = Logger.getLogger(UserVmManagerImpl.class);
@@ -4479,19 +4478,6 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
44794478

44804479
@Override
44814480
public void finalizeExpunge(VirtualMachine vm) {
4482-
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
4483-
final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
4484-
for (final NicVO nic : nics) {
4485-
final NetworkVO network = _networkDao.findById(nic.getNetworkId());
4486-
if (network != null && network.getTrafficType() == TrafficType.Guest) {
4487-
final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
4488-
if (!Strings.isNullOrEmpty(nicIp)) {
4489-
NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
4490-
nicProfile.setId(nic.getId());
4491-
_networkMgr.cleanupNicDhcpDnsEntry(network, profile, nicProfile);
4492-
}
4493-
}
4494-
}
44954481
}
44964482

44974483
@Override

0 commit comments

Comments
 (0)