use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse in project cloudbreak by hortonworks.
the class InstanceGroupToInstanceGroupResponseConverter method convert.
public InstanceGroupResponse convert(InstanceGroup source, Boolean includeAllInstances) {
InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
instanceGroupResponse.setName(source.getGroupName());
if (source.getTemplate() != null) {
instanceGroupResponse.setInstanceTemplate(templateResponseConverter.convert(source.getTemplate()));
}
Set<InstanceMetaData> metaDataSet = includeAllInstances ? source.getInstanceMetaDataSet() : source.getNotTerminatedInstanceMetaDataSet();
instanceGroupResponse.setMetaData(metaDataConverter.convert(metaDataSet));
if (source.getSecurityGroup() != null) {
instanceGroupResponse.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup()));
}
if (source.getInstanceGroupNetwork() != null) {
instanceGroupResponse.setNetwork(instanceGroupNetworkConverter.convert(source.getInstanceGroupNetwork()));
}
instanceGroupResponse.setNodeCount(source.getNodeCount());
instanceGroupResponse.setName(source.getGroupName());
return instanceGroupResponse;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse in project cloudbreak by hortonworks.
the class FreeIpaRepairAction method action.
public FreeIpaTestDto action(TestContext testContext, FreeIpaTestDto testDto, FreeIpaClient client) throws Exception {
Log.when(LOGGER, format(" FreeIPA CRN: %s", testDto.getRequest().getEnvironmentCrn()));
RepairInstancesRequest request = new RepairInstancesRequest();
request.setForceRepair(true);
request.setEnvironmentCrn(testDto.getRequest().getEnvironmentCrn());
List<String> instanceIds = testDto.getResponse().getInstanceGroups().stream().map(InstanceGroupResponse::getMetaData).flatMap(Collection::stream).filter(im -> instanceMetadataType.equals(im.getInstanceType())).map(InstanceMetaDataResponse::getInstanceId).collect(Collectors.toList());
request.setInstanceIds(instanceIds);
Log.whenJson(LOGGER, format(" FreeIPA repair request: %n"), request);
client.getDefaultClient().getFreeIpaV1Endpoint().repairInstances(request);
return testDto;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse in project cloudbreak by hortonworks.
the class FreeIpaInstanceUtil method getInstanceIds.
public List<String> getInstanceIds(FreeIpaTestDto freeIpaTestDto, FreeIpaClient freeIpaClient, String hostGroupName) {
DescribeFreeIpaResponse describeFreeIpaResponse = freeIpaClient.getDefaultClient().getFreeIpaV1Endpoint().describe(freeIpaTestDto.getRequest().getEnvironmentCrn());
List<InstanceGroupResponse> instanceGroupResponses = describeFreeIpaResponse.getInstanceGroups();
InstanceGroupResponse instanceGroupResponse = instanceGroupResponses.stream().filter(instanceGroup -> instanceGroup.getName().equals(hostGroupName)).findFirst().orElse(null);
return Objects.requireNonNull(instanceGroupResponse).getMetaData().stream().map(InstanceMetaDataResponse::getInstanceId).collect(Collectors.toList());
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse in project cloudbreak by hortonworks.
the class FreeIpaConfigProviderTest method testPgwNotChosenIfNotCreated.
@Test
public void testPgwNotChosenIfNotCreated() {
DescribeFreeIpaResponse freeIpaResponse = new DescribeFreeIpaResponse();
InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
InstanceMetaDataResponse pgw = createInstanceMetadata("d", TERMINATED);
pgw.setInstanceType(InstanceMetadataType.GATEWAY_PRIMARY);
instanceGroupResponse.setMetaData(Set.of(createInstanceMetadata("b", TERMINATED), createInstanceMetadata("a", REQUESTED), createInstanceMetadata("f", CREATED), pgw, createInstanceMetadata("c", CREATED)));
freeIpaResponse.setInstanceGroups(List.of(instanceGroupResponse));
when(freeipaClient.findByEnvironmentCrn(ENVIRONMENT_CRN)).thenReturn(Optional.of(freeIpaResponse));
Map<String, Object> result = underTest.createFreeIpaConfig(ENVIRONMENT_CRN);
assertEquals(1, result.size());
assertEquals("c", result.get("host"));
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse in project cloudbreak by hortonworks.
the class FreeIpaConfigProviderTest method testNoChoosenIfInsanceMetadataEmpty.
@Test
public void testNoChoosenIfInsanceMetadataEmpty() {
DescribeFreeIpaResponse freeIpaResponse = new DescribeFreeIpaResponse();
InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
instanceGroupResponse.setMetaData(Set.of());
freeIpaResponse.setInstanceGroups(List.of(instanceGroupResponse));
when(freeipaClient.findByEnvironmentCrn(ENVIRONMENT_CRN)).thenReturn(Optional.of(freeIpaResponse));
Map<String, Object> result = underTest.createFreeIpaConfig(ENVIRONMENT_CRN);
assertTrue(result.isEmpty());
}
Aggregations