ContainerHostSpec hs = new ContainerHostSpec(); hs.hostState = new ComputeState(); hs.hostState.id = hostSpec.hostState.id; hs.hostState.address = hostSpec.hostState.address; hs.hostState.tenantLinks = hostSpec.getHostTenantLinks(); hs.hostState.resourcePoolLink = resourcePoolDocumentSelfLink; hs.acceptCertificate = hostSpec.acceptCertificate;
if (!hostSpec.isSecureScheme()) { logInfo("Using non secure channel, skipping SSL validation for %s", hostSpec.uri); callback.run();
ContainerHostSpec clusterSpec = new ContainerHostSpec(); clusterSpec.hostState = kubernetesHost; clusterSpec.acceptCertificate = true;
private void createInitialClusterState(PKSProvisioningTaskState task, PKSCluster pksCluster) { ContainerHostSpec clusterSpec = new ContainerHostSpec(); ComputeService.ComputeState computeState = new ComputeService.ComputeState(); computeState.tenantLinks = task.tenantLinks;
@Test public void testCreateCluster() throws Throwable { ContainerHostSpec hostSpec1 = new ContainerHostSpec(); hostSpec1.hostState = new ComputeState(); hostSpec1.hostState.id = UUID.randomUUID().toString(); .documentSelfLink, ClusterDto.class); ContainerHostSpec hostSpec2 = new ContainerHostSpec(); hostSpec2.hostState = new ComputeState(); hostSpec2.hostState.id = UUID.randomUUID().toString();
private ContainerHostSpec createContainerHostSpec(final String projectLinkDocker) { ContainerHostSpec hostSpecDocker1 = new ContainerHostSpec(); hostSpecDocker1.hostState = new ComputeState(); hostSpecDocker1.hostState.id = UUID.randomUUID().toString(); hostSpecDocker1.hostState.address = "test-address"; hostSpecDocker1.hostState.tenantLinks = Collections.singletonList(projectLinkDocker); hostSpecDocker1.acceptCertificate = true; hostSpecDocker1.hostState.customProperties = new HashMap<>(); hostSpecDocker1.hostState.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); hostSpecDocker1.hostState.customProperties.put( ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, ContainerHostType.DOCKER.name()); hostSpecDocker1.hostState.customProperties.put( ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, ""); return hostSpecDocker1; }
private ContainerHostSpec createContainerHostSpec(final String endpointLink) { ContainerHostSpec clusterSpec = new ContainerHostSpec(); ComputeService.ComputeState computeState = new ComputeService.ComputeState(); computeState.tenantLinks = Collections .singletonList(UriUtils.buildUriPath(ManagementUriParts.PROJECTS, "test")); computeState.customProperties = new HashMap<>(); computeState.customProperties.put(CLUSTER_NAME_CUSTOM_PROP, "test-cluster"); computeState.customProperties.put(CONTAINER_HOST_TYPE_PROP_NAME, ClusterService.ClusterType.KUBERNETES.name()); computeState.customProperties.put(HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, DockerAdapterType.API.name()); computeState.customProperties.put(ClusterService.CREATE_EMPTY_CLUSTER_PROP, "true"); computeState.customProperties.put(ClusterService.ENFORCED_CLUSTER_STATUS_PROP, ClusterService.ClusterStatus.PROVISIONING.name()); computeState.customProperties.put(PKSConstants.PKS_ENDPOINT_PROP_NAME, endpointLink); clusterSpec.hostState = computeState; return clusterSpec; }
@Test public void testCreateClusterWithIntercept() throws Throwable { ContainerHostSpec hostSpec = new ContainerHostSpec(); hostSpec.hostState = new ComputeState(); hostSpec.hostState.id = UUID.randomUUID().toString(); hostSpec.hostState.address = "test"; hostSpec.hostState.customProperties = new HashMap<>(); hostSpec.hostState.customProperties.put(ContainerHostService .HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, "API"); hostSpec.hostState.customProperties.put(ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, "DOCKER"); ClusterDto dto = doPostWithProjectHeader(hostSpec, ClusterService.SELF_LINK, project .documentSelfLink, ClusterDto.class); ComputeState computeState = getDocument(ComputeState.class, dto.nodeLinks.get(0)); assertTrue(computeState.tenantLinks.contains(project.documentSelfLink)); }
private void forceTrustAliasUpdate(ComputeState computeState) { ContainerHostSpec spec = new ContainerHostSpec(); spec.hostState = computeState; spec.isUpdateOperation = true; sendRequest(Operation.createPut(getHost(), ContainerHostService.SELF_LINK) .setAuthorizationContext(getSystemAuthorizationContext()) .setBodyNoCloning(spec) .setCompletion((o, e) -> { if (e != null) { logWarning("Forcing trust alias update failed: %s", Utils.toString(e)); return; } logInfo("Forcing trust alias update completed!"); })); }
private void validateCreateClusterPost(Operation post) { if (!post.hasBody()) { throw new LocalizableValidationException( "ContainerHostSpec body is required", "compute.host.spec.is.required"); } ContainerHostSpec hostSpec = post.getBody(ContainerHostSpec.class); List<String> hostTenantLinks = hostSpec.getHostTenantLinks(); if (hostTenantLinks == null || hostTenantLinks.isEmpty() || (hostTenantLinks.stream().noneMatch(PATTERN_PROJECT_TENANT_LINK.asPredicate()) && hostTenantLinks.stream().noneMatch(PATTERN_TENANT_LINK.asPredicate()))) { throw new LocalizableValidationException( "Project context is required", "auth.project.context.required"); } }
static ContainerHostSpec createContainerHostSpec(List<String> tenantLinks, String computeDescriptionId) throws Throwable { ContainerHostSpec ch = new ContainerHostSpec(); ch.hostState = createComputeHost(tenantLinks, computeDescriptionId); return ch; }
private ContainerHostSpec createContainerHostSpec(List<String> tenantLinks, ContainerHostType hostType, String clusterName, String clusterDetails) throws Throwable { ContainerHostSpec ch = new ContainerHostSpec(); ch.hostState = createComputeState(hostType, ComputeService.PowerState.ON, tenantLinks, clusterName, clusterDetails); return ch; }
private ContainerHostSpec createContainerHostSpec(List<String> tenantLinks, ContainerHostType hostType, String address) throws Throwable { ContainerHostSpec ch = new ContainerHostSpec(); ch.hostState = createComputeState(hostType, ComputeService.PowerState.ON, tenantLinks, null, null, address); return ch; }
private ContainerHostSpec createContainerHostSpec(List<String> tenantLinks, ContainerHostType hostType, String clusterName, String clusterDetails) throws Throwable { ContainerHostSpec ch = new ContainerHostSpec(); ch.hostState = createComputeState(hostType, ComputeService.PowerState.ON, tenantLinks, clusterName, clusterDetails); return ch; }