Search in sources :

Example 6 with DefaultAnnotations

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

the class OpenRoadmDeviceDescription method buildSrgPortDesc.

/**
 * Parses a component XML doc into a PortDescription.
 * An Och port description is constructed from XML parsed data.
 *
 * @param nodeId The OpenRoadm nodeId of the current node.
 * @param circuitPackName name of circuit pack containing the port.
 * @param pNum the portNumber of the port.
 * @param reversepNum the portNumber of the partner port.
 * @param port the hierarchical configuration of the port to parse
 * @param extLink Hierarchical configuration for the external links.
 * @return PortDescription or null.
 */
private PortDescription buildSrgPortDesc(String nodeId, String circuitPackName, PortNumber pNum, PortNumber reversepNum, HierarchicalConfiguration port, HierarchicalConfiguration extLink) {
    DefaultAnnotations annotations = createPortAnnotations(nodeId, circuitPackName, pNum, reversepNum, port, extLink);
    OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 3);
    return OchPortHelper.ochPortDescription(pNum, true, /* enabled */
    OduSignalType.ODU4, true, /* tunable */
    signalId, annotations);
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) OchSignal(org.onosproject.net.OchSignal)

Example 7 with DefaultAnnotations

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

the class DistributedHostStore method createOrUpdateHost.

// TODO No longer need to return HostEvent
@Override
public HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, HostDescription hostDescription, boolean replaceIPs) {
    hostsConsistentMap.computeIf(hostId, existingHost -> shouldUpdate(existingHost, providerId, hostDescription, replaceIPs), (id, existingHost) -> {
        final Set<IpAddress> addresses;
        if (existingHost == null || replaceIPs) {
            addresses = ImmutableSet.copyOf(hostDescription.ipAddress());
        } else {
            addresses = Sets.newHashSet(existingHost.ipAddresses());
            addresses.addAll(hostDescription.ipAddress());
        }
        final Annotations annotations;
        if (existingHost != null) {
            annotations = merge((DefaultAnnotations) existingHost.annotations(), hostDescription.annotations());
        } else {
            annotations = hostDescription.annotations();
        }
        return new DefaultHost(providerId, hostId, hostDescription.hwAddress(), hostDescription.vlan(), hostDescription.locations(), hostDescription.auxLocations(), addresses, hostDescription.innerVlan(), hostDescription.tpid(), hostDescription.configured(), false, annotations);
    });
    return null;
}
Also used : DefaultHost(org.onosproject.net.DefaultHost) Annotations(org.onosproject.net.Annotations) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) IpAddress(org.onlab.packet.IpAddress)

Example 8 with DefaultAnnotations

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

the class OpenConfigGnmiDeviceDescriptionDiscovery method discoverPortDetails.

@Override
public List<PortDescription> discoverPortDetails() {
    if (!setupBehaviour("discoverPortDetails()")) {
        return Collections.emptyList();
    }
    log.debug("Discovering port details on device {}", handler().data().deviceId());
    final GetResponse response = Futures.getUnchecked(client.get(buildPortStateRequest()));
    final Map<String, DefaultPortDescription.Builder> ports = Maps.newHashMap();
    final Map<String, DefaultAnnotations.Builder> annotations = Maps.newHashMap();
    final Map<String, PortNumber> portIds = Maps.newHashMap();
    // Creates port descriptions with port name and port number
    response.getNotificationList().forEach(notification -> {
        notification.getUpdateList().forEach(update -> {
            // /interfaces/interface[name=ifName]/state/...
            final String ifName = update.getPath().getElem(1).getKeyMap().get("name");
            if (!ports.containsKey(ifName)) {
                ports.put(ifName, DefaultPortDescription.builder());
                annotations.put(ifName, DefaultAnnotations.builder());
            }
            final DefaultPortDescription.Builder builder = ports.get(ifName);
            final DefaultAnnotations.Builder annotationsBuilder = annotations.get(ifName);
            parseInterfaceInfo(update, ifName, builder, annotationsBuilder, portIds);
        });
    });
    final List<PortDescription> portDescriptionList = Lists.newArrayList();
    ports.forEach((key, value) -> {
        // For devices not providing last-change, we set it to 0
        final DefaultAnnotations.Builder annotationsBuilder = annotations.get(key);
        if (!annotationsBuilder.build().keys().contains(LAST_CHANGE)) {
            annotationsBuilder.set(LAST_CHANGE, String.valueOf(0));
        }
        /* Override port number if read port-id is enabled
               and /interfaces/interface/state/id is available */
        if (readPortId() && portIds.containsKey(key)) {
            value.withPortNumber(portIds.get(key));
        }
        DefaultAnnotations annotation = annotations.get(key).build();
        portDescriptionList.add(value.annotations(annotation).build());
    });
    return portDescriptionList;
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) PortDescription(org.onosproject.net.device.PortDescription) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) GetResponse(gnmi.Gnmi.GetResponse) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) PortNumber(org.onosproject.net.PortNumber)

