use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class HostResourceTest method testHostsArray.
/**
* Tests the result of the rest api GET when hosts are defined.
*/
@Test
public void testHostsArray() {
replay(mockHostService);
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);
final MacAddress mac2 = MacAddress.valueOf("00:00:11:00:00:02");
final Set<IpAddress> ips2 = ImmutableSet.of(IpAddress.valueOf("2222:2222:2222:1::"), IpAddress.valueOf("2222:2222:2222:2::"));
final Host host2 = new DefaultHost(pid, HostId.hostId(mac2), valueOf(2), vlanId((short) 2), new HostLocation(DeviceId.deviceId("2"), portNumber(22), 2), ips2);
hosts.add(host1);
hosts.add(host2);
WebTarget wt = target();
String response = wt.path("hosts").request().get(String.class);
assertThat(response, containsString("{\"hosts\":["));
final JsonObject result = Json.parse(response).asObject();
assertThat(result, notNullValue());
assertThat(result.names(), hasSize(1));
assertThat(result.names().get(0), is("hosts"));
final JsonArray hosts = result.get("hosts").asArray();
assertThat(hosts, notNullValue());
assertThat(hosts, hasHost(host1));
assertThat(hosts, hasHost(host2));
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class ECLinkStore method composeLink.
private Link composeLink(LinkKey linkKey) {
ProviderId baseProviderId = getBaseProviderId(linkKey);
if (baseProviderId == null) {
// parent component.
return null;
}
LinkDescription base = linkDescriptions.get(new Provided<>(linkKey, baseProviderId));
// short circuit if link description no longer exists
if (base == null) {
return null;
}
ConnectPoint src = base.src();
ConnectPoint dst = base.dst();
Type type = base.type();
DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
builder.putAll(base.annotations());
getAllProviders(linkKey).stream().map(p -> new Provided<>(linkKey, p)).forEach(key -> {
LinkDescription linkDescription = linkDescriptions.get(key);
if (linkDescription != null) {
builder.putAll(linkDescription.annotations());
}
});
DefaultAnnotations annotations = builder.build();
Link.State initialLinkState;
boolean isExpected;
if (linkDiscoveryMode == LinkDiscoveryMode.PERMISSIVE) {
initialLinkState = ACTIVE;
isExpected = Objects.equals(annotations.value(AnnotationKeys.DURABLE), "true");
} else {
initialLinkState = base.isExpected() ? ACTIVE : INACTIVE;
isExpected = base.isExpected();
}
return DefaultLink.builder().providerId(baseProviderId).src(src).dst(dst).type(type).state(initialLinkState).isExpected(isExpected).annotations(annotations).build();
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class ECLinkStore method injectLink.
private LinkEvent injectLink(Provided<LinkDescription> linkInjectRequest) {
log.trace("Received request to inject link {}", linkInjectRequest);
ProviderId providerId = linkInjectRequest.providerId();
LinkDescription linkDescription = linkInjectRequest.key();
final DeviceId deviceId = linkDescription.dst().deviceId();
if (!deviceClockService.isTimestampAvailable(deviceId)) {
// workaround for ONOS-1208
log.warn("Not ready to accept update. Dropping {}", linkInjectRequest);
return null;
}
return createOrUpdateLink(providerId, linkDescription);
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class DefaultTunnelTest method testEquality.
@Test
public void testEquality() {
TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
GroupId groupId = new GroupId(92034);
TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
TunnelId tunnelId = TunnelId.valueOf("41654654");
ProviderId producerName1 = new ProviderId("producer1", "13");
ProviderId producerName2 = new ProviderId("producer2", "13");
Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
Tunnel p2 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
Tunnel p3 = new DefaultTunnel(producerName2, src, dst, Tunnel.Type.OCH, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3).testEquals();
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class TunnelEventTest method testConstructor.
/**
* Checks the operation of equals(), hashCode() and toString() methods.
*/
@Test
public void testConstructor() {
TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
GroupId groupId = new GroupId(92034);
TunnelName tunnelName = TunnelName.tunnelName("TunnelName");
TunnelId tunnelId = TunnelId.valueOf("41654654");
ProviderId producerName1 = new ProviderId("producer1", "13");
Tunnel p1 = new DefaultTunnel(producerName1, src, dst, Tunnel.Type.VXLAN, Tunnel.State.ACTIVE, groupId, tunnelId, tunnelName, null);
TunnelEvent e1 = new TunnelEvent(TunnelEvent.Type.TUNNEL_ADDED, p1);
assertThat(e1, is(notNullValue()));
assertThat(e1.type(), is(TunnelEvent.Type.TUNNEL_ADDED));
assertThat(e1.subject(), is(p1));
}
Aggregations