Search in sources :

Example 6 with RequisitionNode

use of org.opennms.netmgt.provision.persist.requisition.RequisitionNode in project opennms by OpenNMS.

the class VmwareImporter method getRequisition.

public Requisition getRequisition() {
    logger.debug("Getting existing requisition (if any) for VMware management server {}", request.getHostname());
    Requisition curReq = request.getExistingRequisition();
    logger.debug("Building new requisition for VMware management server {}", request.getHostname());
    Requisition newReq = buildVMwareRequisition();
    logger.debug("Finished building new requisition for VMware management server {}", request.getHostname());
    if (curReq == null) {
        if (newReq == null) {
            // FIXME Is this correct ? This is the old behavior
            newReq = new Requisition(request.getForeignSource());
        }
    } else {
        if (newReq == null) {
            // If there is a requisition and the vCenter is not responding for some reason, it is better to use the old requisition,
            // instead of returning an empty one, which can cause the lost of all the nodes from the DB.
            newReq = curReq;
        } else {
            // The VMWare related assets and categories will be preserved.
            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);
                            }
                        }
                        /*
                             * 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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return newReq;
}
Also used : RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) RequisitionCategory(org.opennms.netmgt.provision.persist.requisition.RequisitionCategory) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) RequisitionAsset(org.opennms.netmgt.provision.persist.requisition.RequisitionAsset) RequisitionMonitoredService(org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService)

Example 7 with RequisitionNode

use of org.opennms.netmgt.provision.persist.requisition.RequisitionNode in project opennms by OpenNMS.

the class SyslogOverlappingIpAddressIT method testAssociateSyslogsWithNodesWithOverlappingIpAddresses.

/**
     * @see https://issues.opennms.org/browse/NMS-8798
     * 
     * @throws Exception
     */
@Test
public void testAssociateSyslogsWithNodesWithOverlappingIpAddresses() throws Exception {
    final Date startOfTest = new Date();
    final String hostIpAddress = "1.2.3.4";
    // Create requisition with two node in different locations but same IP
    final RestClient client = new RestClient(testEnvironment.getServiceAddress(ContainerAlias.OPENNMS, 8980));
    final Requisition requisition = new Requisition("overlapping");
    final RequisitionNode node1 = new RequisitionNode();
    node1.setNodeLabel("node_1");
    node1.setLocation("MINION");
    final RequisitionInterface interface1 = new RequisitionInterface();
    interface1.setIpAddr(hostIpAddress);
    interface1.setManaged(true);
    interface1.setSnmpPrimary(PrimaryType.PRIMARY);
    node1.setInterfaces(ImmutableList.of(interface1));
    node1.setForeignId("node_1");
    requisition.insertNode(node1);
    final RequisitionNode node2 = new RequisitionNode();
    node2.setNodeLabel("node_2");
    node2.setLocation("BANANA");
    final RequisitionInterface interface2 = new RequisitionInterface();
    interface2.setIpAddr(hostIpAddress);
    interface2.setManaged(true);
    interface2.setSnmpPrimary(PrimaryType.PRIMARY);
    node2.setInterfaces(ImmutableList.of(interface2));
    node2.setForeignId("node_2");
    requisition.insertNode(node2);
    client.addOrReplaceRequisition(requisition);
    client.importRequisition("overlapping");
    // Wait for the nodes to be provisioned
    final OnmsNode onmsNode1 = await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.findMatchingCallable(getDaoFactory().getDao(NodeDaoHibernate.class), new CriteriaBuilder(OnmsNode.class).eq("label", "node_1").toCriteria()), notNullValue());
    final OnmsNode onmsNode2 = await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.findMatchingCallable(getDaoFactory().getDao(NodeDaoHibernate.class), new CriteriaBuilder(OnmsNode.class).eq("label", "node_2").toCriteria()), notNullValue());
    // Sending syslog messages to each node and expect it to appear on the node
    sendMessage(ContainerAlias.MINION, hostIpAddress, 1);
    await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(getDaoFactory().getDao(EventDaoHibernate.class), new CriteriaBuilder(OnmsEvent.class).eq("eventUei", "uei.opennms.org/vendor/cisco/syslog/SEC-6-IPACCESSLOGP/aclDeniedIPTraffic").ge("eventCreateTime", startOfTest).eq("node", onmsNode1).toCriteria()), is(1));
    sendMessage(ContainerAlias.MINION_OTHER_LOCATION, hostIpAddress, 1);
    await().atMost(1, MINUTES).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(getDaoFactory().getDao(EventDaoHibernate.class), new CriteriaBuilder(OnmsEvent.class).eq("eventUei", "uei.opennms.org/vendor/cisco/syslog/SEC-6-IPACCESSLOGP/aclDeniedIPTraffic").ge("eventCreateTime", startOfTest).eq("node", onmsNode2).toCriteria()), is(1));
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) OnmsNode(org.opennms.netmgt.model.OnmsNode) RestClient(org.opennms.smoketest.utils.RestClient) Date(java.util.Date) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Test(org.junit.Test)

