org.onosproject.net.host.HostService Java Examples

The following examples show how to use org.onosproject.net.host.HostService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HostToHostIntentCompilerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() {
    super.setUp();
    Host hostOne = createMock(Host.class);
    expect(hostOne.mac()).andReturn(new MacAddress(HOST_ONE_MAC.getBytes())).anyTimes();
    expect(hostOne.vlan()).andReturn(VlanId.vlanId()).anyTimes();
    replay(hostOne);

    Host hostTwo = createMock(Host.class);
    expect(hostTwo.mac()).andReturn(new MacAddress(HOST_TWO_MAC.getBytes())).anyTimes();
    expect(hostTwo.vlan()).andReturn(VlanId.vlanId()).anyTimes();
    replay(hostTwo);

    mockHostService = createMock(HostService.class);
    expect(mockHostService.getHost(eq(hostOneId))).andReturn(hostOne).anyTimes();
    expect(mockHostService.getHost(eq(hostTwoId))).andReturn(hostTwo).anyTimes();
    replay(mockHostService);
}
 
Example #2
Source File: VmIpCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    HostService service = AbstractShellCommand.get(HostService.class);
    Iterator<Host> it = service.getHosts().iterator();
    SortedSet<String> strings = delegate.getStrings();
    while (it.hasNext()) {
        for (IpAddress ip : it.next().ipAddresses()) {
            strings.add(ip.toString() + CIDR);
        }
    }

    return delegate.complete(session, commandLine, candidates);
}
 
Example #3
Source File: SfcwebUiTopovOverlay.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void modifyHostDetails(PropertyPanel pp, HostId hostId) {
    pp.title(MY_HOST_TITLE);
    pp.removeAllProps();
    PortPairService portPairService = AbstractShellCommand.get(PortPairService.class);
    VirtualPortService virtualPortService = AbstractShellCommand.get(VirtualPortService.class);
    HostService hostService = AbstractShellCommand.get(HostService.class);
    Iterable<PortPair> portPairs = portPairService.getPortPairs();
    for (PortPair portPair : portPairs) {
        VirtualPort vPort = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress()));
        MacAddress dstMacAddress = vPort.macAddress();
        Host host = hostService.getHost(HostId.hostId(dstMacAddress));
        if (hostId.toString().equals(host.id().toString())) {
            pp.addProp("SF Name", portPair.name());
            pp.addProp("SF Ip", vPort.fixedIps().iterator().next().ip());
        }
    }
    pp.addProp("SF host Address", hostId.toString());
}
 
Example #4
Source File: RouteManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Sets up the host service with details of some hosts.
 */
private void setUpHostService() {
    hostService = createMock(HostService.class);

    hostService.addListener(anyObject(HostListener.class));
    expectLastCall().andDelegateTo(new TestHostService()).anyTimes();

    Host host1 = createHost(MAC1, V4_NEXT_HOP1);
    expectHost(host1);

    Host host2 = createHost(MAC2, V4_NEXT_HOP2);
    expectHost(host2);

    Host host3 = createHost(MAC3, V6_NEXT_HOP1);
    expectHost(host3);

    Host host4 = createHost(MAC4, V6_NEXT_HOP2);
    expectHost(host4);

    replay(hostService);
}
 
Example #5
Source File: SfcFlowRuleInstallerImpl.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Explicit constructor.
 *
 * @param appId application id.
 */
public SfcFlowRuleInstallerImpl(ApplicationId appId) {
    this.appId = checkNotNull(appId, "ApplicationId can not be null");
    ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
    this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class);
    this.driverService = serviceDirectory.get(DriverService.class);
    this.deviceService = serviceDirectory.get(DeviceService.class);
    this.hostService = serviceDirectory.get(HostService.class);
    this.virtualPortService = serviceDirectory.get(VirtualPortService.class);
    this.vtnRscService = serviceDirectory.get(VtnRscService.class);
    this.portPairService = serviceDirectory.get(PortPairService.class);
    this.portPairGroupService = serviceDirectory.get(PortPairGroupService.class);
    this.flowClassifierService = serviceDirectory.get(FlowClassifierService.class);
    this.tenantNetworkService = serviceDirectory.get(TenantNetworkService.class);
    nshSi = 0xff;
}
 
