use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeExistingUpgradeCommandValidationHandlerTest method getHandlerEvent.
private HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> getHandlerEvent(String buildNumber) {
Image targetImage = mock(Image.class);
Map<String, String> packageVersions = new java.util.HashMap<>();
packageVersions.put(ImagePackageVersion.CDH_BUILD_NUMBER.getKey(), buildNumber);
packageVersions.put(ImagePackageVersion.STACK.getKey(), STACK_VERSION);
when(targetImage.getPackageVersions()).thenReturn(packageVersions);
ClusterUpgradeExistingUpgradeCommandValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeExistingUpgradeCommandValidationEvent(1L, targetImage);
HandlerEvent<ClusterUpgradeExistingUpgradeCommandValidationEvent> handlerEvent = mock(HandlerEvent.class);
when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
return handlerEvent;
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeValidationActions method clusterUpgradeImageValidation.
@Bean(name = "CLUSTER_UPGRADE_IMAGE_VALIDATION_STATE")
public Action<?, ?> clusterUpgradeImageValidation() {
return new AbstractClusterUpgradeValidationAction<>(ClusterUpgradeValidationEvent.class) {
@Override
protected void doExecute(StackContext context, ClusterUpgradeValidationEvent payload, Map<Object, Object> variables) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
LOGGER.info("Starting cluster upgrade image validation.");
UpgradeImageInfo upgradeImageInfo = upgradeImageInfoFactory.create(payload.getImageId(), payload.getResourceId());
Image targetImage = stackImageService.getImageModelFromStatedImage(context.getStack(), upgradeImageInfo.getCurrentImage(), upgradeImageInfo.getTargetStatedImage());
variables.put(TARGET_IMAGE, targetImage);
CloudStack cloudStack = context.getCloudStack().replaceImage(targetImage);
ClusterUpgradeImageValidationEvent event = new ClusterUpgradeImageValidationEvent(payload.getResourceId(), payload.getImageId(), cloudStack, context.getCloudCredential(), context.getCloudContext(), upgradeImageInfo.getTargetStatedImage().getImage());
sendEvent(context, event.selector(), event);
}
@Override
protected Object getFailurePayload(ClusterUpgradeValidationEvent payload, Optional<StackContext> flowContext, Exception ex) {
return new ClusterUpgradeValidationFailureEvent(payload.getResourceId(), ex);
}
};
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeImageValidationHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<ClusterUpgradeImageValidationEvent> event) {
LOGGER.debug("Accepting cluster upgrade image validation event.");
ClusterUpgradeImageValidationEvent request = event.getData();
CloudContext cloudContext = request.getCloudContext();
try {
Set<Response> parcelsResponses = parcelAvailabilityService.validateAvailability(request.getTargetImage(), request.getResourceId());
long requiredDiskSpaceForUpgrade = parcelSizeService.getRequiredFreeSpace(parcelsResponses);
executePlatformSpecificValidations(request, cloudContext);
LOGGER.debug("Cluster upgrade image validation succeeded.");
return new ClusterUpgradeDiskSpaceValidationEvent(START_CLUSTER_UPGRADE_DISK_SPACE_VALIDATION_EVENT.selector(), request.getResourceId(), requiredDiskSpaceForUpgrade);
} catch (RuntimeException e) {
LOGGER.warn("Cluster upgrade image validation failed: ", e);
return new ClusterUpgradeValidationFailureEvent(request.getResourceId(), e);
}
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeFreeIpaStatusValidationHandlerTest method getHandlerEvent.
private HandlerEvent<ClusterUpgradeFreeIpaStatusValidationEvent> getHandlerEvent() {
ClusterUpgradeFreeIpaStatusValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeFreeIpaStatusValidationEvent(1L);
HandlerEvent<ClusterUpgradeFreeIpaStatusValidationEvent> handlerEvent = mock(HandlerEvent.class);
when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
return handlerEvent;
}
use of com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.ClusterUpgradeImageValidationEvent in project cloudbreak by hortonworks.
the class ClusterUpgradeImageValidationHandlerTest method getHandlerEvent.
private HandlerEvent<ClusterUpgradeImageValidationEvent> getHandlerEvent() {
ClusterUpgradeImageValidationEvent clusterUpgradeImageValidationEvent = new ClusterUpgradeImageValidationEvent(1L, "imageId", cloudStack, cloudCredential, cloudContext, mock(Image.class));
HandlerEvent<ClusterUpgradeImageValidationEvent> handlerEvent = mock(HandlerEvent.class);
when(handlerEvent.getData()).thenReturn(clusterUpgradeImageValidationEvent);
return handlerEvent;
}
Aggregations