private RequisitionInterface createInterface(final String ipAddr, final PrimaryType snmpPrimary) {
   final RequisitionInterface iface = new RequisitionInterface();
   iface.setIpAddr(ipAddr);
   iface.setStatus(1);
   iface.setSnmpPrimary(snmpPrimary);
   return iface;
 }
 protected RequisitionNode createNode(final String id) {
   RequisitionNode node = new RequisitionNode();
   node.setForeignId(id);
   node.setNodeLabel("node " + id);
   RequisitionInterface iface = new RequisitionInterface();
   iface.setIpAddr("172.16.0." + id);
   node.putInterface(iface);
   return node;
 }
Пример #3
0
    RequisitionMonitoredService getServiceForInterface(
        final String foreignId, final String ipAddress, final String service) {
      flush();

      final Requisition req = getActiveRequisition(false);
      final RequisitionNode node = req == null ? null : req.getNode(foreignId);
      final RequisitionInterface iface = node == null ? null : node.getInterface(ipAddress);

      return iface == null ? null : iface.getMonitoredService(service);
    }
Пример #4
0
 void addOrReplaceService(
     final String foreignId, final String ipAddress, final RequisitionMonitoredService service) {
   final Requisition req = getActiveRequisition(true);
   if (req != null) {
     final RequisitionNode node = req.getNode(foreignId);
     if (node != null) {
       final RequisitionInterface iface = node.getInterface(ipAddress);
       if (iface != null) {
         req.updateDateStamp();
         iface.putMonitoredService(service);
         save(req);
       }
     }
   }
 }
 /** trimWhitespace Removes leading and trailing whitespace from fields that should not have any */
 private void trimWhitespace(Requisition req) {
   for (RequisitionNode node : req.getNodes()) {
     if (node.getForeignId() != null) {
       node.setForeignId(node.getForeignId().trim());
     }
     if (node.getParentForeignSource() != null) {
       node.setParentForeignSource(node.getParentForeignSource().trim());
     }
     if (node.getParentForeignId() != null) {
       node.setParentForeignId(node.getParentForeignId().trim());
     }
     for (RequisitionInterface intf : node.getInterfaces()) {
       if (intf.getIpAddr() != null) {
         intf.setIpAddr(intf.getIpAddr().trim());
       }
     }
   }
 }
Пример #6
0
 void deleteInterfaceService(
     final String foreignId, final String ipAddress, final String service) {
   LOG.debug(
       "deleteInterfaceService: Deleting service {} from interface {} on node {}/{}",
       service,
       ipAddress,
       getForeignSource(),
       foreignId);
   final Requisition req = getActiveRequisition(false);
   if (req != null) {
     final RequisitionNode node = req.getNode(foreignId);
     if (node != null) {
       final RequisitionInterface iface = node.getInterface(ipAddress);
       if (iface != null) {
         req.updateDateStamp();
         iface.deleteMonitoredService(service);
         save(req);
       }
     }
   }
 }
  /** {@inheritDoc} */
  @Override
  public Requisition addServiceToInterface(
      final String groupName, final String pathToInterface, final String serviceName) {
    m_writeLock.lock();

    try {
      final Requisition group = getProvisioningGroup(groupName);

      final RequisitionInterface iface =
          PropertyUtils.getPathValue(group, pathToInterface, RequisitionInterface.class);

      final RequisitionMonitoredService monSvc = createService(serviceName);
      iface.insertMonitoredService(monSvc);

      m_pendingForeignSourceRepository.save(group);
      m_pendingForeignSourceRepository.flush();
      return m_pendingForeignSourceRepository.getRequisition(groupName);
    } finally {
      m_writeLock.unlock();
    }
  }