• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DefaultHost类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.onosproject.net.DefaultHost的典型用法代码示例。如果您正苦于以下问题:Java DefaultHost类的具体用法?Java DefaultHost怎么用?Java DefaultHost使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DefaultHost类属于org.onosproject.net包,在下文中一共展示了DefaultHost类的35个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testSingleHostByMacAndVlanFetch

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests fetch of one host by mac and vlan.
 */
@Test
public void testSingleHostByMacAndVlanFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01/1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:26,
代码来源:HostResourceTest.java

示例2: testSingleHostByIdFetch

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests fetch of one host by Id.
 */
@Test
public void testSingleHostByIdFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebTarget wt = target();
    String response = wt.path("hosts/00:00:11:00:00:01%2F1").request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, matchesHost(host1));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:26,
代码来源:HostResourceTest.java

示例3: createHost

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Creates a default host connected at the given edge device and port. Note
 * that an identifying hex character ("a" - "f") should be supplied. This
 * will be included in the MAC address of the host (and equivalent value
 * as last byte in IP address).
 *
 * @param device  edge device
 * @param port    port number
 * @param hexChar identifying hex character
 * @return host connected at that location
 */
protected static Host createHost(Device device, int port, String hexChar) {
    DeviceId deviceId = device.id();
    String devNum = deviceId.toString().substring(1);

    MacAddress mac = MacAddress.valueOf(HOST_MAC_PREFIX + devNum + hexChar);
    HostId hostId = hostId(String.format("%s/-1", mac));

    int ipByte = Integer.valueOf(hexChar, 16);
    if (ipByte < 10 || ipByte > 15) {
        throw new IllegalArgumentException("hexChar must be a-f");
    }
    HostLocation loc = new HostLocation(deviceId, portNumber(port), 0);

    IpAddress ip = ip("10." + devNum + ".0." + ipByte);

    return new DefaultHost(ProviderId.NONE, hostId, mac, VlanId.NONE,
            loc, ImmutableSet.of(ip));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:30,
代码来源:AbstractTopoModelTest.java

示例4: testFourInterfacesThreeHostEventsSameVlan

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Checks the case in which six ports are configured with VLANs and
 * initially no hosts are registered by the HostService. The first three
 * ports have an interface configured on VLAN1, the other three have an
 * interface configured on VLAN2. When the module starts up, three hosts -
 * on device one, two and three - port 1 (both on VLAN1), are registered by
 * the HostService and events are sent to the application. sp2mp intents
 * are created for all interfaces configured and mp2sp intents are created
 * only for the hosts attached.
 * The number of intents expected is nine: six for VLAN1, three for VLAN2.
 * Six sp2mp intents, three mp2sp intents. IPs are added on the first two
 * hosts only to demonstrate it doesn't influence the number of intents
 * created.
 * An additional host is added on device seven, port one to demonstrate
 * that, even if it's on the same VLAN of other interfaces configured in
 * the system, it doesn't let the application generate intents, since it's
 * not connected to the interface configured.
 */
@Test
public void testFourInterfacesThreeHostEventsSameVlan() {
    vpls.activate();

    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
                              Collections.singleton(IP1));
    Host h2 = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(2),
                              Collections.singleton(IP2));
    Host h3 = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(3),
                              Collections.EMPTY_SET);
    Host h7 = new DefaultHost(PID, HID7, MAC7, VLAN1, getLocation(7),
                              Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h2, h3, h7));

    hostsAvailable.forEach(host ->
        hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host)));

    List<Intent> expectedIntents = new ArrayList<>();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanOneUni());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:43,
代码来源:VplsTest.java

示例5: testFourInterfacesTwoHostEventsDifferentVlan

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Checks the case in which six ports are configured with VLANs and
 * initially no hosts are registered by the HostService. The first three
 * ports have an interface configured on VLAN1, the other three have an
 * interface configured on VLAN2. When the module starts up, two hosts -
 * on device one and four - port 1 (VLAN 1 and VLAN 2), are registered by
 * the HostService and events are sent to the application. sp2mp intents
 * are created for all interfaces configured and no mp2sp intents are created
 * at all, since the minimum number of hosts needed on the same vlan to
 * create mp2sp intents is 2.
 * The number of intents expected is six: three for VLAN1, three for VLAN2.
 * six sp2mp intents, zero mp2sp intents. IPs are added on the first host
 * only to demonstrate it doesn't influence the number of intents created.
 */