Example 8 with RequisitionNode

use of org.opennms.netmgt.provision.persist.requisition.RequisitionNode in project opennms by OpenNMS.

the class DetectorsOnMinionIT method checkServicesDetectedOnMinion.

@Test
public void checkServicesDetectedOnMinion() throws ClientProtocolException, IOException, InterruptedException {
    final InetSocketAddress opennmsHttp = m_testEnvironment.getServiceAddress(ContainerAlias.OPENNMS, 8980);
    RestClient client = new RestClient(opennmsHttp);
    Requisition requisition = new Requisition("foreignSource");
    List<RequisitionInterface> interfaces = new ArrayList<RequisitionInterface>();
    RequisitionInterface requisitionInterface = new RequisitionInterface();
    requisitionInterface.setIpAddr(LOCALHOST);
    requisitionInterface.setManaged(true);
    requisitionInterface.setSnmpPrimary(PrimaryType.PRIMARY);
    interfaces.add(requisitionInterface);
    RequisitionNode node = new RequisitionNode();
    node.setNodeLabel("label");
    node.setLocation("MINION");
    node.setInterfaces(interfaces);
    node.setForeignId("foreignId");
    requisition.insertNode(node);
    client.addOrReplaceRequisition(requisition);
    client.importRequisition("foreignSource");
    await().atMost(5, MINUTES).pollDelay(0, SECONDS).pollInterval(30, SECONDS).until(getnumberOfServicesDetected(client), greaterThan(0));
}
Also used : RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) InetSocketAddress(java.net.InetSocketAddress) RestClient(org.opennms.smoketest.utils.RestClient) ArrayList(java.util.ArrayList) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Test(org.junit.Test)

Example 9 with RequisitionNode

use of org.opennms.netmgt.provision.persist.requisition.RequisitionNode in project opennms by OpenNMS.

the class VmwareImporter method createRequisitionNode.

/**
     * Creates a requisition node for the given managed entity and type.
     *
     * @param ipAddresses   the set of Ip addresses
     * @param managedEntity the managed entity
     * @return the generated requisition node
     */
