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();
}
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();
}
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();
}
Aggregations