Search in sources :

Example 1 with InterfaceSnmpResourceType

use of org.opennms.netmgt.dao.support.InterfaceSnmpResourceType in project opennms by OpenNMS.

the class CustomSpringConfiguration method createResourceDao.

@Bean(name = "resourceDao")
public ResourceDao createResourceDao() {
    return new ResourceDao() {

        @Override
        public Collection<OnmsResourceType> getResourceTypes() {
            throw new UnsupportedOperationException();
        }

        @Override
        public List<OnmsResource> findTopLevelResources() {
            throw new UnsupportedOperationException();
        }

        @Override
        public OnmsResource getResourceById(ResourceId id) {
            if (id.toString().startsWith("node[1]")) {
                final OnmsResource onmsResource = new OnmsResource(id.toString(), id.toString(), new InterfaceSnmpResourceType(null), new HashSet<OnmsAttribute>(), new ResourcePath());
                if (id.toString().contains("interfaceSnmp[127.0.0.1]")) {
                    final RrdGraphAttribute attribute = new RrdGraphAttribute();
                    attribute.setName("ifInErrors");
                    attribute.setResource(onmsResource);
                    onmsResource.getAttributes().add(attribute);
                }
                return onmsResource;
            }
            return null;
        }

        @Override
        public OnmsResource getResourceForNode(OnmsNode node) {
            throw new UnsupportedOperationException();
        }

        @Override
        public OnmsResource getResourceForIpInterface(OnmsIpInterface ipInterface, OnmsLocationMonitor locationMonitor) {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean deleteResourceById(ResourceId resourceId) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) InterfaceSnmpResourceType(org.opennms.netmgt.dao.support.InterfaceSnmpResourceType) OnmsAttribute(org.opennms.netmgt.model.OnmsAttribute) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute) OnmsResource(org.opennms.netmgt.model.OnmsResource) ResourcePath(org.opennms.netmgt.model.ResourcePath) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsResourceType(org.opennms.netmgt.model.OnmsResourceType) ResourceId(org.opennms.netmgt.model.ResourceId) ResourceDao(org.opennms.netmgt.dao.api.ResourceDao) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) Bean(org.springframework.context.annotation.Bean)

Aggregations

ResourceDao (org.opennms.netmgt.dao.api.ResourceDao)1 InterfaceSnmpResourceType (org.opennms.netmgt.dao.support.InterfaceSnmpResourceType)1 OnmsAttribute (org.opennms.netmgt.model.OnmsAttribute)1 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsResource (org.opennms.netmgt.model.OnmsResource)1 OnmsResourceType (org.opennms.netmgt.model.OnmsResourceType)1 ResourceId (org.opennms.netmgt.model.ResourceId)1 ResourcePath (org.opennms.netmgt.model.ResourcePath)1 RrdGraphAttribute (org.opennms.netmgt.model.RrdGraphAttribute)1 Bean (org.springframework.context.annotation.Bean)1