2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.pcep.pcc.mock;
11 import static org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createPath;
13 import com.google.common.collect.Lists;
14 import java.util.HashMap;
16 import javax.annotation.Nonnull;
17 import org.opendaylight.protocol.pcep.pcc.mock.api.LspType;
18 import org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
27 final class PCCTunnelBuilder {
28 private static final Subobject DEFAULT_ENDPOINT_HOP = getDefaultEROEndpointHop();
29 private static final String ENDPOINT_ADDRESS = "1.1.1.1";
30 private static final String ENDPOINT_PREFIX = ENDPOINT_ADDRESS + "/32";
31 static final int PCC_DELEGATION = -1;
33 private PCCTunnelBuilder() {
34 throw new UnsupportedOperationException();
38 static Map<PlspId, PCCTunnel> createTunnels(final String address, final int lsps) {
39 final Map<PlspId, PCCTunnel> tunnels = new HashMap<>();
40 for (int i = 1; i <= lsps; i++) {
41 final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, i),
42 PCC_DELEGATION, LspType.PCC_LSP, createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
43 tunnels.put(new PlspId((long) i), tunnel);
48 private static Subobject getDefaultEROEndpointHop() {
49 final SubobjectBuilder builder = new SubobjectBuilder();
50 builder.setLoose(false);
51 builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(
52 new IpPrefix(new Ipv4Prefix(ENDPOINT_PREFIX))).build()).build());
53 return builder.build();