use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4Case in project bgpcep by opendaylight.
the class TunnelProgrammingTest method testTunnelProgramming.
@Test
public void testTunnelProgramming() throws TransactionCommitFailedException {
final Bandwidth bwd = new Bandwidth(new byte[] { 0x00, 0x00, 0x00, (byte) 0xff });
final ClassType classType = new ClassType((short) 1);
final String tunnelName = "create-tunnel";
final NetworkTopologyRef topologyRef = new NetworkTopologyRef(TOPO_IID);
// create tunnel
final PcepCreateP2pTunnelInputBuilder createInputBuilder = new PcepCreateP2pTunnelInputBuilder();
createInputBuilder.setDestination(new DestinationBuilder().setNode(NODE2_ID).setTp(TP2_ID).build());
createInputBuilder.setSource(new SourceBuilder().setNode(NODE1_ID).setTp(TP1_ID).build());
createInputBuilder.setNetworkTopologyRef(topologyRef);
createInputBuilder.setBandwidth(bwd);
createInputBuilder.setClassType(classType);
createInputBuilder.setSymbolicPathName(tunnelName);
createInputBuilder.setExplicitHops(Lists.newArrayList());
createInputBuilder.addAugmentation(PcepCreateP2pTunnelInput1.class, new PcepCreateP2pTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build());
this.tunnelProgramming.pcepCreateP2pTunnel(createInputBuilder.build());
// check add-lsp input
Assert.assertNotNull(this.addLspInput);
Assert.assertEquals(tunnelName, this.addLspInput.getName());
final Arguments agrs = this.addLspInput.getArguments();
Assert.assertNotNull(agrs);
Assert.assertEquals(bwd, agrs.getBandwidth().getBandwidth());
Assert.assertEquals(classType, agrs.getClassType().getClassType());
final Ipv4 ipv4Endpoints = ((Ipv4Case) agrs.getEndpointsObj().getAddressFamily()).getIpv4();
Assert.assertEquals(NODE1_IPV4, ipv4Endpoints.getSourceIpv4Address().getValue());
Assert.assertEquals(NODE2_IPV4, ipv4Endpoints.getDestinationIpv4Address().getValue());
Assert.assertEquals(NODE1_ID.getValue(), this.addLspInput.getNode().getValue());
createLink();
// update tunnel
final PcepUpdateTunnelInputBuilder updateInputBuilder = new PcepUpdateTunnelInputBuilder();
updateInputBuilder.setNetworkTopologyRef(topologyRef);
updateInputBuilder.setBandwidth(bwd);
updateInputBuilder.setClassType(classType);
updateInputBuilder.setExplicitHops(Lists.newArrayList(createExplicitHop(IPV4_PREFIX1), createExplicitHop(IPV4_PREFIX2)));
updateInputBuilder.setLinkId(LINK1_ID);
updateInputBuilder.addAugmentation(PcepUpdateTunnelInput1.class, new PcepUpdateTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build());
this.tunnelProgramming.pcepUpdateTunnel(updateInputBuilder.build());
// check update-lsp input
Assert.assertNotNull(this.updateLspInput);
Assert.assertEquals(LINK1_ID.getValue(), this.updateLspInput.getName());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.Arguments updArgs = this.updateLspInput.getArguments();
Assert.assertEquals(2, updArgs.getEro().getSubobject().size());
final List<Subobject> subObjects = updArgs.getEro().getSubobject();
final IpPrefixCase prefix1 = (IpPrefixCase) subObjects.get(0).getSubobjectType();
final IpPrefixCase prefix2 = (IpPrefixCase) subObjects.get(1).getSubobjectType();
Assert.assertEquals(IPV4_PREFIX1, prefix1.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
Assert.assertEquals(IPV4_PREFIX2, prefix2.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
// delete tunnel
final PcepDestroyTunnelInputBuilder destroyInputBuilder = new PcepDestroyTunnelInputBuilder();
destroyInputBuilder.setLinkId(LINK1_ID);
destroyInputBuilder.setNetworkTopologyRef(topologyRef);
this.tunnelProgramming.pcepDestroyTunnel(destroyInputBuilder.build());
Assert.assertNotNull(this.removeLspInput);
Assert.assertEquals(LINK1_ID.getValue(), this.removeLspInput.getName());
Assert.assertEquals(NODE1_ID.getValue(), this.removeLspInput.getNode().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4Case in project bgpcep by opendaylight.
the class Stateful07LSPIdentifierIpv4TlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv instanceof LspIdentifiers, "LspIdentifiersTlv is mandatory.");
final LspIdentifiers lsp = (LspIdentifiers) tlv;
final AddressFamily afi = lsp.getAddressFamily();
final ByteBuf body = Unpooled.buffer();
if (afi.getImplementedInterface().equals(Ipv6Case.class)) {
new Stateful07LSPIdentifierIpv6TlvParser().serializeTlv(tlv, buffer);
}
final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4();
Preconditions.checkArgument(ipv4.getIpv4TunnelSenderAddress() != null, "Ipv4TunnelSenderAddress is mandatory.");
writeIpv4Address(ipv4.getIpv4TunnelSenderAddress(), body);
Preconditions.checkArgument(lsp.getLspId() != null, "LspId is mandatory.");
writeShort(lsp.getLspId().getValue().shortValue(), body);
Preconditions.checkArgument(lsp.getTunnelId() != null, "TunnelId is mandatory.");
writeUnsignedShort(lsp.getTunnelId().getValue(), body);
Preconditions.checkArgument(ipv4.getIpv4ExtendedTunnelId() != null, "Ipv4ExtendedTunnelId is mandatory.");
writeIpv4Address(ipv4.getIpv4ExtendedTunnelId(), body);
Preconditions.checkArgument(ipv4.getIpv4TunnelEndpointAddress() != null, "Ipv4TunnelEndpointAddress is mandatory.");
writeIpv4Address(ipv4.getIpv4TunnelEndpointAddress(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4Case in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParserTest method testParseObject.
@Test
public void testParseObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4Address(IP1)));
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4Address(IP2)));
final EndpointsObj output = (EndpointsObj) new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
assertEquals(IP1, ((Ipv4Case) output.getAddressFamily()).getIpv4().getSourceIpv4Address().getValue());
assertEquals(IP2, ((Ipv4Case) output.getAddressFamily()).getIpv4().getDestinationIpv4Address().getValue());
assertFalse(output.isIgnore());
assertFalse(output.isProcessingRule());
}
Aggregations