Example 9 with DefaultAnnotations

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

the class DistributedOpenstackVtapStore method createOrUpdateVtap.

private OpenstackVtap createOrUpdateVtap(boolean update, OpenstackVtap description, boolean replaceDevices) {
    DefaultOpenstackVtap result = vtapMap.compute(description.id(), (id, existing) -> {
        // Check create or update validity
        if (update && existing == null) {
            return null;
        } else if (!update && existing != null) {
            return existing;
        }
        if (shouldUpdateVtap(existing, description, replaceDevices)) {
            // Replace or add devices
            final Set<DeviceId> txDeviceIds;
            if (existing == null || replaceDevices) {
                txDeviceIds = description.txDeviceIds();
            } else {
                txDeviceIds = Sets.newHashSet(existing.txDeviceIds());
                txDeviceIds.addAll(description.txDeviceIds());
            }
            final Set<DeviceId> rxDeviceIds;
            if (existing == null || replaceDevices) {
                rxDeviceIds = description.rxDeviceIds();
            } else {
                rxDeviceIds = Sets.newHashSet(existing.rxDeviceIds());
                rxDeviceIds.addAll(description.rxDeviceIds());
            }
            // Replace or add annotations
            final SparseAnnotations annotations;
            if (existing != null) {
                annotations = merge((DefaultAnnotations) existing.annotations(), (SparseAnnotations) description.annotations());
            } else {
                annotations = (SparseAnnotations) description.annotations();
            }
            return DefaultOpenstackVtap.builder(description).txDeviceIds(txDeviceIds).rxDeviceIds(rxDeviceIds).annotations(annotations).build();
        }
        return existing;
    });
    return result;
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DeviceId(org.onosproject.net.DeviceId)

Example 10 with DefaultAnnotations

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

the class OchPortHelper method ochPortDescription.

/**
 * Creates OCh port DefaultPortDescription based on the supplied information.
 *
 * @param number      port number
 * @param isEnabled   port enabled state
 * @param signalType  ODU signal type
 * @param isTunable   tunable wavelength capability
 * @param lambda      OCh signal
 * @param annotationsIn key/value annotations map
 * @return OCh port DefaultPortDescription with OCh annotations
 */
public static PortDescription ochPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType, boolean isTunable, OchSignal lambda, SparseAnnotations annotationsIn) {
    Builder builder = DefaultAnnotations.builder();
    builder.putAll(annotationsIn);
    builder.set(TUNABLE, String.valueOf(isTunable));
    builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString());
    builder.set(SIGNAL_TYPE, signalType.toString());
    DefaultAnnotations annotations = builder.build();
    long portSpeed = signalType.bitRate();
    return DefaultPortDescription.builder().withPortNumber(number).isEnabled(isEnabled).type(Port.Type.OCH).portSpeed(portSpeed).annotations(annotations).build();
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Builder(org.onosproject.net.DefaultAnnotations.Builder)

Aggregations

DefaultAnnotations (org.onosproject.net.DefaultAnnotations)33 ConnectPoint (org.onosproject.net.ConnectPoint)9 PortDescription (org.onosproject.net.device.PortDescription)9 DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)8 DeviceId (org.onosproject.net.DeviceId)7 PortNumber (org.onosproject.net.PortNumber)7 ProviderId (org.onosproject.net.provider.ProviderId)7 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)6 LinkDescription (org.onosproject.net.link.LinkDescription)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)4 Device (org.onosproject.net.Device)4 DeviceDescription (org.onosproject.net.device.DeviceDescription)4 ArrayList (java.util.ArrayList)3 ChassisId (org.onlab.packet.ChassisId)3 DefaultDevice (org.onosproject.net.DefaultDevice)3 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)3 DeviceService (org.onosproject.net.device.DeviceService)3 XPath (javax.xml.xpath.XPath)2 XPathExpressionException (javax.xml.xpath.XPathExpressionException)2 Test (org.junit.Test)2