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 7e50f4a server: Fix delete network with no services (#4132) 7e50f4a is described below commit 7e50f4a01bf41f5868168b07f7caefee7305510c Author: Nicolas Vazquez <nicovazque...@gmail.com> AuthorDate: Sat Jun 20 02:15:05 2020 -0300 server: Fix delete network with no services (#4132) Fix delete shared network with no services on network offering Fixes: #4096 --- engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java b/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java index 5e22eb5..12d206e 100644 --- a/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java +++ b/engine/schema/src/main/java/com/cloud/vm/dao/UserVmDaoImpl.java @@ -29,6 +29,8 @@ import java.util.Set; import javax.annotation.PostConstruct; import javax.inject.Inject; +import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; +import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; import com.cloud.network.Network; @@ -82,6 +84,8 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use ResourceTagDao _tagsDao; @Inject NetworkDao networkDao; + @Inject + NetworkOfferingServiceMapDao networkOfferingServiceMapDao; private static final String LIST_PODS_HAVING_VMS_FOR_ACCOUNT = "SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND (state = 'Running' OR state = 'Stopped') " @@ -313,7 +317,10 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder(); nicSearch.and("networkId", nicSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); nicSearch.and("removed", nicSearch.entity().getRemoved(), SearchCriteria.Op.NULL); - if (!Network.GuestType.L2.equals(network.getGuestType())) { + + List<String> networkServices = networkOfferingServiceMapDao.listServicesForNetworkOffering(network.getNetworkOfferingId()); + + if (!Network.GuestType.L2.equals(network.getGuestType()) && CollectionUtils.isNotEmpty(networkServices)) { nicSearch.and().op("ip4Address", nicSearch.entity().getIPv4Address(), SearchCriteria.Op.NNULL); nicSearch.or("ip6Address", nicSearch.entity().getIPv6Address(), SearchCriteria.Op.NNULL); nicSearch.cp();