Search in sources :

Example 26 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class LumentumRoadmDiscovery method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    // TODO get device description
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    DeviceId deviceId = handler().data().deviceId();
    Device device = deviceService.getDevice(deviceId);
    return new DefaultDeviceDescription(device.id().uri(), Device.Type.ROADM, "Lumentum", "SDN ROADM", "1.0", "v1", device.chassisId(), (SparseAnnotations) device.annotations());
}
Also used : DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceService(org.onosproject.net.device.DeviceService)

Example 27 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class LumentumSdnRoadmFlowRuleProgrammable method removeFlowRules.

@Override
public Collection<FlowRule> removeFlowRules(Collection<FlowRule> rules) {
    try {
        snmp = new LumentumSnmpDevice(data().deviceId());
    } catch (IOException e) {
        log.error("Failed to connect to device: ", e);
    }
    // Line ports
    DeviceService deviceService = this.handler().get(DeviceService.class);
    List<Port> ports = deviceService.getPorts(data().deviceId());
    List<PortNumber> linePorts = ports.subList(ports.size() - 2, ports.size()).stream().map(p -> p.number()).collect(Collectors.toList());
    // Apply the valid rules on the device
    Collection<FlowRule> removed = rules.stream().map(r -> new CrossConnectFlowRule(r, linePorts)).filter(xc -> removeCrossConnect(xc)).collect(Collectors.toList());
    // Remove flow rule from cache
    CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
    removed.forEach(xc -> cache.remove(Objects.hash(data().deviceId(), xc.selector(), xc.treatment())));
    return removed;
}
Also used : GridType(org.onosproject.net.GridType) Arrays(java.util.Arrays) FlowRuleProgrammable(org.onosproject.net.flow.FlowRuleProgrammable) TreeEvent(org.snmp4j.util.TreeEvent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) FlowEntry(org.onosproject.net.flow.FlowEntry) PDU(org.snmp4j.PDU) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) VariableBinding(org.snmp4j.smi.VariableBinding) Criteria(org.onosproject.net.flow.criteria.Criteria) LinkedList(java.util.LinkedList) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OchSignalType(org.onosproject.net.OchSignalType) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Logger(org.slf4j.Logger) Collection(java.util.Collection) IOException(java.io.IOException) Integer32(org.snmp4j.smi.Integer32) Collectors(java.util.stream.Collectors) FlowId(org.onosproject.net.flow.FlowId) OchSignal(org.onosproject.net.OchSignal) Objects(java.util.Objects) UnsignedInteger32(org.snmp4j.smi.UnsignedInteger32) List(java.util.List) ResponseEvent(org.snmp4j.event.ResponseEvent) FlowRule(org.onosproject.net.flow.FlowRule) ChannelSpacing(org.onosproject.net.ChannelSpacing) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Collections(java.util.Collections) OID(org.snmp4j.smi.OID) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) IOException(java.io.IOException) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber)

Example 28 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class LumentumSdnRoadmFlowRuleProgrammable method applyFlowRules.