Example #6
Source File: VplsNeighbourHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Handles reply messages between VLAN tagged interfaces.
 *
 * @param context the message context
 * @param hostService the host service
 */
protected void handleReply(NeighbourMessageContext context,
                           HostService hostService) {
    // Find target VPLS, then reply to the host
    VplsData vplsData = findVpls(context);
    if (vplsData != null) {
        MacAddress dstMac = context.dstMac();
        Set<Host> hosts = hostService.getHostsByMac(dstMac);
        hosts = hosts.stream()
                .filter(host -> vplsData.interfaces().contains(getHostInterface(host)))
                .collect(Collectors.toSet());

        // reply to all host in same VPLS
        hosts.stream()
                .map(this::getHostInterface)
                .filter(Objects::nonNull)
                .forEach(context::forward);
    } else {
        // this might be happened when we remove an interface from VPLS
        // just ignore this message
        log.warn(CAN_NOT_FIND_VPLS, context.inPort(), context.vlan());
        context.drop();
    }
}
 
Example #7
Source File: ArpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Processes incoming ARP packets.
 *
 * If it is an ARP request to router itself or known hosts,
 * then it sends ARP response.
 * If it is an ARP request to unknown hosts in its own subnet,
 * then it flood the ARP request to the ports.
 * If it is an ARP response, then set a flow rule for the host
 * and forward any IP packets to the host in the packet buffer to the host.
 * <p>
 * Note: We handles all ARP packet in, even for those ARP packets between
 * hosts in the same subnet.
 * For an ARP packet with broadcast destination MAC,
 * some switches pipelines will send it to the controller due to table miss,
 * other switches will flood the packets directly in the data plane without
 * packet in.
 * We can deal with both cases.
 *
 * @param pkt incoming ARP packet and context information
 * @param hostService the host service
 */
public void processPacketIn(NeighbourMessageContext pkt, HostService hostService) {

    SegmentRoutingAppConfig appConfig = srManager.cfgService
            .getConfig(srManager.appId, SegmentRoutingAppConfig.class);
    if (appConfig != null && appConfig.suppressSubnet().contains(pkt.inPort())) {
        // Ignore ARP packets come from suppressed ports
        pkt.drop();
        return;
    }

    if (!validateArpSpa(pkt)) {
        log.debug("Ignore ARP packet discovered on {} with unexpected src protocol address {}.",
                pkt.inPort(), pkt.sender().getIp4Address());
        pkt.drop();
        return;
    }

    if (pkt.type() == REQUEST) {
        handleArpRequest(pkt, hostService);
    } else {
        handleArpReply(pkt, hostService);
    }
}
 
Example #8
Source File: HostIdCompleter.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();

    HostService service = AbstractShellCommand.get(HostService.class);
    Iterator<Host> it = service.getHosts().iterator();
    SortedSet<String> strings = delegate.getStrings();
    while (it.hasNext()) {
        strings.add(it.next().id().toString());
    }

    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);

}
 
Example #9
Source File: ArpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
private void handleArpReply(NeighbourMessageContext pkt, HostService hostService) {
    // ARP reply for router. Process all pending IP packets.
    if (isArpForRouter(pkt)) {
        Ip4Address hostIpAddress = pkt.sender().getIp4Address();
        srManager.ipHandler.forwardPackets(pkt.inPort().deviceId(), hostIpAddress);
    } else {
        // NOTE: Ignore ARP packets except those target for the router
        //       We will reconsider enabling this when we have host learning support
        /*
        HostId targetHostId = HostId.hostId(pkt.dstMac(), pkt.vlan());
        Host targetHost = hostService.getHost(targetHostId);
        // ARP reply for known hosts. Forward to the host.
        if (targetHost != null) {
            pkt.forward(targetHost.location());
        // ARP reply for unknown host, Flood in the subnet.
        } else {
            // Don't flood to non-edge ports
            if (pkt.vlan().equals(SegmentRoutingManager.INTERNAL_VLAN)) {
                return;
            }
            flood(pkt);
        }
        */
    }
}
 
