Search in sources :

Example 1 with SetMonitorServiceCommand

use of com.cloud.agent.api.routing.SetMonitorServiceCommand 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 SetMonitorServiceCommand

use of com.cloud.agent.api.routing.SetMonitorServiceCommand in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method createMonitorServiceCommand.

private SetMonitorServiceCommand createMonitorServiceCommand(DomainRouterVO router, List<MonitorServiceTO> services, boolean reconfigure, boolean deleteFromProcessedCache) {
    final SetMonitorServiceCommand command = new SetMonitorServiceCommand(services);
    command.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
    command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
    command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_ENABLED, RouterHealthChecksEnabled.value().toString());
    command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_BASIC_INTERVAL, RouterHealthChecksBasicInterval.value().toString());
    command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_ADVANCED_INTERVAL, RouterHealthChecksAdvancedInterval.value().toString());
    String excludedTests = RouterHealthChecksToExclude.valueIn(router.getDataCenterId());
    if (router.getIsRedundantRouter()) {
        // Disable gateway check if VPC has no tiers or no active VM's in it
        final List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
        if (RedundantState.BACKUP.equals(router.getRedundantState()) || routerGuestNtwkIds == null || routerGuestNtwkIds.isEmpty()) {
            excludedTests = excludedTests.isEmpty() ? BACKUP_ROUTER_EXCLUDED_TESTS : excludedTests + "," + BACKUP_ROUTER_EXCLUDED_TESTS;
        }
    }
    command.setAccessDetail(SetMonitorServiceCommand.ROUTER_HEALTH_CHECKS_EXCLUDED, excludedTests);
    command.setHealthChecksConfig(getRouterHealthChecksConfig(router));
    command.setReconfigureAfterUpdate(reconfigure);
    // As part of updating
    command.setDeleteFromProcessedCache(deleteFromProcessedCache);
    return command;
}
Also used : SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand)

Example 3 with SetMonitorServiceCommand

use of com.cloud.agent.api.routing.SetMonitorServiceCommand in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method updateRouterHealthChecksConfig.

/**
 * Updates router health check config to the virtual router that it uses for health checks.
 * @param router - the router ID that data needs to be sent to.
 * @return success of whether data was sent or not
 */
private boolean updateRouterHealthChecksConfig(DomainRouterVO router) {
    if (!RouterHealthChecksEnabled.value()) {
        return false;
    }
    String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
    if (StringUtils.isBlank(controlIP) || controlIP.equals("0.0.0.0")) {
        s_logger.debug("Skipping update data on router " + router.getUuid() + " because controlIp is not correct.");
        return false;
    }
    s_logger.info("Updating data for router health checks for router " + router.getUuid());
    Answer origAnswer = null;
    try {
        SetMonitorServiceCommand command = createMonitorServiceCommand(router, null, true, true);
        origAnswer = _agentMgr.easySend(router.getHostId(), command);
    } catch (final Exception e) {
        s_logger.error("Error while sending update data for health check to router: " + router.getInstanceName(), e);
        return false;
    }
    if (origAnswer == null) {
        s_logger.error("Unable to update health checks data to router " + router.getHostName());
        return false;
    }
    GroupAnswer answer = null;
    if (origAnswer instanceof GroupAnswer) {
        answer = (GroupAnswer) origAnswer;
    } else {
        s_logger.error("Unable to update health checks data to router " + router.getHostName() + " Received answer " + origAnswer.getDetails());
        return false;
    }
    if (!answer.getResult()) {
        s_logger.error("Unable to update health checks data to router " + router.getHostName() + ", details : " + answer.getDetails());
    }
    return answer.getResult();
}
Also used : GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer) Answer(com.cloud.agent.api.Answer) CheckRouterAnswer(com.cloud.agent.api.CheckRouterAnswer) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) GetDomRVersionAnswer(com.cloud.agent.api.GetDomRVersionAnswer) CheckS2SVpnConnectionsAnswer(com.cloud.agent.api.CheckS2SVpnConnectionsAnswer) GetRouterMonitorResultsAnswer(com.cloud.agent.api.routing.GetRouterMonitorResultsAnswer) GetRouterAlertsAnswer(com.cloud.agent.api.GetRouterAlertsAnswer) SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) ConnectionException(com.cloud.exception.ConnectionException) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) JsonSyntaxException(com.google.gson.JsonSyntaxException) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ParseException(java.text.ParseException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) ConfigurationException(javax.naming.ConfigurationException)

Example 4 with SetMonitorServiceCommand

use of com.cloud.agent.api.routing.SetMonitorServiceCommand in project cloudstack by apache.

the class VirtualRoutingResourceTest method testSetMonitorServiceCommand.

@Test
public void testSetMonitorServiceCommand() {
    final SetMonitorServiceCommand cmd = generateSetMonitorServiceCommand();
    final Answer answer = _resource.executeRequest(cmd);
    assertTrue(answer.getResult());
}
Also used : GroupAnswer(com.cloud.agent.api.routing.GroupAnswer) Answer(com.cloud.agent.api.Answer) SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) Test(org.junit.Test)

Example 5 with SetMonitorServiceCommand

use of com.cloud.agent.api.routing.SetMonitorServiceCommand in project cloudstack by apache.

the class VirtualRoutingResourceTest method generateSetMonitorServiceCommand.

protected SetMonitorServiceCommand generateSetMonitorServiceCommand() {
    final List<MonitorServiceTO> services = new ArrayList<>();
    services.add(new MonitorServiceTO("service", "process", "name", "path", "file", true));
    services.add(new MonitorServiceTO("service_2", "process_2", "name_2", "path_2", "file_2", false));
    final SetMonitorServiceCommand cmd = new SetMonitorServiceCommand(services);
    cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME);
    return cmd;
}
Also used : SetMonitorServiceCommand(com.cloud.agent.api.routing.SetMonitorServiceCommand) ArrayList(java.util.ArrayList) MonitorServiceTO(com.cloud.agent.api.to.MonitorServiceTO)

Aggregations

SetMonitorServiceCommand (com.cloud.agent.api.routing.SetMonitorServiceCommand)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 Answer (com.cloud.agent.api.Answer)3 GroupAnswer (com.cloud.agent.api.routing.GroupAnswer)2 MonitorServiceTO (com.cloud.agent.api.to.MonitorServiceTO)2 ArrayList (java.util.ArrayList)2 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)1 AttachIsoCommand (com.cloud.agent.api.AttachIsoCommand)1 BackupSnapshotCommand (com.cloud.agent.api.BackupSnapshotCommand)1 CheckHealthCommand (com.cloud.agent.api.CheckHealthCommand)1 CheckNetworkCommand (com.cloud.agent.api.CheckNetworkCommand)1 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)1 CheckRouterCommand (com.cloud.agent.api.CheckRouterCommand)1 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)1 CheckS2SVpnConnectionsCommand (com.cloud.agent.api.CheckS2SVpnConnectionsCommand)1 CheckVirtualMachineCommand (com.cloud.agent.api.CheckVirtualMachineCommand)1 CleanupNetworkRulesCmd (com.cloud.agent.api.CleanupNetworkRulesCmd)1 ComputeChecksumCommand (com.cloud.agent.api.ComputeChecksumCommand)1 CreatePrivateTemplateFromSnapshotCommand (com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand)1 CreatePrivateTemplateFromVolumeCommand (com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand)1