本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.setForeignSource方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.setForeignSource方法的具体用法?Java OnmsNode.setForeignSource怎么用?Java OnmsNode.setForeignSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.model.OnmsNode
的用法示例。
在下文中一共展示了OnmsNode.setForeignSource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNode
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private OnmsNode createNode(int nodeId, String nodelabel, String foreignSource, String foreignId, String ipAddress) {
OnmsNode n = new OnmsNode();
n.setId(nodeId);
n.setLabel(nodelabel);
if (foreignSource != null) {
n.setForeignSource(foreignSource);
}
if (foreignId != null) {
n.setForeignId(foreignId);
}
OnmsIpInterface ip = new OnmsIpInterface();
ip.setId(10 + nodeId);
ip.setIpAddress(InetAddressUtils.addr(ipAddress));
ip.setNode(n);
n.addIpInterface(ip);
return n;
}
示例2: setUp
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
m_databasePopulator.populateDatabase();
m_trapdIpMgr.dataSourceSync();
OnmsNode n = new OnmsNode(m_databasePopulator.getDistPollerDao().get("localhost"), "my-new-node");
n.setForeignSource("junit");
n.setForeignId("10001");
OnmsIpInterface iface = new OnmsIpInterface("192.168.1.3", n);
iface.setIsManaged("M");
iface.setIsSnmpPrimary(PrimaryType.PRIMARY);
OnmsSnmpInterface snmpIf = new OnmsSnmpInterface(n, 1001);
iface.setSnmpInterface(snmpIf);
snmpIf.getIpInterfaces().add(iface);
n.addIpInterface(iface);
m_databasePopulator.getNodeDao().save(n);
m_testNodeId = n.getId();
}
示例3: SaveOrUpdateOperation
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* <p>Constructor for SaveOrUpdateOperation.</p>
*
* @param nodeId a {@link java.lang.Integer} object.
* @param foreignSource a {@link java.lang.String} object.
* @param foreignId a {@link java.lang.String} object.
* @param nodeLabel a {@link java.lang.String} object.
* @param building a {@link java.lang.String} object.
* @param city a {@link java.lang.String} object.
* @param provisionService a {@link org.opennms.netmgt.provision.service.ProvisionService} object.
* @param rescanExisting a {@link java.lang.Boolean} object
*/
public SaveOrUpdateOperation(Integer nodeId, String foreignSource, String foreignId, String nodeLabel, String building, String city, ProvisionService provisionService, boolean rescanExisting) {
super(provisionService);
m_node = new OnmsNode();
m_node.setId(nodeId);
m_node.setLabel(nodeLabel);
m_node.setLabelSource("U");
m_node.setType("A");
m_node.setForeignSource(foreignSource);
m_node.setForeignId(foreignId);
m_node.getAssetRecord().setBuilding(building);
m_node.getAssetRecord().setCity(city);
m_rescanExisting = rescanExisting;
}
示例4: createNode
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private OnmsNode createNode() {
OnmsNode node = new OnmsNode();
//node.setId(nodeId);
node.setLastCapsdPoll(new Date());
node.setForeignSource("imported:");
node.setLabel("default");
m_nodeDao.save(node);
m_nodeDao.flush();
return node;
}
示例5: AbstractSaveOrUpdateOperation
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* <p>Constructor for AbstractSaveOrUpdateOperation.</p>
*
* @param nodeId a {@link java.lang.Integer} object.
* @param foreignSource a {@link java.lang.String} object.
* @param foreignId a {@link java.lang.String} object.
* @param nodeLabel a {@link java.lang.String} object.
* @param building a {@link java.lang.String} object.
* @param city a {@link java.lang.String} object.
*/
public AbstractSaveOrUpdateOperation(final Integer nodeId, final String foreignSource, final String foreignId, final String nodeLabel, final String building, final String city) {
m_node = new OnmsNode();
m_node.setId(nodeId);
m_node.setLabel(nodeLabel);
m_node.setLabelSource("U");
m_node.setType("A");
m_node.setForeignSource(foreignSource);
m_node.setForeignId(foreignId);
m_node.getAssetRecord().setBuilding(building);
m_node.getAssetRecord().setCity(city);
}
示例6: doPersist
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
* <p>doPersist</p>
*
* @return a {@link java.util.List} object.
*/
public List<Event> doPersist() {
OnmsNode imported = getNode();
OnmsNode db = getNodeDao().getHierarchy(imported.getId());
List<Event> events = new LinkedList<Event>();
// verify that the node label is still the same
if (!db.getLabel().equals(imported.getLabel())) {
db.setLabel(imported.getLabel());
// TODO: nodeLabelChanged event
}
if (!nullSafeEquals(db.getForeignSource(), imported.getForeignSource())) {
db.setForeignSource(imported.getForeignSource());
}
if (!nullSafeEquals(db.getForeignId(), imported.getForeignId())) {
db.setForeignId(imported.getForeignId());
}
if (isSnmpDataForNodeUpToDate()) {
if (!nullSafeEquals(db.getSysContact(), imported.getSysContact())) {
db.setSysContact(imported.getSysContact());
}
if (!nullSafeEquals(db.getSysDescription(), imported.getSysDescription())) {
db.setSysDescription(imported.getSysDescription());
}
if (!nullSafeEquals(db.getSysLocation(), imported.getSysLocation())) {
db.setSysLocation(imported.getSysLocation());
}
if (!nullSafeEquals(db.getSysName(), imported.getSysName())) {
db.setSysName(imported.getSysName());
}
if (!nullSafeEquals(db.getSysObjectId(), imported.getSysObjectId())) {
db.setSysObjectId(imported.getSysObjectId());
}
}
if (isSnmpDataForInterfacesUpToDate())
updateSnmpInterfaces(db, imported);
updateInterfaces(db, imported, events);
updateCategories(db, imported);
getNodeDao().update(db);
return events;
}
示例7: testInterfaceResource
import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
@Test
public void testInterfaceResource() throws Exception {
// Set Defaults
String ipAddress = "10.0.0.1";
String ifName = "eth0";
int ifIndex = 2;
// Initialize Database
MockNetwork network = new MockNetwork();
network.setCriticalService("ICMP");
network.addNode(1, "testNode");
network.addInterface(ipAddress);
network.setIfAlias(ifName);
network.addService("ICMP");
network.addService("SNMP");
network.addService("HTTP");
MockDatabase db = new MockDatabase();
db.populate(network);
db.update("update snmpinterface set snmpifindex=?, snmpifname=?, snmpifdescr=? where id=?", ifIndex, ifName, ifName, 1);
DataSourceFactory.setInstance(db);
Vault.setDataSource(db);
// Create Mock Collection Agent
CollectionAgent agent = createCollectionAgent();
// Create SnmpIfData
OnmsNode node = new OnmsNode();
node.setId(agent.getNodeId());
node.setLabel("testNode");
node.setForeignSource(agent.getForeignSource());
node.setForeignId(agent.getForeignId());
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(node, ifIndex);
snmpIface.setIfDescr(ifName);
snmpIface.setIfName(ifName);
snmpIface.setIfAlias(ifName);
snmpIface.setIfSpeed(10000000l);
snmpIface.setPhysAddr("001122334455");
SnmpIfData ifData = new SnmpIfData(snmpIface);
// Creating IfResourceType
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig);
IfResourceType resourceType = new IfResourceType(agent, collection);
// Creating Resource
SnmpCollectionResource resource = new IfInfo(resourceType, agent, ifData);
SnmpAttribute attribute = addAttributeToCollectionResource(resource, "ifInOctets", "counter", "ifIndex", "5000");
Map<String, CollectionAttribute> attributes = new HashMap<String, CollectionAttribute>();
attributes.put(attribute.getName(), attribute);
// Create Wrapper
CollectionResourceWrapper wrapper = createWrapper(resource, attributes);
// Validations
Assert.assertEquals(node.getId().intValue(), wrapper.getNodeId());
Assert.assertEquals("127.0.0.1", wrapper.getHostAddress()); // Should be the address of the SNMP Agent (Bug 3808)
Assert.assertEquals("eth0-001122334455", wrapper.getIfLabel());
Assert.assertEquals("if", wrapper.getResourceTypeName());
Assert.assertEquals("SNMP", wrapper.getServiceName());
Assert.assertEquals(true, wrapper.isAnInterfaceResource());
Assert.assertEquals(Integer.toString(ifIndex), wrapper.getInstance());
Assert.assertEquals(Integer.toString(ifIndex), wrapper.getIfIndex());
Assert.assertEquals(Integer.toString(ifIndex), wrapper.getIfIndex()); // IfLabel is called only once
Assert.assertEquals(Integer.toString(ifIndex), wrapper.getIfIndex()); // IfLabel is called only once
Assert.assertEquals("eth0", wrapper.getIfInfoValue("snmpifname")); // IfLabel is called only once
Assert.assertEquals("eth0-001122334455", wrapper.getInstanceLabel());
Assert.assertEquals("nodeSource[JUnit%3AT001].interfaceSnmp[eth0-001122334455]", wrapper.getResourceId());
}