@Test
public void testFourInterfacesTwoHostEventsDifferentVlan() {
    vpls.activate();

    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
                              Collections.singleton(IP1));
    Host h4 = new DefaultHost(PID, HID4, MAC4, VLAN2, getLocation(4),
                              Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h4));

    hostsAvailable.forEach(host -> {
        hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host));
    });

    List<Intent> expectedIntents = new ArrayList<>();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:35,
代码来源:VplsTest.java

示例6: createHost

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
private Host createHost() {
    MacAddress mac = MacAddress.valueOf("00:00:11:00:00:01");
    VlanId vlan = VlanId.vlanId((short) 10);
    HostLocation loc = new HostLocation(
                DeviceId.deviceId("of:foo"),
                PortNumber.portNumber(100),
                123L
            );
    Set<IpAddress> ipset = Sets.newHashSet(
                IpAddress.valueOf("10.0.0.1"),
                IpAddress.valueOf("10.0.0.2")
            );
    HostId hid = HostId.hostId(mac, vlan);

    return new DefaultHost(
            new ProviderId("of", "foo"), hid, mac, vlan, loc, ipset);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:18,
代码来源:HostEventTest.java

示例7: testReplyKnown

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is known.
 * Two host using the same VLAN are registered on the host service on devices 5 and 6.
 * Host on port 6 asks for the MAC of the device on port 5.
 * Since the destination mac address is known, the request is not flooded to anywhere
 * and ONOS directly builds an ARP reply, sended back to the requester on device 6.
 * It's verified that a proper ARP reply is received on port 1 of device 6.
 */
@Test
public void testReplyKnown() {
    Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(NUM_DEVICES),
            Collections.singleton(IP1));

    Host replyer = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(NUM_DEVICES - 1),
            Collections.singleton(IP2));

    expect(hostService.getHostsByIp(IP2))
            .andReturn(Collections.singleton(replyer));
    expect(hostService.getHost(HID1)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, IP1, IP2);

    proxyArp.reply(arpRequest, getLocation(NUM_DEVICES));

    assertEquals(1, packetService.packets.size());
    Ethernet arpReply = buildArp(ARP.OP_REPLY, VLAN1, MAC2, MAC1, IP2, IP1);
    verifyPacketOut(arpReply, getLocation(NUM_DEVICES), packetService.packets.get(0));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:33,
代码来源:ProxyArpManagerTest.java

示例8: testReplyUnknown

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is not known.
 * Only a requestor is present (on device 6, port 1). The device has a VLAN configured
 * which is not configured anywhere in the system.
 * Since the destination is not known, and since the ARP request can't be sent out of
 * interfaces configured, the ARP request is flooded out of ports 4 and 5.
 * Verifies the ARP request is flooded out the correct edge ports.
 */
