use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse in project cloudbreak by hortonworks.
the class InstanceMetaDataToInstanceMetaDataResponseConverter method convert.
@Override
public InstanceMetaDataResponse convert(InstanceMetaData source) {
InstanceMetaDataResponse metaDataJson = new InstanceMetaDataResponse();
metaDataJson.setPrivateIp(source.getPrivateIp());
if (source.getPublicIp() != null) {
metaDataJson.setPublicIp(source.getPublicIp());
} else if (source.getPrivateIp() != null) {
metaDataJson.setPublicIp(NOT_AVAILABLE);
}
metaDataJson.setSshPort(source.getSshPort());
metaDataJson.setInstanceId(source.getInstanceId());
metaDataJson.setDiscoveryFQDN(source.getDiscoveryFQDN());
metaDataJson.setInstanceGroup(source.getInstanceGroup().getGroupName());
metaDataJson.setInstanceStatus(source.getInstanceStatus());
metaDataJson.setInstanceType(source.getInstanceMetadataType());
metaDataJson.setLifeCycle(source.getLifeCycle());
metaDataJson.setAvailabilityZone(source.getAvailabilityZone());
metaDataJson.setSubnetId(source.getSubnetId());
return metaDataJson;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse 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.InstanceMetaDataResponse in project cloudbreak by hortonworks.
the class SshJClientActions method getFreeIpaInstanceGroupIps.
private List<String> getFreeIpaInstanceGroupIps(String environmentCrn, FreeIpaClient freeipaClient, boolean publicIp) {
List<String> instanceIPs = new ArrayList<>();
freeipaClient.getDefaultClient().getFreeIpaV1Endpoint().describe(environmentCrn).getInstanceGroups().forEach(ig -> {
InstanceMetaDataResponse instanceMetaDataResponse = ig.getMetaData().stream().findFirst().orElse(null);
assert instanceMetaDataResponse != null;
LOGGER.info("The selected Instance Group [{}] and the available Private IP [{}] and Public IP [{}]]. {} ip will be used.", instanceMetaDataResponse.getInstanceGroup(), instanceMetaDataResponse.getPrivateIp(), instanceMetaDataResponse.getPublicIp(), publicIp ? "Public" : "Private");
instanceIPs.add(publicIp ? instanceMetaDataResponse.getPublicIp() : instanceMetaDataResponse.getPrivateIp());
});
return instanceIPs;
}
use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse 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.InstanceMetaDataResponse 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"));
}
Aggregations