/** * Check if this host is a scheduler host (e.g. VIC, Kubernetes) * * @param computeState * @return boolean value */ public static boolean isSchedulerHost(ComputeState computeState) { return ContainerHostUtil.isVicHost(computeState) || ContainerHostUtil.isKubernetesHost(computeState); }
if (ContainerHostUtil.isKubernetesHost(hostComputeState)) { dockerHostPath = KubernetesHostConstants.KUBERNETES_HOST_HEALTH_PATH;
public static void filterKubernetesHostLinks(Service sender, Set<String> hostLinks, BiConsumer<Set<String>, Map<Long, Throwable>> callback) { List<Operation> getHosts = new ArrayList<>(); for (String hostLink : hostLinks) { getHosts.add(Operation.createGet(sender, hostLink)); } OperationJoin.create(getHosts) .setCompletion((ops, errs) -> { Set<String> kubernetesHostLinks = new HashSet<>(); if (errs != null && !errs.isEmpty()) { callback.accept(null, errs); } else { for (Operation op : ops.values()) { if (op == null || op.getStatusCode() != Operation.STATUS_CODE_OK) { continue; } ComputeState state = op.getBody(ComputeState.class); if (isKubernetesHost(state)) { kubernetesHostLinks.add(state.documentSelfLink); } } callback.accept(kubernetesHostLinks, null); } }).sendWith(sender); }
public static ComputeState transformComputeForExpandedCluster(ComputeState state) { // we would like to have access to the whole object in order to update it if (isVicHost(state) || isKubernetesHost(state)) { return state; } ComputeState outState = new ComputeState(); // Cast before passing the compute state in order to use the // copyTo method with ServiceDocument instead of ResourceState. state.copyTo((ServiceDocument) outState); outState.address = state.address; outState.powerState = state.powerState; outState.name = state.name; return outState; }
private void getHostAndCredentials(Operation op, String hostLink, BiConsumer<ComputeState, AuthCredentialsServiceState> consumer) { getCompute(op, hostLink, (host) -> { if (!ContainerHostUtil.isKubernetesHost(host)) { op.fail(new IllegalArgumentException("host type must be KUBERNETES")); return; } String credentialsLink = host.customProperties.get(HOST_AUTH_CREDENTIALS_PROP_NAME); if (credentialsLink == null) { op.fail(new IllegalStateException("Missing credentials link")); return; } Operation.createGet(this, credentialsLink).setCompletion((o, e) -> { if (e != null) { op.fail(e); return; } AuthCredentialsServiceState credentials = o .getBody(AuthCredentialsServiceState.class); consumer.accept(host, credentials); }).sendWith(this); }); }
@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); }
return; if (ContainerHostUtil.isKubernetesHost(host)) { logInfo("Kubernetes host detected, system containers will not be" + " installed.");
private void updateContainerHosts(List<ComputeState> hosts) { for (ComputeState compute : hosts) { if (LifecycleState.SUSPEND == compute.lifecycleState) { logInfo("Skipping data collection for host %s as it is marked for removal.", compute.documentSelfLink); continue; } updateContainerHostInfo(compute, (o, error) -> { if (error != null) { handleHostNotAvailable(compute, error); } else { handleHostAvailable(compute); } }, null); if (PowerState.ON == compute.powerState) { if (ContainerHostUtil.isKubernetesHost(compute)) { updateKubernetesEntities(compute.documentSelfLink); } else { updateContainerHostContainers(compute); updateContainerHostNetworks(compute); updateContainerHostVolumes(compute.documentSelfLink); } } } }
qr.rpLinksByComputeLink.get(computeState.documentSelfLink), body.remove, body.noHostOperation); if (ContainerHostUtil.isKubernetesHost(computeState)) { updateKubernetesEntities(computeState.documentSelfLink); } else {