Honeynode test tool
[transportpce.git] / tests / honeynode / honeynode-plugin-impl / src / main / java / io / fd / honeycomb / transportpce / device / rpcs / ConnectionPortTrailService.java
1 /*
2  * Copyright (c) 2018 Orange and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package io.fd.honeycomb.transportpce.device.rpcs;
17
18 import io.fd.honeycomb.rpc.RpcService;
19
20 import java.util.Arrays;
21 import java.util.concurrent.CompletableFuture;
22 import java.util.concurrent.CompletionStage;
23
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailInput;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutput;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.GetConnectionPortTrailOutputBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.get.connection.port.trail.output.Ports;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.get.connection.port.trail.output.PortsBuilder;
30 import org.opendaylight.yangtools.yang.common.QName;
31 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 /**
36  * Class to simulate get-connection-port-trail rpc.
37  *
38  * @author Martial COULIBALY ( mcoulibaly.ext@orange.com ) on behalf of Orange
39  */
40 public class ConnectionPortTrailService implements RpcService<GetConnectionPortTrailInput, GetConnectionPortTrailOutput> {
41     private static final Logger LOG = LoggerFactory.getLogger(ConnectionPortTrailService.class);
42     private static final String localName = "get-connection-port-trail";
43     private static final QName name = QName.create(GetConnectionPortTrailInput.QNAME, localName);
44     private static final SchemaPath schemaPath = SchemaPath.ROOT.createChild(name);
45
46     @Override
47     public SchemaPath getManagedNode() {
48         return schemaPath;
49     }
50
51     /* (non-Javadoc)
52      * @see io.fd.honeycomb.rpc.RpcService#invoke(org.opendaylight.yangtools.yang.binding.DataObject)
53      */
54     @Override
55     public CompletionStage<GetConnectionPortTrailOutput> invoke(GetConnectionPortTrailInput arg0) {
56         LOG.info("RPC GetConnectionPortTrail request received !");
57         Ports port = new PortsBuilder()
58                 .setCircuitPackName("2/0")
59                 .setPortName("L1")
60                 .build();
61         GetConnectionPortTrailOutput output = new GetConnectionPortTrailOutputBuilder()
62                 .setStatusMessage("OK")
63                 .setStatus(RpcStatus.Successful)
64                 .setPorts(Arrays.asList(port))
65                 .build();
66         CompletableFuture<GetConnectionPortTrailOutput> result = new CompletableFuture<>();
67         result.complete(output);
68         return result;
69     }
70
71 }