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/12/24 18:12:59 UTC

[GitHub] rhtyd closed pull request #3100: ipv6: Send userdata to Virtual Router if IPv6 is enabled

rhtyd closed pull request #3100: ipv6: Send userdata to Virtual Router if IPv6 is enabled
URL: https://github.com/apache/cloudstack/pull/3100
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java b/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java
index 1a72877b97b..862ccfe69e6 100644
--- a/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/main/java/com/cloud/network/element/VirtualRouterElement.java
@@ -1022,11 +1022,6 @@ public boolean addPasswordAndUserdata(final Network network, final NicProfile ni
                 return false;
             }
 
-            if (network.getIp6Gateway() != null) {
-                s_logger.info("Skip password and userdata service setup for IPv6 VM");
-                return true;
-            }
-
             final VirtualMachineProfile uservm = vm;
 
             final List<DomainRouterVO> routers = getRouters(network, dest);
diff --git a/server/src/test/java/com/cloud/network/element/VirtualRouterElementTest.java b/server/src/test/java/com/cloud/network/element/VirtualRouterElementTest.java
index 4fbc28ee4cb..2d66ea70f6c 100644
--- a/server/src/test/java/com/cloud/network/element/VirtualRouterElementTest.java
+++ b/server/src/test/java/com/cloud/network/element/VirtualRouterElementTest.java
@@ -449,4 +449,60 @@ private void mockDAOs(final NetworkVO network, final NetworkOfferingVO offering)
         when(_routerDao.persist(any(DomainRouterVO.class))).thenReturn(router);
     }
 
+    @Test
+    public void testCanHandle() {
+        Network network = Mockito.mock(Network.class);
+
+        final long networkId = 1;
+        final long physicalNetworkId = 42;
+        final long networkOfferingId = 10;
+        final long dataCenterId = 33;
+
+        when(network.getId()).thenReturn(networkId);
+        when(network.getPhysicalNetworkId()).thenReturn(physicalNetworkId);
+        when(network.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(network.getNetworkOfferingId()).thenReturn(networkOfferingId);
+        when(network.getDataCenterId()).thenReturn(dataCenterId);
+        when(network.getVpcId()).thenReturn(null);
+
+        when(virtualRouterElement._networkMdl.getPhysicalNetworkId(network)).thenReturn(physicalNetworkId);
+        when(virtualRouterElement._networkMdl.isProviderEnabledInPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName())).thenReturn(true);
+        when(virtualRouterElement._networkMdl.isProviderForNetwork(Network.Provider.VirtualRouter, networkId)).thenReturn(true);
+
+        assertTrue(virtualRouterElement.canHandle(network, null));
+    }
+
+    @Test
+    public void testAddPasswordAndUserdata() throws Exception {
+        Network network = Mockito.mock(Network.class);
+        VirtualMachineProfile vm = Mockito.mock(VirtualMachineProfile.class);
+        NicProfile nic = Mockito.mock(NicProfile.class);
+        DeployDestination dest = Mockito.mock(DeployDestination.class);
+        ReservationContext context = Mockito.mock(ReservationContext.class);
+        Service service = Service.UserData;
+
+        final long networkId = 1;
+        final long physicalNetworkId = 42;
+        final long networkOfferingId = 10;
+        final long dataCenterId = 33;
+
+        when(network.getId()).thenReturn(networkId);
+        when(network.getPhysicalNetworkId()).thenReturn(physicalNetworkId);
+        when(network.getTrafficType()).thenReturn(TrafficType.Guest);
+        when(network.getNetworkOfferingId()).thenReturn(networkOfferingId);
+        when(network.getDataCenterId()).thenReturn(dataCenterId);
+        when(network.getVpcId()).thenReturn(null);
+
+        when(vm.getType()).thenReturn(VirtualMachine.Type.User);
+
+        when(virtualRouterElement._networkMdl.getPhysicalNetworkId(network)).thenReturn(physicalNetworkId);
+        when(virtualRouterElement._networkMdl.isProviderEnabledInPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName())).thenReturn(true);
+        when(virtualRouterElement._networkMdl.isProviderSupportServiceInNetwork(networkId, service, Network.Provider.VirtualRouter)).thenReturn(true);
+
+        when(virtualRouterElement._dcDao.findById(dataCenterId)).thenReturn(Mockito.mock(DataCenterVO.class));
+
+        when(virtualRouterElement.canHandle(network, service)).thenReturn(false);
+
+        assertTrue(virtualRouterElement.addPasswordAndUserdata(network, nic, vm, dest, context));
+    }
 }


 

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