Search in sources :

Example 1 with InstanceGroupResponse

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;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)

Example 2 with 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;
}
Also used : InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse) RepairInstancesRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.repair.RepairInstancesRequest)

Example 3 with InstanceGroupResponse

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());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)

Example 4 with InstanceGroupResponse

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"));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse) InstanceMetaDataResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse) Test(org.junit.jupiter.api.Test)

Example 5 with InstanceGroupResponse

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());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceGroupResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)9 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)7 Test (org.junit.jupiter.api.Test)5 InstanceMetaDataResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse)3 RepairInstancesRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.repair.RepairInstancesRequest)1 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)1