weizhouapache commented on a change in pull request #5769:
URL: https://github.com/apache/cloudstack/pull/5769#discussion_r778626479
##########
File path:
api/src/main/java/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java
##########
@@ -249,11 +260,31 @@ public Long getPhysicalNetworkId() {
throw new InvalidParameterValueException("Unable to find network
offering by ID " + networkOfferingId);
}
+ Network associatedNetwork = null;
+ if (associatedNetworkId != null) {
+ associatedNetwork = _entityMgr.findById(Network.class,
associatedNetworkId);
+ if (associatedNetwork == null) {
+ throw new InvalidParameterValueException("Unable to find
network by ID " + associatedNetworkId);
+ }
+ if (offering.getGuestType() != GuestType.Shared) {
+ throw new InvalidParameterValueException("Associated network
ID can be specified for networks of guest IP type " + GuestType.Shared + "
only.");
+ }
+ if (zoneId != null && associatedNetwork.getDataCenterId() !=
zoneId) {
+ throw new InvalidParameterValueException("The network can only
be created in the same zone as the associated network");
+ } else if (zoneId == null) {
+ zoneId = associatedNetwork.getDataCenterId();
+ }
+ if (physicalNetworkId != null &&
!physicalNetworkId.equals(associatedNetwork.getPhysicalNetworkId())) {
+ throw new InvalidParameterValueException("The network can only
be created on the same physical network as the associated network");
+ } else if (physicalNetworkId == null) {
+ physicalNetworkId = associatedNetwork.getPhysicalNetworkId();
+ }
+ }
Review comment:
@DaanHoogland these lines verify associatedNetworkId and set
zoneId/physicalNetworkId. I prefer not to extract to a method.
--
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]