/** * Returns whether the trust alias should be set and it is not (e.g. because the upgrade of an * instance with hosts already configured) */ public static boolean isTrustAliasMissing(ComputeState computeState) { URI hostUri = ContainerDescription.getDockerHostUri(computeState); return UriUtils.HTTPS_SCHEME.equalsIgnoreCase(hostUri.getScheme()) && (getTrustAlias(computeState) == null); }
static ComputeState createComputeHost(List<String> tenantLinks, String computeDescriptionId) throws Throwable { ComputeState cs = new ComputeState(); cs.id = UUID.randomUUID().toString(); cs.primaryMAC = UUID.randomUUID().toString(); cs.address = COMPUTE_ADDRESS; cs.powerState = PowerState.ON; cs.descriptionLink = UriUtils.buildUriPath(ComputeDescriptionService.FACTORY_LINK, computeDescriptionId); cs.resourcePoolLink = UriUtils.buildUriPath(ResourcePoolService.FACTORY_LINK, RESOURCE_POOL_ID); cs.adapterManagementReference = URI.create("http://localhost:8081"); cs.customProperties = new HashMap<>(); cs.customProperties.put(ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ADAPTER_DOCKER_TYPE_ID); cs.customProperties.put(ComputeConstants.DOCKER_URI_PROP_NAME, ContainerDescription.getDockerHostUri(cs).toString()); cs.tenantLinks = new ArrayList<>(tenantLinks); return cs; }
ComputeService.ComputeState createComputeHost() throws Throwable { ComputeService.ComputeState cs = new ComputeService.ComputeState(); cs.id = UUID.randomUUID().toString(); cs.primaryMAC = UUID.randomUUID().toString(); cs.address = "somehost"; cs.powerState = ComputeService.PowerState.ON; cs.descriptionLink = UriUtils.buildUriPath(ComputeDescriptionService.FACTORY_LINK, "test-host-compute-desc-id"); cs.resourcePoolLink = UriUtils.buildUriPath(ResourcePoolService.FACTORY_LINK, "test-host-resource-pool"); cs.adapterManagementReference = URI.create("http://localhost:8081"); cs.customProperties = new HashMap<>(); cs.customProperties.put(ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, "API"); cs.customProperties.put(ComputeConstants.DOCKER_URI_PROP_NAME, ContainerDescription.getDockerHostUri(cs).toString()); cs.documentSelfLink = cs.id; cs.tenantLinks = new ArrayList<>(); return doPost(cs, ComputeService.FACTORY_LINK); }
validate(hostSpec); hostSpec.uri = getDockerHostUri(hostSpec.hostState);
protected void createHostConnection(AdapterRequest request, Operation op, ComputeState hostComputeState, BiConsumer<ComputeState, CommandInput> callbackFunction) { URI dockerUri; try { dockerUri = ContainerDescription.getDockerHostUri(hostComputeState); logFine("Processing request for adapter %s %s", dockerUri, request.getRequestTrackingLog()); getCredentials(request, op, hostComputeState, callbackFunction, dockerUri); } catch (Exception x) { if (op != null) { op.fail(x); } fail(request, x); return; } }
private CommandInput prepareDirectHostOperationCommand(ComputeState hostComputeState, AuthCredentialsServiceState authCredentialsState) { URI dockerUri = ContainerDescription.getDockerHostUri(hostComputeState); CommandInput commandInput = new CommandInput().withDockerUri(dockerUri); if (authCredentialsState != null) { checkAuthCredentialsSupportedType(authCredentialsState, true); commandInput .withCredentials(authCredentialsState) .withProperty(SSL_TRUST_ALIAS_PROP_NAME, ContainerHostUtil.getTrustAlias(hostComputeState)); } return commandInput; }