Update portmapping YANG model
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmOtnInterface221.java
index 538bd2ee897514b82c584a3332bd6ad35c7d79d8..6f06784626e5ea9d7dd8841339b1b3150233acbc 100644 (file)
@@ -10,15 +10,13 @@ package org.opendaylight.transportpce.renderer.openroadminterface;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.IntStream;
-
 import org.opendaylight.transportpce.common.mapping.PortMapping;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev200128.network.nodes.Mapping;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210315.mapping.Mapping;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.interfaces.grp.InterfaceKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev171215.AdminStates;
-import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.Interface1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.Interface1Builder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev181019.ethernet.container.EthernetBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev170626.EthernetCsmacd;
@@ -35,6 +33,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.opu.OpuBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.parent.odu.allocation.ParentOduAllocationBuilder;
 import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -60,15 +59,14 @@ public class OpenRoadmOtnInterface221 {
         }
 
         // Ethernet interface specific data
-        EthernetBuilder ethIfBuilder = new EthernetBuilder();
-        ethIfBuilder.setSpeed(1000L);
+        EthernetBuilder ethIfBuilder = new EthernetBuilder()
+                .setSpeed(Uint32.valueOf(1000));
         InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(
                 portMap, EthernetCsmacd.class,
                 logicalConnPoint + "-ETHERNET1G");
         // Create Interface1 type object required for adding as augmentation
         Interface1Builder ethIf1Builder = new Interface1Builder();
-        ethInterfaceBldr.addAugmentation(Interface1.class,
-                ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
+        ethInterfaceBldr.addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
         // Post interface on the device
         this.openRoadmInterfaces.postOTNInterface(nodeId, ethInterfaceBldr);
         // Post the equipment-state change on the device circuit-pack
@@ -89,7 +87,7 @@ public class OpenRoadmOtnInterface221 {
 
     private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap,
             Class<? extends InterfaceType> type, String key) {
-        InterfaceBuilder interfaceBuilder = new InterfaceBuilder()
+        return new InterfaceBuilder()
                 // .setDescription(" TBD ")
                 // .setCircuitId(" TBD ")
                 .setSupportingCircuitPackName(
@@ -98,7 +96,6 @@ public class OpenRoadmOtnInterface221 {
                 .setAdministrativeState(AdminStates.InService)
                 // TODO get rid of unchecked cast warning
                 .setType(type).setName(key).withKey(new InterfaceKey(key));
-        return interfaceBuilder;
     }
 
     public String createOpenRoadmEth10GInterface(String nodeId,
@@ -111,12 +108,12 @@ public class OpenRoadmOtnInterface221 {
         // Ethernet interface specific data
         EthernetBuilder ethIfBuilder = new EthernetBuilder()
                 // .setAutoNegotiation(EthAttributes.AutoNegotiation.Disabled)
-                .setSpeed(10000L);
+                .setSpeed(Uint32.valueOf(10000));
         // Create Interface1 type object required for adding as augmentation
         Interface1Builder ethIf1Builder = new Interface1Builder();
         InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class,
-                logicalConnPoint + "-ETHERNET10G").addAugmentation(Interface1.class,
-                        ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
+                logicalConnPoint + "-ETHERNET10G").addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build())
+                        .build());
         // Post interface on the device
         this.openRoadmInterfaces.postOTNInterface(nodeId, ethInterfaceBldr);
         // Post the equipment-state change on the device circuit-pack
@@ -147,7 +144,7 @@ public class OpenRoadmOtnInterface221 {
         if (supportingInterface == null) {
             throw new OpenRoadmInterfaceException(
                     "Interface Creation failed because of missing supported "
-                    + "ODU4 on network end or Eth iface on client");
+                    + "ODU4 on network end or Ethernet on client");
         }
 
         InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(
@@ -168,7 +165,8 @@ public class OpenRoadmOtnInterface221 {
             IntStream.range(tribSlotIndex, tribSlotIndex + 8)
                     .forEach(nbr -> tribSlots.add(Uint16.valueOf(nbr)));
             ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
-                    .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots);
+                    .setTribPortNumber(Uint16.valueOf(tribPortNumber))
+                    .setTribSlots(tribSlots);
             oduIfBuilder.setOduFunction(ODUCTP.class)
                     .setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
                     .setParentOduAllocation(parentOduAllocationBuilder.build());
@@ -184,9 +182,7 @@ public class OpenRoadmOtnInterface221 {
         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder
             oduIf1Builder = new
                 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
-        oduInterfaceBldr.addAugmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
-                oduIf1Builder.setOdu(oduIfBuilder.build()).build());
+        oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduIfBuilder.build()).build());
 
         // Post interface on the device
         this.openRoadmInterfaces.postOTNInterface(nodeId, oduInterfaceBldr);
@@ -225,7 +221,8 @@ public class OpenRoadmOtnInterface221 {
             tribSlots.add(Uint16.valueOf(tribSlot));
             ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
                     // set trib port numbers
-                    .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots);
+                    .setTribPortNumber(Uint16.valueOf(tribPortNumber))
+                    .setTribSlots(tribSlots);
             oduIfBuilder.setOduFunction(ODUCTP.class)
                     .setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
                     .setParentOduAllocation(parentOduAllocationBuilder.build());
@@ -245,9 +242,7 @@ public class OpenRoadmOtnInterface221 {
         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder
             oduIf1Builder = new
             org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
-        oduInterfaceBldr.addAugmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
-                oduIf1Builder.setOdu(oduIfBuilder.build()).build());
+        oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduIfBuilder.build()).build());
 
         // Post interface on the device
         this.openRoadmInterfaces.postOTNInterface(nodeId, oduInterfaceBldr);
@@ -285,7 +280,8 @@ public class OpenRoadmOtnInterface221 {
                     .forEach(nbr -> tribSlots.add(Uint16.valueOf(nbr)));
             ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
                     // set trib port numbers
-                    .setTribPortNumber(tribPortNumber).setTribSlots(tribSlots);
+                    .setTribPortNumber(Uint16.valueOf(tribPortNumber))
+                    .setTribSlots(tribSlots);
             oduIfBuilder.setOduFunction(ODUCTP.class)
                     .setMonitoringMode(OduAttributes.MonitoringMode.Monitored)
                     .setParentOduAllocation(parentOduAllocationBuilder.build());
@@ -304,9 +300,7 @@ public class OpenRoadmOtnInterface221 {
         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder
             oduIf1Builder = new
                 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1Builder();
-        oduInterfaceBldr.addAugmentation(
-                org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev181019.Interface1.class,
-                oduIf1Builder.setOdu(oduIfBuilder.build()).build());
+        oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduIfBuilder.build()).build());
 
         // Post interface on the device
         this.openRoadmInterfaces.postOTNInterface(nodeId, oduInterfaceBldr);