Example #10
Source File: SegmentRoutingNeighbourHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Utility to send a ND reply using the supplied information.
 *
 * @param pkt the request
 * @param targetMac the target mac
 * @param hostService the host service
 * @param isRouter true if this reply is sent on behalf of a router
 */
protected void sendResponse(NeighbourMessageContext pkt, MacAddress targetMac, HostService hostService,
                            boolean isRouter) {
    // if this is false, check if host exists in the store
    if (!respondToUnknownHosts()) {
        short vlanId = pkt.packet().getQinQVID();
        HostId dstId = HostId.hostId(pkt.srcMac(), vlanId == Ethernet.VLAN_UNTAGGED
                ? pkt.vlan() : VlanId.vlanId(vlanId));
        Host dst = hostService.getHost(dstId);
        if (dst == null) {
            log.warn("Cannot send {} response to host {} - does not exist in the store",
                     pkt.protocol(), dstId);
            return;
        }
    }
    pkt.setIsRouter(isRouter);
    pkt.reply(targetMac);
}
 
Example #11
Source File: TopologySimulator.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes a new topology simulator with access to the specified service
 * directory and various provider services.
 *
 * @param topoShape             topology shape specifier
 * @param deviceCount           number of devices in the topology
 * @param hostCount             number of hosts per device
 * @param directory             service directory
 * @param deviceProviderService device provider service
 * @param hostProviderService   host provider service
 * @param linkProviderService   link provider service
 */
protected void init(String topoShape, int deviceCount, int hostCount,
                    ServiceDirectory directory,
                    DeviceProviderService deviceProviderService,
                    HostProviderService hostProviderService,
                    LinkProviderService linkProviderService) {
    this.deviceCount = deviceCount;
    this.hostCount = hostCount;
    this.directory = directory;

    this.clusterService = directory.get(ClusterService.class);
    this.mastershipService = directory.get(MastershipService.class);
    this.mastershipAdminService = directory.get(MastershipAdminService.class);

    this.deviceService = directory.get(DeviceAdminService.class);
    this.hostService = directory.get(HostService.class);
    this.linkService = directory.get(LinkService.class);
    this.deviceProviderService = deviceProviderService;
    this.hostProviderService = hostProviderService;
    this.linkProviderService = linkProviderService;

    localNode = clusterService.getLocalNode().id();

    processTopoShape(topoShape);
}
 
Example #12
Source File: SegmentRoutingNeighbourDispatcher.java    From onos with Apache License 2.0 6 votes vote down vote up
private void handleMessageInternal(NeighbourMessageContext context, HostService hostService) {
    log.trace("Received {} packet on {}: {}", context.protocol(),
              context.inPort(), context.packet());
    switch (context.protocol()) {
        case ARP:
            if (this.manager.arpHandler != null) {
                this.manager.arpHandler.processPacketIn(context, hostService);
            }
            break;
        case NDP:
            if (this.manager.icmpHandler != null) {
                this.manager.icmpHandler.processPacketIn(context, hostService);
            }
            break;
        default:
            log.warn("Unknown protocol", context.protocol());
    }
}
 
Example #13
Source File: IcmpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to handle the ndp replies.
 *
 * @param pkt the ndp packet reply and context information
 * @param hostService the host service
 */
private void handleNdpReply(NeighbourMessageContext pkt, HostService hostService) {
    if (isNdpForGateway(pkt)) {
        log.debug("Forwarding all the ip packets we stored");
        Ip6Address hostIpAddress = pkt.sender().getIp6Address();
        srManager.ipHandler.forwardPackets(pkt.inPort().deviceId(), hostIpAddress);
    } else {
        // NOTE: Ignore NDP packets except those target for the router
        //       We will reconsider enabling this when we have host learning support
        /*
        HostId hostId = HostId.hostId(pkt.dstMac(), pkt.vlan());
        Host targetHost = hostService.getHost(hostId);
        if (targetHost != null) {
            log.debug("Forwarding the reply to the host");
            pkt.forward(targetHost.location());
        } else {
            // We don't have to flood towards spine facing ports.
            if (pkt.vlan().equals(SegmentRoutingManager.INTERNAL_VLAN)) {
                return;
            }
            log.debug("Flooding the reply to the subnet");
            flood(pkt);
        }
        */
    }
}
 
