vmware: VR health check in vmware basic zone (#5236)

This PR fixes VR heallth check error in vmware basic zone (#4158).
This commit is contained in:
Wei Zhou 2021-07-30 07:27:21 +02:00 committed by GitHub
parent 5033426057
commit 61fd4028bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 28 deletions

View File

@ -1459,7 +1459,7 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
return null;
}
String controlIP = getRouterControlIP(router);
String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
if (StringUtils.isNotBlank(controlIP) && !controlIP.equals("0.0.0.0")) {
final GetRouterMonitorResultsCommand command = new GetRouterMonitorResultsCommand(performFreshChecks, false);
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlIP);
@ -1491,7 +1491,7 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
return null;
}
String controlIP = getRouterControlIP(router);
String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
if (StringUtils.isNotBlank(controlIP) && !controlIP.equals("0.0.0.0")) {
final GetRouterMonitorResultsCommand command = new GetRouterMonitorResultsCommand(false, true);
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlIP);
@ -1601,7 +1601,7 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
private SetMonitorServiceCommand createMonitorServiceCommand(DomainRouterVO router, List<MonitorServiceTO> services,
boolean reconfigure, boolean deleteFromProcessedCache) {
final SetMonitorServiceCommand command = new SetMonitorServiceCommand(services);
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIP(router));
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());
@ -1633,7 +1633,7 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
return false;
}
String controlIP = getRouterControlIP(router);
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;
@ -1844,7 +1844,7 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
if (!Boolean.parseBoolean(serviceMonitoringFlag)) {
continue;
}
String controlIP = getRouterControlIP(router);
String controlIP = _routerControlHelper.getRouterControlIp(router.getId());
if (controlIP != null && !controlIP.equals("0.0.0.0")) {
OpRouterMonitorServiceVO opRouterMonitorServiceVO = _opRouterMonitorServiceDao.findById(router.getId());
@ -1915,29 +1915,6 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
}
}
private String getRouterControlIP(DomainRouterVO router){
final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
String controlIP = null;
if(router.getHypervisorType() == HypervisorType.VMware && dcVo.getNetworkType() == NetworkType.Basic ){
final List<NicVO> nics = _nicDao.listByVmId(router.getId());
for (final NicVO nic : nics) {
final NetworkVO nc = _networkDao.findById(nic.getNetworkId());
if (nc.getTrafficType() == TrafficType.Guest && nic.getIPv4Address() != null) {
controlIP = nic.getIPv4Address();
break;
}
}
s_logger.debug("Vmware with Basic network selected Guest NIC ip as control IP " + controlIP );
}else{
controlIP = _routerControlHelper.getRouterControlIp(router.getId());
}
s_logger.debug("IP of control NIC " + controlIP );
return controlIP;
}
@Override
public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) {