use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method createTagsV4Request.
private TagsV4Request createTagsV4Request() {
TagsV4Request r = new TagsV4Request();
r.setUserDefined(Map.of("apple", "tree"));
r.setDefaults(Map.of("default", "fruit"));
r.setApplication(Map.of("peach", "tree"));
return r;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class SdxRecommendationServiceTest method validateVmTypeOverrideWhenDefaultVmTypeIsMissingFromAvailableVmTypes.
@Test
public void validateVmTypeOverrideWhenDefaultVmTypeIsMissingFromAvailableVmTypes() {
StackV4Request defaultTemplate = createStackRequest();
defaultTemplate.getInstanceGroups().get(0).getTemplate().setInstanceType("unknown");
when(cdpConfigService.getConfigForKey(any())).thenReturn(defaultTemplate);
when(environmentClientService.getVmTypesByCredential(anyString(), anyString(), anyString(), eq(CdpResourceType.DATALAKE), any())).thenReturn(createPlatformVmtypesResponse());
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.validateVmTypeOverride(createEnvironment("AWS"), createSdxCluster(createStackRequest(), LIGHT_DUTY)));
assertEquals("Missing vm type for default template instance group: master - unknown", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class SdxService method overrideDefaultTemplateValues.
private void overrideDefaultTemplateValues(StackV4Request defaultTemplate, List<SdxInstanceGroupRequest> customInstanceGroups, String accountId) {
if (isCustomInstanceTypeSelected(customInstanceGroups) && !entitlementService.isDatalakeSelectInstanceTypeEnabled(accountId)) {
throw new BadRequestException("Datalake instance type selection is not enabled! " + "Contact Cloudera support to enable CDP_DATALAKE_SELECT_INSTANCE_TYPE entitlement for the account.");
}
if (CollectionUtils.isNotEmpty(customInstanceGroups)) {
LOGGER.debug("Override default template with custom instance groups from request.");
customInstanceGroups.forEach(customInstanceGroup -> {
InstanceGroupV4Request templateInstanceGroup = defaultTemplate.getInstanceGroups().stream().filter(templateGroup -> templateGroup.getName() != null && templateGroup.getName().equals(customInstanceGroup.getName())).findAny().orElseThrow(() -> new BadRequestException("Custom instance group is missing from default template: " + customInstanceGroup.getName()));
overrideInstanceType(templateInstanceGroup, customInstanceGroup.getInstanceType());
});
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ImageCatalogService method getImageResponseFromImageRequest.
public ImageV4Response getImageResponseFromImageRequest(ImageSettingsV4Request imageSettingsV4Request, CloudPlatform cloudPlatform) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
if (imageSettingsV4Request == null) {
return null;
}
ImageCatalogV4Endpoint imageCatalogV4Endpoint = cloudbreakInternalCrnClient.withInternalCrn().imageCatalogV4Endpoint();
try {
LOGGER.info("Calling cloudbreak to get image response for the given image catalog {} and image id {}", imageSettingsV4Request.getCatalog(), imageSettingsV4Request.getId());
ImagesV4Response imagesV4Response = null;
try {
if (StringUtils.isBlank(imageSettingsV4Request.getCatalog())) {
imagesV4Response = imageCatalogV4Endpoint.getImageByImageId(SdxService.WORKSPACE_ID_DEFAULT, imageSettingsV4Request.getId(), accountId);
} else {
imagesV4Response = imageCatalogV4Endpoint.getImageByCatalogNameAndImageId(SdxService.WORKSPACE_ID_DEFAULT, imageSettingsV4Request.getCatalog(), imageSettingsV4Request.getId(), accountId);
}
} catch (Exception e) {
LOGGER.error("Sdx service fails to get image using image id", e);
}
if (imagesV4Response == null) {
return null;
}
for (ImageV4Response imageV4Response : imagesV4Response.getCdhImages()) {
// find the image can be used on the cloud platform of the environment
if (imageV4Response.getImageSetsByProvider() != null) {
if (imageV4Response.getImageSetsByProvider().containsKey(cloudPlatform.name().toLowerCase())) {
return imageV4Response;
}
}
}
String errorMessage = String.format("SDX cluster is on the cloud platform %s, but the image requested with uuid %s:%s does not support it", cloudPlatform.name(), imageSettingsV4Request.getCatalog() != null ? imageSettingsV4Request.getCatalog() : "default", imageSettingsV4Request.getId());
LOGGER.error(errorMessage);
return null;
} catch (javax.ws.rs.NotFoundException e) {
LOGGER.info("Sdx cluster not found on CB side", e);
return null;
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class TestUtil method stack.
public static Stack stack(Status stackStatus, Credential credential) {
User user = new User();
user.setUserId("horton@hortonworks.com");
user.setUserCrn("testCrn");
user.setUserName("Alma ur");
Workspace workspace = new Workspace();
workspace.setId(1L);
Tenant tenant = new Tenant();
tenant.setName("testtenant");
workspace.setTenant(tenant);
Stack stack = new Stack();
stack.setCreator(user);
stack.setWorkspace(workspace);
stack.setStackStatus(new StackStatus(stack, stackStatus, "statusReason", DetailedStackStatus.UNKNOWN));
stack.setName("simplestack");
stack.setId(1L);
stack.setInstanceGroups(generateGcpInstanceGroups(3));
stack.setRegion("region");
stack.setCreated(123L);
stack.setCloudPlatform(credential.cloudPlatform());
stack.setOrchestrator(orchestrator());
stack.setEnvironmentCrn("envCrn");
stack.setResourceCrn("crn:cdp:cloudbreak:us-west-1:someone:stack:12345");
switch(credential.cloudPlatform()) {
case AWS:
stack.setInstanceGroups(generateAwsInstanceGroups(3));
break;
case GCP:
stack.setInstanceGroups(generateGcpInstanceGroups(3));
break;
default:
break;
}
stack.setSecurityConfig(new SecurityConfig());
return stack;
}
Aggregations