...
- ietf harware component: org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component
- data-provider Inventory: org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory
During initialization the Object org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.Hardware is readed from device. This object provides a list of Component.
Here the example, that is reading the hardware and looping through the list of components. The oRanMapper object converts to the data-provider mode and the data is written to the database with writeInventory command.
Code Block | ||
---|---|---|
| ||
public void initialReadFromNetworkElement() {
ORanToInternalDataModel oRanMapper = new ORanToInternalDataModel();
Hardware hardware = readHardware(netconfAccessor);
if (hardware != null) {
List<Component> componentList = hardware.getComponent();
if (componentList != null) {
for (Component component : componentList) {
databaseService.writeInventory( oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component));
}
}
}
} |
The mapping needs to be implemented by code, that is hand-written or generated.
One possible implementation could be like this:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class ORanToInternalDataModel { public Inventory getInternalEquipment(NodeId nodeId, Component component) { InventoryBuilder inventoryBuilder = new InventoryBuilder(); // General inventoryBuilder.setNodeId(nodeId.getValue()); inventoryBuilder.setParentUuid(component.getParent()); inventoryBuilder.setTreeLevel(new Long(component.getParentRelPos())); inventoryBuilder.setUuid(component.getUuid().getValue()); // -- String list with ids of holders List<String> containerHolderKeyList = new ArrayList<>(); List<String> containerHolderList = component.getContainsChild(); if (containerHolderList != null) { for (String containerHolder : containerHolderList) { containerHolderKeyList.add(containerHolder); } } inventoryBuilder.setContainedHolder(containerHolderKeyList); // -- Manufacturer related things inventoryBuilder.setManufacturerName(component.getName()); // Equipment type inventoryBuilder.setDescription(component.getDescription()); inventoryBuilder.setModelIdentifier(component.getModelName()); inventoryBuilder.setPartTypeId(component.getXmlClass().getName()); inventoryBuilder.setTypeName(component.getName()); inventoryBuilder.setVersion(component.getHardwareRev()); // Equipment instance inventoryBuilder.setDate(component.getMfgDate().getValue()); inventoryBuilder.setSerial(component.getSerialNum()); return inventoryBuilder.build(); } |
...