@Test
public void testReplyUnknown() {
    Host requestor = new DefaultHost(PID, HID10, MAC10, VLAN10, getLocation(NUM_DEVICES),
            Collections.singleton(IP1));

    expect(hostService.getHostsByIp(IP2))
            .andReturn(Collections.emptySet());
    expect(interfaceService.getInterfacesByIp(IP1))
            .andReturn(Collections.emptySet());
    expect(hostService.getHost(HID10)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN10, MAC10, null, IP1, IP2);

    proxyArp.reply(arpRequest, getLocation(NUM_DEVICES));

    verifyFlood(arpRequest, noConfigCPoints);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:30,
代码来源:ProxyArpManagerTest.java

示例9: testReplyUnknownIpv6

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is not known.
 * Verifies the NDP request is flooded out the correct edge ports.
 */
@Test
public void testReplyUnknownIpv6() {
    Host requestor = new DefaultHost(PID, HID4, MAC4, VLAN1, getLocation(NUM_DEVICES),
                                     Collections.singleton(IP4));

    expect(hostService.getHostsByIp(IP3))
            .andReturn(Collections.emptySet());
    expect(interfaceService.getInterfacesByIp(IP4))
            .andReturn(Collections.emptySet());
    expect(hostService.getHost(HID4)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
            MAC4, SOLICITED_MAC3,
            IP4, IP3);

    proxyArp.reply(ndpRequest, getLocation(NUM_DEVICES));

    verifyFlood(ndpRequest, noConfigCPoints);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:28,
代码来源:ProxyArpManagerTest.java

示例10: testReplyDifferentVlan

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is known for that IP address, but is not on the same
 * VLAN as the source host.
 * An host is connected on device 6, port 1 where no interfaces are defined. It sends
 * ARP requests from VLAN10, not configured anywhere in the network. Another host with
 * the IP address requested lives on device 5, port 1 in the network. Anyway, since the
 * host uses another VLAN it's not found and the ARP packet is flooded out of port
 * 4 and 5.
 *
 * Verifies the ARP request is flooded out the correct edge ports.
 */
@Test
public void testReplyDifferentVlan() {
    Host requestor = new DefaultHost(PID, HID10, MAC10, VLAN10, getLocation(NUM_DEVICES),
            Collections.singleton(IP1));

    Host replyer = new DefaultHost(PID, HID2, MAC2, VLAN2, getLocation(NUM_DEVICES - 1),
            Collections.singleton(IP2));

    expect(hostService.getHostsByIp(IP2))
            .andReturn(Collections.singleton(replyer));
    expect(interfaceService.getInterfacesByIp(IP1))
            .andReturn(Collections.emptySet());
    expect(hostService.getHost(HID10)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN10, MAC10, null, IP1, IP2);

    proxyArp.reply(arpRequest, getLocation(NUM_DEVICES));

    verifyFlood(arpRequest, noConfigCPoints);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:36,
代码来源:ProxyArpManagerTest.java

示例11: testConfiguredVlan

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * a vlan packet comes in from a port without interfaces configured. The destination
 * host is unknown for that IP address and there are some interfaces configured on
 * the same vlan.
 * It's expected to see the ARP request going out through ports with no interfaces
 * configured, devices 4 and 5, port 1.
 *
 * Verifies the ARP request is flooded out the correct edge ports.
 */
@Test
public void testConfiguredVlan() {
    Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(NUM_DEVICES),
            Collections.singleton(IP1));

    expect(hostService.getHostsByIp(IP2))
            .andReturn(Collections.emptySet());
    expect(interfaceService.getInterfacesByIp(IP1))
            .andReturn(Collections.emptySet());
    expect(hostService.getHost(HID1)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, IP1, IP2);

    proxyArp.reply(arpRequest, getLocation(NUM_DEVICES));

    verifyFlood(arpRequest, noConfigCPoints);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:31,
代码来源:ProxyArpManagerTest.java

示例12: testConfiguredVlanOnInterfaces

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * a vlan packet comes in from a port without interfaces configured. The destination
 * host is not known for that IP address and there are some interfaces configured on
 * the same vlan.
 * It's expected to see the ARP request going out through ports with no interfaces
 * configured, devices 4 and 5, port 1.
 *
 * Verifies the ARP request is flooded out the correct edge ports.
 */
@Test
public void testConfiguredVlanOnInterfaces() {
    Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(6),
            Collections.singleton(IP1));

    expect(hostService.getHostsByIp(IP2))
            .andReturn(Collections.emptySet());
    expect(interfaceService.getInterfacesByIp(IP1))
            .andReturn(Collections.emptySet());
    expect(hostService.getHost(HID1)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, IP1, IP2);

    proxyArp.reply(arpRequest, getLocation(6));

    verifyFlood(arpRequest, configVlanCPoints);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:31,
代码来源:ProxyArpManagerTest.java

示例13: testReplyDifferentVlanIpv6

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is known for that IP address, but is not on the same
 * VLAN as the source host.
 * Verifies the NDP request is flooded out the correct edge ports.
 */
@Test
public void testReplyDifferentVlanIpv6() {
    Host requestor = new DefaultHost(PID, HID4, MAC4, VLAN1, getLocation(NUM_DEVICES),
                                     Collections.singleton(IP4));

    Host replyer = new DefaultHost(PID, HID3, MAC3, VLAN2, getLocation(NUM_DEVICES - 1),
            Collections.singleton(IP3));

    expect(hostService.getHostsByIp(IP3))
            .andReturn(Collections.singleton(replyer));
    expect(interfaceService.getInterfacesByIp(IP4))
            .andReturn(Collections.emptySet());
    expect(hostService.getHost(HID4)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
            MAC4, SOLICITED_MAC3,
            IP4, IP3);

    proxyArp.reply(ndpRequest, getLocation(NUM_DEVICES));

    verifyFlood(ndpRequest, noConfigCPoints);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:32,
代码来源:ProxyArpManagerTest.java

示例14: testForwardToHost

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#forward(Ethernet, ConnectPoint)} in the case where the
 * destination host is known.
 * Verifies the correct ARP request is sent out the correct port.
 */
@Test
public void testForwardToHost() {
    Host host1 = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1,
            Collections.singleton(IP1));
    Host host2 = new DefaultHost(PID, HID2, MAC2, VLAN1, LOC2,
                                 Collections.singleton(IP2));

    expect(hostService.getHost(HID1)).andReturn(host1);
    expect(hostService.getHost(HID2)).andReturn(host2);
    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REPLY, VLAN1, MAC2, MAC1, IP2, IP1);

    proxyArp.forward(arpRequest, LOC2);

    assertEquals(1, packetService.packets.size());
    OutboundPacket packet = packetService.packets.get(0);

    verifyPacketOut(arpRequest, LOC1, packet);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:27,
代码来源:ProxyArpManagerTest.java

示例15: testForwardToHostIpv6

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#forward(Ethernet, ConnectPoint)} in the case where the
 * destination host is known.
 * Verifies the correct ARP request is sent out the correct port.
 */
@Test
public void testForwardToHostIpv6() {
    Host host1 = new DefaultHost(PID, HID3, MAC3, VLAN1, LOC1,
                                 Collections.singleton(IP3));
    Host host2 = new DefaultHost(PID, HID4, MAC4, VLAN1, LOC2,
                                 Collections.singleton(IP4));

    expect(hostService.getHost(SOLICITED_HID3)).andReturn(host1);
    expect(hostService.getHost(HID4)).andReturn(host2);
    replay(hostService);
    replay(interfaceService);

    Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
            MAC4, SOLICITED_MAC3,
            IP4, IP3);

    proxyArp.forward(ndpRequest, LOC2);

    assertEquals(1, packetService.packets.size());
    OutboundPacket packet = packetService.packets.get(0);

    verifyPacketOut(ndpRequest, LOC1, packet);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:29,
代码来源:ProxyArpManagerTest.java

示例16: activate

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Activate
public void activate() {
    KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
            .register(KryoNamespaces.API);

    hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder()
            .withName("onos-hosts")
            .withRelaxedReadConsistency()
            .withSerializer(Serializer.using(hostSerializer.build()))
            .build();

    hosts = hostsConsistentMap.asJavaMap();

    prevHosts.putAll(hosts);

    hostsConsistentMap.addListener(hostLocationTracker);

    log.info("Started");
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:20,
代码来源:DistributedHostStore.java

示例17: testSingleHostByIdFetch

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests fetch of one host by Id.
 */
@Test
public void testSingleHostByIdFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebResource rs = resource();
    String response = rs.path("hosts/00:00:11:00:00:01%2F1").get(String.class);
    final JsonObject result = JsonObject.readFrom(response);
    assertThat(result, matchesHost(host1));
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:26,
代码来源:HostResourceTest.java

示例18: testSingleHostByMacAndVlanFetch

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests fetch of one host by mac and vlan.
 */
@Test
public void testSingleHostByMacAndVlanFetch() {
    final ProviderId pid = new ProviderId("of", "foo");
    final MacAddress mac1 = MacAddress.valueOf("00:00:11:00:00:01");
    final Set<IpAddress> ips1 = ImmutableSet.of(IpAddress.valueOf("1111:1111:1111:1::"));
    final Host host1 =
            new DefaultHost(pid, HostId.hostId(mac1), valueOf(1), vlanId((short) 1),
                    new HostLocation(DeviceId.deviceId("1"), portNumber(11), 1),
                    ips1);

    hosts.add(host1);

    expect(mockHostService.getHost(HostId.hostId("00:00:11:00:00:01/1")))
            .andReturn(host1)
            .anyTimes();
    replay(mockHostService);

    WebResource rs = resource();
    String response = rs.path("hosts/00:00:11:00:00:01/1").get(String.class);
    final JsonObject result = JsonObject.readFrom(response);
    assertThat(result, matchesHost(host1));
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:26,
代码来源:HostResourceTest.java

示例19: testReplyKnown

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is known.
 * Verifies the correct ARP reply is sent out the correct port.
 */
@Test
public void testReplyKnown() {
    Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(4),
            Collections.singleton(IP1));

    Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5),
            Collections.singleton(IP2));

    expect(hostService.getHostsByIp(IP1))
        .andReturn(Collections.singleton(replyer));
    expect(hostService.getHost(HID2)).andReturn(requestor);

    replay(hostService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1);

    proxyArp.reply(arpRequest, getLocation(5));

    assertEquals(1, packetService.packets.size());
    Ethernet arpReply = buildArp(ARP.OP_REPLY, MAC1, MAC2, IP1, IP2);
    verifyPacketOut(arpReply, getLocation(5), packetService.packets.get(0));
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:28,
代码来源:ProxyArpManagerTest.java

示例20: testReplyUnknown

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is not known.
 * Verifies the ARP request is flooded out the correct edge ports.
 */
@Test
public void testReplyUnknown() {
    Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5),
            Collections.singleton(IP2));

    expect(hostService.getHostsByIp(IP1))
            .andReturn(Collections.<Host>emptySet());
    expect(hostService.getHost(HID2)).andReturn(requestor);

    replay(hostService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1);

    proxyArp.reply(arpRequest, getLocation(6));

    verifyFlood(arpRequest);
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:23,
代码来源:ProxyArpManagerTest.java

示例21: testReplyDifferentVlan

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is known for that IP address, but is not on the same
 * VLAN as the source host.
 * Verifies the ARP request is flooded out the correct edge ports.
 */
@Test
public void testReplyDifferentVlan() {
    Host replyer = new DefaultHost(PID, HID1, MAC1, VLAN2, getLocation(4),
            Collections.singleton(IP1));

    Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5),
            Collections.singleton(IP2));

    expect(hostService.getHostsByIp(IP1))
            .andReturn(Collections.singleton(replyer));
    expect(hostService.getHost(HID2)).andReturn(requestor);

    replay(hostService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC2, null, IP2, IP1);

    proxyArp.reply(arpRequest, getLocation(6));

    verifyFlood(arpRequest);
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:27,
代码来源:ProxyArpManagerTest.java

示例22: testForwardToHost

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#forward(Ethernet, ConnectPoint)} in the case where the
 * destination host is known.
 * Verifies the correct ARP request is sent out the correct port.
 */
@Test
public void testForwardToHost() {
    Host host1 = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1,
            Collections.singleton(IP1));

    expect(hostService.getHost(HID1)).andReturn(host1);
    replay(hostService);

    Ethernet arpRequest = buildArp(ARP.OP_REPLY, MAC2, MAC1, IP2, IP1);

    proxyArp.forward(arpRequest, LOC2);

    assertEquals(1, packetService.packets.size());
    OutboundPacket packet = packetService.packets.get(0);

    verifyPacketOut(arpRequest, LOC1, packet);
}
 

