Skip to content

Commit 7d84ead

Browse files
DaanHooglanddhslove
authored andcommitted
server: check startip and endip of shared network (apache#10704)
revert part of apache#10168
1 parent d28a680 commit 7d84ead

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,10 +1779,19 @@ public Network createGuestNetwork(CreateNetworkCmd cmd) throws InsufficientCapac
17791779
throwInvalidIdException("Network offering with specified id doesn't support adding multiple ip ranges", ntwkOff.getUuid(), NETWORK_OFFERING_ID);
17801780
}
17811781

1782-
if (GuestType.Shared == ntwkOff.getGuestType() && !ntwkOff.isSpecifyVlan() && Objects.isNull(associatedNetworkId)) {
1783-
throw new CloudRuntimeException("Associated network must be provided when creating Shared networks when specifyVlan is false");
1784-
}
17851782

1783+
1784+
if (GuestType.Shared == ntwkOff.getGuestType()) {
1785+
if (!ntwkOff.isSpecifyIpRanges()) {
1786+
throw new CloudRuntimeException("The 'specifyipranges' parameter should be true for Shared Networks");
1787+
}
1788+
if (ipv4 && Objects.isNull(startIP)) {
1789+
throw new CloudRuntimeException("IPv4 address range needs to be provided");
1790+
}
1791+
if (ipv6 && Objects.isNull(startIPv6)) {
1792+
throw new CloudRuntimeException("IPv6 address range needs to be provided");
1793+
}
1794+
}
17861795
Pair<Integer, Integer> interfaceMTUs = validateMtuConfig(publicMtu, privateMtu, zone.getId());
17871796
mtuCheckForVpcNetwork(vpcId, interfaceMTUs, publicMtu);
17881797

0 commit comments

Comments
 (0)