Updates to Renderer
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmXponderInterface.java
1 /*
2  * Copyright © 2017 AT&T and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.renderer.openroadminterface;
10
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes.ModulationFormat;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.RateIdentity;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 public class OpenRoadmXponderInterface extends OpenRoadmInterfaces {
19
20     private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmXponderInterface.class);
21     private final  String serviceName;
22
23     public OpenRoadmXponderInterface(DataBroker db, MountPointService mps, String nodeId, String logicalConnPoint,
24         String serviceName) {
25         super(db, mps, nodeId, logicalConnPoint,serviceName);
26         this.serviceName = serviceName;
27
28     }
29
30     public boolean createLineInterfaces(Long waveNumber, Class<? extends RateIdentity> rate, ModulationFormat format) {
31
32         String supportOchInterface = new OpenRoadmOchInterface(db, mps, nodeId, logicalConnPoint,serviceName)
33                 .createInterface(waveNumber, rate, format);
34         String supportingOtuInterface;
35         String supportingOduInterface;
36
37         if (supportOchInterface != null) {
38             supportingOtuInterface = new OpenRoadmOtu4Interface(db, mps, nodeId, logicalConnPoint,serviceName)
39                     .createInterface(supportOchInterface);
40         } else {
41             LOG.error("Unable to create OCH interface on the transponder");
42             return false;
43         }
44         if (supportingOtuInterface != null) {
45             supportingOduInterface = new OpenRoadmOdu4Interface(db, mps, nodeId, logicalConnPoint,serviceName)
46                     .createInterface(supportingOtuInterface);
47         } else {
48             LOG.error("Unable to create OTU interface on the transponder");
49             return false;
50         }
51         if (supportingOduInterface != null) {
52             return true;
53         } else {
54             LOG.error("Unable to create ODU interface on the transponder");
55             return false;
56         }
57     }
58
59     public boolean createClientInterfaces() {
60
61         if (new OpenRoadmEthIterface(db, mps, nodeId, logicalConnPoint,serviceName).createInterface() != null) {
62             return true;
63         }
64         return false;
65     }
66 }