Example #14
Source File: NeighbourResolutionManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Test
public void testPacketDistributionToInterface() {
    Ethernet arpRequest = createArpRequest(IP1);

    NeighbourMessageHandler handler = createMock(NeighbourMessageHandler.class);
    handler.handleMessage(eq(createContext(arpRequest, CP1, null)), anyObject(HostService.class));
    expectLastCall().once();
    replay(handler);
    neighbourManager.registerNeighbourHandler(INTF1, handler, APP_ID);

    // Incoming packet matching the interface where the handler is registered
    packetProcessor.process(context(arpRequest, CP1));

    verify(handler);

    reset(handler);
    replay(handler);

    // Incoming packet on same connect point but not matching the interface
    packetProcessor.process(context(createArpRequest(IP2), CP1));

    verify(handler);
}
 
Example #15
Source File: NeighbourResolutionManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Test
public void testPacketDistribution() {
    Ethernet arpRequest = createArpRequest(IP1);

    NeighbourMessageHandler handler = createMock(NeighbourMessageHandler.class);
    handler.handleMessage(eq(createContext(arpRequest, CP1, null)), anyObject(HostService.class));
    expectLastCall().once();
    replay(handler);
    neighbourManager.registerNeighbourHandler(CP1, handler, APP_ID);

    // Incoming packet on the connect point where the handler is registered
    packetProcessor.process(context(arpRequest, CP1));

    // Send a packet from a different connect point that should not be
    // delivered to the handler
    packetProcessor.process(context(arpRequest, CP2));

    verify(handler);
}
 
Example #16
Source File: HostResourceTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes test mocks and environment.
 */
@Before
public void setUpTest() {
    expect(mockHostService.getHosts()).andReturn(hosts).anyTimes();

    // Register the services needed for the test
    final CodecManager codecService =  new CodecManager();
    codecService.activate();
    ServiceDirectory testDirectory =
            new TestServiceDirectory()
                    .add(HostService.class, mockHostService)
                    .add(HostAdminService.class, mockHostService)
                    .add(CodecService.class, codecService)
                    .add(HostProviderRegistry.class, mockHostProviderRegistry);
    setServiceDirectory(testDirectory);
}
 
Example #17
Source File: ServicesBundle.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the services bundle, from the given directly.
 *
 * @param directory service directory
 */
