@Override public List<String> listHAProviders(final HAResource.ResourceType resourceType, final HAResource.ResourceSubType entityType) { final List<String> haProviderNames = new ArrayList<>(); for (final HAProvider<HAResource> haProvider : haProviders) { if (haProvider.resourceType().equals(resourceType) && haProvider.resourceSubType().equals(entityType)) { haProviderNames.add(haProvider.getClass().getSimpleName()); } } return haProviderNames; }
@Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { if (!Enums.getIfPresent(HAResource.ResourceSubType.class, hypervisorType).isPresent()) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid or unsupported host hypervisor type provided. Supported types are: " + Arrays.toString(HAResource.ResourceSubType.values())); } final List<String> hostHAProviders = haConfigManager.listHAProviders(HAResource.ResourceType.Host, getHypervisorType()); setupResponse(hostHAProviders); } }
public HAResource.ResourceSubType getHypervisorType() { return HAResource.ResourceSubType.valueOf(hypervisorType); }
public void validateHAProviderConfigForResource(final Long resourceId, final HAResource.ResourceType resourceType, final HAProvider<HAResource> haProvider) { if (HAResource.ResourceType.Host.equals(resourceType)) { final Host host = hostDao.findById(resourceId); if (host.getHypervisorType() == null || haProvider.resourceSubType() == null || !host.getHypervisorType().toString().equals(haProvider.resourceSubType().toString())) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Incompatible haprovider provided for the resource of hypervisor type:" + host.getHypervisorType()); } } }