Search in sources :

Example 1 with VmwareConfigDao

use of org.opennms.netmgt.dao.VmwareConfigDao in project opennms by OpenNMS.

the class VmwareCollectorComplianceTest method getRequiredBeans.

@Override
public Map<String, Object> getRequiredBeans() {
    OnmsNode node = mock(OnmsNode.class, RETURNS_DEEP_STUBS);
    NodeDao nodeDao = mock(NodeDao.class);
    when(nodeDao.get(anyInt())).thenReturn(node);
    when(node.getAssetRecord().getVmwareManagementServer()).thenReturn("mdx");
    when(node.getAssetRecord().getVmwareManagedEntityType()).thenReturn("tsx");
    when(node.getForeignId()).thenReturn("rsx");
    VmwareCollection collection = new VmwareCollection();
    VmwareDatacollectionConfigDao vmwareDatacollectionConfigDao = mock(VmwareDatacollectionConfigDao.class);
    when(vmwareDatacollectionConfigDao.getVmwareCollection(COLLECTION)).thenReturn(collection);
    when(vmwareDatacollectionConfigDao.getRrdRepository(COLLECTION)).thenReturn(new RrdRepository());
    VmwareServer vmwareServer = new VmwareServer();
    vmwareServer.setHostname(InetAddrUtils.getLocalHostAddress().getCanonicalHostName());
    Map<String, VmwareServer> serverMap = new ImmutableMap.Builder<String, VmwareServer>().put("mdx", vmwareServer).build();
    VmwareConfigDao vmwareConfigDao = mock(VmwareConfigDao.class);
    when(vmwareConfigDao.getServerMap()).thenReturn(serverMap);
    return new ImmutableMap.Builder<String, Object>().put("nodeDao", nodeDao).put("vmwareDatacollectionConfigDao", vmwareDatacollectionConfigDao).put("vmwareConfigDao", vmwareConfigDao).build();
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) VmwareConfigDao(org.opennms.netmgt.dao.VmwareConfigDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) VmwareServer(org.opennms.netmgt.config.vmware.VmwareServer) VmwareCollection(org.opennms.netmgt.config.vmware.vijava.VmwareCollection) VmwareDatacollectionConfigDao(org.opennms.netmgt.dao.VmwareDatacollectionConfigDao) RrdRepository(org.opennms.netmgt.rrd.RrdRepository)

Example 2 with VmwareConfigDao

use of org.opennms.netmgt.dao.VmwareConfigDao in project opennms by OpenNMS.

the class AbstractVmwareMonitor method getRuntimeAttributes.

@Override
public Map<String, Object> getRuntimeAttributes(MonitoredService svc, Map<String, Object> parameters) {
    if (m_nodeDao == null) {
        m_nodeDao = BeanUtils.getBean("daoContext", "nodeDao", NodeDao.class);
    }
    if (m_vmwareConfigDao == null) {
        m_vmwareConfigDao = BeanUtils.getBean("daoContext", "vmwareConfigDao", VmwareConfigDao.class);
    }
    final OnmsNode onmsNode = m_nodeDao.get(svc.getNodeId());
    if (onmsNode == null) {
        throw new IllegalArgumentException("No node found with ID: " + svc.getNodeId());
    }
    // retrieve the assets
    final String vmwareManagementServer = onmsNode.getAssetRecord().getVmwareManagementServer();
    final String vmwareManagedEntityType = onmsNode.getAssetRecord().getVmwareManagedEntityType();
    final String vmwareManagedObjectId = onmsNode.getForeignId();
    String vmwareMangementServerUsername = null;
    String vmwareMangementServerPassword = null;
    final Map<String, VmwareServer> serverMap = m_vmwareConfigDao.getServerMap();
    if (serverMap == null) {
        logger.error("Error getting vmware-config.xml's server map.");
    } else {
        final VmwareServer vmwareServer = serverMap.get(vmwareManagementServer);
        if (vmwareServer == null) {
            logger.error("Error getting credentials for VMware management server '{}'.", vmwareManagementServer);
        } else {
            vmwareMangementServerUsername = vmwareServer.getUsername();
            vmwareMangementServerPassword = vmwareServer.getPassword();
        }
    }
    return new ImmutableMap.Builder<String, Object>().put(VMWARE_MANAGEMENT_SERVER_KEY, vmwareManagementServer).put(VMWARE_MANAGED_ENTITY_TYPE_KEY, vmwareManagedEntityType).put(VMWARE_MANAGED_OBJECT_ID_KEY, vmwareManagedObjectId).put(VMWARE_MANAGEMENT_SERVER_USERNAME_KEY, vmwareMangementServerUsername).put(VMWARE_MANAGEMENT_SERVER_PASSWORD_KEY, vmwareMangementServerPassword).build();
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) VmwareConfigDao(org.opennms.netmgt.dao.VmwareConfigDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) VmwareServer(org.opennms.netmgt.config.vmware.VmwareServer)