开发者ID:ravikumaran2015,
项目名称:ravikumaran201504,
代码行数:23,
代码来源:ProxyArpManagerTest.java

示例23: populateHosts

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
private static void populateHosts() {
    ip1 = IpAddress.valueOf("10.1.1.1");
    IpAddress ip2 = IpAddress.valueOf("10.1.1.2");
    IpAddress ip3 = IpAddress.valueOf("10.1.1.3");
    mac1 = MacAddress.valueOf("67:11:23:45:87:11");
    MacAddress mac2 = MacAddress.valueOf("67:11:23:45:87:12");
    MacAddress mac3 = MacAddress.valueOf("67:11:23:45:87:13");
    id1 = HostId.hostId(mac1);
    HostId id2 = HostId.hostId(mac2);
    HostId id3 = HostId.hostId(mac3);
    deviceId = DeviceId.deviceId("test");

    c1 = new ConnectPoint(deviceId, PortNumber.portNumber(101));
    HostLocation hostLocation1 = new HostLocation(deviceId, PortNumber.portNumber(101), 0);
    HostLocation hostLocation2 = new HostLocation(deviceId, PortNumber.portNumber(102), 0);
    HostLocation hostLocation3 = new HostLocation(deviceId, PortNumber.portNumber(103), 0);

    h1 = new DefaultHost(ProviderId.NONE, id1, mac1, VlanId.NONE,
                         hostLocation1, ImmutableSet.of(ip1));
    allHosts.add(h1);
    allHosts.add(new DefaultHost(ProviderId.NONE, id2, mac2, VlanId.NONE,
                                 hostLocation2, ImmutableSet.of(ip2)));
    allHosts.add(new DefaultHost(ProviderId.NONE, id3, mac3, VlanId.NONE,
                                 hostLocation3, ImmutableSet.of(ip3)));
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:26,
代码来源:GrpcNbHostServiceTest.java

示例24: testHostRemoved

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Test
public void testHostRemoved() throws Exception {
    Host subject = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED,
            Sets.newHashSet(HOST_LOC11), Sets.newHashSet(HOST_IP11), false);

    // Add a host
    // Expect: add one routing rule and one bridging rule
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, subject));
    assertEquals(1, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertEquals(1, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));

    // Remove the host
    // Expect: add the routing rule and the bridging rule
    hostHandler.processHostRemovedEvent(new HostEvent(HostEvent.Type.HOST_REMOVED, subject));
    assertEquals(0, ROUTING_TABLE.size());
    assertEquals(0, BRIDGING_TABLE.size());
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:20,
代码来源:HostHandlerTest.java

