use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class TopologyMutationDriver method repairDevice.
/**
* Repairs the specified device.
*
* @param deviceId device identifier
*/
void repairDevice(DeviceId deviceId) {
// device IDs are expressed in hexadecimal... (use radix 16)
int chassisId = Integer.parseInt(deviceId.uri().getSchemeSpecificPart(), 16);
simulator.createDevice(deviceId, chassisId);
Set<Link> links = savedLinks.remove(deviceId);
if (links != null) {
links.forEach(l -> linkProviderService.linkDetected(new DefaultLinkDescription(l.src(), l.dst(), DIRECT)));
}
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class SimpleLinkStore method createOrUpdateLinkDescription.
// Guarded by linkDescs value (=locking each Link)
private LinkDescription createOrUpdateLinkDescription(Map<ProviderId, LinkDescription> descs, ProviderId providerId, LinkDescription linkDescription) {
// merge existing attributes and merge
LinkDescription oldDesc = descs.get(providerId);
LinkDescription newDesc = linkDescription;
if (oldDesc != null) {
// we only allow transition from INDIRECT -> DIRECT
final Type newType;
if (oldDesc.type() == DIRECT) {
newType = DIRECT;
} else {
newType = linkDescription.type();
}
SparseAnnotations merged = union(oldDesc.annotations(), linkDescription.annotations());
newDesc = new DefaultLinkDescription(linkDescription.src(), linkDescription.dst(), newType, merged);
}
return descs.put(providerId, newDesc);
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testCreateOrUpdateLink.
@Test
public final void testCreateOrUpdateLink() {
ConnectPoint src = new ConnectPoint(DID1, P1);
ConnectPoint dst = new ConnectPoint(DID2, P2);
// add link
LinkEvent event = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, INDIRECT));
assertLink(DID1, P1, DID2, P2, INDIRECT, event.subject());
assertEquals(LINK_ADDED, event.type());
// update link type
LinkEvent event2 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
assertLink(DID1, P1, DID2, P2, DIRECT, event2.subject());
assertEquals(LINK_UPDATED, event2.type());
// no change
LinkEvent event3 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
assertNull("No change event expected", event3);
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method putLink.
private void putLink(DeviceId srcId, PortNumber srcNum, DeviceId dstId, PortNumber dstNum, Type type, boolean isDurable, SparseAnnotations... annotations) {
ConnectPoint src = new ConnectPoint(srcId, srcNum);
ConnectPoint dst = new ConnectPoint(dstId, dstNum);
linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, type, annotations));
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class SimpleLinkStoreTest method testAncillaryVisible.
@Test
public final void testAncillaryVisible() {
ConnectPoint src = new ConnectPoint(DID1, P1);
ConnectPoint dst = new ConnectPoint(DID2, P2);
// add Ancillary link
linkStore.createOrUpdateLink(PIDA, new DefaultLinkDescription(src, dst, INDIRECT, A1));
// Ancillary only link should not be visible
assertEquals(1, linkStore.getLinkCount());
assertNotNull(linkStore.getLink(src, dst));
}
Aggregations