Updates to Renderer
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmOtu4Interface.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.device.rev170206.interfaces.grp.InterfaceBuilder;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.interfaces.grp.InterfaceKey;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.OtnOtu;
16
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.Interface1Builder;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.OTU4;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.OtuAttributes.Fec;
21 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev161014.otu.container.OtuBuilder;
22
23 public class OpenRoadmOtu4Interface extends OpenRoadmInterfaces {
24
25     public OpenRoadmOtu4Interface(DataBroker db, MountPointService mps, String nodeId, String logicalConnPoint,
26             String serviceName) {
27         super(db, mps, nodeId, logicalConnPoint, serviceName);
28
29     }
30
31     /**
32      * This methods creates an OTU interface on the given termination point.
33      *
34      *
35      * @return Name of the interface if successful, otherwise return null.
36      */
37
38     public String createInterface(String supportOchInterface) {
39         // Create generic interface
40         InterfaceBuilder otuInterfaceBldr = getIntfBuilder(portMap);
41         otuInterfaceBldr.setType(OtnOtu.class);
42         otuInterfaceBldr.setSupportingInterface(supportOchInterface);
43         otuInterfaceBldr.setName(logicalConnPoint + "-OTU");
44         otuInterfaceBldr.setKey(new InterfaceKey(logicalConnPoint + "-OTU"));
45
46         // OTU interface specific data
47         OtuBuilder otuIfBuilder = new OtuBuilder();
48         otuIfBuilder.setFec(Fec.Scfec);
49         otuIfBuilder.setRate(OTU4.class);
50
51         // Create Interface1 type object required for adding as augmentation
52         Interface1Builder otuIf1Builder = new Interface1Builder();
53         otuInterfaceBldr.addAugmentation(Interface1.class, otuIf1Builder.setOtu(otuIfBuilder.build()).build());
54
55         // Post interface on the device
56         if (postInterface(otuInterfaceBldr)) {
57             return otuInterfaceBldr.getName();
58         } else {
59             return null;
60         }
61     }
62 }