Search in sources :

Example 6 with IpPrefixCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase in project bgpcep by opendaylight.

the class XROIpv6PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    final SubobjectType type = subobject.getSubobjectType();
    checkArgument(type instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", type.getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) type).getIpPrefix();
    final Ipv6Prefix ipv6Prefix = specObj.getIpPrefix().getIpv6Prefix();
    checkArgument(ipv6Prefix != null, "Ipv6Prefix is mandatory.");
    serializeSubobject(buffer, subobject, ipv6Prefix);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) SubobjectType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 7 with IpPrefixCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase in project bgpcep by opendaylight.

the class EROIpv4PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final IpPrefix prefix = specObj.getIpPrefix();
    final Ipv6Prefix ipv6prefix = prefix.getIpv6Prefix();
    if (ipv6prefix != null) {
        EROIpv6PrefixSubobjectParser.serializeSubobject(buffer, subobject, ipv6prefix);
        return;
    }
    final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
    checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
    Ipv4Util.writeIpv4Prefix(prefix.getIpv4Prefix(), body);
    body.writeZero(RESERVED);
    EROSubobjectUtil.formatSubobject(TYPE, subobject.getLoose(), body, buffer);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) ByteBuf(io.netty.buffer.ByteBuf) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 8 with IpPrefixCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase in project bgpcep by opendaylight.

the class TunnelProgrammingTest method testTunnelProgramming.

@Test
public void testTunnelProgramming() throws InterruptedException, ExecutionException {
    final Bandwidth bwd = new Bandwidth(new byte[] { 0x00, 0x00, 0x00, (byte) 0xff });
    final ClassType classType = new ClassType(Uint8.ONE);
    final String tunnelName = "create-tunnel";
    final NetworkTopologyRef topologyRef = new NetworkTopologyRef(TOPO_IID);
    // create tunnel
    tunnelProgramming.pcepCreateP2pTunnel(new PcepCreateP2pTunnelInputBuilder().setDestination(new DestinationBuilder().setNode(NODE2_ID).setTp(TP2_ID).build()).setSource(new SourceBuilder().setNode(NODE1_ID).setTp(TP1_ID).build()).setNetworkTopologyRef(topologyRef).setBandwidth(bwd).setClassType(classType).setSymbolicPathName(tunnelName).addAugmentation(new PcepCreateP2pTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build()).build());
    // check add-lsp input
    assertNotNull(addLspInput);
    assertEquals(tunnelName, addLspInput.getName());
    final Arguments agrs = addLspInput.getArguments();
    assertNotNull(agrs);
    assertEquals(bwd, agrs.getBandwidth().getBandwidth());
    assertEquals(classType, agrs.getClassType().getClassType());
    final Ipv4 ipv4Endpoints = ((Ipv4Case) agrs.getEndpointsObj().getAddressFamily()).getIpv4();
    assertEquals(NODE1_IPV4, ipv4Endpoints.getSourceIpv4Address().getValue());
    assertEquals(NODE2_IPV4, ipv4Endpoints.getDestinationIpv4Address().getValue());
    assertEquals(NODE1_ID.getValue(), addLspInput.getNode().getValue());
    createLink();
    // update tunnel
    tunnelProgramming.pcepUpdateTunnel(new PcepUpdateTunnelInputBuilder().setNetworkTopologyRef(topologyRef).setBandwidth(bwd).setClassType(classType).setExplicitHops(BindingMap.ordered(createExplicitHop(IPV4_PREFIX1, Uint32.ONE), createExplicitHop(IPV4_PREFIX2, Uint32.TWO))).setLinkId(LINK1_ID).addAugmentation(new PcepUpdateTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build()).build());
    // check update-lsp input
    assertNotNull(updateLspInput);
    assertEquals(LINK1_ID.getValue(), updateLspInput.getName());
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.update.lsp.args.Arguments updArgs = updateLspInput.getArguments();
    assertEquals(2, updArgs.getEro().nonnullSubobject().size());
    final List<Subobject> subObjects = updArgs.getEro().nonnullSubobject();
    final IpPrefixCase prefix1 = (IpPrefixCase) subObjects.get(0).getSubobjectType();
    final IpPrefixCase prefix2 = (IpPrefixCase) subObjects.get(1).getSubobjectType();
    assertEquals(IPV4_PREFIX1, prefix1.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
    assertEquals(IPV4_PREFIX2, prefix2.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
    // delete tunnel
    final PcepDestroyTunnelInputBuilder destroyInputBuilder = new PcepDestroyTunnelInputBuilder();
    destroyInputBuilder.setLinkId(LINK1_ID);
    destroyInputBuilder.setNetworkTopologyRef(topologyRef);
    tunnelProgramming.pcepDestroyTunnel(destroyInputBuilder.build());
    assertNotNull(removeLspInput);
    assertEquals(LINK1_ID.getValue(), removeLspInput.getName());
    assertEquals(NODE1_ID, removeLspInput.getNode());
}
Also used : NetworkTopologyRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef) PcepUpdateTunnelInput1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcepUpdateTunnelInput1Builder) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth) PcepCreateP2pTunnelInput1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PcepCreateP2pTunnelInput1Builder) PcepUpdateTunnelInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev181109.PcepUpdateTunnelInputBuilder) Ipv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4Case) PcepDestroyTunnelInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev181109.PcepDestroyTunnelInputBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject) SourceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.SourceBuilder) Ipv4(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4) Arguments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.add.lsp.args.Arguments) PcepCreateP2pTunnelInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.pcep.programming.rev181109.PcepCreateP2pTunnelInputBuilder) ClassType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType) DestinationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.tunnel.programming.rev130930.create.p2p.tunnel.input.DestinationBuilder) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 9 with IpPrefixCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase in project bgpcep by opendaylight.

the class EROIpv6PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final Ipv6Prefix ipv6prefix = specObj.getIpPrefix().getIpv6Prefix();
    checkArgument(ipv6prefix != null, "Ipv6Prefix is mandatory.");
    serializeSubobject(buffer, subobject, ipv6prefix);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 10 with IpPrefixCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase in project bgpcep by opendaylight.

the class RROIpv4PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final IpPrefix prefix = specObj.getIpPrefix();
    final Ipv6Prefix ipv6Prefix = prefix.getIpv6Prefix();
    if (ipv6Prefix != null) {
        RROIpv6PrefixSubobjectParser.serializeSubobject(buffer, subobject, ipv6Prefix);
        return;
    }
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LPA_F_OFFSET, subobject.getProtectionAvailable());
    flags.set(LPIU_F_OFFSET, subobject.getProtectionInUse());
    final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
    checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
    Ipv4Util.writeIpv4Prefix(prefix.getIpv4Prefix(), body);
    flags.toByteBuf(body);
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Aggregations

Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)13 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)12 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)10 ByteBuf (io.netty.buffer.ByteBuf)6 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)6 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase)4 BitArray (org.opendaylight.protocol.util.BitArray)2 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)2 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject)2 Attribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute)2 SubobjectType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 AbstractConcurrentDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 Ipv6AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone)1 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)1 NetworkTopologyRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef)1 PathDescription (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.path.descriptions.PathDescription)1