From ea893eaf338bfe914e1cb99517a8429128a64152 Mon Sep 17 00:00:00 2001 From: Saksham Srivastava Date: Fri, 22 Mar 2013 16:37:44 +0530 Subject: [PATCH] CLOUDSTACK-1786: While reserving IPs in guest network, if guestvmcidr is a subset of network cidr but not a subset of cidr, exception is thrown. Signed-off-by: Sateesh Chodapuneedi --- server/src/com/cloud/network/NetworkServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java index c4effc96271..878d2a82bc6 100755 --- a/server/src/com/cloud/network/NetworkServiceImpl.java +++ b/server/src/com/cloud/network/NetworkServiceImpl.java @@ -1868,11 +1868,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService { // If networkCidr is null it implies that there was no prior IP reservation, so the network cidr is network.getCidr() // But in case networkCidr is a non null value (IP reservation already exists), it implies network cidr is networkCidr - if (networkCidr != null && ! NetUtils.isNetworkAWithinNetworkB(guestVmCidr, networkCidr)) { + if (networkCidr != null) { + if(! NetUtils.isNetworkAWithinNetworkB(guestVmCidr, networkCidr)) { throw new InvalidParameterValueException ("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + networkCidr); + } } else { if (! NetUtils.isNetworkAWithinNetworkB(guestVmCidr, network.getCidr())) { - throw new InvalidParameterValueException ("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + network.getCidr()); + throw new InvalidParameterValueException ("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + network.getCidr()); } }