Search in sources :

Example 6 with RWSResourceList

use of org.opennms.rancid.RWSResourceList in project opennms by OpenNMS.

the class InventoryService method getRancidNodeList.

/**
 * <p>getRancidNodeList</p>
 *
 * @param nodeid a int.
 * @param group a {@link java.lang.String} object.
 * @return a java$util$Map object.
 */
public Map<String, Object> getRancidNodeList(int nodeid, String group) {
    LOG.debug("getRancidlist start: nodeid: {} group: {}", nodeid, group);
    Map<String, Object> nodeModel = getRancidNodeBase(nodeid);
    String rancidName = (String) nodeModel.get("id");
    List<InventoryWrapper> ranlist = new ArrayList<>();
    RancidNode rn;
    try {
        rn = RWSClientApi.getRWSRancidNodeInventory(m_cp, group, rancidName);
        nodeModel.put("devicename", rn.getDeviceName());
    } catch (RancidApiException e) {
        if (e.getRancidCode() == 2) {
            LOG.debug("No Inventory found in CVS repository for nodeid:{} nodeLabel: {}", nodeid, rancidName);
        } else {
            nodeModel.put("RWSStatus", e.getLocalizedMessage());
            LOG.error(e.getLocalizedMessage());
        }
        return nodeModel;
    }
    RWSResourceList versionList;
    try {
        versionList = RWSClientApi.getRWSResourceConfigList(m_cp, group, rancidName);
    } catch (RancidApiException e) {
        nodeModel.put("RWSStatus", e.getLocalizedMessage());
        LOG.error(e.getLocalizedMessage());
        return nodeModel;
    }
    List<String> versionListStr = versionList.getResource();
    Iterator<String> iter1 = versionListStr.iterator();
    String vs;
    while (iter1.hasNext()) {
        vs = iter1.next();
        InventoryNode in = (InventoryNode) rn.getNodeVersions().get(vs);
        InventoryWrapper inwr = new InventoryWrapper(in.getVersionId(), in.getCreationDate(), group, in.getConfigurationUrl());
        ranlist.add(inwr);
    }
    nodeModel.put("grouptable", ranlist);
    return nodeModel;
}
Also used : RancidNode(org.opennms.rancid.RancidNode) ArrayList(java.util.ArrayList) RancidApiException(org.opennms.rancid.RancidApiException) RWSResourceList(org.opennms.rancid.RWSResourceList) InventoryNode(org.opennms.rancid.InventoryNode)

Aggregations

RWSResourceList (org.opennms.rancid.RWSResourceList)6 RancidApiException (org.opennms.rancid.RancidApiException)6 RancidNode (org.opennms.rancid.RancidNode)6 ArrayList (java.util.ArrayList)3 InventoryNode (org.opennms.rancid.InventoryNode)3 RancidNodeAuthentication (org.opennms.rancid.RancidNodeAuthentication)2 RWSBucket (org.opennms.rancid.RWSBucket)1 BucketItem (org.opennms.rancid.RWSBucket.BucketItem)1