@Test public void testCanHandle() { final NetworkOffering offering = mock(NetworkOffering.class); when(offering.getId()).thenReturn(NETWORK_ID); when(offering.getTrafficType()).thenReturn(TrafficType.Guest); when(offering.getGuestType()).thenReturn(GuestType.Isolated); final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class); when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[]{"STT", "VXLAN"})); when(physnet.getId()).thenReturn(NETWORK_ID); when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true); assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true); when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[]{"VXLAN"})); assertTrue(guru.canHandle(offering, NetworkType.Advanced, physnet) == true); when(offering.getTrafficType()).thenReturn(TrafficType.Management); assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true); when(offering.getTrafficType()).thenReturn(TrafficType.Guest); when(offering.getGuestType()).thenReturn(GuestType.Shared); assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true); when(offering.getGuestType()).thenReturn(GuestType.Isolated); assertFalse(guru.canHandle(offering, NetworkType.Basic, physnet) == true); when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[]{"VLAN"})); assertFalse(guru.canHandle(offering, NetworkType.Advanced, physnet) == true); }
@Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { s_logger.debug("Checking of guru can handle request"); if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() != GuestType.Shared && isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.Connectivity)) { return true; } else { s_logger.debug("Cannot handle rquest. See GuestNetworkGuru message to check isolation methods. Details I have:\nNetwork type = " + networkType + "\nTraffic type = " + offering.getTrafficType() + "\nGuest type = " + offering.getGuestType()); return false; } }
NiciraNvpGuestNetworkGuru extends GuestNetworkGuru { @Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { s_logger.debug("Checking of guru can handle request"); if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() != GuestType.Shared && isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.Connectivity)) { return true; } else { s_logger.debug("Cannot handle rquest. See GuestNetworkGuru message to check isolation methods. Details I have:\nNetwork type = " + networkType + "\nTraffic type = " + offering.getTrafficType() + "\nGuest type = " + offering.getGuestType()); return false; } } }
NiciraNvpGuestNetworkGuru extends GuestNetworkGuru { @Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { s_logger.debug("Checking of guru can handle request"); if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() != GuestType.Shared && isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.Connectivity)) { return true; } else { s_logger.debug("Cannot handle rquest. See GuestNetworkGuru message to check isolation methods. Details I have:\nNetwork type = " + networkType + "\nTraffic type = " + offering.getTrafficType() + "\nGuest type = " + offering.getGuestType()); return false; } } NiciraNvpGuestNetworkGuru(); }
NiciraNvpGuestNetworkGuru extends GuestNetworkGuru { @Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { s_logger.debug("Checking of guru can handle request"); if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() != GuestType.Shared && isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.Connectivity)) { return true; } else { s_logger.debug("Cannot handle rquest. See GuestNetworkGuru message to check isolation methods. Details I have:\nNetwork type = " + networkType + "\nTraffic type = " + offering.getTrafficType() + "\nGuest type = " + offering.getGuestType()); return false; } } NiciraNvpGuestNetworkGuru(); @Override Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner); @Override Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context); @Override void reserve(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context); @Override boolean release(final NicProfile nic, final VirtualMachineProfile vm, final String reservationId); @Override void shutdown(final NetworkProfile profile, final NetworkOffering offering); @Override boolean trash(final Network network, final NetworkOffering offering); }
NiciraNvpGuestNetworkGuru extends GuestNetworkGuru { @Override protected boolean canHandle(final NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { s_logger.debug("Checking of guru can handle request"); if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() != GuestType.Shared && isMyIsolationMethod(physicalNetwork) && ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.Connectivity)) { return true; } else { s_logger.debug("Cannot handle rquest. See GuestNetworkGuru message to check isolation methods. Details I have:\nNetwork type = " + networkType + "\nTraffic type = " + offering.getTrafficType() + "\nGuest type = " + offering.getGuestType()); return false; } } NiciraNvpGuestNetworkGuru(); @Override Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner); @Override Network implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context); @Override void reserve(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context); @Override boolean release(final NicProfile nic, final VirtualMachineProfile vm, final String reservationId); @Override void shutdown(final NetworkProfile profile, final NetworkOffering offering); @Override boolean trash(final Network network, final NetworkOffering offering);  }