示例25: testDualHomedHostRemoved

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Test
public void testDualHomedHostRemoved() throws Exception {
    // Add a dual-homed host that has 2 locations
    // Expect: add two routing rules and two bridging rules
    Host subject = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED,
            Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP11), false);
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, subject));
    assertEquals(2, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertEquals(2, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV2, HOST_MAC, INTF_VLAN_UNTAGGED)));

    // Remove a dual-homed host that has 2 locations
    // Expect: all routing and bridging rules are removed
    hostHandler.processHostRemovedEvent(new HostEvent(HostEvent.Type.HOST_REMOVED, subject));
    assertEquals(0, ROUTING_TABLE.size());
    assertEquals(0, BRIDGING_TABLE.size());
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:21,
代码来源:HostHandlerTest.java

示例26: appendLocation

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Override
public void appendLocation(HostId hostId, HostLocation location) {
    log.debug("Appending location {} to host {}", location, hostId);
    hosts.compute(hostId, (id, existingHost) -> {
        if (existingHost != null) {
            checkState(Objects.equals(hostId.mac(), existingHost.mac()),
                    "Existing and new MAC addresses differ.");
            checkState(Objects.equals(hostId.vlanId(), existingHost.vlan()),
                    "Existing and new VLANs differ.");

            Set<HostLocation> locations = new HashSet<>(existingHost.locations());
            locations.add(location);

            return new DefaultHost(existingHost.providerId(),
                            hostId, existingHost.mac(), existingHost.vlan(),
                            locations, existingHost.ipAddresses(),
                            existingHost.configured(), existingHost.annotations());
        }
        return null;
    });
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:22,
代码来源:DistributedHostStore.java

示例27: removeLocation

点赞 3

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Override
public void removeLocation(HostId hostId, HostLocation location) {
    log.debug("Removing location {} from host {}", location, hostId);
    hosts.compute(hostId, (id, existingHost) -> {
        if (existingHost != null) {
            checkState(Objects.equals(hostId.mac(), existingHost.mac()),
                    "Existing and new MAC addresses differ.");
            checkState(Objects.equals(hostId.vlanId(), existingHost.vlan()),
                    "Existing and new VLANs differ.");

            Set<HostLocation> locations = new HashSet<>(existingHost.locations());
            locations.remove(location);

            // Remove entire host if we are removing the last location
            return locations.isEmpty() ? null :
                    new DefaultHost(existingHost.providerId(),
                            hostId, existingHost.mac(), existingHost.vlan(),
                            locations, existingHost.ipAddresses(),
                            existingHost.configured(), existingHost.annotations());
        }
        return null;
    });
}
 

开发者ID:opennetworkinglab,
项目名称:onos,
代码行数:24,
代码来源:DistributedHostStore.java

示例28: testFourInterfacesConfiguredHostsPresent

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Checks the case in which six ports are configured with VLANs and four
 * hosts are registered by the HostService. The first three ports have an
 * interface configured on VLAN1, the other three on VLAN2. The number of
 * intents expected is twelve: six for VLAN1, six for VLAN2. six sp2mp
 * intents, six mp2sp intents. For VLAN1 IPs are added to demonstrate it
 * doesn't influence the number of intents created.
 */
@Test
public void testFourInterfacesConfiguredHostsPresent() {
    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
                              Collections.singleton(IP1));
    Host h2 = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(2),
                              Collections.singleton(IP2));
    Host h3 = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(3),
                              Collections.EMPTY_SET);
    Host h4 = new DefaultHost(PID, HID4, MAC4, VLAN2, getLocation(4),
                              Collections.EMPTY_SET);
    Host h5 = new DefaultHost(PID, HID5, MAC5, VLAN2, getLocation(5),
                              Collections.EMPTY_SET);
    Host h6 = new DefaultHost(PID, HID6, MAC6, VLAN2, getLocation(6),
                              Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h2, h3, h4, h5, h6));

    vpls.activate();

    List<Intent> expectedIntents = new ArrayList<>();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanOneUni());
    expectedIntents.addAll(generateVlanTwoBrc());
    expectedIntents.addAll(generateVlanTwoUni());

    checkIntents(expectedIntents);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:35,
