use of org.opennms.rancid.RWSBucket in project opennms by OpenNMS.
the class InventoryService method getRancidNode.
/*
* getRancidNode will filter any exception, the page will show an empty table
* in case of node not in DB or device name not in RWS
*/
/**
* <p>getRancidNode</p>
*
* @param nodeid a int.
* @return a java$util$Map object.
*/
public Map<String, Object> getRancidNode(int nodeid) {
LOG.debug("getRancidNode start");
Map<String, Object> nodeModel = getRancidNodeBase(nodeid);
String rancidName = (String) nodeModel.get("id");
List<RancidNodeWrapper> ranlist = new ArrayList<RancidNodeWrapper>();
List<BucketItem> bucketlist = new ArrayList<BucketItem>();
// Group list
RWSResourceList groups;
try {
groups = RWSClientApi.getRWSResourceGroupsList(m_cp);
} catch (RancidApiException e) {
LOG.error(e.getLocalizedMessage());
nodeModel.put("RWSStatus", e.getLocalizedMessage());
return nodeModel;
}
List<String> grouplist = groups.getResource();
Iterator<String> iter1 = grouplist.iterator();
boolean first = true;
while (iter1.hasNext()) {
String groupname = iter1.next();
LOG.debug("getRancidNode: {} for group {}", nodeid, groupname);
try {
if (first) {
RancidNode rn = RWSClientApi.getRWSRancidNodeTLO(m_cp, groupname, rancidName);
nodeModel.put("devicename", rn.getDeviceName());
nodeModel.put("status", rn.getState());
nodeModel.put("devicetype", rn.getDeviceType());
nodeModel.put("comment", rn.getComment());
nodeModel.put("groupname", groupname);
first = false;
}
try {
RancidNode rn = RWSClientApi.getRWSRancidNodeInventory(m_cp, groupname, rancidName);
String vs = rn.getHeadRevision();
InventoryNode in = (InventoryNode) rn.getNodeVersions().get(vs);
RancidNodeWrapper rnw = new RancidNodeWrapper(rn.getDeviceName(), groupname, rn.getDeviceType(), rn.getComment(), rn.getHeadRevision(), rn.getTotalRevisions(), in.getCreationDate(), rn.getRootConfigurationUrl());
ranlist.add(rnw);
} catch (RancidApiException e) {
LOG.debug("No configuration found for nodeid:{} on Group: {} .Cause: {}", nodeid, groupname, e.getLocalizedMessage());
}
} catch (RancidApiException e) {
if (e.getRancidCode() == 2) {
LOG.debug("No device found in router.db for nodeid:{} on Group: {} .Cause: {}", nodeid, groupname, e.getLocalizedMessage());
} else {
nodeModel.put("RWSStatus", e.getLocalizedMessage());
LOG.error(e.getLocalizedMessage());
}
}
}
//Groups invariant
nodeModel.put("grouptable", ranlist);
try {
RWSBucket bucket = RWSClientApi.getBucket(m_cp, rancidName);
bucketlist.addAll(bucket.getBucketItem());
} catch (RancidApiException e) {
if (e.getRancidCode() == 2) {
LOG.debug("No entry in storage for nodeid:{} nodeLabel: {}", nodeid, rancidName);
} else {
nodeModel.put("RWSStatus", e.getLocalizedMessage());
LOG.error(e.getLocalizedMessage());
}
}
nodeModel.put("bucketitems", bucketlist);
return nodeModel;
}
use of org.opennms.rancid.RWSBucket in project opennms by OpenNMS.
the class InventoryService method getBuckets.
/**
* <p>getBuckets</p>
*
* @param nodeid a int.
* @return a java$util$Map object.
*/
public Map<String, Object> getBuckets(int nodeid) {
LOG.debug("getBuckets start: nodeid: {}", nodeid);
Map<String, Object> nodeModel = getRancidNodeBase(nodeid);
String rancidName = (String) nodeModel.get("id");
List<BucketItem> bucketlist = new ArrayList<BucketItem>();
try {
RWSBucket bucket = RWSClientApi.getBucket(m_cp, rancidName);
nodeModel.put("bucketexist", true);
bucketlist.addAll(bucket.getBucketItem());
} catch (RancidApiException e) {
if (e.getRancidCode() == 2) {
nodeModel.put("bucketexist", false);
LOG.debug("No entry in storage for nodeid:{} nodeLabel: {}", nodeid, rancidName);
} else {
nodeModel.put("RWSStatus", e.getLocalizedMessage());
LOG.error(e.getLocalizedMessage());
}
}
nodeModel.put("bucketlistsize", bucketlist.size());
nodeModel.put("bucketitems", bucketlist);
return nodeModel;
}
Aggregations