Search in sources :

Example 6 with HostId

use of org.onosproject.net.HostId in project onos by opennetworkinglab.

the class UiTopologyTest method mockTopology.

@Test
public void mockTopology() {
    host = new DefaultHost(PID, HID, MAC_ADDRESS, VID, LOC, IPSET);
    uiHost = new UiHost(topo, host);
    deviceLink = new UiDeviceLink(topo, DX1_DY2);
    edgeLink = DefaultEdgeLink.createEdgeLink(CP, true);
    linkId = UiLinkId.uiLinkId(edgeLink);
    uiEdgeLink = new UiEdgeLink(topo, linkId);
    mem1 = clusterMember(MID, 001);
    region1 = region();
    dev1 = device();
    Set<DeviceId> deviceIds = new HashSet<>();
    Set<HostId> hostIds = new HashSet<>();
    topo.add(uiHost);
    topo.add(mem1);
    topo.add(region1);
    topo.add(dev1);
    topo.add(deviceLink);
    topo.add(uiEdgeLink);
    assertTrue(topo.allRegions().contains(region1));
    assertTrue(topo.allClusterMembers().contains(mem1));
    assertTrue(topo.findClusterMember(NodeId.nodeId("id1")).equals(mem1));
    assertTrue(topo.findRegion(R1).equals(region1));
    assertTrue(topo.findDevice(DID).equals(dev1));
    assertTrue(topo.findHost(HID).equals(uiHost));
    assertTrue(topo.findDeviceLink(DX1_DY2).equals(deviceLink));
    deviceIds.add(DID);
    assertTrue(topo.deviceSet(deviceIds).contains(dev1));
    hostIds.add(HID);
    assertTrue(topo.hostSet(hostIds).contains(uiHost));
    topo.clear();
    assertThat(topo.allClusterMembers(), is(empty()));
    assertThat(topo.allDeviceLinks(), is(empty()));
    assertThat(topo.allDevices(), is(empty()));
    assertThat(topo.allHosts(), is(empty()));
    assertThat(topo.allRegions(), is(empty()));
}
Also used : DefaultHost(org.onosproject.net.DefaultHost) DeviceId(org.onosproject.net.DeviceId) HostId(org.onosproject.net.HostId) HashSet(java.util.HashSet) Test(org.junit.Test) AbstractUiModelTest(org.onosproject.ui.model.AbstractUiModelTest)

Example 7 with HostId

use of org.onosproject.net.HostId in project onos by opennetworkinglab.

the class IntentMonitorAndRerouteManager method applyPath.

@Override
public boolean applyPath(Route route) {
    checkNotNull(route, "Route to apply must be not null");
    checkNotNull(route.appId(), "Application id must be not null");
    checkNotNull(route.key(), "Intent key to apply must be not null");
    checkNotNull(route.paths(), "New path must be not null");
    checkArgument(route.paths().size() >= 1);
    ApplicationId appId = route.appId();
    Key key = route.key();
    // check if the app and the intent key are monitored
    if (!monitoredIntents.containsKey(appId)) {
        return false;
    }
    if (!monitoredIntents.get(appId).containsKey(key)) {
        return false;
    }
    // TODO: now we manage only the unsplittable routing
    Path currentPath = route.paths().stream().max(Comparator.comparing(Path::weight)).get();
    // in this case remove them from the list
    if (currentPath.path().get(0) instanceof HostId) {
        currentPath.path().remove(0);
    }
    if (currentPath.path().get(currentPath.path().size() - 1) instanceof HostId) {
        currentPath.path().remove(currentPath.path().size() - 1);
    }
    List<Link> links = createPathFromDeviceList(currentPath.path());
    // Generate the new Link collection intent, if not possible it will return the old intent
    ConnectivityIntent intent = generateLinkCollectionIntent(links, key, appId);
    storeMonitoredIntent(intent);
    intentService.submit(intent);
    return true;
}
Also used : Path(org.onosproject.imr.data.Path) ApplicationId(org.onosproject.core.ApplicationId) HostId(org.onosproject.net.HostId) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Key(org.onosproject.net.intent.Key) Link(org.onosproject.net.Link)

Example 8 with HostId

use of org.onosproject.net.HostId in project onos by opennetworkinglab.

the class PathManagerTest method edgeToEdgeDirect.

@Test
public void edgeToEdgeDirect() {
    HostId src = hid("12:34:56:78:90:ab/1");
    HostId dst = hid("12:34:56:78:90:ef/1");
    fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge"));
    fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "edge"));
    Set<Path> paths = service.getPaths(src, dst);
    validatePaths(paths, 1, 2, src, dst);
    validatePaths(service.getKShortestPaths(src, dst).collect(Collectors.toSet()), 1, 2, src, dst);
}
Also used : Path(org.onosproject.net.Path) HostId(org.onosproject.net.HostId) Test(org.junit.Test)

Example 9 with HostId

use of org.onosproject.net.HostId in project onos by opennetworkinglab.

the class PathManagerTest method edgeToInfra.

@Test
public void edgeToInfra() {
    HostId src = hid("12:34:56:78:90:ab/1");
    DeviceId dst = did("dst");
    fakeTopoMgr.paths.add(createPath("edge", "middle", "dst"));
    fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "edge"));
    Set<Path> paths = service.getPaths(src, dst);
    validatePaths(paths, 1, 3, src, dst);
}
Also used : Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) HostId(org.onosproject.net.HostId) Test(org.junit.Test)

Example 10 with HostId

use of org.onosproject.net.HostId in project onos by opennetworkinglab.

the class PathManagerTest method edgeToEdge.

@Test
public void edgeToEdge() {
    HostId src = hid("12:34:56:78:90:ab/1");
    HostId dst = hid("12:34:56:78:90:ef/1");
    fakeTopoMgr.paths.add(createPath("srcEdge", "middle", "dstEdge"));
    fakeHostMgr.hosts.put(src, host("12:34:56:78:90:ab/1", "srcEdge"));
    fakeHostMgr.hosts.put(dst, host("12:34:56:78:90:ef/1", "dstEdge"));
    Set<Path> paths = service.getPaths(src, dst);
    validatePaths(paths, 1, 4, src, dst);
    validatePaths(service.getKShortestPaths(src, dst).collect(Collectors.toSet()), 1, 4, src, dst);
}
Also used : Path(org.onosproject.net.Path) HostId(org.onosproject.net.HostId) Test(org.junit.Test)

Aggregations

HostId (org.onosproject.net.HostId)86 IpAddress (org.onlab.packet.IpAddress)27 DeviceId (org.onosproject.net.DeviceId)24 VlanId (org.onlab.packet.VlanId)23 HostLocation (org.onosproject.net.HostLocation)23 MacAddress (org.onlab.packet.MacAddress)21 Test (org.junit.Test)18 ConnectPoint (org.onosproject.net.ConnectPoint)17 Host (org.onosproject.net.Host)17 HostDescription (org.onosproject.net.host.HostDescription)16 DefaultHostDescription (org.onosproject.net.host.DefaultHostDescription)14 Set (java.util.Set)13 DhcpRecord (org.onosproject.dhcprelay.store.DhcpRecord)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)11 HashSet (java.util.HashSet)11 Logger (org.slf4j.Logger)11 ImmutableSet (com.google.common.collect.ImmutableSet)10 Device (org.onosproject.net.Device)10 Path (org.onosproject.net.Path)10 LoggerFactory (org.slf4j.LoggerFactory)10