代码来源:VplsTest.java

示例29: createHost

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
private Host createHost(MacAddress macAddress, ConnectPoint location) {
    return new DefaultHost(
            new ProviderId("host", "org.onosproject.segmentrouting"),
            HostId.hostId(macAddress),
            macAddress,
            VlanId.NONE,
            new HostLocation(location, System.currentTimeMillis()),
            ImmutableSet.of());
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:10,
代码来源:CordConfigHandler.java

示例30: getHost

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Override
public Host getHost(HostId hostId) {
    ProviderId providerId = ProviderId.NONE;
    MacAddress mac =  MacAddress.valueOf("fa:12:3e:56:ee:a2");
    VlanId vlan = VlanId.NONE;
    HostLocation location =  HostLocation.NONE;
    Set<IpAddress> ips = Sets.newHashSet();
    Annotations annotations = null;
    return new DefaultHost(providerId, hostId, mac, vlan, location, ips, annotations);
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:11,
代码来源:HostServiceAdapter.java

示例31: testReplyKnownIpv6

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Tests {@link ProxyArpManager#reply(Ethernet, ConnectPoint)} in the case where the
 * destination host is known.
 * Verifies the correct NDP reply is sent out the correct port.
 */
@Test
public void testReplyKnownIpv6() {
    Host replyer = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(4),
                                   Collections.singleton(IP3));

    Host requestor = new DefaultHost(PID, HID4, MAC4, VLAN1, getLocation(5),
                                     Collections.singleton(IP4));

    expect(hostService.getHostsByIp(IP3))
            .andReturn(Collections.singleton(replyer));
    expect(hostService.getHost(HID4)).andReturn(requestor);

    replay(hostService);
    replay(interfaceService);

    Ethernet ndpRequest = buildNdp(ICMP6.NEIGHBOR_SOLICITATION,
            MAC4, SOLICITED_MAC3,
            IP4, IP3);

    proxyArp.reply(ndpRequest, getLocation(5));

    assertEquals(1, packetService.packets.size());
    Ethernet ndpReply = buildNdp(ICMP6.NEIGHBOR_ADVERTISEMENT,
            MAC3, MAC4, IP3, IP4);
    verifyPacketOut(ndpReply, getLocation(5), packetService.packets.get(0));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:32,
代码来源:ProxyArpManagerTest.java

示例32: testReplyToRequestForUs

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
/**
 * Test ARP request from external network to an internal host.
 */
@Test
public void testReplyToRequestForUs() {
    Ip4Address theirIp = Ip4Address.valueOf("10.0.1.254");
    Ip4Address ourFirstIp = Ip4Address.valueOf("10.0.1.1");
    Ip4Address ourSecondIp = Ip4Address.valueOf("10.0.2.1");
    MacAddress firstMac = MacAddress.valueOf(1L);
    MacAddress secondMac = MacAddress.valueOf(2L);

    Host requestor = new DefaultHost(PID, HID1, MAC1, VLAN1, LOC1,
            Collections.singleton(theirIp));

    expect(hostService.getHost(HID1)).andReturn(requestor);
    replay(hostService);
    replay(interfaceService);

    Ethernet arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, theirIp, ourFirstIp);

    proxyArp.reply(arpRequest, LOC1);

    assertEquals(1, packetService.packets.size());
    Ethernet arpReply = buildArp(ARP.OP_REPLY, VLAN1, firstMac, MAC1, ourFirstIp, theirIp);
    verifyPacketOut(arpReply, LOC1, packetService.packets.get(0));

    // Test a request for the second address on that port
    packetService.packets.clear();
    arpRequest = buildArp(ARP.OP_REQUEST, VLAN1, MAC1, null, theirIp, ourSecondIp);

    proxyArp.reply(arpRequest, LOC1);

    assertEquals(1, packetService.packets.size());
    arpReply = buildArp(ARP.OP_REPLY, VLAN1, secondMac, MAC1, ourSecondIp, theirIp);
    verifyPacketOut(arpReply, LOC1, packetService.packets.get(0));
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:37,
代码来源:ProxyArpManagerTest.java

示例33: shouldUpdate

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
private boolean shouldUpdate(DefaultHost existingHost,
                             ProviderId providerId,
                             HostId hostId,
                             HostDescription hostDescription,
                             boolean replaceIPs) {
    if (existingHost == null) {
        return true;
    }

    if (!Objects.equals(existingHost.providerId(), providerId) ||
            !Objects.equals(existingHost.mac(), hostDescription.hwAddress()) ||
            !Objects.equals(existingHost.vlan(), hostDescription.vlan()) ||
            !Objects.equals(existingHost.location(), hostDescription.location())) {
        return true;
    }

    if (replaceIPs) {
        if (!Objects.equals(hostDescription.ipAddress(),
                            existingHost.ipAddresses())) {
            return true;
        }
    } else {
        if (!existingHost.ipAddresses().containsAll(hostDescription.ipAddress())) {
            return true;
        }
    }

    // check to see if any of the annotations provided by hostDescription
    // differ from those in the existing host
    return hostDescription.annotations().keys().stream()
                .anyMatch(k -> !Objects.equals(hostDescription.annotations().value(k),
                                               existingHost.annotations().value(k)));


}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:36,
代码来源:DistributedHostStore.java

示例34: createOrUpdateHost

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Override
public HostEvent createOrUpdateHost(ProviderId providerId,
                                    HostId hostId,
                                    HostDescription hostDescription,
                                    boolean replaceIPs) {
    hostsConsistentMap.computeIf(hostId,
                   existingHost -> shouldUpdate(existingHost, providerId, hostId,
                                                hostDescription, replaceIPs),
                   (id, existingHost) -> {
                       HostLocation location = hostDescription.location();

                       final Set<IpAddress> addresses;
                       if (existingHost == null || replaceIPs) {
                           addresses = ImmutableSet.copyOf(hostDescription.ipAddress());
                       } else {
                           addresses = Sets.newHashSet(existingHost.ipAddresses());
                           addresses.addAll(hostDescription.ipAddress());
                       }

                       final Annotations annotations;
                       if (existingHost != null) {
                           annotations = merge((DefaultAnnotations) existingHost.annotations(),
                                   hostDescription.annotations());
                       } else {
                           annotations = hostDescription.annotations();
                       }

                       return new DefaultHost(providerId,
                                              hostId,
                                              hostDescription.hwAddress(),
                                              hostDescription.vlan(),
                                              location,
                                              addresses,
                                              annotations);
                   });
    return null;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:38,
代码来源:DistributedHostStore.java

示例35: removeIp

点赞 2

import org.onosproject.net.DefaultHost; //导入依赖的package包/类
@Override
public HostEvent removeIp(HostId hostId, IpAddress ipAddress) {
    hosts.compute(hostId, (id, existingHost) -> {
        if (existingHost != null) {
            checkState(Objects.equals(hostId.mac(), existingHost.mac()),
                    "Existing and new MAC addresses differ.");
            checkState(Objects.equals(hostId.vlanId(), existingHost.vlan()),
                    "Existing and new VLANs differ.");

            Set<IpAddress> addresses = existingHost.ipAddresses();
            if (addresses != null && addresses.contains(ipAddress)) {
                addresses = new HashSet<>(existingHost.ipAddresses());
                addresses.remove(ipAddress);
                return new DefaultHost(existingHost.providerId(),
                        hostId,
                        existingHost.mac(),
                        existingHost.vlan(),
                        existingHost.location(),
                        ImmutableSet.copyOf(addresses),
                        existingHost.annotations());
            } else {
                return existingHost;
            }
        }
        return null;
    });
    return null;
}
 

开发者ID:shlee89,
项目名称:athena,
代码行数:29,
代码来源:DistributedHostStore.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)