public ServicesBundle(ServiceDirectory directory) {
    checkNotNull(directory, "Directory cannot be null");

    clusterService = directory.get(ClusterService.class);

    topologyService = directory.get(TopologyService.class);
    deviceService = directory.get(DeviceService.class);
    driverService = directory.get(DriverService.class);
    hostService = directory.get(HostService.class);
    linkService = directory.get(LinkService.class);

    mastershipService = directory.get(MastershipService.class);
    mastershipAdminService = directory.get(MastershipAdminService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    flowStatsService = directory.get(StatisticService.class);
    portStatsService = directory.get(PortStatisticsService.class);
}
 
Example #18
Source File: Topo2Jsonifier.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an instance with a reference to the services directory, so that
 * additional information about network elements may be looked up on
 * on the fly.
 *
 * @param directory service directory
 * @param userName  logged in user name
 */
public Topo2Jsonifier(ServiceDirectory directory, String userName) {
    this.directory = checkNotNull(directory, "Directory cannot be null");
    this.userName = checkNotNull(userName, "User name cannot be null");

    clusterService = directory.get(ClusterService.class);
    deviceService = directory.get(DeviceService.class);
    linkService = directory.get(LinkService.class);
    hostService = directory.get(HostService.class);
    mastershipService = directory.get(MastershipService.class);
    intentService = directory.get(IntentService.class);
    flowService = directory.get(FlowRuleService.class);
    flowStatsService = directory.get(StatisticService.class);
    portStatsService = directory.get(PortStatisticsService.class);
    topologyService = directory.get(TopologyService.class);
    uiextService = directory.get(UiExtensionService.class);
    prefService = directory.get(UiPreferencesService.class);
}
 
Example #19
Source File: IcmpHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Process incoming NDP packet.
 *
 * If it is an NDP request for the router or for the gateway, then sends a NDP reply.
 * If it is an NDP request to unknown host flood in the subnet.
 * If it is an NDP packet to known host forward the packet to the host.
 *
 * FIXME If the NDP packets use link local addresses we fail.
 *
 * @param pkt inbound packet
 * @param hostService the host service
 */
public void processPacketIn(NeighbourMessageContext pkt, HostService hostService) {
    // First we validate the ndp packet
    SegmentRoutingAppConfig appConfig = srManager.cfgService
            .getConfig(srManager.appId, SegmentRoutingAppConfig.class);
    if (appConfig != null && appConfig.suppressSubnet().contains(pkt.inPort())) {
        // Ignore NDP packets come from suppressed ports
        pkt.drop();
        return;
    }

    if (pkt.type() == NeighbourMessageType.REQUEST) {
        handleNdpRequest(pkt, hostService);
    } else {
        handleNdpReply(pkt, hostService);
    }

}
 
Example #20
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for hosts with null mac.
 */
@Test(expected = NullPointerException.class)
public void testGetHostsByNullMac() {
    VirtualNetwork vnet = setupEmptyVnet();
    HostService hostService = manager.get(vnet.id(), HostService.class);

    hostService.getHostsByMac(null);
}
 
Example #21
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the getHosts(), getHost(), getHostsByXX(), getConnectedHosts() methods
 * on an empty virtual network.
 */
@Test
public void testGetHostsOnEmptyVnet() {
    VirtualNetwork virtualNetwork = setupEmptyVnet();
    HostService hostService = manager.get(virtualNetwork.id(), HostService.class);

    // test the getHosts() and getHostCount() methods
    Iterator<Host> itHosts = hostService.getHosts().iterator();
    assertEquals("The host set size did not match.", 0, Iterators.size(itHosts));
    assertEquals("The host count did not match.", 0, hostService.getHostCount());

    // test the getHost() method
    Host testHost = hostService.getHost(HID2);
    assertNull("The host should be null.", testHost);

    // test the getHostsByVlan(...) method
    Collection<Host> collHost = hostService.getHostsByVlan(VLAN1);
    assertEquals("The host set size did not match.", 0, collHost.size());

    // test the getHostsByMac(...) method
    collHost = hostService.getHostsByMac(MAC2);
    assertEquals("The host set size did not match.", 0, collHost.size());

    // test the getHostsByIp(...) method
    collHost = hostService.getHostsByIp(IP1);
    assertEquals("The host set size did not match.", 0, collHost.size());

    // test the getConnectedHosts(ConnectPoint) method
    collHost = hostService.getConnectedHosts(LOC1);
    assertEquals("The host set size did not match.", 0, collHost.size());

    // test the getConnectedHosts(DeviceId) method
    collHost = hostService.getConnectedHosts(DID2);
    assertEquals("The host set size did not match.", 0, collHost.size());
}
 
Example #22
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for hosts with null vlan.
 */
@Test(expected = NullPointerException.class)
public void testGetHostsByNullVlan() {
    VirtualNetwork vnet = setupEmptyVnet();
    HostService hostService = manager.get(vnet.id(), HostService.class);

    hostService.getHostsByVlan(null);
}
 
Example #23
Source File: VirtualNetworkPathManager.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new virtual network path service object.
 *
 * @param virtualNetworkManager virtual network manager service
 * @param networkId a virtual network identifier
 */

public VirtualNetworkPathManager(VirtualNetworkService virtualNetworkManager,
                                 NetworkId networkId) {
    this.networkId = networkId;

    topologyService = virtualNetworkManager.get(networkId(), TopologyService.class);
    hostService = virtualNetworkManager.get(networkId(), HostService.class);
}
 
Example #24
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for a host using a null host identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetHostByNullId() {
    VirtualNetwork vnet = setupEmptyVnet();
    HostService hostService = manager.get(vnet.id(), HostService.class);

    hostService.getHost(null);
}
 
Example #25
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for hosts with null ip.
 */
@Test(expected = NullPointerException.class)
public void testGetHostsByNullIp() {
    VirtualNetwork vnet = setupVnet();
    HostService hostService = manager.get(vnet.id(), HostService.class);

    hostService.getHostsByIp(null);
}
 
Example #26
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for connected hosts with null host location (connect point).
 */
@Test(expected = NullPointerException.class)
public void testGetConnectedHostsByNullLoc() {
    VirtualNetwork vnet = setupEmptyVnet();
    HostService hostService = manager.get(vnet.id(), HostService.class);

    hostService.getConnectedHosts((ConnectPoint) null);
}
 
Example #27
Source File: VirtualNetworkHostManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for connected hosts with null device id.
 */
@Test(expected = NullPointerException.class)
public void testGetConnectedHostsByNullDeviceId() {
    VirtualNetwork vnet = setupVnet();
    HostService hostService = manager.get(vnet.id(), HostService.class);

    hostService.getConnectedHosts((DeviceId) null);
}
 
Example #28
Source File: VirtualNetworkManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the get() method returns saved service instances.
 */
@Test
public void testServiceGetReturnsSavedInstance() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork =
            manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));

    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), DeviceService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), LinkService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), TopologyService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), HostService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), PathService.class);

    // extra setup needed for FlowRuleService, PacketService, GroupService, and IntentService
    VirtualProviderManager virtualProviderManager = new VirtualProviderManager();
    virtualProviderManager.registerProvider(new DefaultVirtualFlowRuleProvider());
    virtualProviderManager.registerProvider(new DefaultVirtualPacketProvider());
    virtualProviderManager.registerProvider(new DefaultVirtualGroupProvider());
    testDirectory.add(CoreService.class, coreService)
            .add(VirtualProviderRegistryService.class, virtualProviderManager)
            .add(EventDeliveryService.class, new TestEventDispatcher())
            .add(ClusterService.class, new ClusterServiceAdapter())
            .add(VirtualNetworkFlowRuleStore.class, new SimpleVirtualFlowRuleStore())
            .add(VirtualNetworkPacketStore.class, new SimpleVirtualPacketStore())
            .add(VirtualNetworkGroupStore.class, new SimpleVirtualGroupStore())
            .add(VirtualNetworkIntentStore.class, new SimpleVirtualIntentStore())
            .add(VirtualNetworkFlowObjectiveStore.class, new SimpleVirtualFlowObjectiveStore());

    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), FlowRuleService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), FlowObjectiveService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), PacketService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), GroupService.class);
    validateServiceGetReturnsSavedInstance(virtualNetwork.id(), IntentService.class);
}
 
