Search in sources :

Example 1 with MonitoringServiceVO

use of com.cloud.network.dao.MonitoringServiceVO in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method finalizeMonitorServiceOnStrat.

private void finalizeMonitorServiceOnStrat(final Commands cmds, final VirtualMachineProfile profile, final DomainRouterVO router, final Provider provider, final long networkId, final Boolean add) {
    final NetworkVO network = _networkDao.findById(networkId);
    s_logger.debug("Creating  monitoring services on " + router + " start...");
    // get the list of sevices for this network to monitor
    final List<MonitoringServiceVO> services = new ArrayList<MonitoringServiceVO>();
    if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, Provider.VirtualRouter) || _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VirtualRouter)) {
        final MonitoringServiceVO dhcpService = _monitorServiceDao.getServiceByName(MonitoringService.Service.Dhcp.toString());
        if (dhcpService != null) {
            services.add(dhcpService);
        }
    }
    if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Lb, Provider.VirtualRouter)) {
        final MonitoringServiceVO lbService = _monitorServiceDao.getServiceByName(MonitoringService.Service.LoadBalancing.toString());
        if (lbService != null) {
            services.add(lbService);
        }
    }
    final List<MonitoringServiceVO> defaultServices = _monitorServiceDao.listDefaultServices(true);
    services.addAll(defaultServices);
    final List<MonitorServiceTO> servicesTO = new ArrayList<MonitorServiceTO>();
    for (final MonitoringServiceVO service : services) {
        final MonitorServiceTO serviceTO = new MonitorServiceTO(service.getService(), service.getProcessName(), service.getServiceName(), service.getServicePath(), service.getServicePidFile(), service.isDefaultService());
        servicesTO.add(serviceTO);
    }
    // TODO : This is a hacking fix
    // at VR startup time, information in VirtualMachineProfile may not
    // updated to DB yet,
    // getRouterControlIp() may give wrong IP under basic network mode in
    // VMware environment
    final NicProfile controlNic = getControlNic(profile);
    if (controlNic == null) {
        throw new CloudRuntimeException("VirtualMachine " + profile.getInstanceName() + " doesn't have a control interface");
    }
    final SetMonitorServiceCommand command = new SetMonitorServiceCommand(servicesTO);
    command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlNic.getIPv4Address());
    command.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(networkId, router.getId()));
    command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
    if (!add) {
        command.setAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE, add.toString());
    }
    cmds.addCommand("monitor", command);
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ArrayList(java.util.ArrayList) MonitoringServiceVO(com.cloud.network.dao.MonitoringServiceVO) NicProfile(com.cloud.vm.NicProfile) MonitorServiceTO(com.cloud.agent.api.to.MonitorServiceTO)

Example 2 with MonitoringServiceVO

use of com.cloud.network.dao.MonitoringServiceVO in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method finalizeMonitorService.

protected void finalizeMonitorService(final Commands cmds, final VirtualMachineProfile profile, final DomainRouterVO router, final Provider provider, final long networkId, boolean onStart) {
    final NetworkOffering offering = _networkOfferingDao.findById(_networkDao.findById(networkId).getNetworkOfferingId());
    if (offering.isRedundantRouter()) {
        // service monitoring is currently not added in RVR
        return;
    }
    final String serviceMonitoringSet = _configDao.getValue(Config.EnableServiceMonitoring.key());
    final Boolean isMonitoringServicesEnabled = serviceMonitoringSet != null && serviceMonitoringSet.equalsIgnoreCase("true");
    final NetworkVO network = _networkDao.findById(networkId);
    s_logger.debug("Creating  monitoring services on " + router + " start...");
    // get the list of sevices for this network to monitor
    final List<MonitoringServiceVO> services = new ArrayList<MonitoringServiceVO>();
    if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, provider) || _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, provider)) {
        final MonitoringServiceVO dhcpService = _monitorServiceDao.getServiceByName(MonitoringService.Service.Dhcp.toString());
        if (dhcpService != null) {
            services.add(dhcpService);
        }
    }
    if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Lb, provider)) {
        final MonitoringServiceVO lbService = _monitorServiceDao.getServiceByName(MonitoringService.Service.LoadBalancing.toString());
        if (lbService != null) {
            services.add(lbService);
        }
    }
    services.addAll(getDefaultServicesToMonitor(network));
    final List<MonitorServiceTO> servicesTO = new ArrayList<MonitorServiceTO>();
    for (final MonitoringServiceVO service : services) {
        final MonitorServiceTO serviceTO = new MonitorServiceTO(service.getService(), service.getProcessName(), service.getServiceName(), service.getServicePath(), service.getServicePidFile(), service.isDefaultService());
        servicesTO.add(serviceTO);
    }
    // TODO : This is a hacking fix
    // at VR startup time, information in VirtualMachineProfile may not
    // updated to DB yet,
    // getRouterControlIp() may give wrong IP under basic network mode in
    // VMware environment
    final NicProfile controlNic = getControlNic(profile);
    if (controlNic == null) {
        throw new CloudRuntimeException("VirtualMachine " + profile.getInstanceName() + " doesn't have a control interface");
    }
    // As part of aggregate command we don't need to reconfigure if onStart and persist in processed cache. Subsequent updates are not needed.
    SetMonitorServiceCommand command = createMonitorServiceCommand(router, servicesTO, !onStart, false);
    command.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(networkId, router.getId()));
    if (!isMonitoringServicesEnabled) {
        command.setAccessDetail(SetMonitorServiceCommand.ROUTER_MONITORING_ENABLED, isMonitoringServicesEnabled.toString());
    }
    cmds.addCommand("monitor", command);
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) NetworkOffering(com.cloud.offering.NetworkOffering) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) MonitoringServiceVO(com.cloud.network.dao.MonitoringServiceVO) ArrayList(java.util.ArrayList) NicProfile(com.cloud.vm.NicProfile) MonitorServiceTO(com.cloud.agent.api.to.MonitorServiceTO)

Aggregations

SetMonitorServiceCommand (com.cloud.agent.api.routing.SetMonitorServiceCommand)2 MonitorServiceTO (com.cloud.agent.api.to.MonitorServiceTO)2 MonitoringServiceVO (com.cloud.network.dao.MonitoringServiceVO)2 NetworkVO (com.cloud.network.dao.NetworkVO)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 NicProfile (com.cloud.vm.NicProfile)2 ArrayList (java.util.ArrayList)2 NetworkOffering (com.cloud.offering.NetworkOffering)1