use of com.sequenceiq.cloudbreak.core.flow2.stack.migration.handler.service.ResourceRecreator in project cloudbreak by hortonworks.
the class CreateResourcesHandler method accept.
@Override
public void accept(Event<CreateResourcesRequest> event) {
LOGGER.info("Re-create the resources during the AWS migration");
CreateResourcesRequest request = event.getData();
try {
CloudContext cloudContext = request.getCloudContext();
CloudCredential cloudCredential = request.getCloudCredential();
CloudStack cloudStack = request.getCloudStack();
AuthenticatedContext ac = awsAuthenticator.authenticate(cloudContext, cloudCredential);
Network network = cloudStack.getNetwork();
AwsContext awsContext = awsContextBuilder.contextInit(cloudContext, ac, network, List.of(), true);
for (ResourceRecreator resourceRecreator : resourceRecreators) {
resourceRecreator.recreate(request, awsContext, ac);
}
CreateResourcesResult result = new CreateResourcesResult(request.getResourceId());
request.getResult().onNext(result);
eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
} catch (Exception e) {
LOGGER.error("Cannot re-create the AWS security group during the variant migration", e);
CreateResourcesResult result = new CreateResourcesResult(e.getMessage(), e, request.getResourceId());
request.getResult().onNext(result);
eventBus.notify(AWS_VARIANT_MIGRATION_FAILED_EVENT.event(), new Event<>(event.getHeaders(), result));
}
}
Aggregations