Example #29
Source File: LayoutAlgorithm.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes layout algorithm for operating on device and host inventory.
 *
 * @param deviceService        device service
 * @param hostService          host service
 * @param linkService          link service
 * @param networkConfigService net config service
 */
protected void init(DeviceService deviceService,
                    HostService hostService,
                    LinkService linkService,
                    NetworkConfigService networkConfigService) {
    this.deviceService = deviceService;
    this.hostService = hostService;
    this.linkService = linkService;
    this.netConfigService = networkConfigService;
}
 
Example #30
Source File: ArpHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private void handleArpRequest(NeighbourMessageContext pkt, HostService hostService) {
    // ARP request for router. Send ARP reply.
    if (isArpForRouter(pkt)) {
        MacAddress targetMac = config.getRouterMacForAGatewayIp(pkt.target().getIp4Address());
        if (targetMac == null) {
            log.warn("Router MAC of {} is not configured. Cannot handle ARP request from {}",
                    pkt.inPort().deviceId(), pkt.sender());
            return;
        }
        sendResponse(pkt, targetMac, hostService, true);
    } else {
        // NOTE: Ignore ARP packets except those target for the router
        //       We will reconsider enabling this when we have host learning support
        /*
        Set<Host> hosts = hostService.getHostsByIp(pkt.target());
        if (hosts.size() > 1) {
            log.warn("More than one host with the same ip {}", pkt.target());
        }
        Host targetHost = hosts.stream().findFirst().orElse(null);
        // ARP request for known hosts. Send proxy ARP reply on behalf of the target.
        if (targetHost != null) {
            pkt.forward(targetHost.location());
        // ARP request for unknown host in the subnet. Flood in the subnet.
        } else {
            flood(pkt);
        }
        */
    }
}