private URI getAdapterManagementReferenceForType(ContainerHostType type) { switch (type) { case DOCKER: return UriUtils.buildUri(getHost(), ManagementUriParts.ADAPTER_DOCKER_HOST); case VCH: return UriUtils.buildUri(getHost(), ManagementUriParts.ADAPTER_DOCKER_HOST); case KUBERNETES: return UriUtils.buildUri(getHost(), ManagementUriParts.ADAPTER_KUBERNETES_HOST); default: throw new LocalizableValidationException(String.format( ContainerHostUtil.CONTAINER_HOST_TYPE_NOT_SUPPORTED_MESSAGE_FORMAT, type), ContainerHostUtil.CONTAINER_HOST_TYPE_NOT_SUPPORTED_MESSAGE_CODE, type); } }
Boolean.toString(true)); PlacementZoneUtil.generatePlacementZone(getHost(), hostState) .thenCompose((generatedZone) -> { generatedResourcesIds.add(generatedZone.documentSelfLink); hostState.resourcePoolLink = generatedZone.documentSelfLink; return PlacementZoneUtil.generatePlacement(getHost(), generatedZone); }) .thenAccept((generatedPlacement) -> { if (ContainerHostUtil.isVicHost(computeState)) { String version = ContainerHostUtil.getHostServerVersion(computeState); ContainerHostUtil.verifyVchVersionIsSupported(getHost(), version) .whenComplete((ignore, ex) -> { if (ex != null) {
private AdapterRequest prepareAdapterRequest(ContainerHostOperationType operationType, ComputeState cs, SslTrustCertificateState sslTrust) { AdapterRequest request = new AdapterRequest(); request.operationTypeId = operationType.id; request.serviceTaskCallback = ServiceTaskCallback.createEmpty(); request.resourceReference = UriUtils.buildUri(getHost(), ComputeService.FACTORY_LINK); request.customProperties = cs.customProperties == null ? new HashMap<>() : new HashMap<>(cs.customProperties); request.customProperties.putIfAbsent(ComputeConstants.HOST_URI_PROP_NAME, cs.address); if (sslTrust != null) { request.customProperties.put(SSL_TRUST_CERT_PROP_NAME, sslTrust.certificate); request.customProperties.put(SSL_TRUST_ALIAS_PROP_NAME, SslTrustCertificateFactoryService.generateFingerprint(sslTrust)); } return request; }
private void updateContainerHostInfo(String documentSelfLink) { URI uri = UriUtils.buildUri(getHost(), ContainerHostDataCollectionService.HOST_INFO_DATA_COLLECTION_LINK); ContainerHostDataCollectionState state = new ContainerHostDataCollectionState(); state.createOrUpdateHost = true; state.computeContainerHostLinks = Collections.singleton(documentSelfLink); sendRequest(Operation.createPatch(uri) .setBody(state) .setCompletion((o, ex) -> { if (ex != null) { logWarning("Failed to update host data collection: %s", ex.getMessage()); } })); }
private void verifyPlacementZoneIsEmpty(ContainerHostSpec hostSpec, Operation op, Runnable successCallback) { String placementZoneLink = hostSpec.hostState.resourcePoolLink; if (placementZoneLink == null || placementZoneLink.isEmpty()) { // no placement zone to verify successCallback.run(); return; } AtomicBoolean emptyZone = new AtomicBoolean(true); QueryTask queryTask = QueryUtil.buildPropertyQuery(ComputeState.class, ComputeState.FIELD_NAME_RESOURCE_POOL_LINK, placementZoneLink); QueryUtil.addCountOption(queryTask); new ServiceDocumentQuery<>(getHost(), ComputeState.class) .query(queryTask, (r) -> { if (r.hasException()) { op.fail(r.getException()); } else if (r.getCount() > 0) { emptyZone.set(false); op.fail(new LocalizableValidationException(PLACEMENT_ZONE_NOT_EMPTY_MESSAGE, PLACEMENT_ZONE_NOT_EMPTY_MESSAGE_CODE)); } else { if (emptyZone.get()) { successCallback.run(); } } }); }
private void verifyNoSchedulersInPlacementZone(ContainerHostSpec hostSpec, Operation op, Runnable successCallback) { String placementZoneLink = hostSpec.hostState.resourcePoolLink; if (placementZoneLink == null || placementZoneLink.isEmpty()) { // no placement zone => no schedulers successCallback.run(); return; } AtomicBoolean schedulerFound = new AtomicBoolean(false); QueryTask queryTask = QueryUtil.buildPropertyQuery(ComputeState.class, ComputeState.FIELD_NAME_RESOURCE_POOL_LINK, placementZoneLink); QueryUtil.addExpandOption(queryTask); new ServiceDocumentQuery<>(getHost(), ComputeState.class) .query(queryTask, (r) -> { if (r.hasException()) { op.fail(r.getException()); } else if (r.hasResult()) { if (ContainerHostUtil.isTreatedLikeSchedulerHost(r.getResult())) { schedulerFound.set(true); op.fail(new LocalizableValidationException( PLACEMENT_ZONE_CONTAINS_SCHEDULERS_MESSAGE, PLACEMENT_ZONE_CONTAINS_SCHEDULERS_MESSAGE_CODE)); } } else { if (!schedulerFound.get()) { successCallback.run(); } } }); }
Operation.createGet(getHost(), hostSpec.hostState.resourcePoolLink) .setCompletion((o, e) -> { if (e != null) {
new ServiceDocumentQuery<>(getHost(), ComputeState.class) .query(q, (r) -> {
private void checkForDefaultHostDescription(String descriptionLink, String descriptionId) { new ServiceDocumentQuery<>(getHost(), ComputeDescription.class) .queryDocument(descriptionLink, (r) -> { if (r.hasException()) {