DaanHoogland commented on code in PR #6781:
URL: https://github.com/apache/cloudstack/pull/6781#discussion_r996962042


##########
server/src/main/java/com/cloud/network/NetworkServiceImpl.java:
##########
@@ -4617,36 +4635,30 @@ public PhysicalNetworkServiceProvider 
getCreatedPhysicalNetworkServiceProvider(L
 
     @Override
     public long findPhysicalNetworkId(long zoneId, String tag, TrafficType 
trafficType) {
-        List<PhysicalNetworkVO> pNtwks = new ArrayList<PhysicalNetworkVO>();
-        if (trafficType != null) {
-            pNtwks = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, 
trafficType);
-        } else {
-            pNtwks = _physicalNetworkDao.listByZone(zoneId);
-        }
-
-        if (pNtwks.isEmpty()) {
-            throw new InvalidParameterValueException("Unable to find physical 
network in zone id=" + zoneId);
-        }
+        return _networkModel.findPhysicalNetworkId(zoneId, tag, trafficType);
+    }
 
-        if (pNtwks.size() > 1) {
-            if (tag == null) {
-                throw new InvalidParameterValueException("More than one 
physical networks exist in zone id=" + zoneId + " and no tags are specified in 
order to make a choice");
-            }
+    /**
+     * Function to check if there are any physical networks with traffic type 
of "trafficType"
+     * and check their tags. If there is more than one network with null tags 
then throw exception
+     * @param physicalNetwork
+     * @param trafficType
+     */
+    private void checkForPhysicalNetworksWithoutTag(PhysicalNetworkVO 
physicalNetwork, TrafficType trafficType) {
+        int networkWithoutTagCount = 0;
+        List<PhysicalNetworkVO> physicalNetworkVOList = _physicalNetworkDao
+                .listByZoneAndTrafficType(physicalNetwork.getDataCenterId(), 
trafficType);
 
-            Long pNtwkId = null;
-            for (PhysicalNetwork pNtwk : pNtwks) {
-                if (pNtwk.getTags().contains(tag)) {
-                    s_logger.debug("Found physical network id=" + 
pNtwk.getId() + " based on requested tags " + tag);
-                    pNtwkId = pNtwk.getId();
-                    break;
-                }
+        for (PhysicalNetworkVO physicalNetworkVO : physicalNetworkVOList) {
+            List<String> tags = physicalNetworkVO.getTags();
+            if (tags == null || tags.size() == 0){

Review Comment:
   ```suggestion
               CollectionUtils.isEmpty(tags) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to