DaanHoogland commented on a change in pull request #5769:
URL: https://github.com/apache/cloudstack/pull/5769#discussion_r778737706



##########
File path: server/src/main/java/com/cloud/network/NetworkServiceImpl.java
##########
@@ -4560,13 +4783,22 @@ public Network createPrivateNetwork(final String 
networkName, final String displ
 
         final String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
 
-        URI uri = BroadcastDomainType.fromString(broadcastUriString);
-        final String uriString = uri.toString();
-        BroadcastDomainType tiep = BroadcastDomainType.getSchemeValue(uri);
-        // numeric vlan or vlan uri are ok for now
-        // TODO make a test for any supported scheme
-        if (!(tiep == BroadcastDomainType.Vlan || tiep == 
BroadcastDomainType.Lswitch)) {
-            throw new InvalidParameterValueException("unsupported type of 
broadcastUri specified: " + broadcastUriString);
+        final String uriString;
+        if (broadcastUriString != null) {
+            URI uri = BroadcastDomainType.fromString(broadcastUriString);
+            uriString = uri.toString();
+            BroadcastDomainType tiep = BroadcastDomainType.getSchemeValue(uri);
+            // numeric vlan or vlan uri are ok for now
+            // TODO make a test for any supported scheme
+            if (!(tiep == BroadcastDomainType.Vlan || tiep == 
BroadcastDomainType.Lswitch)) {
+                throw new InvalidParameterValueException("unsupported type of 
broadcastUri specified: " + broadcastUriString);
+            }
+        } else if (associatedNetworkId != null) {
+            DataCenter zone = _dcDao.findById(pNtwk.getDataCenterId());
+            Network associatedNetwork = 
implementAssociatedNetwork(associatedNetworkId, caller, owner, zone, null, 
owner.getAccountId(), cidr, startIp, endIp);
+            uriString = associatedNetwork.getBroadcastUri().toString();
+        } else {
+            throw new InvalidParameterValueException("One of uri and 
associatedNetworkId must be passed");

Review comment:
       :+1: ok, not making a big point of this.




-- 
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