@@ -2014,15 +2014,6 @@ 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- }
20262017 removeNic (vm , nic );
20272018 }
20282019 }
@@ -2044,9 +2035,18 @@ protected void removeNic(final VirtualMachineProfile vm, final NicVO nic) {
20442035 }
20452036 }
20462037
2038+ final NetworkVO network = _networksDao .findById (nic .getNetworkId ());
2039+ if (network != null && network .getTrafficType () == TrafficType .Guest ) {
2040+ final String nicIp = Strings .isNullOrEmpty (nic .getIPv4Address ()) ? nic .getIPv6Address () : nic .getIPv4Address ();
2041+ if (!Strings .isNullOrEmpty (nicIp )) {
2042+ NicProfile nicProfile = new NicProfile (nic .getIPv4Address (), nic .getIPv6Address (), nic .getMacAddress ());
2043+ nicProfile .setId (nic .getId ());
2044+ cleanupNicDhcpDnsEntry (network , vm , nicProfile );
2045+ }
2046+ }
2047+
20472048 nic .setState (Nic .State .Deallocating );
20482049 _nicDao .update (nic .getId (), nic );
2049- final NetworkVO network = _networksDao .findById (nic .getNetworkId ());
20502050 final NicProfile profile = new NicProfile (nic , network , null , null , null , _networkModel .isSecurityGroupSupportedInNetwork (network ), _networkModel .getNetworkTag (
20512051 vm .getHypervisorType (), network ));
20522052
0 commit comments