当前位置: 首页>>代码示例>>Java>>正文


Java RancidNode类代码示例

本文整理汇总了Java中org.opennms.rancid.RancidNode的典型用法代码示例。如果您正苦于以下问题:Java RancidNode类的具体用法?Java RancidNode怎么用?Java RancidNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RancidNode类属于org.opennms.rancid包,在下文中一共展示了RancidNode类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildRancidNodeMap

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
private void buildRancidNodeMap() {
    List<OnmsNode> nodes = m_nodeDao.findAllProvisionedNodes();
    m_onmsNodeRancidNodeMap = new ConcurrentHashMap<Integer, RancidNode>(nodes.size());
    m_onmsNodeIpMap = new ConcurrentHashMap<Integer, String>(nodes.size());

    for (OnmsNode onmsNode : nodes) {
        String ipaddr = getSuitableIpForRancid(onmsNode);
        if (ipaddr != null)
            m_onmsNodeIpMap.putIfAbsent(onmsNode.getId(), ipaddr);
        
        RancidNode rNode = getSuitableRancidNode(onmsNode);
        if (rNode != null) {            
            m_onmsNodeRancidNodeMap.putIfAbsent(onmsNode.getId(), rNode);
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:17,代码来源:RancidProvisioningAdapter.java

示例2: getSuitableRancidNode

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
private RancidNode getSuitableRancidNode(OnmsNode node) {
    

    //The group should be the foreign source of the node

    String group = node.getForeignSource();

    if (group == null) return null;
    RancidNode r_node = new RancidNode(group, node.getLabel());

    String ipaddress = m_onmsNodeIpMap.get(node.getId());

    if (m_rancidAdapterConfig.useCategories(ipaddress)) {
        log().debug("getSuitableRancidNode: Using Categories to get Rancid devicetype for node: " + node.getLabel());
        r_node.setDeviceType(getTypeFromCategories(node)); 
    } else {
        log().debug("getSuitableRancidNode: Using Sysoid to get Rancid devicetype for node: " + node.getLabel());
        r_node.setDeviceType(getTypeFromSysObjectId(node.getSysObjectId()));
    }
    r_node.setStateUp(false);
    r_node.setComment(RANCID_COMMENT);
    r_node.setAuth(getSuitableRancidNodeAuthentication(node));
    return r_node;
    

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:RancidProvisioningAdapter.java

示例3: switchStatus

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
 * <p>switchStatus</p>
 *
 * @param groupName a {@link java.lang.String} object.
 * @param deviceName a {@link java.lang.String} object.
 * @return a boolean.
 */
public boolean switchStatus(String groupName, String deviceName){
    
  log().debug("InventoryService switchStatus " + groupName+"/"+deviceName);

  try {  
      RancidNode rn = RWSClientApi.getRWSRancidNodeTLO(m_cp, groupName, deviceName);
      if (rn.isStateUp()){
          log().debug("InventoryService switchStatus :down");
          rn.setStateUp(false);
      }else {
          log().debug("InventoryService switchStatus :up");
          rn.setStateUp(true);
      }
      RWSClientApi.updateRWSRancidNode(m_cp, rn);
  }
  catch (Throwable e){
      log().debug("switchStatus has given exception on node "  + groupName+"/"+deviceName + " "+ e.getMessage() );
      return false;
  }
  return true;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:InventoryService.java

示例4: updateNodeOnRouterDb

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
 * <p>updateNodeOnRouterDb</p>
 *
 * @param groupName a {@link java.lang.String} object.
 * @param deviceName a {@link java.lang.String} object.
 * @param deviceType a {@link java.lang.String} object.
 * @param status a {@link java.lang.String} object.
 * @param comment a {@link java.lang.String} object.
 * @return a boolean.
 */
public boolean updateNodeOnRouterDb(String groupName, String deviceName, String deviceType, String status, String comment ){
    
    log().debug("InventoryService updateNodeOnRouterDb: " + groupName+"->"+deviceName+":"+ deviceType+":"+ status + ":" + comment);

    try {  
        RancidNode rn = RWSClientApi.getRWSRancidNodeTLO(m_cp, groupName, deviceName);
        rn.setDeviceType(deviceType);
        if (comment != null) rn.setComment(comment);
        if ("up".equalsIgnoreCase(status)) {
            rn.setStateUp(true);
        } else if ("down".equalsIgnoreCase(status)) {
            rn.setStateUp(false);
        }
        RWSClientApi.updateRWSRancidNode(m_cp, rn);
    }
    catch (Throwable e){
        log().debug("updateNodeOnRouterDb has given exception on node "  + groupName+"/"+deviceName + " "+ e.getMessage() );
        return false;
    }
    return true;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:32,代码来源:InventoryService.java

示例5: createNodeOnRouterDb

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
  * <p>createNodeOnRouterDb</p>
  *
  * @param groupName a {@link java.lang.String} object.
  * @param deviceName a {@link java.lang.String} object.
  * @param deviceType a {@link java.lang.String} object.
  * @param status a {@link java.lang.String} object.
  * @param comment a {@link java.lang.String} object.
  * @return a boolean.
  */
 public boolean createNodeOnRouterDb(String groupName, String deviceName, String deviceType, String status,String comment ){
     
     log().debug("InventoryService createNodeOnRouterDb: " + groupName+"->"+deviceName+":"+ deviceType+":"+ status + ":" + comment);

     try {  
         RancidNode rn = new RancidNode(groupName,deviceName);
         rn.setDeviceType(deviceType);
         if (comment != null) rn.setComment(comment);
         if ("up".equalsIgnoreCase(status)) {
             rn.setStateUp(true);
         } else if ("down".equalsIgnoreCase(status)) {
             rn.setStateUp(false);
         }
         RWSClientApi.createRWSRancidNode(m_cp, rn);
     }
     catch (Throwable e){
         log().debug("createNodeOnRouterDb has given exception on node "  + groupName+"/"+deviceName + " "+ e.getMessage() );
         return false;
     }
     return true;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:32,代码来源:InventoryService.java

示例6: doDelete

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
 * <p>doDelete</p>
 *
 * @param nodeId a int.
 * @param cp a {@link org.opennms.rancid.ConnectionProperties} object.
 * @param retry a boolean.
 * @throws org.opennms.netmgt.provision.ProvisioningAdapterException if any.
 */
public void doDelete(int nodeId,ConnectionProperties cp, boolean retry) throws ProvisioningAdapterException {
    if (! isAdapterConfigured()) {
        return;
    }

    log().debug("doDelete: deleting nodeid: " + nodeId);
    
    /*
     * The work to maintain the hashmap boils down to needing to do deletes, so
     * here we go.
     */
    try {
        m_rwsConfig.getWriteLock().lock();
        try {
            if (m_onmsNodeRancidNodeMap.containsKey(Integer.valueOf(nodeId))) {
                RancidNode rNode = m_onmsNodeRancidNodeMap.get(Integer.valueOf(nodeId));

                RWSClientApi.deleteRWSRancidNode(cp, rNode);
                RWSClientApi.deleteRWSAuthNode(cp, rNode.getAuth());

                m_onmsNodeRancidNodeMap.remove(Integer.valueOf(nodeId));
                m_onmsNodeIpMap.remove(Integer.valueOf(nodeId));
            } else {
                log().warn("doDelete: no device found in node Rancid Map for nodeid: " + nodeId);                
            }
        } finally {
            m_rwsConfig.getWriteLock().unlock();
        }
    } catch (Throwable e) {
        cp = getStandByRWSConnection();
        if (retry && cp != null) {
            log().info("doDelete: retry Delete on standByConn: " + cp.getUrl());
            doDelete(nodeId, cp, false);
        } else {
            sendAndThrow(nodeId, e);            
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:47,代码来源:RancidProvisioningAdapter.java

示例7: updateConfiguration

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
private void updateConfiguration(int nodeid, RancidNode rNode,ConnectionProperties cp, boolean retry) throws ProvisioningAdapterException {
    log().debug("updateConfiguration: Updating Rancid Router.db configuration for node: " + rNode.getDeviceName() + " type: " + rNode.getDeviceType() + " group: " + rNode.getGroup());
    try {
            RWSClientApi.updateRWSRancidNode(cp, rNode);
    } catch (Throwable e) {
        cp = getStandByRWSConnection();
        if (retry && cp != null) {
            log().info("updateConfiguration: retry update on standByConn: " + cp.getUrl());
            updateConfiguration(nodeid, rNode, cp, false);
        } else {
            sendAndThrow(nodeid, e);            
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:RancidProvisioningAdapter.java

示例8: updateGroupConfiguration

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
private void updateGroupConfiguration(String group) {
    Iterator<Integer> ite = m_onmsNodeRancidNodeMap.keySet().iterator();
    while (ite.hasNext()) {
        Integer nodeId = ite.next();
        RancidNode rnode = m_onmsNodeRancidNodeMap.get(nodeId);
        if (group.equals(rnode.getGroup())) {
            boolean stateUp = rnode.isStateUp();
            rnode.setStateUp(false);
            updateConfiguration(nodeId.intValue(), rnode, m_cp, true);
            rnode.setStateUp(stateUp);
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:RancidProvisioningAdapter.java

示例9: getFullNode

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
private RancidNode getFullNode(String groupName, String deviceName) {
    try {
        return RWSClientApi.getRWSRancidNodeInventory(m_cp ,groupName, deviceName);
    } catch (RancidApiException e) {
        log().error("getFullNode:  device has no inventory ["+deviceName+ "]. " + e.getLocalizedMessage()); 
    }
    return null;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:9,代码来源:InventoryReportCalculator.java

示例10: deleteNodeOnRouterDb

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
 * <p>deleteNodeOnRouterDb</p>
 *
 * @param groupName a {@link java.lang.String} object.
 * @param deviceName a {@link java.lang.String} object.
 * @return a boolean.
 */
public boolean deleteNodeOnRouterDb(String groupName, String deviceName){
    
    log().debug("InventoryService deleteNodeOnRouterDb: " + groupName+"/"+deviceName);

    try {  
        RancidNode rn = RWSClientApi.getRWSRancidNodeTLO(m_cp, groupName, deviceName);
        RWSClientApi.deleteRWSRancidNode(m_cp, rn);
    }
    catch (Throwable e){
        log().debug("deleteNodeOnRouterDb has given exception on node "  + groupName+"/"+deviceName + " "+ e.getMessage() );
        return false;
    }
    return true;
  }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:InventoryService.java

示例11: doDelete

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
 * <p>doDelete</p>
 *
 * @param nodeId a int.
 * @param cp a {@link org.opennms.rancid.ConnectionProperties} object.
 * @param retry a boolean.
 * @throws org.opennms.netmgt.provision.ProvisioningAdapterException if any.
 */
public void doDelete(int nodeId,ConnectionProperties cp, boolean retry) throws ProvisioningAdapterException {

    log().debug("doDelete: deleting nodeid: " + nodeId);
    
    /*
     * The work to maintain the hashmap boils down to needing to do deletes, so
     * here we go.
     */
    try {
        m_rwsConfig.getWriteLock().lock();
        try {
            if (m_onmsNodeRancidNodeMap.containsKey(Integer.valueOf(nodeId))) {
                RancidNode rNode = m_onmsNodeRancidNodeMap.get(Integer.valueOf(nodeId));

                RWSClientApi.deleteRWSRancidNode(cp, rNode);
                RWSClientApi.deleteRWSAuthNode(cp, rNode.getAuth());

                m_onmsNodeRancidNodeMap.remove(Integer.valueOf(nodeId));
                m_onmsNodeIpMap.remove(Integer.valueOf(nodeId));
            } else {
                log().warn("doDelete: no device found in node Rancid Map for nodeid: " + nodeId);                
            }
        } finally {
            m_rwsConfig.getWriteLock().unlock();
        }
    } catch (Throwable e) {
        cp = getStandByRWSConnection();
        if (retry && cp != null) {
            log().info("doDelete: retry Delete on standByConn: " + cp.getUrl());
            doDelete(nodeId, cp, false);
        } else {
            sendAndThrow(nodeId, e);            
        }
    }
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:44,代码来源:RancidProvisioningAdapter.java

示例12: updateRancidNodeState

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
private void updateRancidNodeState(int nodeid, boolean up) {
    RancidNode rnode = m_onmsNodeRancidNodeMap.get(Integer.valueOf(nodeid));
    rnode.setStateUp(up);
    m_onmsNodeRancidNodeMap.put(nodeid, rnode);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:6,代码来源:RancidProvisioningAdapter.java

示例13: getInventory

import org.opennms.rancid.RancidNode; //导入依赖的package包/类
/**
 * <p>getInventory</p>
 *
 * @param nodeid a int.
 * @param group a {@link java.lang.String} object.
 * @param version a {@link java.lang.String} object.
 * @return a java$util$Map object.
 */
public Map<String, Object> getInventory(int nodeid,
                                            String group, String version) {
    log().debug("getInventoryNode start: nodeid: " + nodeid + " group: " + group + " version: " + version);
    Map<String, Object> nodeModel = getRancidNodeBase(nodeid);
    String rancidName = (String)nodeModel.get("id"); 

    try {
        RancidNode rn = RWSClientApi.getRWSRancidNodeInventory(m_cp, group, rancidName);

        InventoryNode in = (InventoryNode)rn.getNodeVersions().get(version);
        
        nodeModel.put("devicename", rancidName);
        nodeModel.put("groupname", group);
        nodeModel.put("version", version);
        nodeModel.put("status", in.getParent().getState());
        nodeModel.put("creationdate", in.getCreationDate());
        nodeModel.put("swconfigurationurl", in.getSoftwareImageUrl());
        nodeModel.put("configurationurl", in.getConfigurationUrl());

        log().debug("getInventoryNode date: " + in.getCreationDate());

        List<InventoryElement2> ie = RWSClientApi.getRWSRancidNodeInventoryElement2(m_cp, rn, version);
        
        
        Iterator<InventoryElement2> iter1 = ie.iterator();
                                   
        while (iter1.hasNext()) {
            InventoryElement2 ietmp = iter1.next();
            
            log().debug("Adding inventory: " + ietmp.expand());
        }
                           
        nodeModel.put("inventory",ie);
        
    } catch (RancidApiException e) {
        if (e.getRancidCode() == 2) {
            log().debug("No Inventory found in CVS repository for nodeid:" + nodeid  + " nodeLabel: " + rancidName);
        } else {
            nodeModel.put("RWSStatus",e.getLocalizedMessage());
            log().error(e.getLocalizedMessage());
        }
    }
    return nodeModel;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:53,代码来源:InventoryService.java


注:本文中的org.opennms.rancid.RancidNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。