2 * Copyright © 2018 Orange, 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
8 package org.opendaylight.transportpce.tapi.utils;
10 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.equipment.types.rev181130.OpticTypes;
11 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.node.types.rev181130.NodeIdType;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ConnectionType;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.RpcActions;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.sdnc.request.header.SdncRequestHeaderBuilder;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.RxDirectionBuilder;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.endpoint.TxDirectionBuilder;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.lgx.LgxBuilder;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.service.port.PortBuilder;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInput;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.ServiceCreateInputBuilder;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEnd;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceAEndBuilder;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEnd;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev190531.service.create.input.ServiceZEndBuilder;
27 public final class TapiUtils {
32 public static ServiceCreateInput buildServiceCreateInput(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
33 ServiceCreateInputBuilder builtInput = new ServiceCreateInputBuilder();
34 ServiceAEnd serviceAEnd = getServiceAEnd(sepA, sepZ);
35 ServiceZEnd serviceZEnd = getServiceZEnd(sepA, sepZ);
36 if (serviceAEnd != null && serviceZEnd != null) {
37 builtInput.setCommonId("commonId");
38 builtInput.setConnectionType(ConnectionType.Service);
39 builtInput.setCustomer("Customer");
40 builtInput.setServiceName("service test");
41 builtInput.setServiceAEnd(serviceAEnd);
42 builtInput.setServiceZEnd(serviceZEnd);
43 builtInput.setSdncRequestHeader(new SdncRequestHeaderBuilder().setRequestId("request-1")
44 .setRpcAction(RpcActions.ServiceCreate).setNotificationUrl("notification url").setRequestSystemId(
50 return builtInput.build();
53 public static ServiceAEnd buildServiceAEnd(String nodeid, String clli, String txPortDeviceName,
54 String txPortName, String rxPortDeviceName, String rxPortName) {
55 ServiceAEnd serviceAEnd = new ServiceAEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid)).setOpticType(
56 OpticTypes.Gray).setServiceFormat(
57 ServiceFormat.Ethernet).setServiceRate(new Long(100))
59 new TxDirectionBuilder()
60 .setPort(new PortBuilder().setPortDeviceName(txPortDeviceName).setPortName(txPortName)
61 .setPortRack("000000.00").setPortShelf("00").setPortType("some port type").build())
62 .setLgx(new LgxBuilder().setLgxDeviceName("Some lgx-device-name").setLgxPortName(
63 "Some lgx-port-name").setLgxPortRack("000000.00").setLgxPortShelf("00").build())
66 new RxDirectionBuilder()
67 .setPort(new PortBuilder().setPortDeviceName(rxPortDeviceName).setPortName(rxPortName)
68 .setPortRack("000000.00").setPortShelf("00").setPortType("some port type").build())
69 .setLgx(new LgxBuilder().setLgxDeviceName("Some lgx-device-name").setLgxPortName(
70 "Some lgx-port-name").setLgxPortRack("000000.00").setLgxPortShelf("00").build()).build())
75 public static ServiceZEnd buildServiceZEnd(String nodeid, String clli, String txPortDeviceName,
76 String txPortName, String rxPortDeviceName, String rxPortName) {
77 ServiceZEnd serviceZEnd = new ServiceZEndBuilder().setClli(clli).setNodeId(new NodeIdType(nodeid)).setOpticType(
78 OpticTypes.Gray).setServiceFormat(
79 ServiceFormat.Ethernet).setServiceRate(new Long(100))
81 new TxDirectionBuilder()
82 .setPort(new PortBuilder().setPortDeviceName(txPortDeviceName).setPortName(txPortName)
83 .setPortRack("000000.00").setPortShelf("00").setPortType("some port type").build())
84 .setLgx(new LgxBuilder().setLgxDeviceName("Some lgx-device-name").setLgxPortName(
85 "Some lgx-port-name").setLgxPortRack("000000.00").setLgxPortShelf("00").build())
88 new RxDirectionBuilder()
89 .setPort(new PortBuilder().setPortDeviceName(rxPortDeviceName).setPortName(rxPortName)
90 .setPortRack("000000.00").setPortShelf("00").setPortType("some port type").build())
91 .setLgx(new LgxBuilder().setLgxDeviceName("Some lgx-device-name").setLgxPortName(
92 "Some lgx-port-name").setLgxPortRack("000000.00").setLgxPortShelf("00").build()).build())
97 private static ServiceAEnd getServiceAEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
98 if (sepA.getType().equals(ServiceEndpointType.SERVICEAEND)) {
99 return new ServiceAEndBuilder(sepA.getValue()).build();
100 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEAEND)) {
101 return new ServiceAEndBuilder(sepZ.getValue()).build();
107 private static ServiceZEnd getServiceZEnd(GenericServiceEndpoint sepA, GenericServiceEndpoint sepZ) {
108 if (sepA.getType().equals(ServiceEndpointType.SERVICEZEND)) {
109 return new ServiceZEndBuilder(sepA.getValue()).build();
110 } else if (sepZ.getType().equals(ServiceEndpointType.SERVICEZEND)) {
111 return new ServiceZEndBuilder(sepZ.getValue()).build();