@Override @ActionEvent(eventType = EventTypes.EVENT_HA_RESOURCE_DISABLE, eventDescription = "disabling HA for resource") public boolean disableHA(final Long resourceId, final HAResource.ResourceType resourceType) { Preconditions.checkArgument(resourceId != null && resourceId > 0L); Preconditions.checkArgument(resourceType != null); boolean result = configureHA(resourceId, resourceType, false, null); if (result) { transitionHAState(HAConfig.Event.Disabled, haConfigDao.findHAResource(resourceId, resourceType)); purgeHACounter(resourceId, resourceType); } return result; }
public Boolean isVMAliveOnHost(final Host host) throws Investigator.UnknownVM { final HAConfig haConfig = haConfigDao.findHAResource(host.getId(), HAResource.ResourceType.Host); if (haConfig != null) { if (haConfig.getState() == HAConfig.HAState.Fenced) { if (LOG.isDebugEnabled()){ LOG.debug("HA: Host is fenced " + host.getId()); } return false; } if (LOG.isDebugEnabled()){ LOG.debug("HA: HOST is alive " + host.getId()); } return true; } throw new Investigator.UnknownVM(); }
public Status getHostStatus(final Host host) { final HAConfig haConfig = haConfigDao.findHAResource(host.getId(), HAResource.ResourceType.Host); if (haConfig != null) { if (haConfig.getState() == HAConfig.HAState.Fenced) { if (LOG.isDebugEnabled()){ LOG.debug("HA: Agent is available/suspect/checking Up " + host.getId()); } return Status.Down; } else if (haConfig.getState() == HAConfig.HAState.Degraded || haConfig.getState() == HAConfig.HAState.Recovering || haConfig.getState() == HAConfig.HAState.Fencing) { if (LOG.isDebugEnabled()){ LOG.debug("HA: Agent is disconnected " + host.getId()); } return Status.Disconnected; } return Status.Up; } return Status.Unknown; }
private boolean isHAEligibleForResource(final HAResource resource) { if (resource == null || resource.getId() < 1L) { return false; } HAResource.ResourceType resourceType = null; if (resource instanceof Host) { resourceType = HAResource.ResourceType.Host; } if (resourceType == null) { return false; } final HAConfig haConfig = haConfigDao.findHAResource(resource.getId(), resourceType); return haConfig != null && haConfig.isEnabled() && haConfig.getState() != HAConfig.HAState.Disabled && haConfig.getState() != HAConfig.HAState.Ineligible; }
private boolean transitionResourceStateToDisabled(final Partition partition) { List<? extends HAResource> resources; if (partition.partitionType() == Partition.PartitionType.Cluster) { resources = hostDao.findByClusterId(partition.getId()); } else if (partition.partitionType() == Partition.PartitionType.Zone) { resources = hostDao.findByDataCenterId(partition.getId()); } else { return true; } boolean result = true; for (final HAResource resource: resources) { result = result && transitionHAState(HAConfig.Event.Disabled, haConfigDao.findHAResource(resource.getId(), resource.resourceType())); } return result; }
@Override public Boolean doInTransaction(TransactionStatus status) { HAConfigVO haConfig = (HAConfigVO) haConfigDao.findHAResource(resourceId, resourceType); if (haConfig == null) { haConfig = new HAConfigVO();
hostResponse.setHostHAResponse(haConfigDao.findHAResource(host.getId(), HAResource.ResourceType.Host)); hostResponse.setOutOfBandManagementResponse(outOfBandManagementDao.findByHost(host.getId())); hostResponse.setResourceState(host.getResourceState().toString());