DaanHoogland commented on a change in pull request #3522: New API endpoint:
UpdateVlanIpRange
URL: https://github.com/apache/cloudstack/pull/3522#discussion_r310585195
##########
File path:
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
##########
@@ -3958,6 +3961,116 @@ public VlanVO doInTransaction(final TransactionStatus
status) {
}
+ @Override
+ public Vlan updateVlanAndPublicIpRange(UpdateVlanIpRangeCmd cmd) throws
ConcurrentOperationException,
+ ResourceUnavailableException, ResourceAllocationException{
+
+ return updateVlanAndPublicIpRange(cmd.getId(),
cmd.getStartIp(),cmd.getEndIp(),
+ cmd.getGateway(),cmd.getNetmask());
+ }
+
+ @DB
+ @ActionEvent(eventType = EventTypes.EVENT_VLAN_IP_RANGE_UPDATE,
eventDescription = "update vlan ip Range", async
+ = false)
+ public Vlan updateVlanAndPublicIpRange(final long id, String startIp,
+ String endIp,
+ String gateway,
+ String netmask) throws
ConcurrentOperationException{
+
+ // verify parameters
+ VlanVO vlanRange = _vlanDao.findById(id);
+ if (vlanRange == null) {
+ throw new InvalidParameterValueException("Please specify a valid
IP range id.");
+ }
+
+ if (gateway == null) {
+ gateway = vlanRange.getVlanGateway();
+ }
+
+ if (netmask == null) {
+ netmask = vlanRange.getVlanNetmask();
+ }
+
+ final String[] existingVlanIPRangeArray =
vlanRange.getIpRange().split("-");
+ final String currentStartIP= existingVlanIPRangeArray[0];
+ final String currentEndIP = existingVlanIPRangeArray [1];
+
+ if(startIp == null){
+ startIp= currentStartIP;
+ }
+
+ if(endIp == null){
+ endIp= currentEndIP;
+ }
+
+ // Check if the VLAN has any allocated public IPs
+ final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(id);
+ for (final IPAddressVO ip : ips) {
+ if (ip.getState()== IpAddress.State.Allocated){
Review comment:
very good below, but.. does it make sense to look for the first used from
the range for lower boundry and the highest for upper boundry, to facilitate
admins? Now and exception is thrown for the first mismatch and some usefull
information may be withheld from the user.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services