nvazquez commented on code in PR #8465:
URL: https://github.com/apache/cloudstack/pull/8465#discussion_r1445148090


##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -4564,16 +4564,24 @@ public NicVO savePlaceholderNic(final Network network, 
final String ip4Address,
 
     @DB
     @Override
-    public Pair<NicProfile, Integer> importNic(final String macAddress, int 
deviceId, final Network network, final Boolean isDefaultNic, final 
VirtualMachine vm, final Network.IpAddresses ipAddresses, final boolean forced)
+    public Pair<NicProfile, Integer> importNic(final String macAddress, int 
deviceId, final Network network, final Boolean isDefaultNic, final 
VirtualMachine vm, final Network.IpAddresses ipAddresses, final DataCenter 
dataCenter, final boolean forced)
             throws ConcurrentOperationException, 
InsufficientVirtualNetworkCapacityException, 
InsufficientAddressCapacityException {
         s_logger.debug("Allocating nic for vm " + vm.getUuid() + " in network 
" + network + " during import");
         String guestIp = null;
+        IPAddressVO freeIpAddress = null;
         if (ipAddresses != null && 
StringUtils.isNotEmpty(ipAddresses.getIp4Address())) {
             if (ipAddresses.getIp4Address().equals("auto")) {
                 ipAddresses.setIp4Address(null);
             }
             if (network.getGuestType() != GuestType.L2) {
-                guestIp = _ipAddrMgr.acquireGuestIpAddress(network, 
ipAddresses.getIp4Address());
+                if (dataCenter.getNetworkType() == NetworkType.Advanced) {
+                    guestIp = _ipAddrMgr.acquireGuestIpAddress(network, 
ipAddresses.getIp4Address());
+                } else {
+                    freeIpAddress = 
_ipAddressDao.findBySourceNetworkIdAndDatacenterIdAndState(network.getId(), 
dataCenter.getId(), IpAddress.State.Free);
+                    if (freeIpAddress != null && freeIpAddress.getAddress() != 
null) {
+                        guestIp = freeIpAddress.getAddress().addr();
+                    }
+                }

Review Comment:
   Done, thanks



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to