use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method configureCmMgmtServices.
private void configureCmMgmtServices(TemplatePreparationObject templatePreparationObject, String sdxCrn, Telemetry telemetry, String sdxContextName, ProxyConfig proxyConfig) throws ApiException {
Optional<ApiHost> optionalCmHost = getCmHost(templatePreparationObject, apiClient);
if (optionalCmHost.isPresent()) {
ApiHost cmHost = optionalCmHost.get();
ApiHostRef cmHostRef = new ApiHostRef();
cmHostRef.setHostId(cmHost.getHostId());
cmHostRef.setHostname(cmHost.getHostname());
mgmtSetupService.setupMgmtServices(stack, apiClient, cmHostRef, telemetry, sdxContextName, sdxCrn, proxyConfig);
} else {
LOGGER.warn("Unable to determine Cloudera Manager host. Skipping management services installation.");
}
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusService method getCertCheck.
private static Optional<HealthCheck> getCertCheck(ApiHost apiHost) {
Optional<ApiHealthCheck> healthCheck = emptyIfNull(apiHost.getHealthChecks()).stream().filter(health -> HOST_AGENT_CERTIFICATE_EXPIRY.equals(health.getName())).findFirst();
if (healthCheck.isPresent()) {
HealthCheckResult result = ApiHealthSummary.BAD.equals(healthCheck.get().getSummary()) || ApiHealthSummary.CONCERNING.equals(healthCheck.get().getSummary()) ? HealthCheckResult.UNHEALTHY : HealthCheckResult.HEALTHY;
Optional<String> reason = Optional.ofNullable(healthCheck.get().getSummary()).map(apiSum -> "Cert health on CM: " + apiSum.getValue());
return Optional.of(new HealthCheck(HealthCheckType.CERT, result, reason));
}
return Optional.empty();
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerModificationServiceTest method setUpListClusterHosts.
private void setUpListClusterHosts() throws ApiException {
ApiHostList clusterHostsRef = new ApiHostList().items(List.of(new ApiHost().hostname("original")));
when(clustersResourceApi.listHosts(eq(STACK_NAME), eq(null), eq(null), eq(null))).thenReturn(clusterHostsRef);
when(clouderaManagerApiFactory.getClustersResourceApi(eq(apiClientMock))).thenReturn(clustersResourceApi);
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerSecurityServiceTest method createApiHostList.
private ApiHostList createApiHostList() {
ApiHostList apiHostList = new ApiHostList();
ApiClusterRef clusterRef = new ApiClusterRef();
ApiHost apiHost1 = new ApiHost().hostId("host-1").clusterRef(clusterRef);
ApiHost apiHost2 = new ApiHost().hostId("host@company.com 2").clusterRef(clusterRef);
apiHostList.items(List.of(apiHost1, apiHost2));
return apiHostList;
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerDecommisionerTest method testCollectDownscaleCandidatesWhenOneHostDoesNotHaveFQDN.
@Test
public void testCollectDownscaleCandidatesWhenOneHostDoesNotHaveFQDN() throws ApiException {
// GIVEN
VolumeSetAttributes volumeSetAttributes = new VolumeSetAttributes("az", false, "fstab", List.of(), 50, "vt");
Stack stack = createTestStack(volumeSetAttributes);
Cluster cluster = new Cluster();
stack.setCluster(cluster);
Set<HostGroup> hostGroups = createTestHostGroups(1, 6);
cluster.setHostGroups(hostGroups);
HostGroup downscaledHostGroup = hostGroups.iterator().next();
Optional<InstanceMetaData> hgHost2 = downscaledHostGroup.getInstanceGroup().getAllInstanceMetaData().stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN().equals("hg0-host-2")).findFirst();
hgHost2.ifPresent(instanceMetaData -> instanceMetaData.setDiscoveryFQDN(null));
HostsResourceApi hostsResourceApi = mock(HostsResourceApi.class);
when(clouderaManagerApiFactory.getHostsResourceApi(any(ApiClient.class))).thenReturn(hostsResourceApi);
HostTemplatesResourceApi hostTemplatesResourceApi = mock(HostTemplatesResourceApi.class);
when(clouderaManagerApiFactory.getHostTemplatesResourceApi(any(ApiClient.class))).thenReturn(hostTemplatesResourceApi);
ApiHostTemplateList hostTemplates = createEmptyHostTemplates();
when(hostTemplatesResourceApi.readHostTemplates(stack.getName())).thenReturn(hostTemplates);
ApiHostList apiHostRefList = new ApiHostList();
List<ApiHost> apiHosts = new ArrayList<>();
hostGroups.stream().flatMap(hostGroup -> hostGroup.getInstanceGroup().getAllInstanceMetaData().stream()).map(InstanceMetaData::getDiscoveryFQDN).forEach(hostName -> {
ApiHost apiHostRef = new ApiHost();
apiHostRef.setHostname(hostName);
apiHostRef.setHostId(hostName);
apiHostRef.setHealthSummary(ApiHealthSummary.GOOD);
apiHosts.add(apiHostRef);
});
apiHostRefList.setItems(apiHosts);
when(hostsResourceApi.readHosts(any(), any(), any())).thenReturn(apiHostRefList);
Set<InstanceMetaData> downscaleCandidates = underTest.collectDownscaleCandidates(mock(ApiClient.class), stack, downscaledHostGroup, -2, downscaledHostGroup.getInstanceGroup().getAllInstanceMetaData());
assertEquals(2, downscaleCandidates.size());
assertTrue("Assert if downscaleCandidates contains hg0-host-2, because FQDN is missing", downscaleCandidates.stream().anyMatch(instanceMetaData -> "hg0-instanceid-2".equals(instanceMetaData.getInstanceId())));
assertTrue("Assert if downscaleCandidates contains hg0-host-5", downscaleCandidates.stream().anyMatch(instanceMetaData -> "hg0-host-5".equals(instanceMetaData.getDiscoveryFQDN())));
}
Aggregations