Example 3 with VmwareConfigDao

use of org.opennms.netmgt.dao.VmwareConfigDao in project opennms by OpenNMS.

the class VmwareCimCollectorComplianceTest method getRequiredBeans.

@Override
public Map<String, Object> getRequiredBeans() {
    OnmsNode node = mock(OnmsNode.class, RETURNS_DEEP_STUBS);
    NodeDao nodeDao = mock(NodeDao.class);
    when(nodeDao.get(anyInt())).thenReturn(node);
    when(node.getAssetRecord().getVmwareManagementServer()).thenReturn("mdx");
    when(node.getAssetRecord().getVmwareManagedEntityType()).thenReturn("tsx");
    when(node.getForeignId()).thenReturn("rsx");
    VmwareCimCollection collection = new VmwareCimCollection();
    VmwareCimDatacollectionConfigDao vmwareCimDatacollectionConfigDao = mock(VmwareCimDatacollectionConfigDao.class);
    when(vmwareCimDatacollectionConfigDao.getVmwareCimCollection(COLLECTION)).thenReturn(collection);
    when(vmwareCimDatacollectionConfigDao.getRrdRepository(COLLECTION)).thenReturn(new RrdRepository());
    VmwareServer vmwareServer = new VmwareServer();
    vmwareServer.setHostname(InetAddrUtils.getLocalHostAddress().getCanonicalHostName());
    Map<String, VmwareServer> serverMap = new ImmutableMap.Builder<String, VmwareServer>().put("mdx", vmwareServer).build();
    VmwareConfigDao vmwareConfigDao = mock(VmwareConfigDao.class);
    when(vmwareConfigDao.getServerMap()).thenReturn(serverMap);
    return new ImmutableMap.Builder<String, Object>().put("nodeDao", nodeDao).put("vmwareCimDatacollectionConfigDao", vmwareCimDatacollectionConfigDao).put("vmwareConfigDao", vmwareConfigDao).build();
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) VmwareConfigDao(org.opennms.netmgt.dao.VmwareConfigDao) OnmsNode(org.opennms.netmgt.model.OnmsNode) VmwareCimDatacollectionConfigDao(org.opennms.netmgt.dao.VmwareCimDatacollectionConfigDao) VmwareServer(org.opennms.netmgt.config.vmware.VmwareServer) VmwareCimCollection(org.opennms.netmgt.config.vmware.cim.VmwareCimCollection) RrdRepository(org.opennms.netmgt.rrd.RrdRepository)

Aggregations

VmwareServer (org.opennms.netmgt.config.vmware.VmwareServer)3 VmwareConfigDao (org.opennms.netmgt.dao.VmwareConfigDao)3 NodeDao (org.opennms.netmgt.dao.api.NodeDao)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)2 VmwareCimCollection (org.opennms.netmgt.config.vmware.cim.VmwareCimCollection)1 VmwareCollection (org.opennms.netmgt.config.vmware.vijava.VmwareCollection)1 VmwareCimDatacollectionConfigDao (org.opennms.netmgt.dao.VmwareCimDatacollectionConfigDao)1 VmwareDatacollectionConfigDao (org.opennms.netmgt.dao.VmwareDatacollectionConfigDao)1