use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.
the class Ipv6ServiceInterfaceEventListener method add.
@Override
protected void add(InstanceIdentifier<Interface> key, Interface add) {
List<String> ofportIds = add.getLowerLayerIf();
if (!L2vlan.class.equals(add.getType())) {
return;
}
// In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(add.getName())) {
return;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface;
iface = ipv6ServiceUtils.getInterface(add.getName());
if (null != iface) {
LOG.debug("Port {} is a Neutron port", iface.getName());
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
if (!dpId.equals(Ipv6Constants.INVALID_DPID)) {
Uuid portId = new Uuid(iface.getName());
VirtualPort port = ifMgr.obtainV6Interface(portId);
if (port == null) {
LOG.info("Port {} does not include IPv6Address, skipping.", portId);
return;
}
Long ofPort = MDSALUtil.getOfPortNumberFromPortName(nodeConnectorId);
ifMgr.updateDpnInfo(portId, dpId, ofPort);
VirtualPort routerPort = ifMgr.getRouterV6InterfaceForNetwork(port.getNetworkID());
if (routerPort == null) {
LOG.info("Port {} is not associated to a Router, skipping.", portId);
return;
}
// Check and program icmpv6 punt flows on the dpnID if its the first VM on the host.
ifMgr.programIcmpv6PuntFlowsIfNecessary(portId, dpId, routerPort);
if (!port.getServiceBindingStatus()) {
jobCoordinator.enqueueJob("IPv6-" + String.valueOf(portId), () -> {
// Bind Service
Long elanTag = ifMgr.getNetworkElanTag(routerPort.getNetworkID());
ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
port.setServiceBindingStatus(true);
return Collections.emptyList();
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.
the class AclServiceUtils method getDpIdFromIterfaceState.
public static BigInteger getDpIdFromIterfaceState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState) {
BigInteger dpId = null;
List<String> ofportIds = interfaceState.getLowerLayerIf();
if (ofportIds != null && !ofportIds.isEmpty()) {
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
}
return dpId;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.
the class QosInterfaceStateChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface intrf) {
if (L2vlan.class.equals(intrf.getType())) {
final String interfaceName = intrf.getName();
// Guava Optional asSet().forEach() emulates Java 8 Optional ifPresent()
getNeutronPortForRemove(intrf).asSet().forEach(port -> {
LOG.trace("Qos Service : Received interface {} PORT DOWN event ", interfaceName);
String lowerLayerIf = intrf.getLowerLayerIf().get(0);
LOG.trace("lowerLayerIf {}", lowerLayerIf);
qosAlertManager.removeFromQosAlertCache(new NodeConnectorId(lowerLayerIf));
QosPortExtension removeQos = port.getAugmentation(QosPortExtension.class);
if (removeQos != null) {
qosNeutronUtils.handleNeutronPortRemove(port, removeQos.getQosPolicyId(), intrf);
qosNeutronUtils.removeFromQosPortsCache(removeQos.getQosPolicyId(), port);
} else {
Network network = neutronVpnManager.getNeutronNetwork(port.getNetworkId());
if (network != null && network.getAugmentation(QosNetworkExtension.class) != null) {
Uuid networkQosUuid = network.getAugmentation(QosNetworkExtension.class).getQosPolicyId();
if (networkQosUuid != null) {
qosNeutronUtils.handleNeutronPortRemove(port, networkQosUuid, intrf);
}
}
}
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project openflowplugin by opendaylight.
the class ActionConvertorTest method setFieldData.
private void setFieldData() {
SetFieldBuilder matchBuilder = new SetFieldBuilder();
matchBuilder.setInPort(new NodeConnectorId("openflow:1:2125"));
SetFieldBuilder setFB = new SetFieldBuilder();
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setOrder(actionItem).setAction(new SetFieldCaseBuilder().setSetField(setFB.build()).build());
actions.add(actionItem++, actionBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project openflowplugin by opendaylight.
the class MatchConvertorTest method testConversion.
@Test
public void testConversion() {
MatchBuilder builder = new MatchBuilder();
builder.setInPort(new NodeConnectorId("openflow:42:1"));
builder.setInPhyPort(new NodeConnectorId("openflow:42:2"));
MetadataBuilder metadataBuilder = new MetadataBuilder();
metadataBuilder.setMetadata(new BigInteger("3"));
builder.setMetadata(metadataBuilder.build());
EthernetMatchBuilder ethernetBuilder = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(4L));
ethernetBuilder.setEthernetType(ethTypeBuilder.build());
EthernetSourceBuilder ethSrcBuilder = new EthernetSourceBuilder();
ethSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
ethernetBuilder.setEthernetSource(ethSrcBuilder.build());
EthernetDestinationBuilder ethDstBuilder = new EthernetDestinationBuilder();
ethDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
ethernetBuilder.setEthernetDestination(ethDstBuilder.build());
builder.setEthernetMatch(ethernetBuilder.build());
VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
vlanIdBuilder.setVlanId(new VlanId(7));
vlanIdBuilder.setVlanIdPresent(true);
vlanBuilder.setVlanId(vlanIdBuilder.build());
vlanBuilder.setVlanPcp(new VlanPcp((short) 7));
builder.setVlanMatch(vlanBuilder.build());
IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
ipMatchBuilder.setIpDscp(new Dscp((short) 8));
ipMatchBuilder.setIpEcn((short) 9);
ipMatchBuilder.setIpProtocol((short) 10);
builder.setIpMatch(ipMatchBuilder.build());
TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
tcpMatchBuilder.setTcpSourcePort(new PortNumber(11));
tcpMatchBuilder.setTcpDestinationPort(new PortNumber(12));
builder.setLayer4Match(tcpMatchBuilder.build());
Icmpv4MatchBuilder icmpv4Builder = new Icmpv4MatchBuilder();
icmpv4Builder.setIcmpv4Type((short) 13);
icmpv4Builder.setIcmpv4Code((short) 14);
builder.setIcmpv4Match(icmpv4Builder.build());
Icmpv6MatchBuilder icmpv6Builder = new Icmpv6MatchBuilder();
icmpv6Builder.setIcmpv6Type((short) 15);
icmpv6Builder.setIcmpv6Code((short) 16);
builder.setIcmpv6Match(icmpv6Builder.build());
ProtocolMatchFieldsBuilder protoBuilder = new ProtocolMatchFieldsBuilder();
protoBuilder.setMplsLabel(17L);
protoBuilder.setMplsTc((short) 18);
protoBuilder.setMplsBos((short) 19);
PbbBuilder pbbBuilder = new PbbBuilder();
pbbBuilder.setPbbIsid(20L);
protoBuilder.setPbb(pbbBuilder.build());
builder.setProtocolMatchFields(protoBuilder.build());
TunnelBuilder tunnelBuilder = new TunnelBuilder();
tunnelBuilder.setTunnelId(new BigInteger("21"));
builder.setTunnel(tunnelBuilder.build());
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.1/32"));
ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.2/32"));
builder.setLayer3Match(ipv4MatchBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 24, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, InPort.class, false);
Assert.assertEquals("Wrong in port", 1, ((InPortCase) entry.getMatchEntryValue()).getInPort().getPortNumber().getValue().intValue());
entry = entries.get(1);
checkEntryHeader(entry, InPhyPort.class, false);
Assert.assertEquals("Wrong in phy port", 2, ((InPhyPortCase) entry.getMatchEntryValue()).getInPhyPort().getPortNumber().getValue().intValue());
entry = entries.get(2);
checkEntryHeader(entry, Metadata.class, false);
Assert.assertArrayEquals("Wrong metadata", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, ((MetadataCase) entry.getMatchEntryValue()).getMetadata().getMetadata());
entry = entries.get(3);
checkEntryHeader(entry, EthDst.class, false);
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:06"), ((EthDstCase) entry.getMatchEntryValue()).getEthDst().getMacAddress());
entry = entries.get(4);
checkEntryHeader(entry, EthSrc.class, false);
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:05"), ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc().getMacAddress());
entry = entries.get(5);
checkEntryHeader(entry, EthType.class, false);
Assert.assertEquals("Wrong eth type", 4, ((EthTypeCase) entry.getMatchEntryValue()).getEthType().getEthType().getValue().intValue());
entry = entries.get(6);
checkEntryHeader(entry, VlanVid.class, false);
Assert.assertEquals("Wrong vlan id", 7, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
entry = entries.get(7);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
Assert.assertEquals("Wrong vlan pcp", 7, ((VlanPcpCase) entry.getMatchEntryValue()).getVlanPcp().getVlanPcp().intValue());
entry = entries.get(8);
checkEntryHeader(entry, IpDscp.class, false);
Assert.assertEquals("Wrong ip dscp", 8, ((IpDscpCase) entry.getMatchEntryValue()).getIpDscp().getDscp().getValue().intValue());
entry = entries.get(9);
checkEntryHeader(entry, IpEcn.class, false);
Assert.assertEquals("Wrong ip ecn", 9, ((IpEcnCase) entry.getMatchEntryValue()).getIpEcn().getEcn().intValue());
entry = entries.get(10);
checkEntryHeader(entry, IpProto.class, false);
Assert.assertEquals("Wrong ip proto", 10, ((IpProtoCase) entry.getMatchEntryValue()).getIpProto().getProtocolNumber().intValue());
entry = entries.get(11);
checkEntryHeader(entry, TcpSrc.class, false);
Assert.assertEquals("Wrong tcp src", 11, ((TcpSrcCase) entry.getMatchEntryValue()).getTcpSrc().getPort().getValue().intValue());
entry = entries.get(12);
checkEntryHeader(entry, TcpDst.class, false);
Assert.assertEquals("Wrong tcp dst", 12, ((TcpDstCase) entry.getMatchEntryValue()).getTcpDst().getPort().getValue().intValue());
entry = entries.get(13);
checkEntryHeader(entry, Icmpv4Type.class, false);
Assert.assertEquals("Wrong icmpv4 type", 13, ((Icmpv4TypeCase) entry.getMatchEntryValue()).getIcmpv4Type().getIcmpv4Type().intValue());
entry = entries.get(14);
checkEntryHeader(entry, Icmpv4Code.class, false);
Assert.assertEquals("Wrong icmpv4 code", 14, ((Icmpv4CodeCase) entry.getMatchEntryValue()).getIcmpv4Code().getIcmpv4Code().intValue());
entry = entries.get(15);
checkEntryHeader(entry, Icmpv6Type.class, false);
Assert.assertEquals("Wrong icmpv6 type", 15, ((Icmpv6TypeCase) entry.getMatchEntryValue()).getIcmpv6Type().getIcmpv6Type().intValue());
entry = entries.get(16);
checkEntryHeader(entry, Icmpv6Code.class, false);
Assert.assertEquals("Wrong icmpv6 code", 16, ((Icmpv6CodeCase) entry.getMatchEntryValue()).getIcmpv6Code().getIcmpv6Code().intValue());
entry = entries.get(17);
checkEntryHeader(entry, Ipv4Src.class, false);
Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(18);
checkEntryHeader(entry, Ipv4Dst.class, false);
Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
entry = entries.get(19);
checkEntryHeader(entry, MplsLabel.class, false);
Assert.assertEquals("Wrong mpls label", 17, ((MplsLabelCase) entry.getMatchEntryValue()).getMplsLabel().getMplsLabel().intValue());
entry = entries.get(20);
checkEntryHeader(entry, MplsBos.class, false);
Assert.assertEquals("Wrong mpls bos", true, ((MplsBosCase) entry.getMatchEntryValue()).getMplsBos().isBos());
entry = entries.get(21);
checkEntryHeader(entry, MplsTc.class, false);
Assert.assertEquals("Wrong mpls tc", 18, ((MplsTcCase) entry.getMatchEntryValue()).getMplsTc().getTc().intValue());
entry = entries.get(22);
checkEntryHeader(entry, PbbIsid.class, false);
Assert.assertEquals("Wrong pbb isid", 20, ((PbbIsidCase) entry.getMatchEntryValue()).getPbbIsid().getIsid().intValue());
entry = entries.get(23);
checkEntryHeader(entry, TunnelId.class, false);
Assert.assertArrayEquals("Wrong tunnel id", new byte[] { 0, 0, 0, 0, 0, 0, 0, 21 }, ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getTunnelId());
}
Aggregations