private void addAliasesToEntities(Map<Integer, SortedSet<OnmsHwEntityAlias>> aliasMap, OnmsHwEntity entity) { for (OnmsHwEntity child : entity.getChildren()) { addAliasesToEntities(aliasMap, child); } SortedSet<OnmsHwEntityAlias> aliases = aliasMap.get(entity.getEntPhysicalIndex()); if (aliases != null) { entity.setEntAliases(aliases); } }
@Override public void rowCompleted(SnmpRowResult row) { OnmsHwEntity entity = ((EntityPhysicalTableRow) row).getOnmsHwEntity(vendorAttributes, replacementMap); LOG.debug("rowCompleted: found entity {}, index: {}, parent: {}", entity.getEntPhysicalName(), entity.getEntPhysicalIndex(), entity.getEntPhysicalContainedIn()); if (entity.getEntPhysicalContainedIn() != null && entity.getEntPhysicalContainedIn() > 0) { OnmsHwEntity parent = getParent(entity.getEntPhysicalContainedIn().intValue()); if (parent != null) { LOG.debug("rowCompleted: adding child index {} to parent index {}", entity.getEntPhysicalIndex(), parent.getEntPhysicalIndex()); parent.addChildEntity(entity); } } entities.add(entity); }
@Override protected Integer getId(final OnmsHwEntity outage) { return outage.getId(); }
/** * Adds the child entity. * * @param child the child */ public void addChildEntity(OnmsHwEntity child) { child.setParent(this); getChildren().add(child); }
if (entity.getId() != null) { builder.setEntityId(entity.getId()); if (entity.getEntPhysicalIndex() != null) { builder.setEntPhysicalIndex(entity.getEntPhysicalIndex()); if (entity.getEntPhysicalClass() != null) { builder.setEntPhysicalClass(entity.getEntPhysicalClass()); if (entity.getEntPhysicalDescr() != null) { builder.setEntPhysicalDescr(entity.getEntPhysicalDescr()); if (entity.getEntPhysicalIsFRU() != null) { builder.setEntPhysicalIsFru(entity.getEntPhysicalIsFRU()); if (entity.getEntPhysicalName() != null) { builder.setEntPhysicalName(entity.getEntPhysicalName()); if (entity.getEntPhysicalVendorType() != null) { builder.setEntPhysicalVendorType(entity.getEntPhysicalVendorType()); entity.getEntAliases() .stream() .forEach(alias -> builder.addEntHwAlias(toHwAlias(alias))); entity.getChildren() .stream() .forEach(child -> builder.addChildren(toHwEntity(child)));
final OnmsHwEntity entity = new OnmsHwEntity(); entity.setEntPhysicalIndex(getEntPhysicalIndex()); entity.setEntPhysicalClass(getEntPhysicalClass()); v = getValue(entPhysicalDescr); if (v != null && !v.toDisplayString().trim().isEmpty()) entity.setEntPhysicalDescr(v.toDisplayString().trim()); v = getValue(entPhysicalVendorType); if (v != null && !v.toDisplayString().trim().isEmpty()) entity.setEntPhysicalVendorType(v.toDisplayString().trim()); v = getValue(entPhysicalContainedIn); if (v != null) entity.setEntPhysicalContainedIn(v.toInt()); v = getValue(entPhysicalParentRelPos); if (v != null) entity.setEntPhysicalParentRelPos(v.toInt()); v = getValue(entPhysicalName); if (v != null && !v.toDisplayString().trim().isEmpty()) entity.setEntPhysicalName(v.toDisplayString().trim().trim()); v = getValue(entPhysicalHardwareRev); if (v != null && !v.toDisplayString().trim().isEmpty()) entity.setEntPhysicalHardwareRev(v.toDisplayString().trim()); v = getValue(entPhysicalFirmwareRev); if (v != null && !v.toDisplayString().trim().isEmpty()) entity.setEntPhysicalFirmwareRev(v.toDisplayString().trim()); v = getValue(entPhysicalSoftwareRev); if (v != null && !v.toDisplayString().trim().isEmpty()) entity.setEntPhysicalSoftwareRev(v.toDisplayString().trim()); v = getValue(entPhysicalSerialNum); if (v != null && !v.toDisplayString().trim().isEmpty())
/** * Find attribute. * * @param entity the entity * @param nameRegex the regular expression for entPhysicalName * @param attributeName the attribute name * @return the string */ private String findAttribute(OnmsHwEntity entity, String nameRegex, String attributeName) { if (entity.getEntPhysicalName().matches(nameRegex)) { return getAttributeValue(entity, attributeName); } for (OnmsHwEntity c : entity.getChildren()) { String v = findAttribute(c, nameRegex, attributeName); if (v != null) { return v; } } return null; }
/** * Gets the child by index. * * @param entPhysicalIndex the entity physical index * @return the child by index */ public OnmsHwEntity getChildByIndex(Integer entPhysicalIndex) { for (OnmsHwEntity child : m_children) { if (child.getEntPhysicalIndex() == entPhysicalIndex) { return child; } } return null; }
/** * Sets the entity id. * * @param id the entity id */ public void setOnmsHwEntityId(final String id) { setId(Integer.valueOf(id)); }
SnmpAgentConfig agentConfig = m_snmpConfigDao.getAgentConfig(ipAddress, locationName); final OnmsHwEntity newRoot = getRootEntity(agentConfig, node); newRoot.setNode(node); final OnmsHwEntity currentRoot = m_hwEntityDao.findRootByNodeId(node.getId()); if (newRoot.equals(currentRoot)) { LOG.info("No changes detected on the hardware inventory for nodeId {}", nodeId); return;
/** * Sets the node. * * @param node the node */ public void setNode(OnmsNode node) { if (node == null) return; m_node = node; if (m_children == null) return; for (OnmsHwEntity child : m_children) { child.setNode(node); } }
if (entity.getId() != null) { builder.setEntityId(entity.getId()); if (entity.getEntPhysicalIndex() != null) { builder.setEntPhysicalIndex(entity.getEntPhysicalIndex()); if (entity.getEntPhysicalClass() != null) { builder.setEntPhysicalClass(entity.getEntPhysicalClass()); if (entity.getEntPhysicalDescr() != null) { builder.setEntPhysicalDescr(entity.getEntPhysicalDescr()); if (entity.getEntPhysicalIsFRU() != null) { builder.setEntPhysicalIsFru(entity.getEntPhysicalIsFRU()); if (entity.getEntPhysicalName() != null) { builder.setEntPhysicalName(entity.getEntPhysicalName()); if (entity.getEntPhysicalVendorType() != null) { builder.setEntPhysicalVendorType(entity.getEntPhysicalVendorType()); entity.getEntAliases() .stream() .forEach(alias -> builder.addEntHwAlias(toHwAlias(alias))); entity.getChildren() .stream() .forEach(child -> builder.addChildren(toHwEntity(child)));
/** * Gets the parent. * * @param parentId the parent ID * @return the parent */ private OnmsHwEntity getParent(int parentId) { for (OnmsHwEntity e : entities) { if (e.getEntPhysicalIndex() != null && e.getEntPhysicalIndex().intValue() == parentId) { return e; } } return null; } }
@Override protected void generateId(final OnmsHwEntity outage) { outage.setId(m_id.incrementAndGet()); }
/** * Gets the parent id. * * @return the parent id */ @Transient @XmlAttribute(name="parentPhysicalIndex") public Integer getParentIndex() { return m_parent == null ? null : m_parent.getEntPhysicalIndex(); }
@Override protected Integer getId(final OnmsHwEntity outage) { return outage.getId(); }
@Override protected void generateId(final OnmsHwEntity outage) { outage.setId(m_id.incrementAndGet()); }
@Override public String toString() { return new ToStringBuilder(this.getClass().getSimpleName(), ToStringStyle.SHORT_PREFIX_STYLE) .append("entPhysicalIndex", m_hwEntity == null ? null : m_hwEntity.getEntPhysicalIndex()) .append("type", m_attributeType) .append("value", m_attributeValue) .toString(); }
@Override public String toString() { ToStringBuilder b = new ToStringBuilder(OnmsHwEntityAlias.class.getSimpleName(), ToStringStyle.SHORT_PREFIX_STYLE); if (m_hwEntity != null) { b.append("entity", m_hwEntity.getEntPhysicalIndex()); } if (m_index != null) { b.append("idx", m_index); } if (m_oid != null) { b.append("oid", m_oid); } return b.toString(); }