Skip to content

Commit 666ec69

Browse files
Merge remote-tracking branch 'origin/4.13'
2 parents 899eab6 + b853ebd commit 666ec69

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import javax.inject.Inject;
4141
import javax.naming.ConfigurationException;
4242

43-
import com.cloud.storage.TemplateOVFPropertyVO;
44-
import com.cloud.storage.dao.TemplateOVFPropertiesDao;
4543
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
4644
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
4745
import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -101,7 +99,6 @@
10199
import org.apache.commons.lang3.StringUtils;
102100
import org.apache.log4j.Logger;
103101

104-
import com.cloud.hypervisor.kvm.dpdk.DpdkHelper;
105102
import com.cloud.agent.AgentManager;
106103
import com.cloud.agent.api.Answer;
107104
import com.cloud.agent.api.Command;
@@ -186,6 +183,7 @@
186183
import com.cloud.hypervisor.Hypervisor.HypervisorType;
187184
import com.cloud.hypervisor.HypervisorCapabilitiesVO;
188185
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
186+
import com.cloud.hypervisor.kvm.dpdk.DpdkHelper;
189187
import com.cloud.network.IpAddressManager;
190188
import com.cloud.network.Network;
191189
import com.cloud.network.Network.IpAddresses;
@@ -243,6 +241,7 @@
243241
import com.cloud.storage.Storage.TemplateType;
244242
import com.cloud.storage.StoragePool;
245243
import com.cloud.storage.StoragePoolStatus;
244+
import com.cloud.storage.TemplateOVFPropertyVO;
246245
import com.cloud.storage.VMTemplateStorageResourceAssoc;
247246
import com.cloud.storage.VMTemplateVO;
248247
import com.cloud.storage.VMTemplateZoneVO;
@@ -253,6 +252,7 @@
253252
import com.cloud.storage.dao.GuestOSCategoryDao;
254253
import com.cloud.storage.dao.GuestOSDao;
255254
import com.cloud.storage.dao.SnapshotDao;
255+
import com.cloud.storage.dao.TemplateOVFPropertiesDao;
256256
import com.cloud.storage.dao.VMTemplateDao;
257257
import com.cloud.storage.dao.VMTemplateZoneDao;
258258
import com.cloud.storage.dao.VolumeDao;
@@ -4479,6 +4479,19 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
44794479

44804480
@Override
44814481
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+
}
44824495
}
44834496

44844497
@Override
@@ -4542,12 +4555,6 @@ public void finalizeStop(VirtualMachineProfile profile, Answer answer) {
45424555
for (final NicVO nic : nics) {
45434556
final NetworkVO network = _networkDao.findById(nic.getNetworkId());
45444557
if (network != null && network.getTrafficType() == TrafficType.Guest) {
4545-
final String nicIp = Strings.isNullOrEmpty(nic.getIPv4Address()) ? nic.getIPv6Address() : nic.getIPv4Address();
4546-
if (!Strings.isNullOrEmpty(nicIp)) {
4547-
NicProfile nicProfile = new NicProfile(nic.getIPv4Address(), nic.getIPv6Address(), nic.getMacAddress());
4548-
nicProfile.setId(nic.getId());
4549-
_networkMgr.cleanupNicDhcpDnsEntry(network, profile, nicProfile);
4550-
}
45514558
if (nic.getBroadcastUri() != null && nic.getBroadcastUri().getScheme().equals("pvlan")) {
45524559
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic");
45534560
setupVmForPvlan(false, vm.getHostId(), nicProfile);

0 commit comments

Comments
 (0)