/** * Check if this host should be treated as scheduler host. Note that a host may be a scheduler * (e.g. VIC, Kubernetes) but it may be declared as plain docker host and in this case the host * should be treated as a plain docker host * * @param computeState * @return boolean value */ public static boolean isTreatedLikeSchedulerHost(ComputeState computeState) { return getDeclaredContainerHostType(computeState) != ContainerHostType.DOCKER; }
private Map<String, HostSelection> buildHostSelectionMap(QueryResult rpQueryResult) { Collection<ComputeState> computes = rpQueryResult.computesByLink.values(); final Map<String, HostSelection> initHostSelectionMap = new LinkedHashMap<>( computes.size()); for (ComputeState computeState : computes) { final HostSelection hostSelection = new HostSelection(); hostSelection.hostLink = computeState.documentSelfLink; hostSelection.resourcePoolLinks = rpQueryResult.rpLinksByComputeLink .get(computeState.documentSelfLink); hostSelection.deploymentPolicyLink = computeState.customProperties .get(ContainerHostService.CUSTOM_PROPERTY_DEPLOYMENT_POLICY); hostSelection.availableMemory = getPropertyLong( computeState.customProperties, ContainerHostService.DOCKER_HOST_AVAILABLE_MEMORY_PROP_NAME) .orElse(Long.MAX_VALUE); hostSelection.clusterStore = computeState.customProperties .get(ContainerHostService.DOCKER_HOST_CLUSTER_STORE_PROP_NAME); hostSelection.plugins = computeState.customProperties .get(ContainerHostService.DOCKER_HOST_PLUGINS_PROP_NAME); hostSelection.name = computeState.name != null ? computeState.name : "N/A"; hostSelection.hostType = ContainerHostUtil.getDeclaredContainerHostType(computeState); initHostSelectionMap.put(hostSelection.hostLink, hostSelection); } return initHostSelectionMap; }
ContainerHostType hostType = ContainerHostUtil.getDeclaredContainerHostType(hostState); ResourcePoolState resourcePool = new ResourcePoolState(); if (clusterName != null && !clusterName.isEmpty()) {
ContainerHostService.DockerAdapterType.API.name()); ContainerHostType hostType = ContainerHostUtil.getDeclaredContainerHostType( hostSpec.hostState); map.put(ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, hostType.name());
.getDeclaredContainerHostType(hostSpec.hostState);
private void validateHostTypeAndConnection(ContainerHostSpec hostSpec, Operation op) { ContainerHostType hostType; try { hostType = ContainerHostUtil.getDeclaredContainerHostType(hostSpec.hostState); } catch (LocalizableValidationException ex) { logWarning("Error getting host type: %s", ex.getMessage()); op.fail(ex); return; } // Apply the appropriate validation for each host type switch (hostType) { case DOCKER: validateConnection(hostSpec, op); break; case VCH: validateVicHost(hostSpec, op); break; case KUBERNETES: validateConnection(hostSpec, op); break; default: String error = String.format( ContainerHostUtil.CONTAINER_HOST_TYPE_NOT_SUPPORTED_MESSAGE_FORMAT, hostType.toString()); op.fail(new LocalizableValidationException(error, ContainerHostUtil.CONTAINER_HOST_TYPE_NOT_SUPPORTED_MESSAGE_CODE, hostType)); break; } }
ContainerHostUtil.getDeclaredContainerHostType(cs));
try { hostType = ContainerHostUtil .getDeclaredContainerHostType(hostSpec.hostState); } catch (LocalizableValidationException ex) { logWarning("Error getting host type: %s", ex.getMessage());
if (clusterType == ClusterType.DOCKER) { assertEquals(ContainerHostType.DOCKER, ContainerHostUtil.getDeclaredContainerHostType(hostState)); } else { assertEquals(ContainerHostType.VCH, ContainerHostUtil.getDeclaredContainerHostType(hostState));