Search in sources :

Example 71 with DeviceId

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

the class ControlMessageEventTest method createControlMessages.

private Set<ControlMessage> createControlMessages() {
    final DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
    Set<ControlMessage> controlMessages = Sets.newConcurrentHashSet();
    controlMessages.add(createControlMessage(INBOUND_PACKET, deviceId));
    controlMessages.add(createControlMessage(OUTBOUND_PACKET, deviceId));
    return controlMessages;
}
Also used : DeviceId(org.onosproject.net.DeviceId) ControlMessage(org.onosproject.cpman.ControlMessage) DefaultControlMessage(org.onosproject.cpman.DefaultControlMessage)

Example 72 with DeviceId

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

the class DefaultControlMessageTest method testBasic.

/**
 * Tests creation of a DefaultControlMessage using a regular constructor.
 */
@Test
public void testBasic() {
    final DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
    final DefaultControlMessage cm = new DefaultControlMessage(INBOUND_PACKET, deviceId, 0L, 1L, 2L, 3L);
    assertThat(cm.type(), is(INBOUND_PACKET));
    assertThat(cm.load(), is(0L));
    assertThat(cm.rate(), is(1L));
    assertThat(cm.count(), is(2L));
    assertThat(cm.timestamp(), is(3L));
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultControlMessage(org.onosproject.cpman.DefaultControlMessage) Test(org.junit.Test)

Example 73 with DeviceId

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

the class GnpyManager method obtainConnectivity.

@Override
public Pair<IntentId, Double> obtainConnectivity(ConnectPoint ingress, ConnectPoint egress, boolean bidirectional) {
    ByteArrayOutputStream connectivityRequest = createGnpyRequest(ingress, egress, bidirectional);
    String response = gnpyHttpUtil.post(null, "/gnpy-experimental", new ByteArrayInputStream(connectivityRequest.toByteArray()), MediaType.APPLICATION_JSON_TYPE, String.class);
    ObjectMapper om = new ObjectMapper();
    final ObjectReader reader = om.reader();
    JsonNode jsonNode;
    try {
        jsonNode = reader.readTree(response);
        if (jsonNode == null) {
            log.error("JsonNode is null for response {}", response);
            return null;
        }
        log.info("Response {}", response);
        String bestPath;
        try {
            bestPath = getBestOsnrPathKey(jsonNode);
        } catch (IllegalStateException e) {
            log.error("Exception while contacting GNPy", e);
            return null;
        }
        OchSignal ochSignal = createOchSignal(jsonNode);
        Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
        Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
        // TODO this list is currently only populated in the forward direction
        List<DeviceId> deviceIds = getDeviceAndPopulatePowerMap(jsonNode, deviceAtoBPowerMap, deviceBtoAPowerMap, bestPath);
        Path suggestedPath = createSuggestedPath(deviceIds);
        log.info("Suggested path {}", suggestedPath);
        Intent intent = createOpticalIntent(ingress, egress, deviceService, null, appId, bidirectional, ochSignal, suggestedPath);
        intentsPowerMap.put(intent.id(), new GnpyPowerInfo(deviceAtoBPowerMap, deviceBtoAPowerMap, getLaunchPower(jsonNode), suggestedPath.links(), ingress, egress, ochSignal));
        intentService.submit(intent);
        return Pair.of(intent.id(), getOsnr(jsonNode, bestPath));
    } catch (IOException e) {
        log.error("Exception while reading response {}", response, e);
        return null;
    }
}
Also used : Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) OchSignal(org.onosproject.net.OchSignal) JsonNode(com.fasterxml.jackson.databind.JsonNode) OpticalIntentUtility.createOpticalIntent(org.onosproject.net.optical.util.OpticalIntentUtility.createOpticalIntent) Intent(org.onosproject.net.intent.Intent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 74 with DeviceId

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

the class DcsBasedTapiDataProducer method getNodes.

/**
 * Extract Tapi Nodes from context modelObject and convert them to NodeRefs.
 *
 * @param context
 * @return List of NodeRef
 */
private List<TapiNodeRef> getNodes(DefaultContext context) {
    DefaultAugmentedTapiCommonContext topologyContext = context.augmentation(DefaultAugmentedTapiCommonContext.class);
    Topology topology = topologyContext.topologyContext().topology().get(0);
    if (topology.node() == null) {
        return Collections.emptyList();
    }
    return topology.node().stream().map(node -> {
        TapiNodeRef nodeRef = DcsBasedTapiObjectRefFactory.create(topology, node);
        if (node.name() != null) {
            String deviceId = node.name().stream().filter(kv -> kv.valueName().equals(DEVICE_ID)).findFirst().map(Name::value).get();
            nodeRef.setDeviceId(DeviceId.deviceId(deviceId));
        }
        return nodeRef;
    }).collect(Collectors.toList());
}
Also used : DcsBasedTapiObjectRefFactory(org.onosproject.odtn.utils.tapi.DcsBasedTapiObjectRefFactory) HashMap(java.util.HashMap) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) ResourceData(org.onosproject.yang.model.ResourceData) ConnectPoint(org.onosproject.net.ConnectPoint) DataNode(org.onosproject.yang.model.DataNode) Map(java.util.Map) DynamicConfigService(org.onosproject.config.DynamicConfigService) Name(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name) DefaultServiceDirectory.getService(org.onlab.osgi.DefaultServiceDirectory.getService) Logger(org.slf4j.Logger) DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) ModelConverter(org.onosproject.yang.model.ModelConverter) ModelObjectId(org.onosproject.yang.model.ModelObjectId) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext) Collectors(java.util.stream.Collectors) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) ResourceId(org.onosproject.yang.model.ResourceId) DefaultAugmentedTapiTopologyOwnedNodeEdgePoint(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.topologycontext.topology.node.ownednodeedgepoint.DefaultAugmentedTapiTopologyOwnedNodeEdgePoint) List(java.util.List) CONNECTION_ID(org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID) ModelObjectData(org.onosproject.yang.model.ModelObjectData) Topology(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology) ODTN_PORT_TYPE(org.onosproject.odtn.utils.tapi.TapiObjectHandler.ODTN_PORT_TYPE) DEVICE_ID(org.onosproject.odtn.utils.tapi.TapiObjectHandler.DEVICE_ID) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Filter(org.onosproject.config.Filter) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) ONOS_CP(org.onosproject.odtn.utils.tapi.TapiObjectHandler.ONOS_CP) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) Topology(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology) Name(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name)

