use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class SdxService method resizeSdx.
public Pair<SdxCluster, FlowIdentifier> resizeSdx(final String userCrn, final String clusterName, final SdxClusterResizeRequest sdxClusterResizeRequest) {
LOGGER.info("Re-sizing SDX cluster with name {}", clusterName);
String accountIdFromCrn = getAccountIdFromCrn(userCrn);
String environmentName = sdxClusterResizeRequest.getEnvironment();
SdxClusterShape shape = sdxClusterResizeRequest.getClusterShape();
final SdxCluster sdxCluster = sdxClusterRepository.findByAccountIdAndClusterNameAndDeletedIsNullAndDetachedIsFalse(accountIdFromCrn, clusterName).orElseThrow(() -> notFound("SDX cluster", clusterName).get());
MDCBuilder.buildMdcContext(sdxCluster);
validateSdxResizeRequest(sdxCluster, accountIdFromCrn, shape);
StackV4Response stackV4Response = getDetail(clusterName, Set.of(StackResponseEntries.HARDWARE_INFO.getEntryName(), StackResponseEntries.EVENTS.getEntryName()), accountIdFromCrn);
DetailedEnvironmentResponse environment = validateAndGetEnvironment(environmentName);
SdxCluster newSdxCluster = validateAndCreateNewSdxCluster(userCrn, clusterName, sdxCluster.getRuntime(), shape, sdxCluster.isRangerRazEnabled(), sdxCluster.isEnableMultiAz(), environment);
newSdxCluster.setTags(sdxCluster.getTags());
newSdxCluster.setCrn(sdxCluster.getCrn());
CloudPlatform cloudPlatform = CloudPlatform.valueOf(environment.getCloudPlatform());
if (!StringUtils.isBlank(sdxCluster.getCloudStorageBaseLocation())) {
newSdxCluster.setCloudStorageBaseLocation(sdxCluster.getCloudStorageBaseLocation());
newSdxCluster.setCloudStorageFileSystemType(sdxCluster.getCloudStorageFileSystemType());
} else if (!CloudPlatform.YARN.equalsIgnoreCase(cloudPlatform.name()) && !CloudPlatform.GCP.equalsIgnoreCase(cloudPlatform.name()) && !CloudPlatform.MOCK.equalsIgnoreCase(cloudPlatform.name())) {
throw new BadRequestException("Cloud storage parameter is required.");
}
newSdxCluster.setDatabaseAvailabilityType(sdxCluster.getDatabaseAvailabilityType());
newSdxCluster.setDatabaseEngineVersion(sdxCluster.getDatabaseEngineVersion());
StackV4Request stackRequest = getStackRequest(shape, sdxCluster.isRangerRazEnabled(), null, cloudPlatform, sdxCluster.getRuntime(), null);
if (shape == SdxClusterShape.MEDIUM_DUTY_HA) {
// This is added to make sure the host name used by Light and Medium duty are not the same.
CustomDomainSettingsV4Request customDomainSettingsV4Request = new CustomDomainSettingsV4Request();
customDomainSettingsV4Request.setHostname(sdxCluster.getClusterName() + SDX_RESIZE_NAME_SUFFIX);
stackRequest.setCustomDomain(customDomainSettingsV4Request);
}
prepareCloudStorageForStack(stackRequest, stackV4Response, newSdxCluster, environment);
prepareDefaultSecurityConfigs(null, stackRequest, cloudPlatform);
try {
if (!StringUtils.isBlank(sdxCluster.getStackRequestToCloudbreak())) {
StackV4Request stackV4RequestOrig = JsonUtil.readValue(sdxCluster.getStackRequestToCloudbreak(), StackV4Request.class);
stackRequest.setImage(stackV4RequestOrig.getImage());
}
} catch (IOException ioException) {
LOGGER.error("Failed to re-use the image catalog. Will use default catalog", ioException);
}
stackRequest.setResourceCrn(newSdxCluster.getCrn());
newSdxCluster.setStackRequest(stackRequest);
FlowIdentifier flowIdentifier = sdxReactorFlowManager.triggerSdxResize(sdxCluster.getId(), newSdxCluster);
return Pair.of(sdxCluster, flowIdentifier);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class StackToStackV4ResponseConverterTest method setUp.
@Before
public void setUp() throws CloudbreakImageNotFoundException {
underTest = new StackToStackV4ResponseConverter();
MockitoAnnotations.initMocks(this);
when(imageService.getImage(anyLong())).thenReturn(new Image("cb-centos66-amb200-2015-05-25", Collections.emptyMap(), "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()));
when(componentConfigProviderService.getCloudbreakDetails(anyLong())).thenReturn(new CloudbreakDetails("version"));
when(componentConfigProviderService.getStackTemplate(anyLong())).thenReturn(new StackTemplate("{}", "version"));
when(componentConfigProviderService.getTelemetry(anyLong())).thenReturn(new Telemetry());
Mockito.doAnswer(answer -> {
StackV4Response result = answer.getArgument(1, StackV4Response.class);
result.setSharedService(new SharedServiceV4Response());
return null;
}).when(datalakeService).addSharedServiceResponse(any(Stack.class), any(StackV4Response.class));
when(serviceEndpointCollector.filterByStackType(any(StackType.class), any(List.class))).thenReturn(new ArrayList());
credentialResponse = new CredentialResponse();
credentialResponse.setName("cred-name");
credentialResponse.setCrn("crn");
when(loadBalancerService.findByStackId(any())).thenReturn(Set.of());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method testWhenProvidedRegionIsEmptyButDefaultOnesAreNotAndPlatformRegionIsNullThenBadRequestExceptionComes.
@Test
void testWhenProvidedRegionIsEmptyButDefaultOnesAreNotAndPlatformRegionIsNullThenBadRequestExceptionComes() {
setDefaultRegions(AWS);
StackV4Request request = getRequest("stack.json");
request.setCloudPlatform(MOCK);
request.getPlacement().setRegion(null);
BadRequestException resultException = assertThrows(BadRequestException.class, () -> underTest.convert(request));
assertEquals(String.format("No default region specified for: %s. Region cannot be empty.", request.getCloudPlatform().name()), resultException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class ImageToStackImageV4ResponseConverter method convert.
public StackImageV4Response convert(Image source) {
StackImageV4Response image = new StackImageV4Response();
image.setName(source.getImageName());
decorateWithImageCatalogUrl(source, image);
image.setCatalogName(Strings.isNullOrEmpty(source.getImageCatalogName()) ? "cloudbreak-default" : source.getImageCatalogName());
image.setId(Strings.isNullOrEmpty(source.getImageId()) ? null : source.getImageId());
return image;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.ResourceStatus.DEFAULT in project cloudbreak by hortonworks.
the class NetworkV1ToNetworkV4Converter method convertToNetworkV4Request.
public NetworkV4Request convertToNetworkV4Request(Pair<NetworkV1Request, DetailedEnvironmentResponse> network) {
EnvironmentNetworkResponse value = network.getValue().getNetwork();
NetworkV1Request key = network.getKey();
if (key == null) {
key = new NetworkV1Request();
}
NetworkV4Request request = new NetworkV4Request();
if (network.getValue().getCloudPlatform() == null) {
throw new IllegalStateException("Unable to determine cloud platform for network since it has not been set!");
}
switch(network.getValue().getCloudPlatform()) {
case "AWS":
request.setAws(getAwsNetworkParameters(Optional.ofNullable(key.getAws()), value));
break;
case "AZURE":
request.setAzure(getAzureNetworkParameters(Optional.ofNullable(key.getAzure()), value));
break;
case "MOCK":
request.setMock(getMockNetworkParameters(Optional.ofNullable(key.getMock()), value));
break;
case "GCP":
request.setGcp(getGcpNetworkParameters(Optional.ofNullable(key.getGcp()), value));
break;
default:
LOGGER.warn(NetworkV1ToNetworkV4Converter.class.getSimpleName() + " has no implemented action for cloud platform: " + network.getValue().getCloudPlatform());
}
return request;
}
Aggregations