use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ResourceStatusConverterTest method testConvertToEntityAttributeWhenDefaultIsReturnAsDefault.
@Test
public void testConvertToEntityAttributeWhenDefaultIsReturnAsDefault() {
ResourceStatus resourceStatus = resourceStatusConverter.convertToEntityAttribute("DEFAULT");
Assert.assertEquals(ResourceStatus.DEFAULT, resourceStatus);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class SdxServiceTest method testCreateSdxClusterWithCustomRequestContainsImageInfo.
@Test
void testCreateSdxClusterWithCustomRequestContainsImageInfo() throws Exception {
ImageV4Response imageResponse = getImageResponse();
when(transactionService.required(isA(Supplier.class))).thenAnswer(invocation -> invocation.getArgument(0, Supplier.class).get());
String lightDutyJson = FileReaderUtils.readFileFromClasspath("/duties/7.2.7/aws/light_duty.json");
when(cdpConfigService.getConfigForKey(any())).thenReturn(JsonUtil.readValue(lightDutyJson, StackV4Request.class));
SdxCustomClusterRequest sdxClusterRequest = createSdxCustomClusterRequest(LIGHT_DUTY, "cdp-default", "imageId_1");
setSpot(sdxClusterRequest);
withCloudStorage(sdxClusterRequest);
when(imageCatalogService.getImageResponseFromImageRequest(eq(sdxClusterRequest.getImageSettingsV4Request()), any())).thenReturn(imageResponse);
long id = 10L;
when(sdxClusterRepository.save(any(SdxCluster.class))).thenAnswer(invocation -> {
SdxCluster sdxWithId = invocation.getArgument(0, SdxCluster.class);
sdxWithId.setId(id);
return sdxWithId;
});
mockEnvironmentCall(sdxClusterRequest, CloudPlatform.AWS, null);
Pair<SdxCluster, FlowIdentifier> result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.createSdx(USER_CRN, CLUSTER_NAME, sdxClusterRequest));
SdxCluster createdSdxCluster = result.getLeft();
StackV4Request stackV4Request = JsonUtil.readValue(createdSdxCluster.getStackRequest(), StackV4Request.class);
assertNotNull(stackV4Request.getImage());
assertEquals("cdp-default", stackV4Request.getImage().getCatalog());
assertEquals("imageId_1", stackV4Request.getImage().getId());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class SdxRecommendationServiceTest method validateVmTypeOverrideWhenInstanceGroupIsMissingFromDefaultTemplate.
@Test
public void validateVmTypeOverrideWhenInstanceGroupIsMissingFromDefaultTemplate() {
when(cdpConfigService.getConfigForKey(any())).thenReturn(createStackRequest());
when(environmentClientService.getVmTypesByCredential(anyString(), anyString(), anyString(), eq(CdpResourceType.DATALAKE), any())).thenReturn(createPlatformVmtypesResponse());
StackV4Request stackRequest = createStackRequest();
stackRequest.getInstanceGroups().get(0).setName("unknown");
SdxCluster sdxCluster = createSdxCluster(stackRequest, LIGHT_DUTY);
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.validateVmTypeOverride(createEnvironment("AWS"), sdxCluster));
assertEquals("Instance group is missing from default template: unknown", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class DefaultBlueprintCache method loadBlueprintsFromFile.
@PostConstruct
public void loadBlueprintsFromFile() {
Map<String, Set<String>> blueprints = blueprints();
for (Map.Entry<String, Set<String>> blueprintEntry : blueprints.entrySet()) {
try {
for (String blueprintText : blueprintEntry.getValue()) {
String[] split = blueprintText.trim().split("=");
if (blueprintUtils.isBlueprintNamePreConfigured(blueprintText, split)) {
LOGGER.debug("Load default validation '{}'.", AnonymizerUtil.anonymize(blueprintText));
BlueprintV4Request blueprintJson = new BlueprintV4Request();
blueprintJson.setName(split[0].trim());
JsonNode jsonNode = blueprintUtils.convertStringToJsonNode(blueprintUtils.readDefaultBlueprintFromFile(blueprintEntry.getKey(), split));
JsonNode blueprintNode = jsonNode.get("blueprint");
blueprintJson.setBlueprint(blueprintNode.toString());
Blueprint bp = converter.convert(blueprintJson);
JsonNode tags = jsonNode.get("tags");
Map<String, Object> tagParameters = blueprintUtils.prepareTags(tags);
bp.setTags(new Json(tagParameters));
JsonNode description = jsonNode.get("description");
bp.setDescription(description == null ? split[0] : description.asText(split[0]));
JsonNode blueprintUpgradeOption = blueprintNode.isMissingNode() ? null : blueprintNode.get("blueprintUpgradeOption");
bp.setBlueprintUpgradeOption(getBlueprintUpgradeOption(blueprintUpgradeOption));
BlueprintFile bpf = new BlueprintFile.Builder().name(bp.getName()).blueprintText(bp.getBlueprintText()).stackName(bp.getStackName()).stackVersion(bp.getStackVersion()).stackType(bp.getStackType()).blueprintUpgradeOption(bp.getBlueprintUpgradeOption()).hostGroupCount(bp.getHostGroupCount()).description(bp.getDescription()).build();
defaultBlueprints.put(bp.getName(), bpf);
}
}
} catch (IOException e) {
LOGGER.error("Can not read default validation from file: ", e);
}
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class DefaultClusterTemplateCache method convertToClusterTemplate.
private void convertToClusterTemplate(String templateAsString) throws IOException {
DefaultClusterTemplateV4Request clusterTemplateRequest = new Json(templateAsString).get(DefaultClusterTemplateV4Request.class);
if (defaultClusterTemplates.get(clusterTemplateRequest.getName()) != null) {
LOGGER.warn("Default cluster template exists and it will be override: {}", clusterTemplateRequest.getName());
}
defaultClusterTemplates.put(clusterTemplateRequest.getName(), Base64.getEncoder().encodeToString(templateAsString.getBytes()));
}
Aggregations