use of org.opennms.rancid.InventoryNode 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;
}
use of org.opennms.rancid.InventoryNode in project opennms by OpenNMS.
the class InventoryService method getInventory.
/**
* <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: {} group: {} version: {}", nodeid, group, 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:{} nodeLabel: {}", nodeid, rancidName);
} else {
nodeModel.put("RWSStatus", e.getLocalizedMessage());
LOG.error(e.getLocalizedMessage());
}
}
return nodeModel;
}
Aggregations