@Test public void canHandleTest() { final Network net = mock(Network.class); when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch); when(net.getId()).thenReturn(NETWORK_ID); when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true); assertTrue(element.canHandle(net, Service.Connectivity)); when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vlan); assertFalse(element.canHandle(net, Service.Connectivity)); when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch); when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(false); assertFalse(element.canHandle(net, Service.Connectivity)); when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(false); when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true); assertFalse(element.canHandle(net, Service.Connectivity)); when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(true); assertFalse(element.canHandle(net, Service.Dhcp)); }
protected boolean canHandle(final Network network, final Network.Service service) { s_logger.debug("Checking if NiciraNvpElement can handle service " + service.getName() + " on network " + network.getDisplayText()); if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) { return false; } if (!this.networkModel.isProviderForNetwork(getProvider(), network.getId())) { s_logger.debug("NiciraNvpElement is not a provider for network " + network.getDisplayText()); return false; } if (!this.ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.NiciraNvp)) { s_logger.debug("NiciraNvpElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); return false; } return true; }
NiciraNvpElement extends AdapterBase implements ConnectivityProvider, SourceNatServiceProvider, PortForwardingServiceProvider, StaticNatServiceProvider,
        NiciraNvpElementService, ResourceStateAdapter, IpDeployer { protected boolean canHandle(final Network network, final Network.Service service) { s_logger.debug("Checking if NiciraNvpElement can handle service " + service.getName() + " on network " + network.getDisplayText()); if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) { return false; } if (!this.networkModel.isProviderForNetwork(getProvider(), network.getId())) { s_logger.debug("NiciraNvpElement is not a provider for network " + network.getDisplayText()); return false; } if (!this.ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.NiciraNvp)) { s_logger.debug("NiciraNvpElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); return false; } return true; } }
NiciraNvpElement extends AdapterBase implements ConnectivityProvider, SourceNatServiceProvider, PortForwardingServiceProvider, StaticNatServiceProvider,
        NiciraNvpElementService, ResourceStateAdapter, IpDeployer { protected boolean canHandle(final Network network, final Network.Service service) { s_logger.debug("Checking if NiciraNvpElement can handle service " + service.getName() + " on network " + network.getDisplayText()); if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) { return false; } if (!this.networkModel.isProviderForNetwork(getProvider(), network.getId())) { s_logger.debug("NiciraNvpElement is not a provider for network " + network.getDisplayText()); return false; } if (!this.ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.NiciraNvp)) { s_logger.debug("NiciraNvpElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); return false; } return true; }  }
NiciraNvpElement extends AdapterBase implements ConnectivityProvider, SourceNatServiceProvider, PortForwardingServiceProvider, StaticNatServiceProvider,
        NiciraNvpElementService, ResourceStateAdapter, IpDeployer { protected boolean canHandle(final Network network, final Network.Service service) { s_logger.debug("Checking if NiciraNvpElement can handle service " + service.getName() + " on network " + network.getDisplayText()); if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) { return false; } if (!this.networkModel.isProviderForNetwork(getProvider(), network.getId())) { s_logger.debug("NiciraNvpElement is not a provider for network " + network.getDisplayText()); return false; } if (!this.ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.NiciraNvp)) { s_logger.debug("NiciraNvpElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); return false; } return true; }  @Override Map<Network.Service, Map<Network.Capability, String>> getCapabilities(); @Override Network.Provider getProvider(); @Override boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context); @Override boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context); @Override boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context); @Override boolean shutdown(final Network network, final ReservationContext context, final boolean cleanup); @Override boolean destroy(final Network network, final ReservationContext context); @Override boolean isReady(final PhysicalNetworkServiceProvider provider); @Override boolean shutdownProviderInstances(final PhysicalNetworkServiceProvider provider, final ReservationContext context); @Override boolean canEnableIndividualServices(); @Override boolean verifyServicesCombination(final Set<Network.Service> services); @Override boolean configure(final String name, final Map<String, Object> params); @Override List<Class<?>> getCommands(); @Override @DB NiciraNvpDeviceVO addNiciraNvpDevice(final AddNiciraNvpDeviceCmd cmd); @Override NiciraNvpDeviceResponse createNiciraNvpDeviceResponse(final NiciraNvpDeviceVO niciraNvpDeviceVO); @Override boolean deleteNiciraNvpDevice(final DeleteNiciraNvpDeviceCmd cmd); @Override List<? extends Network> listNiciraNvpDeviceNetworks(final ListNiciraNvpDeviceNetworksCmd cmd); @Override List<NiciraNvpDeviceVO> listNiciraNvpDevices(final ListNiciraNvpDevicesCmd cmd); @Override HostVO createHostVOForConnectedAgent(final HostVO host, final StartupCommand[] cmd); @Override HostVO createHostVOForDirectConnectAgent(final HostVO host, final StartupCommand[] startup, final ServerResource resource, final Map<String, String> details, final
    List<String> hostTags); @Override DeleteHostAnswer deleteHost(final HostVO host, final boolean isForced, final boolean isForceDeleteStorage); @Override IpDeployer getIpDeployer(final Network network); @Override boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Network.Service> services); @Override boolean applyStaticNats(final Network network, final List<? extends StaticNat> rules); @Override boolean applyPFRules(final Network network, final List<PortForwardingRule> rules); }
NiciraNvpElement extends AdapterBase implements ConnectivityProvider, SourceNatServiceProvider, PortForwardingServiceProvider, StaticNatServiceProvider,
        NiciraNvpElementService, ResourceStateAdapter, IpDeployer { protected boolean canHandle(final Network network, final Network.Service service) { s_logger.debug("Checking if NiciraNvpElement can handle service " + service.getName() + " on network " + network.getDisplayText()); if (network.getBroadcastDomainType() != BroadcastDomainType.Lswitch) { return false; } if (!this.networkModel.isProviderForNetwork(getProvider(), network.getId())) { s_logger.debug("NiciraNvpElement is not a provider for network " + network.getDisplayText()); return false; } if (!this.ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.NiciraNvp)) { s_logger.debug("NiciraNvpElement can't provide the " + service.getName() + " service on network " + network.getDisplayText()); return false; } return true; }  @Override Map<Network.Service, Map<Network.Capability, String>> getCapabilities(); @Override Network.Provider getProvider(); @Override boolean implement(final Network network, final NetworkOffering offering, final DeployDestination dest, final ReservationContext context); @Override boolean prepare(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context); @Override boolean release(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final ReservationContext context); @Override boolean shutdown(final Network network, final ReservationContext context, final boolean cleanup); @Override boolean destroy(final Network network, final ReservationContext context); @Override boolean isReady(final PhysicalNetworkServiceProvider provider); @Override boolean shutdownProviderInstances(final PhysicalNetworkServiceProvider provider, final ReservationContext context); @Override boolean canEnableIndividualServices(); @Override boolean verifyServicesCombination(final Set<Network.Service> services); @Override boolean configure(final String name, final Map<String, Object> params); @Override List<Class<?>> getCommands(); @Override @DB NiciraNvpDeviceVO addNiciraNvpDevice(final AddNiciraNvpDeviceCmd cmd); @Override NiciraNvpDeviceResponse createNiciraNvpDeviceResponse(final NiciraNvpDeviceVO niciraNvpDeviceVO); @Override boolean deleteNiciraNvpDevice(final DeleteNiciraNvpDeviceCmd cmd); @Override List<? extends Network> listNiciraNvpDeviceNetworks(final ListNiciraNvpDeviceNetworksCmd cmd); @Override List<NiciraNvpDeviceVO> listNiciraNvpDevices(final ListNiciraNvpDevicesCmd cmd); @Override HostVO createHostVOForConnectedAgent(final HostVO host, final StartupCommand[] cmd); @Override HostVO createHostVOForDirectConnectAgent(final HostVO host, final StartupCommand[] startup, final ServerResource resource, final Map<String, String> details, final
    List<String> hostTags); @Override DeleteHostAnswer deleteHost(final HostVO host, final boolean isForced, final boolean isForceDeleteStorage); @Override IpDeployer getIpDeployer(final Network network); @Override boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Network.Service> services); @Override boolean applyStaticNats(final Network network, final List<? extends StaticNat> rules); @Override boolean applyPFRules(final Network network, final List<PortForwardingRule> rules);  }