Search in sources :

Example 1 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class ReverseDnsRecordTest method setUp.

@Before
public void setUp() throws Exception {
    nb = new NetworkBuilder();
    nb.addNode(hostname).setForeignSource("dns").setForeignId("1");
    nb.addSnmpInterface(100).setIfName(ifname).addIpInterface(ip);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) Before(org.junit.Before)

Example 2 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class Nms4930NetworkBuilder method addMacNodeWithSnmpInterface.

public void addMacNodeWithSnmpInterface(String mac, String ip, Integer ifindex) {
    NetworkBuilder nb = getNetworkBuilder();
    nb.addNode(ip).setForeignSource("linkd").setForeignId(ip).setType(NodeType.ACTIVE);
    nb.addInterface(ip).setIsSnmpPrimary("N").setIsManaged("M").addSnmpInterface(ifindex).setIfName("eth0").setIfType(6).setPhysAddr(mac).setIfDescr("eth0");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
    IpNetToMedia at0 = new IpNetToMedia();
    at0.setSourceIfIndex(100);
    at0.setPhysAddress(mac);
    at0.setLastPollTime(at0.getCreateTime());
    at0.setSourceNode(m_nodeDao.findByForeignId("linkd", ip));
    try {
        at0.setNetAddress(InetAddress.getByName(ip));
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
    at0.setIpNetToMediaType(IpNetToMediaType.IPNETTOMEDIA_TYPE_DYNAMIC);
    m_ipNetToMediaDao.saveOrUpdate(at0);
    m_ipNetToMediaDao.flush();
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) IpNetToMedia(org.opennms.netmgt.model.IpNetToMedia) UnknownHostException(java.net.UnknownHostException)

Example 3 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class AccessPointDaoTest method addNewAccessPoint.

private void addNewAccessPoint(String name, String mac, String pkg) {
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode(name).setForeignSource("apmd").setForeignId(name);
    nb.addInterface("169.254.0.1");
    m_nodeDao.save(nb.getCurrentNode());
    final OnmsAccessPoint ap1 = new OnmsAccessPoint(mac, nb.getCurrentNode().getId(), pkg);
    ap1.setStatus(AccessPointStatus.UNKNOWN);
    m_accessPointDao.save(ap1);
    m_nodeDao.flush();
    m_accessPointDao.flush();
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsAccessPoint(org.opennms.netmgt.model.OnmsAccessPoint)

Example 4 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class InstanceStrategyIntegrationTest method addNewController.

private void addNewController(String nodeName, String ipAddress, String pollerCategory) {
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode(nodeName).setForeignSource("apmd").setForeignId(nodeName).setType(NodeType.ACTIVE);
    nb.setAssetAttribute("pollerCategory", pollerCategory);
    nb.addInterface(ipAddress).setIsSnmpPrimary("P").setIsManaged("M");
    m_nodeDao.save(nb.getCurrentNode());
    m_nodeDao.flush();
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder)

Example 5 with NetworkBuilder

use of org.opennms.netmgt.model.NetworkBuilder in project opennms by OpenNMS.

the class AccessPointMonitordTest method addNewAccessPoint.

@Transactional(propagation = Propagation.MANDATORY)
public void addNewAccessPoint(String name, String mac, String pkg) {
    NetworkBuilder nb = new NetworkBuilder();
    nb.addNode(name).setForeignSource("apmd").setForeignId(name);
    nb.addInterface("169.254.0.1");
    m_nodeDao.save(nb.getCurrentNode());
    final OnmsAccessPoint ap1 = new OnmsAccessPoint(mac, nb.getCurrentNode().getId(), pkg);
    ap1.setStatus(AccessPointStatus.UNKNOWN);
    m_accessPointDao.save(ap1);
    m_nodeDao.flush();
    m_accessPointDao.flush();
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) OnmsAccessPoint(org.opennms.netmgt.model.OnmsAccessPoint) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)45 Before (org.junit.Before)21 OnmsNode (org.opennms.netmgt.model.OnmsNode)15 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)9 File (java.io.File)6 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)5 NCSBuilder (org.opennms.netmgt.model.ncs.NCSBuilder)5 Date (java.util.Date)4 Test (org.junit.Test)4 IpInterfaceDao (org.opennms.netmgt.dao.api.IpInterfaceDao)4 AdapterOperation (org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation)4 ArrayList (java.util.ArrayList)3 InterfaceBuilder (org.opennms.netmgt.model.NetworkBuilder.InterfaceBuilder)3 OnmsAccessPoint (org.opennms.netmgt.model.OnmsAccessPoint)3 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)3 NCSComponent (org.opennms.netmgt.model.ncs.NCSComponent)3 UnknownHostException (java.net.UnknownHostException)2 HashMap (java.util.HashMap)2 MockPlatformTransactionManager (org.opennms.core.test.MockPlatformTransactionManager)2 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)2