private PortDescription ensurePortEnabledState(PortDescription desc, boolean enabled) { if (desc.isEnabled() != enabled) { return DefaultPortDescription.builder(desc) .isEnabled(enabled) .build(); } return desc; }
DefaultPortDescription.Builder builder = DefaultPortDescription.builder() .withPortNumber(portNumber); if (portNode.has(ENABLED)) {
portDescs.add(DefaultPortDescription.builder().withPortNumber(number) .isEnabled(isEnabled).build());
@Override public void deletePort(DeviceId deviceId, PortDescription basePortDescription) { checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(basePortDescription, PORT_DESCRIPTION_NULL); checkValidity(); if (!mastershipService.isLocalMaster(deviceId)) { // Never been a master for this device // any update will be ignored. log.trace("Ignoring {} port update on standby node. {}", deviceId, basePortDescription); return; } Device device = getDevice(deviceId); if (device == null) { log.trace("Device not found: {}", deviceId); } PortDescription newPortDescription = DefaultPortDescription.builder(basePortDescription) .isRemoved(true) .build(); final DeviceEvent event = store.updatePortStatus(this.provider().id(), deviceId, newPortDescription); if (event != null) { log.info("Device {} port {} status changed", deviceId, event.port().number()); post(event); } }
/** * Updates {@link PortDescription} using specified number and annotations. * * @param port {@link PortNumber} to use in updated description * @param sa annotations to use in updated description * @param descr base {@link PortDescription} * @return updated {@link PortDescription} */ private static PortDescription updateDescription(PortNumber port, SparseAnnotations sa, PortDescription descr) { if (port.exactlyEquals(descr.portNumber()) && sa.equals(descr.annotations())) { // result is no-op return descr; } return DefaultPortDescription.builder(descr) .withPortNumber(port) .annotations(sa) .build(); }
@Override public PortDescription combine(ConnectPoint cp, PortDescription descr) { PortAnnotationConfig cfg = lookupConfig(cp); if (cfg == null) { return descr; } Map<String, String> annotations = cfg.annotations(); if (annotations.isEmpty()) { return descr; } Builder builder = DefaultAnnotations.builder(); builder.putAll(descr.annotations()); builder.putAll(annotations); return DefaultPortDescription.builder(descr) .annotations(builder.build()) .build(); }
return DefaultPortDescription.builder() .withPortNumber(number) .isEnabled(isEnabled)
/** * 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(); }
/** * Creates OTU port description based on the supplied information. * * @param number port number * @param isEnabled port enabled state * @param signalType OTU client signal type * @param annotations key/value annotations map * @return port description */ public static PortDescription otuPortDescription(PortNumber number, boolean isEnabled, OtuSignalType signalType, SparseAnnotations annotations) { Builder builder = DefaultAnnotations.builder(); builder.putAll(annotations); builder.set(SIGNAL_TYPE, signalType.toString()); long portSpeed = 0; // TODO specify appropriate value? return DefaultPortDescription.builder() .withPortNumber(number) .isEnabled(isEnabled) .type(Port.Type.OTU) .portSpeed(portSpeed) .annotations(builder.build()) .build(); }
/** * Creates ODU client port description based on the supplied information. * * @param number port number * @param isEnabled port enabled state * @param signalType ODU client signal type * @param annotations key/value annotations map * @return port description */ public static PortDescription oduCltPortDescription(PortNumber number, boolean isEnabled, CltSignalType signalType, SparseAnnotations annotations) { Builder builder = DefaultAnnotations.builder(); builder.putAll(annotations); builder.set(SIGNAL_TYPE, signalType.toString()); long portSpeed = signalType.bitRate(); return DefaultPortDescription.builder() .withPortNumber(number) .isEnabled(isEnabled) .type(Port.Type.ODUCLT) .portSpeed(portSpeed) .annotations(builder.build()) .build(); }