@Override
public Collection<FlowRule> applyFlowRules(Collection<FlowRule> rules) {
    try {
        snmp = new LumentumSnmpDevice(data().deviceId());
    } catch (IOException e) {
        log.error("Failed to connect to device: ", e);
    }
    // Line ports
    DeviceService deviceService = this.handler().get(DeviceService.class);
    List<Port> ports = deviceService.getPorts(data().deviceId());
    List<PortNumber> linePorts = ports.subList(ports.size() - 2, ports.size()).stream().map(p -> p.number()).collect(Collectors.toList());
    // Apply the valid rules on the device
    Collection<FlowRule> added = rules.stream().map(r -> new CrossConnectFlowRule(r, linePorts)).filter(xc -> installCrossConnect(xc)).collect(Collectors.toList());
    // Cache the cookie/priority
    CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
    added.forEach(xc -> cache.set(Objects.hash(data().deviceId(), xc.selector(), xc.treatment()), xc.id(), xc.priority()));
    return added;
}
Also used : GridType(org.onosproject.net.GridType) Arrays(java.util.Arrays) FlowRuleProgrammable(org.onosproject.net.flow.FlowRuleProgrammable) TreeEvent(org.snmp4j.util.TreeEvent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) FlowEntry(org.onosproject.net.flow.FlowEntry) PDU(org.snmp4j.PDU) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) VariableBinding(org.snmp4j.smi.VariableBinding) Criteria(org.onosproject.net.flow.criteria.Criteria) LinkedList(java.util.LinkedList) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OchSignalType(org.onosproject.net.OchSignalType) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Logger(org.slf4j.Logger) Collection(java.util.Collection) IOException(java.io.IOException) Integer32(org.snmp4j.smi.Integer32) Collectors(java.util.stream.Collectors) FlowId(org.onosproject.net.flow.FlowId) OchSignal(org.onosproject.net.OchSignal) Objects(java.util.Objects) UnsignedInteger32(org.snmp4j.smi.UnsignedInteger32) List(java.util.List) ResponseEvent(org.snmp4j.event.ResponseEvent) FlowRule(org.onosproject.net.flow.FlowRule) ChannelSpacing(org.onosproject.net.ChannelSpacing) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Collections(java.util.Collections) OID(org.snmp4j.smi.OID) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) IOException(java.io.IOException) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber)

Example 29 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class OpenRoadmFlowRuleProgrammable method openRoadmConnectionName.

/**
 * Construct a connection name given an OpenRoadmFlowRule.
 *
 * @param xc the flow rule or crossconnection.
 */
private String openRoadmConnectionName(OpenRoadmFlowRule xc) {
    DeviceService deviceService = this.handler().get(DeviceService.class);
    Port srcPort = deviceService.getPort(did(), xc.inPort());
    Port dstPort = deviceService.getPort(did(), xc.outPort());
    Frequency centerFreq = xc.ochSignal().centralFrequency();
    return openRoadmConnectionName(srcPort, dstPort, centerFreq);
}
Also used : Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) Frequency(org.onlab.util.Frequency)

Example 30 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class OpenRoadmFlowRuleProgrammable method editConfigCreateConnection.

/**
 * Request the device to setup the Connection for the rule.
 *
 * @param xc - OpenRoadmFlowRule crossconnect
 *
 * @return true if operation was completed, false otherwise.
 */
private boolean editConfigCreateConnection(OpenRoadmFlowRule xc) {
    checkNotNull(xc);
    String openRoadmConnectionName = openRoadmConnectionName(xc);
    DeviceService deviceService = this.handler().get(DeviceService.class);
    OpenRoadmConnection connection = OpenRoadmConnectionFactory.create(openRoadmConnectionName, xc, deviceService);
    if (!editConfigCreateInterfaces(connection)) {
        return false;
    }
    if (!editConfigCreateConnectionEntry(connection, "merge")) {
        return false;
    }
    // Add connection to local cache
    getConnectionCache().add(did(), openRoadmConnectionName, xc);
    openRoadmLog("Connection {} created", connection.connectionName);
    return true;
}
Also used : DeviceService(org.onosproject.net.device.DeviceService)

Aggregations

DeviceService (org.onosproject.net.device.DeviceService)187 Device (org.onosproject.net.Device)75 DeviceId (org.onosproject.net.DeviceId)73 Port (org.onosproject.net.Port)59 ConnectPoint (org.onosproject.net.ConnectPoint)42 PortNumber (org.onosproject.net.PortNumber)40 List (java.util.List)30 Collectors (java.util.stream.Collectors)24 Set (java.util.Set)23 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)19 Logger (org.slf4j.Logger)19 ArrayList (java.util.ArrayList)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Optional (java.util.Optional)17 Test (org.junit.Test)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Collections (java.util.Collections)15 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)15 DriverHandler (org.onosproject.net.driver.DriverHandler)15 Collection (java.util.Collection)14