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 2020/07/29 07:54:51 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3902: vrouter: Save PlaceHolder nic for VR if network does not have source nat

DaanHoogland commented on a change in pull request #3902:
URL: https://github.com/apache/cloudstack/pull/3902#discussion_r461593221



##########
File path: server/src/main/java/com/cloud/network/guru/ExternalGuestNetworkGuru.java
##########
@@ -261,6 +265,17 @@ public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile
             profile.setIPv4Netmask(null);
         }
 
+        if (config.getVpcId() == null && vm.getType() == VirtualMachine.Type.DomainRouter) {
+            boolean isPublicNetwork = _networkModel.isProviderSupportServiceInNetwork(config.getId(), Service.SourceNat, Provider.VirtualRouter);
+            if (!isPublicNetwork) {
+                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(config, null);
+                if (placeholderNic == null) {
+                    s_logger.debug("Saving placeholder nic with ip4 address " + profile.getIPv4Address() +
+                            " and ipv6 address " + profile.getIPv6Address() + " for the network " + config);
+                    _networkMgr.savePlaceholderNic(config, profile.getIPv4Address(), profile.getIPv6Address(), VirtualMachine.Type.DomainRouter);
+                }
+            }
+        }

Review comment:
       `allocateRegularVrNic(...)`

##########
File path: server/src/main/java/com/cloud/network/guru/GuestNetworkGuru.java
##########
@@ -372,15 +373,25 @@ public NicProfile allocate(final Network network, NicProfile nic, final VirtualM
 
                 if (isGateway) {
                     guestIp = network.getGateway();
-                } else if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
-                    guestIp = _ipAddrMgr.acquireGuestIpAddressByPlacement(network, nic.getRequestedIPv4());
                 } else {
-                    guestIp = _ipAddrMgr.acquireGuestIpAddress(network, nic.getRequestedIPv4());
-                }
-
-                if (!isGateway && guestIp == null && network.getGuestType() != GuestType.L2 && !_networkModel.listNetworkOfferingServices(network.getNetworkOfferingId()).isEmpty()) {
-                    throw new InsufficientVirtualNetworkCapacityException("Unable to acquire Guest IP" + " address for network " + network, DataCenter.class,
-                            dc.getId());
+                    if (network.getGuestType() != GuestType.L2 && vm.getType() == VirtualMachine.Type.DomainRouter) {
+                        Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
+                        if (placeholderNic != null) {
+                            s_logger.debug("Nic got an ip address " + placeholderNic.getIPv4Address() + " stored in placeholder nic for the network " + network);
+                            guestIp = placeholderNic.getIPv4Address();
+                        }
+                    }
+                    if (guestIp == null) {
+                        if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
+                            guestIp = _ipAddrMgr.acquireGuestIpAddressByPlacement(network, nic.getRequestedIPv4());
+                        } else {
+                            guestIp = _ipAddrMgr.acquireGuestIpAddress(network, nic.getRequestedIPv4());
+                        }
+                    }
+                    if (guestIp == null && network.getGuestType() != GuestType.L2 && !_networkModel.listNetworkOfferingServices(network.getNetworkOfferingId()).isEmpty()) {
+                        throw new InsufficientVirtualNetworkCapacityException("Unable to acquire Guest IP" + " address for network " + network, DataCenter.class,
+                                dc.getId());
+                    }

Review comment:
       `allocateRegularVrNic(...)`




----------------------------------------------------------------
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:
users@infra.apache.org