private RequisitionNode createRequisitionNode(Set<String> ipAddresses, ManagedEntity managedEntity, int apiVersion, VmwareViJavaAccess vmwareViJavaAccess) {
    RequisitionNode requisitionNode = new RequisitionNode();
    // Setting the node label
    requisitionNode.setNodeLabel(managedEntity.getName());
    // Foreign Id consisting of managed entity Id
    requisitionNode.setForeignId(managedEntity.getMOR().getVal());
    if (managedEntity instanceof VirtualMachine) {
        boolean firstInterface = true;
        // add all given interfaces
        for (String ipAddress : ipAddresses) {
            try {
                if ((request.isPersistIPv4() && InetAddressUtils.isIPv4Address(ipAddress)) || (request.isPersistIPv6() && InetAddressUtils.isIPv6Address(ipAddress))) {
                    InetAddress inetAddress = InetAddress.getByName(ipAddress);
                    if (!inetAddress.isLoopbackAddress()) {
                        RequisitionInterface requisitionInterface = new RequisitionInterface();
                        requisitionInterface.setIpAddr(ipAddress);
                        //  the first one will be primary
                        if (firstInterface) {
                            requisitionInterface.setSnmpPrimary(PrimaryType.PRIMARY);
                            for (String service : request.getVirtualMachineServices()) {
                                requisitionInterface.insertMonitoredService(new RequisitionMonitoredService(service.trim()));
                            }
                            firstInterface = false;
                        } else {
                            requisitionInterface.setSnmpPrimary(PrimaryType.SECONDARY);
                        }
                        requisitionInterface.setManaged(Boolean.TRUE);
                        requisitionInterface.setStatus(Integer.valueOf(1));
                        requisitionNode.putInterface(requisitionInterface);
                    }
                }
            } catch (UnknownHostException unknownHostException) {
                logger.warn("Invalid IP address '{}'", unknownHostException.getMessage());
            }
        }
    } else {
        if (managedEntity instanceof HostSystem) {
            boolean reachableInterfaceFound = false, firstInterface = true;
            List<RequisitionInterface> requisitionInterfaceList = new ArrayList<RequisitionInterface>();
            RequisitionInterface primaryInterfaceCandidate = null;
            // add all given interfaces
            for (String ipAddress : ipAddresses) {
                try {
                    if ((request.isPersistIPv4() && InetAddressUtils.isIPv4Address(ipAddress)) || (request.isPersistIPv6() && InetAddressUtils.isIPv6Address(ipAddress))) {
                        InetAddress inetAddress = InetAddress.getByName(ipAddress);
                        if (!inetAddress.isLoopbackAddress()) {
                            RequisitionInterface requisitionInterface = new RequisitionInterface();
                            requisitionInterface.setIpAddr(ipAddress);
                            if (firstInterface) {
                                primaryInterfaceCandidate = requisitionInterface;
                                firstInterface = false;
                            }
                            if (!reachableInterfaceFound && reachableCimService(vmwareViJavaAccess, (HostSystem) managedEntity, ipAddress)) {
                                primaryInterfaceCandidate = requisitionInterface;
                                reachableInterfaceFound = true;
                            }
                            requisitionInterface.setManaged(Boolean.TRUE);
                            requisitionInterface.setStatus(Integer.valueOf(1));
                            requisitionInterface.setSnmpPrimary(PrimaryType.SECONDARY);
                            requisitionInterfaceList.add(requisitionInterface);
                        }
                    }
                } catch (UnknownHostException unknownHostException) {
                    logger.warn("Invalid IP address '{}'", unknownHostException.getMessage());
                }
            }
            if (primaryInterfaceCandidate != null) {
                if (reachableInterfaceFound) {
                    logger.warn("Found reachable primary interface '{}'", primaryInterfaceCandidate.getIpAddr());
                } else {
                    logger.warn("Only non-reachable interfaces found, using first one for primary interface '{}'", primaryInterfaceCandidate.getIpAddr());
                }
                primaryInterfaceCandidate.setSnmpPrimary(PrimaryType.PRIMARY);
                for (String service : request.getHostSystemServices()) {
                    if (reachableInterfaceFound || !"VMwareCim-HostSystem".equals(service)) {
                        primaryInterfaceCandidate.insertMonitoredService(new RequisitionMonitoredService(service.trim()));
                    }
                }
            } else {
                logger.warn("No primary interface found");
            }
            for (RequisitionInterface requisitionInterface : requisitionInterfaceList) {
                requisitionNode.putInterface(requisitionInterface);
            }
        } else {
            logger.error("Undefined type of managedEntity '{}'", managedEntity.getMOR().getType());
            return null;
        }
    }
    /*
         * For now we use displaycategory, notifycategory and pollercategory for storing
         * the vcenter Ip address, the username and the password
         */
    String powerState = "unknown";
    StringBuffer vmwareTopologyInfo = new StringBuffer();
    // putting parents to topology information
    ManagedEntity parentEntity = managedEntity.getParent();
    do {
        if (vmwareTopologyInfo.length() > 0) {
            vmwareTopologyInfo.append(", ");
        }
        try {
            if (parentEntity != null && parentEntity.getMOR() != null) {
                vmwareTopologyInfo.append(parentEntity.getMOR().getVal() + "/" + URLEncoder.encode(parentEntity.getName(), StandardCharsets.UTF_8.name()));
            } else {
                logger.warn("Can't add topologyInformation because either the parentEntity or the MOR is null for " + managedEntity.getName());
            }
        } catch (UnsupportedEncodingException e) {
            logger.warn("Unsupported encoding '{}'", e.getMessage());
        }
        parentEntity = parentEntity == null ? null : parentEntity.getParent();
    } while (parentEntity != null);
    if (managedEntity instanceof HostSystem) {
        HostSystem hostSystem = (HostSystem) managedEntity;
        HostRuntimeInfo hostRuntimeInfo = hostSystem.getRuntime();
        if (hostRuntimeInfo == null) {
            logger.debug("hostRuntimeInfo=null");
        } else {
            HostSystemPowerState hostSystemPowerState = hostRuntimeInfo.getPowerState();
            if (hostSystemPowerState == null) {
                logger.debug("hostSystemPowerState=null");
            } else {
                powerState = hostSystemPowerState.toString();
            }
        }
        try {
            if (request.isTopologyDatastores()) {
                for (Datastore datastore : hostSystem.getDatastores()) {
                    if (vmwareTopologyInfo.length() > 0) {
                        vmwareTopologyInfo.append(", ");
                    }
                    try {
                        vmwareTopologyInfo.append(datastore.getMOR().getVal() + "/" + URLEncoder.encode(datastore.getSummary().getName(), StandardCharsets.UTF_8.name()));
                    } catch (UnsupportedEncodingException e) {
                        logger.warn("Unsupported encoding '{}'", e.getMessage());
                    }
                }
            }
        } catch (RemoteException e) {
            logger.warn("Cannot retrieve datastores for managedEntity '{}': '{}'", managedEntity.getMOR().getVal(), e.getMessage());
        }
        try {
            if (request.isTopologyNetworks()) {
                for (Network network : hostSystem.getNetworks()) {
                    if (vmwareTopologyInfo.length() > 0) {
                        vmwareTopologyInfo.append(", ");
                    }
                    try {
                        if (network instanceof DistributedVirtualPortgroup ? request.isTopologyPortGroups() : true) {
                            vmwareTopologyInfo.append(network.getMOR().getVal() + "/" + URLEncoder.encode(network.getSummary().getName(), StandardCharsets.UTF_8.name()));
                        }
                    } catch (UnsupportedEncodingException e) {
                        logger.warn("Unsupported encoding '{}'", e.getMessage());
                    }
                }
            }
        } catch (RemoteException e) {
            logger.warn("Cannot retrieve networks for managedEntity '{}': '{}'", managedEntity.getMOR().getVal(), e.getMessage());
        }
    } else {
        if (managedEntity instanceof VirtualMachine) {
            VirtualMachine virtualMachine = (VirtualMachine) managedEntity;
            VirtualMachineRuntimeInfo virtualMachineRuntimeInfo = virtualMachine.getRuntime();
            if (virtualMachineRuntimeInfo == null) {
                logger.debug("virtualMachineRuntimeInfo=null");
            } else {
                VirtualMachinePowerState virtualMachinePowerState = virtualMachineRuntimeInfo.getPowerState();
                if (virtualMachinePowerState == null) {
                    logger.debug("virtualMachinePowerState=null");
                } else {
                    powerState = virtualMachinePowerState.toString();
                }
            }
            try {
                if (request.isTopologyDatastores()) {
                    for (Datastore datastore : virtualMachine.getDatastores()) {
                        if (vmwareTopologyInfo.length() > 0) {
                            vmwareTopologyInfo.append(", ");
                        }
                        try {
                            vmwareTopologyInfo.append(datastore.getMOR().getVal() + "/" + URLEncoder.encode(datastore.getSummary().getName(), StandardCharsets.UTF_8.name()));
                        } catch (UnsupportedEncodingException e) {
                            logger.warn("Unsupported encoding '{}'", e.getMessage());
                        }
                    }
                }
            } catch (RemoteException e) {
                logger.warn("Cannot retrieve datastores for managedEntity '{}': '{}'", managedEntity.getMOR().getVal(), e.getMessage());
            }
            try {
                if (request.isTopologyNetworks()) {
                    for (Network network : virtualMachine.getNetworks()) {
                        if (vmwareTopologyInfo.length() > 0) {
                            vmwareTopologyInfo.append(", ");
                        }
                        try {
                            if (network instanceof DistributedVirtualPortgroup ? request.isTopologyPortGroups() : true) {
                                vmwareTopologyInfo.append(network.getMOR().getVal() + "/" + URLEncoder.encode(network.getSummary().getName(), StandardCharsets.UTF_8.name()));
                            }
                        } catch (UnsupportedEncodingException e) {
                            logger.warn("Unsupported encoding '{}'", e.getMessage());
                        }
                    }
                }
            } catch (RemoteException e) {
                logger.warn("Cannot retrieve networks for managedEntity '{}': '{}'", managedEntity.getMOR().getVal(), e.getMessage());
            }
            if (vmwareTopologyInfo.length() > 0) {
                vmwareTopologyInfo.append(", ");
            }
            try {
                if (m_hostSystemMap.get(virtualMachine.getRuntime().getHost().getVal()) != null) {
                    vmwareTopologyInfo.append(virtualMachine.getRuntime().getHost().getVal() + "/" + URLEncoder.encode(m_hostSystemMap.get(virtualMachine.getRuntime().getHost().getVal()), StandardCharsets.UTF_8.name()));
                } else {
                    logger.warn("Problem building topology information for virtual machine '{}' with power state '{}' running on host system '{}'", virtualMachine.getMOR().getVal(), powerState, virtualMachine.getRuntime().getHost().getVal());
                }
            } catch (UnsupportedEncodingException e) {
                logger.warn("Unsupported encoding '{}'", e.getMessage());
            }
        } else {
            logger.error("Undefined type of managedEntity '{}'", managedEntity.getMOR().getType());
            return null;
        }
    }
    RequisitionAsset requisitionAssetHostname = new RequisitionAsset("vmwareManagementServer", request.getHostname());
    requisitionNode.putAsset(requisitionAssetHostname);
    RequisitionAsset requisitionAssetType = new RequisitionAsset("vmwareManagedEntityType", (managedEntity instanceof HostSystem ? "HostSystem" : "VirtualMachine"));
    requisitionNode.putAsset(requisitionAssetType);
    RequisitionAsset requisitionAssetId = new RequisitionAsset("vmwareManagedObjectId", managedEntity.getMOR().getVal());
    requisitionNode.putAsset(requisitionAssetId);
    RequisitionAsset requisitionAssetTopologyInfo = new RequisitionAsset("vmwareTopologyInfo", vmwareTopologyInfo.toString());
    requisitionNode.putAsset(requisitionAssetTopologyInfo);
    RequisitionAsset requisitionAssetState = new RequisitionAsset("vmwareState", powerState);
    requisitionNode.putAsset(requisitionAssetState);
    requisitionNode.putCategory(new RequisitionCategory("VMware" + apiVersion));
    return requisitionNode;
}
Also used : ManagedEntity(com.vmware.vim25.mo.ManagedEntity) RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) HostRuntimeInfo(com.vmware.vim25.HostRuntimeInfo) UnknownHostException(java.net.UnknownHostException) VirtualMachineRuntimeInfo(com.vmware.vim25.VirtualMachineRuntimeInfo) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RequisitionMonitoredService(org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService) HostSystemPowerState(com.vmware.vim25.HostSystemPowerState) RequisitionAsset(org.opennms.netmgt.provision.persist.requisition.RequisitionAsset) DistributedVirtualPortgroup(com.vmware.vim25.mo.DistributedVirtualPortgroup) VirtualMachinePowerState(com.vmware.vim25.VirtualMachinePowerState) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) Datastore(com.vmware.vim25.mo.Datastore) Network(com.vmware.vim25.mo.Network) RequisitionCategory(org.opennms.netmgt.provision.persist.requisition.RequisitionCategory) HostSystem(com.vmware.vim25.mo.HostSystem) RemoteException(java.rmi.RemoteException) InetAddress(java.net.InetAddress) VirtualMachine(com.vmware.vim25.mo.VirtualMachine)

