Search in sources :

Example 11 with HostDescription

use of org.onosproject.net.host.HostDescription in project onos by opennetworkinglab.

the class NetworkConfigHostProvider method updateHost.

/**
 * Updates host information.
 * IP information will be replaced if host exists.
 *
 * @param mac MAC address of the host
 * @param vlan VLAN ID of the host
 * @param locations Location of the host
 * @param ips Set of IP addresses of the host
 */
protected void updateHost(MacAddress mac, VlanId vlan, Set<HostLocation> locations, Set<IpAddress> ips) {
    HostId hid = HostId.hostId(mac, vlan);
    HostDescription desc = new DefaultHostDescription(mac, vlan, locations, ips, true);
    providerService.hostDetected(hid, desc, true);
}
Also used : DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostId(org.onosproject.net.HostId) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostDescription(org.onosproject.net.host.HostDescription)

Example 12 with HostDescription

use of org.onosproject.net.host.HostDescription in project onos by opennetworkinglab.

the class NetworkConfigHostProvider method updateHost.

/**
 * Updates host information.
 * IP information will be replaced if host exists.
 *
 * @param mac       MAC address of the host
 * @param vlan      VLAN ID of the host
 * @param locations Locations of the host
 * @param auxLocations auxiliary locations of the host
 * @param ips       Set of IP addresses of the host
 * @param innerVlan host inner VLAN identifier
 * @param outerTpid outer TPID of a host
 */
protected void updateHost(MacAddress mac, VlanId vlan, Set<HostLocation> locations, Set<HostLocation> auxLocations, Set<IpAddress> ips, VlanId innerVlan, EthType outerTpid) {
    HostId hid = HostId.hostId(mac, vlan);
    HostDescription desc = new DefaultHostDescription(mac, vlan, locations, auxLocations, ips, innerVlan, outerTpid, true);
    providerService.hostDetected(hid, desc, true);
}
Also used : DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostId(org.onosproject.net.HostId) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostDescription(org.onosproject.net.host.HostDescription)

Example 13 with HostDescription

use of org.onosproject.net.host.HostDescription in project onos by opennetworkinglab.

the class NetworkConfigHostProvider method addHost.

/**
 * Adds host information.
 * IP information will be appended if host exists.
 *
 * @param mac       MAC address of the host
 * @param vlan      VLAN ID of the host
 * @param locations Locations of the host
 * @param auxLocations auxiliary locations of the host
 * @param ips       Set of IP addresses of the host
 * @param innerVlan host inner VLAN identifier
 * @param outerTpid outer TPID of a host
 */
protected void addHost(MacAddress mac, VlanId vlan, Set<HostLocation> locations, Set<HostLocation> auxLocations, Set<IpAddress> ips, VlanId innerVlan, EthType outerTpid) {
    HostId hid = HostId.hostId(mac, vlan);
    HostDescription desc = (ips != null) ? new DefaultHostDescription(mac, vlan, locations, auxLocations, ips, innerVlan, outerTpid, true) : new DefaultHostDescription(mac, vlan, locations, auxLocations, Collections.emptySet(), innerVlan, outerTpid, true);
    providerService.hostDetected(hid, desc, true);
}
Also used : DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostId(org.onosproject.net.HostId) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostDescription(org.onosproject.net.host.HostDescription)

Example 14 with HostDescription

use of org.onosproject.net.host.HostDescription in project onos by opennetworkinglab.

the class HostLocationProviderTest method receiveRs.

/**
 * When receiving RouterSolicitation, update location and IP.
 */
@Test
public void receiveRs() {
    testProcessor.process(new TestRSPacketContext(DEV4));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat("receiveRs. No host description expected", providerService.descriptions.size(), is(1)));
    final HostDescription desc = providerService.descriptions.get(0);
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(desc.location(), is(LOCATION2)));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(desc.hwAddress(), is(MAC2)));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(desc.ipAddress().toArray()[0], is(IP_ADDRESS2)));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(desc.vlan(), is(VLAN)));
}
Also used : HostDescription(org.onosproject.net.host.HostDescription) Test(org.junit.Test)

Example 15 with HostDescription

use of org.onosproject.net.host.HostDescription in project onos by opennetworkinglab.

the class HostLocationProviderTest method receiveNs.

/**
 * When receiving NeighborSolicitation, updates location and IP.
 */
@Test
public void receiveNs() {
    testProcessor.process(new TestNsPacketContext(DEV4));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat("receiveNs. One host description expected", providerService.descriptions.size(), is(1)));
    HostDescription descr = providerService.descriptions.get(0);
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(descr.location(), is(LOCATION2)));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(descr.hwAddress(), is(MAC2)));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(descr.ipAddress().toArray()[0], is(IP_ADDRESS2)));
    TestTools.assertAfter(ASSERTION_DELAY, () -> assertThat(descr.vlan(), is(VLAN)));
}
Also used : HostDescription(org.onosproject.net.host.HostDescription) Test(org.junit.Test)

Aggregations

HostDescription (org.onosproject.net.host.HostDescription)29 Test (org.junit.Test)19 DefaultHostDescription (org.onosproject.net.host.DefaultHostDescription)16 HostId (org.onosproject.net.HostId)12 IpAddress (org.onlab.packet.IpAddress)8 HostLocation (org.onosproject.net.HostLocation)8 Host (org.onosproject.net.Host)7 MacAddress (org.onlab.packet.MacAddress)4 VlanId (org.onlab.packet.VlanId)4 DeviceEvent (org.onosproject.net.device.DeviceEvent)4 HashSet (java.util.HashSet)3 ConnectPoint (org.onosproject.net.ConnectPoint)3 DefaultHost (org.onosproject.net.DefaultHost)3 InterfaceIpAddress (org.onosproject.net.host.InterfaceIpAddress)3 Strings (com.google.common.base.Strings)2 Set (java.util.Set)2 ExecutorService (java.util.concurrent.ExecutorService)2 Executors (java.util.concurrent.Executors)2 Collectors (java.util.stream.Collectors)2 Tools (org.onlab.util.Tools)2