Search in sources :

Example 11 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project netvirt by opendaylight.

the class Ipv6ServiceInterfaceEventListener method remove.

@Override
protected void remove(InstanceIdentifier<Interface> key, Interface del) {
    LOG.debug("Port removed {}, {}", key, del);
    if (!L2vlan.class.equals(del.getType())) {
        return;
    }
    // In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
    List<String> ofportIds = del.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(del.getName())) {
        return;
    }
    Uuid portId = new Uuid(del.getName());
    VirtualPort port = ifMgr.obtainV6Interface(portId);
    if (port == null) {
        LOG.info("Port {} does not include IPv6Address, skipping.", portId);
        return;
    }
    if (port.getServiceBindingStatus()) {
        jobCoordinator.enqueueJob("IPv6-" + String.valueOf(portId), () -> {
            // Unbind Service
            ipv6ServiceUtils.unbindIpv6Service(portId.getValue());
            port.setServiceBindingStatus(false);
            return Collections.emptyList();
        }, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
    }
}
Also used : L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)

Example 12 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project netvirt by opendaylight.

the class NeutronPortChangeListenerTest method addPort__Ipv6FixedIps.

@Test
public void addPort__Ipv6FixedIps() throws Exception {
    PortBuilder pb = new PortBuilder();
    pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
    pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
    pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
    IpAddress ipv6 = new IpAddress(new Ipv6Address("1::1"));
    FixedIpsBuilder fib = new FixedIpsBuilder();
    fib.setIpAddress(ipv6);
    List<FixedIps> fixedIps = new ArrayList<>();
    fixedIps.add(fib.build());
    pb.setFixedIps(fixedIps);
    Port port = pb.build();
    neutronPortChangeListener.add(InstanceIdentifier.create(Port.class), port);
}
Also used : FixedIpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Test(org.junit.Test)

Example 13 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project openflowplugin by opendaylight.

the class SalToOfSetNwSrcActionCase method process.

@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    final ActionBuilder builder = new ActionBuilder();
    final Address address = source.getSetNwSrcAction().getAddress();
    if (address instanceof Ipv4) {
        Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
        Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
        Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
        Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
        ipv4SrcBuilder.setIpv4Address(result);
        Integer prefix = IpConversionUtil.extractPrefix(result);
        ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
        ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
        matchEntryBuilder.setHasMask(false);
        matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
        List<MatchEntry> entries = new ArrayList<>();
        entries.add(matchEntryBuilder.build());
        SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
        setFieldBuilder.setMatchEntry(entries);
        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
        setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
        builder.setActionChoice(setFieldCaseBuilder.build());
    } else if (address instanceof Ipv6) {
        Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
        Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
        Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
        Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
        ipv6SrcBuilder.setIpv6Address(result);
        Integer prefix = IpConversionUtil.extractPrefix(result);
        ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
        ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
        matchEntryBuilder.setHasMask(false);
        matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
        List<MatchEntry> matchEntriesList = new ArrayList<>();
        matchEntriesList.add(matchEntryBuilder.build());
        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
        SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
        setFieldActionBuilder.setMatchEntry(matchEntriesList);
        setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
        builder.setActionChoice(setFieldCaseBuilder.build());
    } else {
        throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
    }
    return Optional.of(builder.build());
}
Also used : Ipv4SrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder) SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) Ipv6Src(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) Address(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) ArrayList(java.util.ArrayList) OpenflowBasicClass(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass) Ipv6SrcCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) ArrayList(java.util.ArrayList) List(java.util.List) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6) Ipv4(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4) Ipv6SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder) Ipv4SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder) Nonnull(javax.annotation.Nonnull)

Example 14 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project openflowplugin by opendaylight.

the class SalToOfSetNwDstActionCase method process.

@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
    final ActionBuilder builder = new ActionBuilder();
    final Address address = source.getSetNwDstAction().getAddress();
    if (address instanceof Ipv4) {
        Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
        Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
        Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
        Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
        ipv4DstBuilder.setIpv4Address(result);
        Integer prefix = IpConversionUtil.extractPrefix(result);
        ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
        ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
        matchEntryBuilder.setHasMask(false);
        matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
        List<MatchEntry> matchEntriesList = new ArrayList<>();
        matchEntriesList.add(matchEntryBuilder.build());
        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
        SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
        setFieldActionBuilder.setMatchEntry(matchEntriesList);
        setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
        builder.setActionChoice(setFieldCaseBuilder.build());
    } else if (address instanceof Ipv6) {
        Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
        Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
        MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
        matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
        matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
        Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
        Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
        ipv6DstBuilder.setIpv6Address(result);
        Integer prefix = IpConversionUtil.extractPrefix(result);
        ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
        ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
        matchEntryBuilder.setHasMask(false);
        matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
        List<MatchEntry> matchEntriesList = new ArrayList<>();
        matchEntriesList.add(matchEntryBuilder.build());
        SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
        SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
        setFieldActionBuilder.setMatchEntry(matchEntriesList);
        setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
        builder.setActionChoice(setFieldCaseBuilder.build());
    } else {
        throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
    }
    return Optional.of(builder.build());
}
Also used : SetFieldCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder) MatchEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) Address(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) ArrayList(java.util.ArrayList) OpenflowBasicClass(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass) Ipv6DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder) MatchEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder) Ipv4DstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder) Ipv4DstBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder) SetFieldActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder) ArrayList(java.util.ArrayList) List(java.util.List) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv6DstCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Ipv6Dst(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst) Ipv6(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6) Ipv4(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4) Nonnull(javax.annotation.Nonnull)

Example 15 with Ipv6Address

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address in project bgpcep by opendaylight.

the class VpnIpv6NextHopTest method testSerializeIpv6NextHopCase.

@Test
public void testSerializeIpv6NextHopCase() throws Exception {
    // put some random valid IPv6 address here
    final String TEST_IPV6 = "2001::1234:5678:90ab:cdef";
    final ByteBuf buffer = Unpooled.buffer();
    final byte[] nextHop = new byte[Ipv6Util.IPV6_LENGTH + RouteDistinguisherUtil.RD_LENGTH];
    // now copy the IPv6 address to the byte array
    System.arraycopy(Inet6Address.getByName(TEST_IPV6).getAddress(), 0, nextHop, RouteDistinguisherUtil.RD_LENGTH, Ipv6Util.IPV6_LENGTH);
    final CNextHop hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(new Ipv6Address(TEST_IPV6)).build()).build();
    HANDLER.serializeNextHop(hop, buffer);
    assertArrayEquals(nextHop, ByteArray.readAllBytes(buffer));
    final CNextHop parsedHop = HANDLER.parseNextHop(Unpooled.wrappedBuffer(nextHop));
    assertTrue(hop instanceof Ipv6NextHopCase);
    assertEquals(hop, parsedHop);
}
Also used : Ipv6NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder) ByteBuf(io.netty.buffer.ByteBuf) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address) Ipv6NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCaseBuilder) Ipv6NextHopCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase) Test(org.junit.Test)

Aggregations

Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)83 Test (org.junit.Test)67 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)23 ByteBuf (io.netty.buffer.ByteBuf)21 ArrayList (java.util.ArrayList)21 IPv6Address (com.googlecode.ipv6.IPv6Address)18 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)17 BigInteger (java.math.BigInteger)16 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)16 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)15 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)14 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)13 Ipv6MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder)12 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)12 Ipv6SrcCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder)11 Ipv6SrcBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder)11 Ipv6DstCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder)9 Ipv6DstBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder)9 Match (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match)9 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder)9