Example 10 with RequisitionNode

use of org.opennms.netmgt.provision.persist.requisition.RequisitionNode in project opennms by OpenNMS.

the class VmwareImporter method iterateVirtualMachines.

/**
     * Iterates through the virtual machines and adds them to the requisition object.
     *
     * @param vmwareViJavaAccess the access/connection to use
     * @throws RemoteException
     */
private void iterateVirtualMachines(VmwareViJavaAccess vmwareViJavaAccess, int apiVersion) throws RemoteException {
    ManagedEntity[] virtualMachines;
    // search for all virtual machines
    virtualMachines = vmwareViJavaAccess.searchManagedEntities("VirtualMachine");
    if (virtualMachines != null) {
        // check for correct key/value-pair
        for (ManagedEntity managedEntity : virtualMachines) {
            VirtualMachine virtualMachine = (VirtualMachine) managedEntity;
            logger.debug("Iterating host systems on VMware management server {} : {} (ID: {})", request.getHostname(), virtualMachine.getName(), virtualMachine.getMOR().getVal());
            // import only when the specified attributes is set
            if (checkVMPowerState(virtualMachine) && checkForAttribute(virtualMachine)) {
                logger.debug("Adding Virtual Machine '{}' (ID: {})", virtualMachine.getName(), virtualMachine.getMOR().getVal());
                // iterate over all interfaces
                TreeSet<String> ipAddresses = vmwareViJavaAccess.getVirtualMachineIpAddresses(virtualMachine);
                // create the new node...
                RequisitionNode node = createRequisitionNode(ipAddresses, virtualMachine, apiVersion, vmwareViJavaAccess);
                // add the operating system
                if (virtualMachine.getGuest().getGuestFullName() != null) {
                    node.putAsset(new RequisitionAsset("operatingSystem", virtualMachine.getGuest().getGuestFullName()));
                }
                // add cpu
                try {
                    node.putAsset(new RequisitionAsset("cpu", virtualMachine.getConfig().getHardware().getNumCPU() + " vCPU"));
                } catch (Exception e) {
                    logger.debug("Can't find CPU information for {} (ID: {})", virtualMachine.getName(), virtualMachine.getMOR().getVal());
                }
                // add memory
                try {
                    node.putAsset(new RequisitionAsset("ram", virtualMachine.getConfig().getHardware().getMemoryMB() + " MB"));
                } catch (Exception e) {
                    logger.debug("Can't find Memory information for {} (ID: {})", virtualMachine.getName(), virtualMachine.getMOR().getVal());
                }
                // set the location
                node.setLocation(request.getLocation());
                // ...and add it to the requisition
                if (node != null && request.isPersistVMs()) {
                    m_requisition.insertNode(node);
                }
            }
        }
    }
}
Also used : ManagedEntity(com.vmware.vim25.mo.ManagedEntity) RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionAsset(org.opennms.netmgt.provision.persist.requisition.RequisitionAsset) CIMException(org.sblim.wbem.cim.CIMException) ConnectException(java.net.ConnectException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RemoteException(java.rmi.RemoteException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) VirtualMachine(com.vmware.vim25.mo.VirtualMachine)

Aggregations

RequisitionNode (org.opennms.netmgt.provision.persist.requisition.RequisitionNode)18 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)12 RequisitionInterface (org.opennms.netmgt.provision.persist.requisition.RequisitionInterface)11 Test (org.junit.Test)6 RequisitionMonitoredService (org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService)6 RequisitionAsset (org.opennms.netmgt.provision.persist.requisition.RequisitionAsset)4 RequisitionCategory (org.opennms.netmgt.provision.persist.requisition.RequisitionCategory)4 ManagedEntity (com.vmware.vim25.mo.ManagedEntity)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 UnknownHostException (java.net.UnknownHostException)3 RemoteException (java.rmi.RemoteException)3 HostSystem (com.vmware.vim25.mo.HostSystem)2 VirtualMachine (com.vmware.vim25.mo.VirtualMachine)2 IOException (java.io.IOException)2 ConnectException (java.net.ConnectException)2 InetAddress (java.net.InetAddress)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)2