public KubernetesContext() { this.credentials = null; this.host = new ComputeState(); this.customProperties = new HashMap<>(); } }
private ComputeState createComputeState(String certLink) throws Throwable { ComputeState computeState = new ComputeState(); computeState.name = UUID.randomUUID().toString(); computeState.address = UUID.randomUUID().toString(); computeState.descriptionLink = UUID.randomUUID().toString(); if (certLink != null && !certLink.isEmpty()) { computeState.customProperties = Collections.singletonMap( CertificateUtilExtended.CUSTOM_PROPERTY_TRUST_CERT_LINK, certLink); } return createEntity(computeState, ComputeService.FACTORY_LINK); }
private ComputeState createCompute() throws Throwable { ComputeState compute = new ComputeState(); compute.name = UUID.randomUUID().toString(); compute.descriptionLink = "/link/desc"; return doPost(compute, ComputeService.FACTORY_LINK); }
private String createDockerHostWithVolumeDrivers(String... drivers) throws Throwable { String hostLink = createDockerHost(createDockerHostDescription(), createResourcePool(), true).documentSelfLink; ComputeState csPatch = new ComputeState(); csPatch.documentSelfLink = hostLink; csPatch.customProperties = new HashMap<>(); csPatch.customProperties.put(ContainerHostService.DOCKER_HOST_PLUGINS_PROP_NAME, createSupportedPluginsInfoString(new HashSet<>(Arrays.asList(drivers)))); doPatch(csPatch, hostLink); initialHostLinks.add(hostLink); return hostLink; } }
private static KubernetesContext createKubernetesContext(String hostAddress, String namespace) { KubernetesContext context = new KubernetesContext(); context.host = new ComputeState(); context.host.address = hostAddress; context.host.customProperties = new HashMap<>(); if (namespace != null) { context.host.customProperties.put( KubernetesHostConstants.KUBERNETES_HOST_NAMESPACE_PROP_NAME, namespace); } return context; }
@Test public void testIsPKSManagedHost() { assertFalse(KubernetesUtil.isPKSManagedHost(null)); assertFalse(KubernetesUtil.isPKSManagedHost(new ComputeState())); ComputeState noProperties = new ComputeState(); noProperties.customProperties = new HashMap<>(); assertFalse(KubernetesUtil.isPKSManagedHost(noProperties)); ComputeState pksManagedHost = new ComputeState(); pksManagedHost.customProperties = new HashMap<>(); pksManagedHost.customProperties.put(PKS_ENDPOINT_PROP_NAME, "/resources/pks/endpoints/8d50dc9a46ed487556f736eb0c8f8"); assertTrue(KubernetesUtil.isPKSManagedHost(pksManagedHost)); }
private ComputeState createComputeState(String endpointLink, String pksClusterUUID) { ComputeState pksHost = new ComputeState(); pksHost.address = "hostname"; pksHost.descriptionLink = "description"; pksHost.customProperties = new HashMap<>(); pksHost.customProperties.put(PKS_ENDPOINT_PROP_NAME, endpointLink); pksHost.customProperties.put(PKS_CLUSTER_UUID_PROP_NAME, pksClusterUUID); Operation createHostOp = Operation.createPost(host, ComputeService.FACTORY_LINK) .setBody(pksHost); pksHost = sender.sendAndWait(createHostOp, ComputeState.class); return pksHost; } }
private ComputeState createComputeState(String hostId, List<String> tenantLinks) { ComputeState cs = new ComputeState(); cs.id = hostId; cs.descriptionLink = "test"; cs.documentSelfLink = cs.id; cs.address = "test-address"; cs.tenantLinks = tenantLinks; return cs; } }
private String createDockerHostWithKVStore(String kvStore) throws Throwable { String hostLink = createDockerHost(createDockerHostDescription(), createResourcePool(), true).documentSelfLink; ComputeState csPatch = new ComputeState(); csPatch.documentSelfLink = hostLink; csPatch.customProperties = new HashMap<>(); csPatch.customProperties.put(ContainerHostService.DOCKER_HOST_CLUSTER_STORE_PROP_NAME, kvStore); doPatch(csPatch, hostLink); return hostLink; }
@Test public void testGetTrustAlias() { final String alias = "alias"; ComputeService.ComputeState state = new ComputeService.ComputeState(); state.customProperties = new HashMap<>(); state.customProperties.put(ContainerHostService.SSL_TRUST_ALIAS_PROP_NAME, alias); String result = ContainerHostUtil.getTrustAlias(state); assertEquals(alias, result); // negative test state.customProperties = null; result = ContainerHostUtil.getTrustAlias(state); assertNull(result); }
@Test public void testIsKubernetesHost() { ComputeService.ComputeState state = new ComputeService.ComputeState(); state.customProperties = new HashMap<>(); state.customProperties.put(ContainerHostService.CONTAINER_HOST_TYPE_PROP_NAME, ContainerHostType.KUBERNETES.name()); boolean result = ContainerHostUtil.isKubernetesHost(state); assertTrue(result); // negative test state.customProperties = null; result = ContainerHostUtil.isKubernetesHost(state); assertFalse(result); }
@Test public void testIsVic() { final String driver = ContainerHostUtil.VMWARE_VIC_DRIVER2; ComputeService.ComputeState state = new ComputeService.ComputeState(); state.customProperties = new HashMap<>(); state.customProperties.put(ContainerHostUtil.PROPERTY_NAME_DRIVER, driver); boolean result = ContainerHostUtil.isVicHost(state); assertTrue(result); // nagative test state.customProperties = null; result = ContainerHostUtil.isVicHost(state); assertFalse(result); }
private ComputeState createComputeState(String desc, String address, String rpLink, String... tags) throws Throwable { ComputeState cs = new ComputeState(); cs.address = address; cs.descriptionLink = desc; cs.resourcePoolLink = rpLink; cs.type = ComputeType.VM_GUEST; cs.tagLinks = tagSet(tags); return doPost(cs, ComputeService.FACTORY_LINK); }
private ComputeState createComputeState(ResourcePoolState placementZone) throws Throwable { ComputeState computeState = new ComputeState(); computeState.address = "no-address"; computeState.descriptionLink = "no-description-link"; if (placementZone != null) { computeState.resourcePoolLink = placementZone.documentSelfLink; } else { computeState.resourcePoolLink = defaultPlacementZone.documentSelfLink; } return doPost(computeState, ComputeService.FACTORY_LINK); }
private ComputeState createComputeState(String hostId, String pool) { ComputeState cs = new ComputeState(); cs.id = hostId; cs.descriptionLink = "test"; cs.documentSelfLink = cs.id; cs.address = "test-address"; cs.resourcePoolLink = pool; return cs; }
private ComputeState createComputeState(String descriptionLink, String rpLink) throws Throwable { ComputeState cs = new ComputeState(); cs.descriptionLink = descriptionLink; cs.resourcePoolLink = rpLink; return doPost(cs, ComputeService.FACTORY_LINK); }
private ComputeState createCompute(ComputeType type, String endpointLink, String rpLink, List<String> tagLinks, List<String> tenantLinks) throws Throwable { ComputeState state = new ComputeState(); state.name = UUID.randomUUID().toString(); state.descriptionLink = "desc-link"; state.type = type; state.endpointLink = endpointLink; state.resourcePoolLink = rpLink; state.tagLinks = tagLinks != null ? new HashSet<>(tagLinks) : null; state.tenantLinks = correctTenantPrefixes(tenantLinks); return doPost(state, ComputeService.FACTORY_LINK); }
private ComputeState createComputeState(String hostId, List<String> tenantLinks) { ComputeState cs = new ComputeState(); cs.id = hostId; cs.descriptionLink = "test"; cs.documentSelfLink = cs.id; cs.address = "test-address"; cs.tenantLinks = tenantLinks; return cs; } }
@Test public void testConstructDashboardLink() { ComputeState host = new ComputeState(); host.address = "https://localhost:6443"; assertEquals("Unexpected dashboard link", "https://localhost:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy", KubernetesUtil.constructDashboardLink(host, null)); }
private ComputeState createComputeState(String hostId, List<String> tenantLinks) { ComputeState cs = new ComputeState(); cs.id = hostId; cs.descriptionLink = "test"; cs.documentSelfLink = cs.id; cs.address = "test-address"; cs.tenantLinks = tenantLinks; return cs; } }