use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class ClusterCommonServiceTest method testRotateAutoTls.
@Test
public void testRotateAutoTls() {
NameOrCrn cluster = NameOrCrn.ofName("cluster");
Stack stack = new Stack();
stack.setName("cluster");
stack.setStackStatus(new StackStatus(stack, AVAILABLE));
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
when(clusterOperationService.rotateAutoTlsCertificates(stack, certificatesRotationV4Request)).thenReturn(new FlowIdentifier(FlowType.FLOW, "1"));
when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request);
verify(clusterOperationService, times(1)).rotateAutoTlsCertificates(stack, certificatesRotationV4Request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class ClusterCommonServiceTest method testRotateAutoTlsCertificatesWithStoppedInstances.
@Test
public void testRotateAutoTlsCertificatesWithStoppedInstances() {
NameOrCrn cluster = NameOrCrn.ofName("cluster");
Stack stack = new Stack();
stack.setStackStatus(new StackStatus(stack, AVAILABLE));
when(instanceMetaDataService.anyInstanceStopped(any())).thenReturn(true);
when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request));
assertEquals("Please start all stopped instances. Certificates rotation can only be made when all your nodes in running state.", badRequestException.getMessage());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackCommonService method putScalingInWorkspace.
public FlowIdentifier putScalingInWorkspace(NameOrCrn nameOrCrn, Long workspaceId, StackScaleV4Request stackScaleV4Request) {
User user = userService.getOrCreate(restRequestThreadLocalService.getCloudbreakUser());
Stack stack;
try {
stack = transactionService.required(() -> {
Stack stackInTransaction = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
validateNetworkScaleRequest(stackInTransaction, stackScaleV4Request.getStackNetworkScaleV4Request());
return stackInTransaction;
});
} catch (TransactionService.TransactionExecutionException e) {
LOGGER.error("Cannot validate network scaling: {}", e.getMessage(), e);
throw new TransactionService.TransactionRuntimeExecutionException(e);
}
MDCBuilder.buildMdcContext(stack);
stackScaleV4Request.setStackId(stack.getId());
UpdateStackV4Request updateStackJson = stackScaleV4RequestToUpdateStackV4RequestConverter.convert(stackScaleV4Request);
Integer scalingAdjustment = updateStackJson.getInstanceGroupAdjustment().getScalingAdjustment();
validateScalingRequest(stack, scalingAdjustment);
FlowIdentifier flowIdentifier;
if (scalingAdjustment > 0) {
flowIdentifier = put(stack, updateStackJson);
} else {
UpdateClusterV4Request updateClusterJson = stackScaleV4RequestToUpdateClusterV4RequestConverter.convert(stackScaleV4Request);
workspaceService.get(workspaceId, user);
flowIdentifier = clusterCommonService.put(stack.getResourceCrn(), updateClusterJson);
}
return flowIdentifier;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class StackCommonService method syncInWorkspace.
public FlowIdentifier syncInWorkspace(NameOrCrn nameOrCrn, Long workspaceId) {
Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
MDCBuilder.buildMdcContext(stack);
UpdateStackV4Request updateStackJson = new UpdateStackV4Request();
updateStackJson.setStatus(StatusRequest.FULL_SYNC);
updateStackJson.setWithClusterEvent(true);
return put(stack, updateStackJson);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.
the class ClusterCommonService method rotateAutoTlsCertificates.
public CertificatesRotationV4Response rotateAutoTlsCertificates(NameOrCrn nameOrCrn, Long workspaceId, CertificatesRotationV4Request certificatesRotationV4Request) {
Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
MDCBuilder.buildMdcContext(stack);
validateOperationOnStack(stack, "Certificates rotation");
return new CertificatesRotationV4Response(clusterOperationService.rotateAutoTlsCertificates(stack, certificatesRotationV4Request));
}
Aggregations