Example 75 with DeviceId

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

the class GnpyManagerTest method testCreateSuggestedPath.

@Test
public void testCreateSuggestedPath() throws IOException {
    Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
    Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
    List<DeviceId> deviceIds = manager.getDeviceAndPopulatePowerMap(reply, deviceAtoBPowerMap, deviceBtoAPowerMap, "second");
    Path path = manager.createSuggestedPath(deviceIds);
    assertTrue(path.links().contains(tx1rdm1Link));
    assertTrue(path.links().contains(rmd1ln1Link));
    assertTrue(path.links().contains(ln1ln2Link));
    assertTrue(path.links().contains(ln2rdm2Link));
    assertTrue(path.links().contains(tx2rmd2Link));
    assertEquals(path.src(), tx2);
    assertEquals(path.dst(), tx1);
}
Also used : Path(org.onosproject.net.Path) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) Test(org.junit.Test)

Aggregations

DeviceId (org.onosproject.net.DeviceId)782 List (java.util.List)178 PortNumber (org.onosproject.net.PortNumber)170 Collectors (java.util.stream.Collectors)152 ConnectPoint (org.onosproject.net.ConnectPoint)152 Set (java.util.Set)138 DeviceService (org.onosproject.net.device.DeviceService)122 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)118 ArrayList (java.util.ArrayList)115 VlanId (org.onlab.packet.VlanId)115 Logger (org.slf4j.Logger)114 Collections (java.util.Collections)109 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)109 Device (org.onosproject.net.Device)107 Collection (java.util.Collection)106 Test (org.junit.Test)104 CoreService (org.onosproject.core.CoreService)103 FlowRule (org.onosproject.net.flow.FlowRule)101 ImmutableSet (com.google.common.collect.ImmutableSet)99 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)96