ContainerHostType.KUBERNETES.name()); kubernetesHost.customProperties.put(HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); kubernetesHost.customProperties.put(CLUSTER_NAME_CUSTOM_PROP, clusterRequest.cluster.name);
private void validate(ContainerHostSpec hostSpec) { final ComputeState cs = hostSpec.hostState; AssertUtil.assertNotNull(cs, "computeState"); AssertUtil.assertNotEmpty(cs.address, "address"); AssertUtil.assertNotEmpty(cs.customProperties, "customProperties"); String adapterDockerType = cs.customProperties.get(HOST_DOCKER_ADAPTER_TYPE_PROP_NAME); AssertUtil.assertNotEmpty(adapterDockerType, HOST_DOCKER_ADAPTER_TYPE_PROP_NAME); DockerAdapterType adapterType = DockerAdapterType.valueOf(adapterDockerType); AssertUtil.assertNotNull(adapterType, "adapterType"); cs.address = cs.address.trim(); String kubernetesNamespace = cs.customProperties.get( KubernetesHostConstants.KUBERNETES_HOST_NAMESPACE_PROP_NAME); if (kubernetesNamespace == null || kubernetesNamespace.isEmpty()) { cs.customProperties.put( KubernetesHostConstants.KUBERNETES_HOST_NAMESPACE_PROP_NAME, KubernetesHostConstants.KUBERNETES_HOST_DEFAULT_NAMESPACE); } else { kubernetesNamespace = kubernetesNamespace.trim(); AssertUtil.assertTrue(!kubernetesNamespace.contains("/") && !kubernetesNamespace.contains("\\"), "Namespace cannot contain" + " slashes."); AssertUtil.assertTrue(kubernetesNamespace.matches( KubernetesHostConstants.KUBERNETES_NAMESPACE_REGEX), "Invalid namespace."); cs.customProperties.put( KubernetesHostConstants.KUBERNETES_HOST_NAMESPACE_PROP_NAME, kubernetesNamespace); } }
hs.hostState.customProperties = map; map.put(ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name());
DockerAdapterType.API.name()); computeState.customProperties.put(PKS_ENDPOINT_PROP_NAME, task.endpointLink); computeState.customProperties.put(PKS_CLUSTER_UUID_PROP_NAME, pksCluster.uuid);
protected void createParentComputeState() throws Throwable { waitForServiceAvailability(ComputeService.FACTORY_LINK); ComputeDescription computeDescription = new ComputeDescription(); computeDescription.customProperties = new HashMap<>(); computeDescription.id = UUID.randomUUID().toString(); String computeDescriptionLink = doPost(computeDescription, ComputeDescriptionService.FACTORY_LINK).documentSelfLink; ComputeState computeState = new ComputeState(); computeState.id = "testParentComputeState"; computeState.descriptionLink = computeDescriptionLink; computeState.customProperties = new HashMap<>(); computeState.customProperties.put( ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testDockerCredentialsLink); computeState.address = dockerUri.getHost(); computeState.customProperties.put( ContainerHostService.DOCKER_HOST_SCHEME_PROP_NAME, String.valueOf(dockerUri.getScheme())); computeState.customProperties.put( ContainerHostService.DOCKER_HOST_PORT_PROP_NAME, String.valueOf(dockerUri.getPort())); computeState.customProperties.put( ContainerHostService.DOCKER_HOST_PATH_PROP_NAME, String.valueOf(dockerUri.getPath())); computeState.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); computeState = doPost(computeState, ComputeService.FACTORY_LINK); this.parentComputeStateLink = computeState.documentSelfLink; }
protected ComputeState createKubernetesHostComputeState(String testKubernetesCredentialsLink) throws Throwable { ComputeDescription computeDescription = new ComputeDescription(); computeDescription.customProperties = new HashMap<>(); computeDescription.id = UUID.randomUUID().toString(); waitForServiceAvailability(ComputeDescriptionService.FACTORY_LINK); String computeDescriptionLink = doPost(computeDescription, ComputeDescriptionService.FACTORY_LINK).documentSelfLink; ComputeState computeState = new ComputeState(); computeState.id = "testParentComputeState"; computeState.descriptionLink = computeDescriptionLink; computeState.customProperties = new HashMap<>(); computeState.customProperties.put( ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testKubernetesCredentialsLink); computeState.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); computeState.customProperties.put( ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, ContainerHostType.KUBERNETES.name()); computeState.customProperties.put( KubernetesHostConstants.KUBERNETES_HOST_NAMESPACE_PROP_NAME, KubernetesHostConstants.KUBERNETES_HOST_DEFAULT_NAMESPACE); computeState.address = kubernetesUri.toString(); waitForServiceAvailability(ComputeService.FACTORY_LINK); ComputeState kubernetesHostState = doPost(computeState, ComputeService.FACTORY_LINK); return kubernetesHostState; }
protected void createParentComputeState() throws Throwable { waitForServiceAvailability(ComputeService.FACTORY_LINK); ComputeDescription computeDescription = new ComputeDescription(); computeDescription.customProperties = new HashMap<String, String>(); computeDescription.id = UUID.randomUUID().toString(); String computeDescriptionLink = doPost(computeDescription, ComputeDescriptionService.FACTORY_LINK).documentSelfLink; ComputeState computeState = new ComputeState(); computeState.id = "testParentComputeState"; computeState.descriptionLink = computeDescriptionLink; computeState.customProperties = new HashMap<String, String>(); computeState.customProperties.put(ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testDockerCredentialsLink); computeState.address = dockerUri.getHost(); computeState.customProperties.put(ContainerHostService.DOCKER_HOST_SCHEME_PROP_NAME, String.valueOf(dockerUri.getScheme())); computeState.customProperties.put(ContainerHostService.DOCKER_HOST_PORT_PROP_NAME, String.valueOf(dockerUri.getPort())); computeState.customProperties.put(ContainerHostService.DOCKER_HOST_PATH_PROP_NAME, String.valueOf(dockerUri.getPath())); computeState.customProperties.put(ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); computeState = doPost(computeState, ComputeService.FACTORY_LINK); this.parentComputeStateLink = computeState.documentSelfLink; }
protected void createParentComputeState() throws Throwable { waitForServiceAvailability(ComputeService.FACTORY_LINK); ComputeDescription computeDescription = new ComputeDescription(); computeDescription.customProperties = new HashMap<String, String>(); computeDescription.id = UUID.randomUUID().toString(); String computeDescriptionLink = doPost(computeDescription, ComputeDescriptionService.FACTORY_LINK).documentSelfLink; ComputeState computeState = new ComputeState(); computeState.id = "testParentComputeState"; computeState.descriptionLink = computeDescriptionLink; computeState.customProperties = new HashMap<String, String>(); computeState.customProperties.put(ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testDockerCredentialsLink); computeState.address = dockerUri.getHost(); computeState.customProperties.put(ContainerHostService.DOCKER_HOST_SCHEME_PROP_NAME, String.valueOf(dockerUri.getScheme())); computeState.customProperties.put(ContainerHostService.DOCKER_HOST_PORT_PROP_NAME, String.valueOf(dockerUri.getPort())); computeState.customProperties.put(ContainerHostService.DOCKER_HOST_PATH_PROP_NAME, String.valueOf(dockerUri.getPath())); computeState.customProperties.put(ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); computeState = doPost(computeState, ComputeService.FACTORY_LINK); this.parentComputeStateLink = computeState.documentSelfLink; }
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; }
protected void createVicHostComputeState() throws Throwable { waitForServiceAvailability(ComputeService.FACTORY_LINK); ComputeDescription computeDescription = new ComputeDescription(); computeDescription.customProperties = new HashMap<>(); computeDescription.id = UUID.randomUUID().toString(); String computeDescriptionLink = doPost(computeDescription, ComputeDescriptionService.FACTORY_LINK).documentSelfLink; ComputeState computeState = new ComputeState(); computeState.id = "testVCHComputeState"; computeState.descriptionLink = computeDescriptionLink; computeState.customProperties = new HashMap<>(); computeState.customProperties.put( ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testDockerCredentialsLink); computeState.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); computeState.customProperties.put( MockDockerHostAdapterService.DOCKER_INFO_STORAGE_DRIVER_PROP_NAME, "vSphere Integrated Containers"); computeState.address = dockerUri.toString(); dockerHostState = doPost(computeState, ComputeService.FACTORY_LINK); }
protected void createDockerHostComputeState() throws Throwable { waitForServiceAvailability(ComputeService.FACTORY_LINK); ComputeDescription computeDescription = new ComputeDescription(); computeDescription.customProperties = new HashMap<>(); computeDescription.id = UUID.randomUUID().toString(); String computeDescriptionLink = doPost(computeDescription, ComputeDescriptionService.FACTORY_LINK).documentSelfLink; ComputeState computeState = new ComputeState(); computeState.id = "testParentComputeState"; computeState.descriptionLink = computeDescriptionLink; computeState.customProperties = new HashMap<>(); computeState.customProperties.put( ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testDockerCredentialsLink); computeState.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); computeState.address = dockerUri.toString(); dockerHostState = doPost(computeState, ComputeService.FACTORY_LINK); }
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; }
private ContainerHostRequest prepareDirectHostOperationRequest( ContainerHostOperationType opType) { ContainerHostRequest request = new ContainerHostRequest(); request.resourceReference = UriUtils.buildUri(host, ComputeService.FACTORY_LINK); request.operationTypeId = opType.id; request.serviceTaskCallback = ServiceTaskCallback.create(provisioningTaskLink); request.customProperties = new HashMap<>(); request.customProperties.put(ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testDockerCredentialsLink); request.customProperties.put(ContainerHostService.DOCKER_HOST_ADDRESS_PROP_NAME, dockerUri.toString()); request.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); return request; }
private void addRequestProperties(AdapterRequest request) { if (request.customProperties == null) { request.customProperties = new HashMap<>(); } request.customProperties.put(ComputeConstants.HOST_AUTH_CREDENTIALS_PROP_NAME, testKubernetesCredentialsLink); request.customProperties.put(ComputeConstants.HOST_URI_PROP_NAME, kubernetesUri.toString()); request.customProperties.put( ContainerHostService.HOST_DOCKER_ADAPTER_TYPE_PROP_NAME, ContainerHostService.DockerAdapterType.API.name()); request.customProperties.put( ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, ContainerHostType.KUBERNETES.name()); }