/** * 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); }
private void updateHostStateCustomProperties(ComputeState computeState, Map<String, Object> properties) { if (computeState != null && properties != null && !properties.isEmpty()) { computeState.customProperties = new HashMap<>(); properties.entrySet().stream() .forEach(entry -> { if (!entry.getKey().startsWith(HIDDEN_CUSTOM_PROPERTY_PREFIX)) { computeState.customProperties.put( HIDDEN_CUSTOM_PROPERTY_PREFIX + entry.getKey(), Utils.toJson(entry.getValue())); } else { computeState.customProperties.put(entry.getKey(), Utils.toJson(entry.getValue())); } }); computeState.customProperties.remove( ContainerHostService.NUMBER_OF_CONTAINERS_PER_HOST_PROP_NAME); if (ContainerHostUtil.isVicHost(computeState)) { parseVicStats(computeState, properties); } } }
private static boolean isAgentSupported(ComputeState host) { return !DeploymentProfileConfig.getInstance().isTest() && !ContainerHostUtil.isVicHost(host); }
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; }
@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); }
if (ContainerHostUtil.isVicHost(context.computeState)) {
private void processDiscoveredNetworks(NetworkListCallback callback) { // finished removing existing ContainerNetworkState, now deal with remaining IDs List<ContainerNetworkState> networksLeft = new ArrayList<>(); Operation operation = Operation .createGet(this, callback.containerHostLink) .setCompletion( (o, ex) -> { if (ex != null) { logSevere("Failure to retrieve host [%s]. Error: %s", callback.containerHostLink, Utils.toString(ex)); unlockCurrentDataCollectionForHost(callback.containerHostLink); return; } ComputeState host = o.getBody(ComputeState.class); List<String> group = host.tenantLinks; for (Entry<String, String> entry : callback.networkIdsAndNames .entrySet()) { ContainerNetworkState networkState = buildDiscoveredNetworkState( callback, group, ContainerHostUtil.isVicHost(host), entry); networksLeft.add(networkState); } createDiscoveredContainerNetworks( networksLeft, (e) -> { unlockCurrentDataCollectionForHost( callback.containerHostLink); }); }); sendRequest(operation); }
protected void uploadCertificate(String hostLink, String registryAddress, String certificate, List<String> tenantLinks) { OperationUtil.getDocumentState(this, hostLink, ComputeState.class, (ComputeState host) -> { if (ContainerHostUtil.isVicHost(host)) { logInfo("Skip installing certificate for VIC host [%s]", hostLink); return; } ShellContainerExecutorState execState = new ShellContainerExecutorState(); execState.command = new String[] { "sh", "/copy-certificate.sh", getCertificateDirName(registryAddress), certificate }; try { processUploadCertificateQuery(execState, hostLink, MAX_RETRIES, registryAddress, tenantLinks); } catch (Throwable t) { logSevere("Fail to upload registry certificate to host %s: " + "failed to connect to shell container executor service.", hostLink); } }); }
if (ContainerHostUtil.isVicHost(host)) { logInfo("VIC host detected, system containers will not be installed."); return;
private void validateVicHost(ContainerHostSpec hostSpec, Operation op) { String computeAddress = hostSpec.hostState.address; EndpointCertificateUtil.validateSslTrust(this, hostSpec, op, () -> { fetchSslTrustAliasProperty(hostSpec, () -> { getHostInfo(hostSpec, op, hostSpec.sslTrust, (computeState) -> { if (ContainerHostUtil.isVicHost(computeState)) { logInfo("VIC host verification passed for %s", computeAddress); completeOperationSuccess(op); } else { logInfo("VIC host verification failed for %s", computeAddress); op.fail(new LocalizableValidationException( CONTAINER_HOST_IS_NOT_VCH_MESSAGE, CONTAINER_HOST_IS_NOT_VCH_MESSAGE_CODE)); } }); }); }); }
if (ContainerHostUtil.isVicHost(computeState)) { String version = ContainerHostUtil.getHostServerVersion(computeState); ContainerHostUtil.verifyVchVersionIsSupported(getHost(), version)
if (ContainerHostUtil.isVicHost(context.computeState) && !allowVchStatsCollection) { context.operation.fail(new LocalizableValidationException( "Container stats are not supported by VCH hosts.",