use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class LumentumPowerConfig method acquireTargetPower.
// TODO implement actual get configuration from the device
// This is used by ROADM application to retrieve attenuation parameter, with T instanceof OchSignal
// The ROADM app expresses the attenuation in 0.01 dB units
private Double acquireTargetPower(PortNumber port, T component) {
log.debug("Lumentum get port {} target power...", port);
if (component instanceof OchSignal) {
Set<FlowRule> rules = getConnectionCache().get(did());
FlowRule rule;
if (rules == null) {
log.error("Lumentum NETCONF fail to retrieve attenuation signal {} port {}", component, port);
return 0.0;
} else {
rule = rules.stream().filter(c -> ((LumentumFlowRule) c).getOutputPort() == port).filter(c -> ((LumentumFlowRule) c).ochSignal() == component).findFirst().orElse(null);
}
if (rule == null) {
log.error("Lumentum NETCONF fail to retrieve attenuation signal {} port {}", component, port);
return 0.0;
} else {
log.debug("Lumentum NETCONF on port {} attenuation {}", port, (((LumentumFlowRule) rule).attenuation * 100));
return ((LumentumFlowRule) rule).attenuation * 100;
}
}
return 0.0;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class LumentumPowerConfig method acquireCurrentPower.
// TODO implement actual get configuration from the device
// This is used by ROADM application to retrieve power parameter, with T instanceof OchSignal
private Double acquireCurrentPower(PortNumber port, T component) {
log.debug("Lumentum get port {} current power...", port);
if (component instanceof OchSignal) {
Set<FlowRule> rules = getConnectionCache().get(did());
FlowRule rule;
if (rules == null) {
log.error("Lumentum NETCONF fail to retrieve power signal {} port {}", component, port);
return 0.0;
} else {
rule = rules.stream().filter(c -> ((LumentumFlowRule) c).getInputPort() == port).filter(c -> ((LumentumFlowRule) c).ochSignal() == component).findFirst().orElse(null);
}
if (rule == null) {
log.error("Lumentum NETCONF fail to retrieve power signal {} port {}", component, port);
return 0.0;
} else {
log.debug("Lumentum NETCONF on port {} power {}", port, (((LumentumFlowRule) rule).inputPower));
return ((double) (((LumentumFlowRule) rule).inputPower * 100));
}
}
return 0.0;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class LumentumRoadmLambdaQuery method queryLambdas.
@Override
public Set<OchSignal> queryLambdas(PortNumber portNumber) {
DeviceService deviceService = this.handler().get(DeviceService.class);
Port port = deviceService.getPort(data().deviceId(), portNumber);
if ((port.type() == Port.Type.FIBER) || (port.type() == Port.Type.OMS)) {
// Complete set of 50GHz OchSignal
int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
Set<OchSignal> channels50 = IntStream.range(0, LAMBDA_COUNT_50).mapToObj(x -> new OchSignal(GRID_TYPE, CHANNEL_SPACING_50, startMultiplier50 + x, 4)).collect(Collectors.toSet());
return channels50;
} else {
return Collections.emptySet();
}
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class LumentumWaveReadyDiscovery method extractPorts.
// Extract ports from response on pluggable inventory retrieval.
// Client ports are identified by 850nm, everything else is a network port.
private List<PortDescription> extractPorts(String s) {
List<PortDescription> ports = new ArrayList<>();
if (s.length() == 0) {
return ports;
}
Arrays.stream(s.split("\"\"")).forEach(p -> {
if (p.contains(EIGHTFIFTY)) {
PortDescription cltPort = oduCltPortDescription(PortNumber.portNumber(ports.size() + 1L), true, CltSignalType.CLT_10GBE, extractAnnotations(p));
ports.add(cltPort);
} else {
PortDescription netPort = ochPortDescription(PortNumber.portNumber(ports.size() + 1L), true, OduSignalType.ODU2e, true, new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4), extractAnnotations(p));
ports.add(netPort);
}
});
return ports;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class DefaultTrafficSelectorTest method testCriteriaCreation.
/**
* Tests the builder functions that add specific criteria.
*/
@Test
public void testCriteriaCreation() {
TrafficSelector selector;
final long longValue = 0x12345678;
final int intValue = 22;
final short shortValue = 33;
final byte byteValue = 44;
final byte dscpValue = 0xf;
final byte ecnValue = 3;
final MacAddress macValue = MacAddress.valueOf("11:22:33:44:55:66");
final IpPrefix ipPrefixValue = IpPrefix.valueOf("192.168.1.0/24");
final IpPrefix ipv6PrefixValue = IpPrefix.valueOf("fe80::1/64");
final Ip6Address ipv6AddressValue = Ip6Address.valueOf("fe80::1");
selector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(11)).build();
assertThat(selector, hasCriterionWithType(Type.IN_PORT));
selector = DefaultTrafficSelector.builder().matchInPhyPort(PortNumber.portNumber(11)).build();
assertThat(selector, hasCriterionWithType(Type.IN_PHY_PORT));
selector = DefaultTrafficSelector.builder().matchMetadata(longValue).build();
assertThat(selector, hasCriterionWithType(Type.METADATA));
selector = DefaultTrafficSelector.builder().matchEthDst(macValue).build();
assertThat(selector, hasCriterionWithType(Type.ETH_DST));
selector = DefaultTrafficSelector.builder().matchEthSrc(macValue).build();
assertThat(selector, hasCriterionWithType(Type.ETH_SRC));
selector = DefaultTrafficSelector.builder().matchEthType(shortValue).build();
assertThat(selector, hasCriterionWithType(Type.ETH_TYPE));
selector = DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId(shortValue)).build();
assertThat(selector, hasCriterionWithType(Type.VLAN_VID));
selector = DefaultTrafficSelector.builder().matchVlanPcp(byteValue).build();
assertThat(selector, hasCriterionWithType(Type.VLAN_PCP));
selector = DefaultTrafficSelector.builder().matchIPDscp(dscpValue).build();
assertThat(selector, hasCriterionWithType(Type.IP_DSCP));
selector = DefaultTrafficSelector.builder().matchIPEcn(ecnValue).build();
assertThat(selector, hasCriterionWithType(Type.IP_ECN));
selector = DefaultTrafficSelector.builder().matchIPProtocol(byteValue).build();
assertThat(selector, hasCriterionWithType(Type.IP_PROTO));
selector = DefaultTrafficSelector.builder().matchIPSrc(ipPrefixValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV4_SRC));
selector = DefaultTrafficSelector.builder().matchIPDst(ipPrefixValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV4_DST));
selector = DefaultTrafficSelector.builder().matchTcpSrc(TpPort.tpPort(intValue)).build();
assertThat(selector, hasCriterionWithType(Type.TCP_SRC));
selector = DefaultTrafficSelector.builder().matchTcpDst(TpPort.tpPort(intValue)).build();
assertThat(selector, hasCriterionWithType(Type.TCP_DST));
selector = DefaultTrafficSelector.builder().matchUdpSrc(TpPort.tpPort(intValue)).build();
assertThat(selector, hasCriterionWithType(Type.UDP_SRC));
selector = DefaultTrafficSelector.builder().matchUdpDst(TpPort.tpPort(intValue)).build();
assertThat(selector, hasCriterionWithType(Type.UDP_DST));
selector = DefaultTrafficSelector.builder().matchSctpSrc(TpPort.tpPort(intValue)).build();
assertThat(selector, hasCriterionWithType(Type.SCTP_SRC));
selector = DefaultTrafficSelector.builder().matchSctpDst(TpPort.tpPort(intValue)).build();
assertThat(selector, hasCriterionWithType(Type.SCTP_DST));
selector = DefaultTrafficSelector.builder().matchIcmpType(byteValue).build();
assertThat(selector, hasCriterionWithType(Type.ICMPV4_TYPE));
selector = DefaultTrafficSelector.builder().matchIcmpCode(byteValue).build();
assertThat(selector, hasCriterionWithType(Type.ICMPV4_CODE));
selector = DefaultTrafficSelector.builder().matchIPv6Src(ipv6PrefixValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_SRC));
selector = DefaultTrafficSelector.builder().matchIPv6Dst(ipv6PrefixValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_DST));
selector = DefaultTrafficSelector.builder().matchIPv6FlowLabel(intValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_FLABEL));
selector = DefaultTrafficSelector.builder().matchIcmpv6Type(byteValue).build();
assertThat(selector, hasCriterionWithType(Type.ICMPV6_TYPE));
selector = DefaultTrafficSelector.builder().matchIPv6NDTargetAddress(ipv6AddressValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_ND_TARGET));
selector = DefaultTrafficSelector.builder().matchIPv6NDSourceLinkLayerAddress(macValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_ND_SLL));
selector = DefaultTrafficSelector.builder().matchIPv6NDTargetLinkLayerAddress(macValue).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_ND_TLL));
selector = DefaultTrafficSelector.builder().matchMplsLabel(MplsLabel.mplsLabel(3)).build();
assertThat(selector, hasCriterionWithType(Type.MPLS_LABEL));
selector = DefaultTrafficSelector.builder().matchIPv6ExthdrFlags(Criterion.IPv6ExthdrFlags.NONEXT.getValue()).build();
assertThat(selector, hasCriterionWithType(Type.IPV6_EXTHDR));
selector = DefaultTrafficSelector.builder().add(Criteria.matchLambda(new OchSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 1, 1))).build();
assertThat(selector, hasCriterionWithType(Type.OCH_SIGID));
selector = DefaultTrafficSelector.builder().matchEthDst(macValue).extension(new MockExtensionSelector(1), DeviceId.NONE).extension(new MockExtensionSelector(2), DeviceId.NONE).build();
assertThat(selector.criteria().size(), is(equalTo(3)));
}
Aggregations