cloudstack-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLOUDSTACK-9880) Expansion of Management IP Range.
Date Fri, 03 Nov 2017 15:14:01 GMT

    [ https://issues.apache.org/jira/browse/CLOUDSTACK-9880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16237724#comment-16237724
] 

ASF GitHub Bot commented on CLOUDSTACK-9880:
--------------------------------------------

rhtyd commented on a change in pull request #2048: CLOUDSTACK-9880: Expansion of Management
IP Range.
URL: https://github.com/apache/cloudstack/pull/2048#discussion_r148809473
 
 

 ##########
 File path: server/src/com/cloud/configuration/ConfigurationManagerImpl.java
 ##########
 @@ -1097,8 +1095,243 @@ public void doInTransactionWithoutResult(final TransactionStatus
status) {
     }
 
     @Override
+    @DB
+    public Pod createPodIpRange(final CreateManagementNetworkIpRangeCmd cmd) {
+
+        //Check if calling account is root admin.
+        final Account account = CallContext.current().getCallingAccount();
+
+        if(!_accountMgr.isRootAdmin(account.getId())) {
+            throw new PermissionDeniedException("Cannot perform this operation, Calling account
is not root admin: " + account.getId());
+        }
+
+        final long podId = cmd.getPodId();
+        final String gateway = cmd.getGateWay();
+        final String netmask = cmd.getNetmask();
+        final String startIp = cmd.getStartIp();
+        String endIp = cmd.getEndIp();
+
+        final HostPodVO pod = _podDao.findById(podId);
+
+        if(pod == null) {
+            throw new InvalidParameterValueException("Unable to find pod by ID: " + podId);
+        }
+
+        final long zoneId = pod.getDataCenterId();
+
+        //Check if gateway is a valid IP address.
+        if(!NetUtils.isValidIp(gateway)) {
+            throw new InvalidParameterValueException("The gateway IP address is invalid.");
+        }
+
+        //Check if netmask is valid.
+        if(!NetUtils.isValidNetmask(netmask)) {
+            throw new InvalidParameterValueException("The netmask IP address is invalid.");
+        }
+
+        if(endIp == null) {
+            endIp = startIp;
+        }
+
+        final String cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
+
+        if(!NetUtils.isValidCIDR(cidr)) {
+            throw new InvalidParameterValueException("The CIDR is invalid " + cidr);
+        }
+
+        final String cidrAddress = pod.getCidrAddress();
+        final long cidrSize = pod.getCidrSize();
+
+        // Because each pod has only one Gateway and Netmask.
+        if (!gateway.equals(pod.getGateway())) {
+            throw new InvalidParameterValueException("Multiple gateways for the POD: " +
pod.getId() + " are not allowed. The Gateway should be same as the existing Gateway " + pod.getGateway());
+        }
+
+        if (!netmask.equals(NetUtils.getCidrNetmask(cidrSize))) {
+            throw new InvalidParameterValueException("Multiple subnets for the POD: " + pod.getId()
+ " are not allowed. The Netmask should be same as the existing Netmask " + NetUtils.getCidrNetmask(cidrSize));
+        }
+
+        // Check if the IP range is valid.
+        checkIpRange(startIp, endIp, cidrAddress, cidrSize);
+
+        // Check if the IP range overlaps with the public ip.
+        checkOverlapPublicIpRange(zoneId, startIp, endIp);
+
+        // Check if the gateway is in the CIDR subnet
+        if (!NetUtils.getCidrSubNet(gateway, cidrSize).equalsIgnoreCase(NetUtils.getCidrSubNet(cidrAddress,
cidrSize))) {
+            throw new InvalidParameterValueException("The gateway is not in the CIDR subnet.");
+        }
+
+        if (NetUtils.ipRangesOverlap(startIp, endIp, gateway, gateway)) {
+            throw new InvalidParameterValueException("The gateway shouldn't overlap start/end
ip addresses");
+        }
+
+        final String[] existingPodIpRanges = pod.getDescription().split(",");
+
+        for(String podIpRange: existingPodIpRanges) {
+            final String[] existingPodIpRange = podIpRange.split("-");
+
+            if (existingPodIpRange.length > 1) {
+                if (!NetUtils.isValidIp(existingPodIpRange[0]) || !NetUtils.isValidIp(existingPodIpRange[1]))
{
+                    continue;
+                }
+                // Check if the range overlaps with any existing range.
+                if (NetUtils.ipRangesOverlap(startIp, endIp, existingPodIpRange[0], existingPodIpRange[1]))
{
+                    throw new InvalidParameterValueException("The new range overlaps with
existing range. Please add a mutually exclusive range.");
+                }
+            }
+        }
+
+        try {
 
 Review comment:
   Consider a `try-with-resource` syntax

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Expansion of Management IP Range.
> ---------------------------------
>
>                 Key: CLOUDSTACK-9880
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9880
>             Project: CloudStack
>          Issue Type: New Feature
>      Security Level: Public(Anyone can view this level - this is the default.) 
>          Components: API
>    Affects Versions: 4.10.0.0
>            Reporter: Nitin Kumar Maharana
>            Priority: Major
>             Fix For: 4.10.1.0
>
>
> At present, The management IP range can only be expanded under the same subnet. According
to existing range, either the last IP can be forward extended or the first IP can be backward
extended. But we cannot add an entirely different range from the same subnet. So the expansion
of range is subnet bound, which is fixed. But when the range gets exhausted and a user wants
to deploy more system VMs, then the operation would fail. The purpose of this feature is to
expand the range of management network IPs within the existing subnet. It can also delete
and list the IP ranges. 
> Please find the FS here : https://cwiki.apache.org/confluence/display/CLOUDSTACK/Expansion+of+Management+IP+Range



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message