You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLOUDSTACK-705 IP Address reservation for Isolated Guest Networks
CloudStack uses Guest CIDR for dhcp-range for the Guest VMs. The entire
CIDR is used by CloudStack for assigning IPs to Guest VMs. IP Address
Reservation will allow part of address space to be used fornon CloudStack
hosts/physical servers also, by restricting the address space of CloudStack
Guest VMs. Reservation can be configured using update Network API by specifying
guestvmCidr as an additional parameter. Reservation will be applicable for
Isolated Guest Networks including VPC. reservediprange in the response
will return the IP range that can be used for non Cloudstack hosts.
Tested manually the following scenarios:
Applying reservation when there are running VMs inside the
guest_vm_cidr.
Applying reservation when there are running VMs outside the
guest_vm_cidr.(not allowed)
Applying reservation when external device like Netscaler is configured
in the guest_cidr.
Applying reservation in VPC tiers.
Applying reservation outside the range of guest_cidr.(not allowed)
Copy file name to clipboardExpand all lines: api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,9 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
64
64
description="network offering ID")
65
65
privateLongnetworkOfferingId;
66
66
67
+
@Parameter(name=ApiConstants.GUEST_VM_CIDR, type=CommandType.STRING, description="CIDR for Guest VMs,Cloudstack allocates IPs to Guest VMs only from this CIDR")
@SerializedName(ApiConstants.CIDR) @Param(description="the cidr the network")
55
+
@SerializedName(ApiConstants.CIDR) @Param(description="Cloudstack managed address space, all CloudStack managed VMs get IP address from CIDR")
56
56
privateStringcidr;
57
57
58
+
@SerializedName(ApiConstants.NETWORK_CIDR) @Param(description="the network CIDR of the guest network configured with IP reservation. It is the summation of CIDR and RESERVED_IP_RANGE")
59
+
privateStringnetworkCidr;
60
+
61
+
@SerializedName(ApiConstants.RESERVED_IP_RANGE) @Param(description="the network's IP range not to be used by CloudStack guest VMs and can be used for non CloudStack purposes")
62
+
privateStringreservedIpRange;
63
+
58
64
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the network")
59
65
privateStringzoneId;
60
66
@@ -289,6 +295,14 @@ public void setCidr(String cidr) {
thrownewInvalidParameterValueException("Guest VM CIDR can't be specified for zone with " + NetworkType.Basic + " networking");
1627
+
}
1628
+
if (network.getGuestType() != GuestType.Isolated) {
1629
+
thrownewInvalidParameterValueException("Can only allow IP Reservation in networks with guest type " + GuestType.Isolated);
1630
+
}
1631
+
if (networkOfferingChanged == true) {
1632
+
thrownewInvalidParameterValueException("Cannot specify this nework offering change and guestVmCidr at same time. Specify only one.");
1633
+
}
1634
+
if (!(network.getState() == Network.State.Implemented)) {
1635
+
thrownewInvalidParameterValueException ("The network must be in " + Network.State.Implemented + " state. IP Reservation cannot be applied in " + network.getState() + " state");
1636
+
}
1637
+
if (!NetUtils.isValidCIDR(guestVmCidr)) {
1638
+
thrownewInvalidParameterValueException ("Invalid format of Guest VM CIDR.");
1639
+
}
1640
+
if (!NetUtils.validateGuestCidr(guestVmCidr)) {
1641
+
thrownewInvalidParameterValueException ("Invalid format of Guest VM CIDR. Make sure it is RFC1918 compliant. ");
1642
+
}
1643
+
1644
+
// If networkCidr is null it implies that there was no prior IP reservation, so the network cidr is network.getCidr()
1645
+
// But in case networkCidr is a non null value (IP reservation already exists), it implies network cidr is networkCidr
1646
+
if (networkCidr != null && ! NetUtils.isNetworkAWithinNetworkB(guestVmCidr, networkCidr)) {
1647
+
thrownewInvalidParameterValueException ("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + networkCidr);
1648
+
} else {
1649
+
if (! NetUtils.isNetworkAWithinNetworkB(guestVmCidr, network.getCidr())) {
1650
+
thrownewInvalidParameterValueException ("Invalid value of Guest VM CIDR. For IP Reservation, Guest VM CIDR should be a subset of network CIDR : " + network.getCidr());
1651
+
}
1652
+
}
1653
+
1654
+
// This check makes sure there are no active IPs existing outside the guestVmCidr in the network
s_logger.warn ("Existing IP reservation will become ineffective for the network with id = " + networkId + " You need to reapply reservation after network reimplementation.");
1716
+
//set cidr to the newtork cidr
1717
+
network.setCidr(network.getNetworkCidr());
1718
+
//set networkCidr to null to bring network back to no IP reservation state
1719
+
network.setNetworkCidr(null);
1720
+
}
1721
+
1638
1722
if (!_networkMgr.shutdownNetwork(network.getId(), context, true)) {
1639
1723
s_logger.warn("Failed to shutdown the network as a part of update to network with specified id");
1640
1724
CloudRuntimeExceptionex = newCloudRuntimeException("Failed to shutdown the network as a part of update of specified network id");
CloudRuntimeExceptionex = newCloudRuntimeException("Failed to implement the network elements and resources as a part of update to network with specified id; network is in wrong state: " + networkState);
0 commit comments