Skip to content

Commit

Permalink
Fix for NMS-6139 - merge existing services on interfaces (VMWare)
Browse files Browse the repository at this point in the history
  • Loading branch information
agalue committed Sep 24, 2013
1 parent 2768932 commit a5e563e
Showing 1 changed file with 50 additions and 0 deletions.
Expand Up @@ -866,16 +866,34 @@ public InputStream getInputStream() throws IOException {
for (RequisitionNode newNode : newReq.getNodes()) {
for (RequisitionNode curNode : curReq.getNodes()) {
if (newNode.getForeignId().equals(curNode.getForeignId())) {
// Add existing custom assets
for (RequisitionAsset asset : curNode.getAssets()) {
if (!asset.getName().startsWith("vmware")) {
newNode.putAsset(asset);
}
}
// Add existing custom categories
for (RequisitionCategory cat : curNode.getCategories()) {
if (!cat.getName().startsWith("VMWare")) {
newNode.putCategory(cat);
}
}
// Add existing custom services
/*
* For each interface on the new requisition,
* - Retrieve the list of custom services from the corresponding interface on the existing requisition,
* matching the interface by the IP address
* - If the list of services is not empty, add them to the new interface
*/
for (RequisitionInterface intf : curNode.getInterfaces()) {
List<RequisitionMonitoredService> services = getManualyConfiguredServices(intf);
if (!services.isEmpty()) {
RequisitionInterface newIntf = getRequisitionInterface(newNode, intf.getIpAddr());
if (newIntf != null) {
newIntf.getMonitoredServices().addAll(services);
}
}
}
}
}
}
Expand All @@ -890,6 +908,38 @@ public InputStream getInputStream() throws IOException {
return stream;
}

private RequisitionInterface getRequisitionInterface(RequisitionNode node, String ipAddr) {
for (RequisitionInterface intf : node.getInterfaces()) {
if (ipAddr.equals(intf.getIpAddr())) {
return intf;
}
}
return null;
}

private List<RequisitionMonitoredService> getManualyConfiguredServices(RequisitionInterface intf) {
List<RequisitionMonitoredService> services = new ArrayList<RequisitionMonitoredService>();
for (RequisitionMonitoredService svc : intf.getMonitoredServices()) {
boolean found = false;
for (String svcName : m_hostSystemServices) {
if (svcName.trim().equals(svc.getServiceName())) {
found = true;
continue;
}
}
for (String svcName : m_virtualMachineServices) {
if (svcName.trim().equals(svc.getServiceName())) {
found = true;
continue;
}
}
if (!found) {
services.add(svc);
}
}
return services;
}

/**
* Utility to marshal the Requisition class into XML.
*
Expand Down

0 comments on commit a5e563e

Please sign in to comment.