aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-02-23 08:08:21 +0100
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-02-23 08:08:35 +0100
commit72a2da9f59cae86d7468bcb1b4dc61939a7b1552 (patch)
tree3e31ed6c79c10e5efbc1104478151620a31f8389 /sdnr
parentf333557c8bf0a74eb7b88d6294dea2a420b1ec61 (diff)
ORAN Devicemanager null exception
optional field uuid should not be used as key Issue-ID: CCSDK-3159 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: I55d561dacb5892b3539eb06681bde820d0e83973 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr')
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java31
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java24
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java5
3 files changed, 46 insertions, 14 deletions
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
index 59d51e199..757768573 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
@@ -85,12 +85,22 @@ public class ORanNetworkElement implements NetworkElement {
if (hardware != null) {
Collection<Component> componentList = YangHelper.getCollection(hardware.getComponent());
if (componentList != null) {
+ int componentListSize = componentList.size();
+ int writeCount = 0;
+
for (Component component : componentList) {
- databaseService
- .writeInventory(oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component));
+ if (component.getParent() == null) {
+ writeCount += writeInventory(component, componentList, 0);
+ }
+ }
+ if (componentListSize != writeCount) {
+ log.warn("Not all data were written to the Inventory. Potential entries with missing "
+ + "contained-child. Node Id = {}, Components Found = {}, Entries written to Database = {}",
+ netconfAccessor.getNodeId().getValue(), componentListSize, writeCount);
}
}
}
+
System1 sys = getOnapSystemData(netconfAccessor);
if (sys != null) {
GuicutthroughBuilder gcBuilder = new GuicutthroughBuilder();
@@ -99,6 +109,23 @@ public class ORanNetworkElement implements NetworkElement {
}
}
+ private int writeInventory(Component component, Collection<Component> componentList, int treeLevel) {
+ databaseService
+ .writeInventory(oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component, treeLevel));
+ int count = 1;
+ if (component.getContainsChild() != null) {
+ List<String> containerHolderList = component.getContainsChild();
+ for (String containerHolder : containerHolderList) {
+ for (Component c : componentList) {
+ if (containerHolder.equals(c.getName())) {
+ count += writeInventory(c, componentList, treeLevel + 1);
+ }
+ }
+ }
+ }
+ return count;
+ }
+
@Override
public NetworkElementDeviceType getDeviceType() {
return NetworkElementDeviceType.ORAN;
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java
index c563cc491..ca44e63f2 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java
@@ -31,18 +31,16 @@ import org.opendaylight.yangtools.yang.common.Uint32;
*/
public class ORanToInternalDataModel {
-
- public Inventory getInternalEquipment(NodeId nodeId, Component component) {
+ public Inventory getInternalEquipment(NodeId nodeId, Component component, int treeLevel) {
InventoryBuilder inventoryBuilder = new InventoryBuilder();
// General
inventoryBuilder.setNodeId(nodeId.getValue());
- inventoryBuilder.setParentUuid(component.getParent());
- inventoryBuilder.setTreeLevel(new Long(component.getParentRelPos()));
- inventoryBuilder.setTreeLevel(Uint32.valueOf(component.getParentRelPos().intValue()));
+ inventoryBuilder.setParentUuid(component.getParent()!=null?component.getParent():component.getName());
+ inventoryBuilder.setTreeLevel(Uint32.valueOf(treeLevel));
- inventoryBuilder.setUuid(component.getUuid().getValue());
+ inventoryBuilder.setUuid(component.getName());
// -- String list with ids of holders
List<String> containerHolderKeyList = new ArrayList<>();
List<String> containerHolderList = component.getContainsChild();
@@ -53,19 +51,25 @@ public class ORanToInternalDataModel {
}
inventoryBuilder.setContainedHolder(containerHolderKeyList);
// -- Manufacturer related things
- inventoryBuilder.setManufacturerName(component.getName());
+ inventoryBuilder.setManufacturerName(component.getMfgName());
+ inventoryBuilder.setManufacturerIdentifier(component.getMfgName());
+
// Equipment type
inventoryBuilder.setDescription(component.getDescription());
inventoryBuilder.setModelIdentifier(component.getModelName());
- inventoryBuilder.setPartTypeId(component.getXmlClass().getName());
+ if (component.getXmlClass() != null) {
+ inventoryBuilder.setPartTypeId(component.getXmlClass().getName());
+ }
inventoryBuilder.setTypeName(component.getName());
inventoryBuilder.setVersion(component.getHardwareRev());
+
// Equipment instance
- inventoryBuilder.setDate(component.getMfgDate().getValue());
+ if (component.getMfgDate() != null) {
+ inventoryBuilder.setDate(component.getMfgDate().getValue());
+ }
inventoryBuilder.setSerial(component.getSerialNum());
-
return inventoryBuilder.build();
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
index c33926bd8..76b2f32ce 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
@@ -39,13 +39,14 @@ public class TestORanToInternalDataModel {
NodeId nodeId;
Component component;
- @Before
+ @Before
public void init() throws InterruptedException, IOException {
nodeId = mock(NodeId.class);
component = mock(Component.class);
when(nodeId.getValue()).thenReturn("ORan-1000");
when(component.getParent()).thenReturn("Shelf");
+ when(component.getName()).thenReturn("Slot-0");
when(component.getParentRelPos()).thenReturn(0);
when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
@@ -67,7 +68,7 @@ public class TestORanToInternalDataModel {
@Test
public void test() throws Exception {
ORanToInternalDataModel model = new ORanToInternalDataModel();
- model.getInternalEquipment(nodeId, component);
+ model.getInternalEquipment(nodeId, component,0);
assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB");
assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z");