private void doVisit(SystemDef systemDef, DataCollectionVisitor visitor) { visitor.visitSystemDef(systemDef); // handle the choice between sysOid and sysOidMask doVisit(systemDef.getSystemDefChoice(), visitor); // handle ipList doVisit(systemDef.getIpList(), visitor); // handle collect doVisit(systemDef.getCollect(), visitor); visitor.completeSystemDef(systemDef); }
@Override public void visitSystemDef(final SystemDef systemDef) { //LOG.debug("visitSystemDef({})", systemDef); final SystemDefImpl def = new SystemDefImpl(systemDef.getName()); if (systemDef.getSysoid() != null) { def.setSysoid(systemDef.getSysoid()); } else if (systemDef.getSysoidMask() != null) { def.setSysoidMask(systemDef.getSysoidMask()); } m_currentSystemDef = def; }
/** * Creates the basic system definition. * * @return the system definition */ public SystemDef createBasicSystemDef() { SystemDef sysDef = new SystemDef(); sysDef.setName("New System Definition"); sysDef.setSysoidMask(".1.3.6.1.4.1."); sysDef.setCollect(new Collect()); return sysDef; }
@Override public Object generateCell(Table source, Object itemId, Object columnId) { final SystemDef s = container.getItem(itemId).getBean(); final String value = s.getSysoid() == null ? s.getSysoidMask() : s.getSysoid(); return value == null ? "N/A" : value; } });
/** * Gets the parent system definitions. * <p>The list of systemDef per SNMP collection that are referencing a given groupName</p> * * @param dataCollectionConfigDao the data collection configuration DAO * @param groupName the group name * @return the parent system definitions. */ private Set<String> getParentSystemDefs(final DataCollectionConfigDao dataCollectionConfigDao, String groupName) { Set<String> systemDefMap = new TreeSet<>(); for (final SnmpCollection collection : dataCollectionConfigDao.getRootDataCollection().getSnmpCollections()) { for (final SystemDef systemDef : collection.getSystems().getSystemDefs()) { for (final String group : systemDef.getCollect().getIncludeGroups()) { if (group.equals(groupName)) { systemDefMap.add(systemDef.getName() + '@' + collection.getName()); } } } } return systemDefMap; }
/** * Verify if the systemDefs list contains a specific system definition. * <p>One system definition will be considered the same as another one, if they have the same name.</p> * * @param globalContainer * @param systemDef * * @return true, if the list contains the system definition */ // TODO Include sysoid and sysoidMask on validation process private boolean contains(List<SystemDef> systemDefs, SystemDef systemDef) { for (SystemDef sd : systemDefs) { if (systemDef.getName().equals(sd.getName())) return true; } return false; }
SystemDefChoice sysChoice = system.getSystemDefChoice(); LOG.debug("getMibObjectList: includes sysoid {} for system <name>: {}", aSysoid, system.getName()); bMatchSysoid = true; LOG.debug("getMibObjectList: includes sysoid {} for system <name>: {}", aSysoid, system.getName()); bMatchSysoid = true; List<String> addrList = null; List<String> maskList = null; if (system.getIpList() != null) { addrList = system.getIpList().getIpAddresses(); maskList = system.getIpList().getIpAddressMasks(); LOG.debug("getMibObjectList: addrList exists and does include IP address {} for system <name>: {}", anAddress, system.getName()); bMatchIPAddress = true;
@Override public Object generateCell(Table source, Object itemId, Object columnId) { final SystemDef s = container.getItem(itemId).getBean(); return s.getCollect() == null ? 0 : s.getCollect().getIncludeGroups().size(); } });
/** * Gets the parent system definitions. * <p>The list of systemDef per SNMP collection that are referencing a given groupName</p> * * @param dataCollectionConfigDao the data collection configuration DAO * @param groupName the group name * @return the parent system definitions. */ private Set<String> getParentSystemDefs(final DataCollectionConfigDao dataCollectionConfigDao, String groupName) { Set<String> systemDefMap = new TreeSet<>(); for (final SnmpCollection collection : dataCollectionConfigDao.getRootDataCollection().getSnmpCollections()) { for (final SystemDef systemDef : collection.getSystems().getSystemDefs()) { for (final String group : systemDef.getCollect().getIncludeGroups()) { if (group.equals(groupName)) { systemDefMap.add(systemDef.getName() + '@' + collection.getName()); } } } } return systemDefMap; }
/** * Get a system definition from datacollection-group map. * * @param systemDefName the systemDef object name. * @return the systemDef object. */ private SystemDef getSystemDef(String systemDefName) { for (DatacollectionGroup group : externalGroupsMap.values()) { for (SystemDef sd : group.getSystemDefs()) { if (sd.getName().equals(systemDefName)) { return sd; } } } return null; }
@Override public Object generateCell(Table source, Object itemId, Object columnId) { final SystemDef s = container.getItem(itemId).getBean(); final String value = s.getSysoid() == null ? s.getSysoidMask() : s.getSysoid(); return value == null ? "N/A" : value; } });
@Override public Object generateCell(Table source, Object itemId, Object columnId) { final SystemDef s = container.getItem(itemId).getBean(); return s.getCollect() == null ? 0 : s.getCollect().getIncludeGroups().size(); } });
LOG.debug("getMibObjectList: MATCH!! adding system '{}'", system.getName()); systemList.add(system); for (final String grpName : system.getCollect().getIncludeGroups()) { processGroupName(cName, grpName, ifType, mibObjectList);
/** * Gets the parent SNMP Collections. * <p>The list of SNMP collection that are referencing a given systemDefName</p> * * @param dataCollectionConfigDao the data collection configuration DAO * @param systemDefName the system definition name * @return the parent collections. */ private Set<String> getParentCollections(final DataCollectionConfigDao dataCollectionConfigDao, String systemDefName) { Set<String> collectionMap = new TreeSet<>(); for (final SnmpCollection collection : dataCollectionConfigDao.getRootDataCollection().getSnmpCollections()) { for (final SystemDef systemDef : collection.getSystems().getSystemDefs()) { if (systemDefName.equals(systemDef.getName())) { collectionMap.add(collection.getName()); } } } return collectionMap; }
/** * Creates the basic system definition. * * @return the system definition */ public SystemDef createBasicSystemDef() { SystemDef sysDef = new SystemDef(); sysDef.setName("New System Definition"); sysDef.setSysoidMask(".1.3.6.1.4.1."); sysDef.setCollect(new Collect()); return sysDef; }
@Override public List<MibObjProperty> getMibObjProperties(final String cName, final String aSysoid, final String anAddress) { LOG.debug("getMibObjProperties: collection: {} sysoid: {} address: {}", cName, aSysoid, anAddress); if (aSysoid == null) { LOG.debug("getMibObjProperties: aSysoid parameter is NULL..."); return new ArrayList<>(); } final SnmpCollection collection = getSnmpCollection(getContainer(), cName); if (collection == null) { return Collections.emptyList(); } final Systems systems = collection.getSystems(); if (systems == null) { return Collections.emptyList(); } final List<SystemDef> systemList = new ArrayList<>(); for (final SystemDef system : systems.getSystemDefs()) { if (systemDefMatches(system, aSysoid, anAddress)) { systemList.add(system); } } final List<MibObjProperty> mibProperties = new ArrayList<>(); for (final SystemDef system : systemList) { for (final String grpName : system.getCollect().getIncludeGroups()) { processGroupForProperties(cName, grpName, mibProperties); } } return mibProperties; }
LOG.debug("addSystemDef: merging system defintion {} into snmp-collection {}", systemDef.getName(), collection.getName()); LOG.warn("addSystemDef: system definition {} from data collection group {} already exist on SNMP collection {}", systemDef.getName(), dcGroup, collection.getName()); } else { LOG.debug("addSystemDef: adding system definition {} from data collection group {} to snmp-collection {}", systemDef.getName(), dcGroup, collection.getName()); collection.getSystems().addSystemDef(systemDef); for (String groupName : systemDef.getCollect().getIncludeGroups()) { Group group = getMibObjectGroup(groupName, dataCollectionGroupName); if (group == null) {
@Override public List<String> getAvailableSystemDefs() { List<String> systemDefs = new ArrayList<>(); for (final SnmpCollection collection : getContainer().getObject().getSnmpCollections()) { if (collection.getSystems() != null) { for (final SystemDef systemDef : collection.getSystems().getSystemDefs()) { systemDefs.add(systemDef.getName()); } } } return systemDefs; }
@Override public boolean delete() { Object systemDefId = systemDefTable.getValue(); if (systemDefId != null) { SystemDef systemDef = systemDefTable.getSystemDef(systemDefId); Set<String> collections = getParentCollections(dataCollectionConfigDao, systemDef.getName()); if (!collections.isEmpty()) { final String msg = "The systemDef cannot be deleted because it is being referenced by:\n" + collections.toString(); Notification.show(msg, Notification.Type.WARNING_MESSAGE); return false; } logger.info("SNMP SystemDef " + systemDef.getName() + " has been removed."); systemDefTable.select(null); systemDefTable.removeItem(systemDefId); systemDefTable.refreshRowCache(); } return true; } @Override
@Override public boolean delete() { Object systemDefId = systemDefTable.getValue(); if (systemDefId != null) { SystemDef systemDef = systemDefTable.getSystemDef(systemDefId); Set<String> collections = getParentCollections(dataCollectionConfigDao, systemDef.getName()); if (!collections.isEmpty()) { final String msg = "The systemDef cannot be deleted because it is being referenced by:\n" + collections.toString(); Notification.show(msg, Notification.Type.WARNING_MESSAGE); return false; } logger.info("SNMP SystemDef " + systemDef.getName() + " has been removed."); systemDefTable.select(null); systemDefTable.removeItem(systemDefId); systemDefTable.refreshRowCache(); } return true; } @Override