You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/05/03 13:59:21 UTC

[GitHub] DaanHoogland commented on a change in pull request #2595: CLOUDSTACK-10199: Support requesting a specific IPv4 address

DaanHoogland commented on a change in pull request #2595: CLOUDSTACK-10199: Support requesting a specific IPv4 address
URL: https://github.com/apache/cloudstack/pull/2595#discussion_r185807052
 
 

 ##########
 File path: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
 ##########
 @@ -883,6 +885,78 @@ public void saveExtraDhcpOptions(final String networkUuid, final Long nicId, fin
         return new Pair<NicProfile, Integer>(vmNic, Integer.valueOf(deviceId));
     }
 
+    /**
+     * If the requested IPv4 address from the NicProfile was configured then it configures the IPv4 address, Netmask and Gateway to deploy the VM with the requested IP.
+     */
+    protected void configureNicProfileBasedOnRequestedIp(NicProfile requestedNicProfile, NicProfile nicProfile, Network network) {
+        if (requestedNicProfile == null) {
+            return;
+        }
+        String requestedIpv4Address = requestedNicProfile.getRequestedIPv4();
+        if (requestedIpv4Address == null) {
+            return;
+        }
+        if (!NetUtils.isValidIp4(requestedIpv4Address)) {
+            throw new InvalidParameterValueException(String.format("The requested [IPv4 address='%s'] is not a valid IP address", requestedIpv4Address));
+        }
+
+        VlanVO vlanVo = _vlanDao.findByNetworkIdAndIpv4Range(network.getId(), requestedIpv4Address);
 
 Review comment:
   convention says to leave out the vlan (we are already in the vlandao. so findByNetworkIdAndIpv4Range actually makes sense.

----------------------------------------------------------------
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


With regards,
Apache Git Services