use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredNotificationEvent in project cloudbreak by hortonworks.
the class StructuredFlowEventFactory method createStructuredNotificationEvent.
public StructuredNotificationEvent createStructuredNotificationEvent(Long stackId, String notificationType, String message, String instanceGroupName) {
Stack stack = stackService.getById(stackId);
UserProfile userProfile = userProfileService.get(stack.getAccount(), stack.getOwner());
OperationDetails operationDetails = new OperationDetails("NOTIFICATION", "STACK", stackId, stack.getAccount(), stack.getOwner(), userProfile.getUserName(), cloudbreakNodeConfig.getInstanceUUID(), cbVersion);
NotificationDetails notificationDetails = new NotificationDetails();
notificationDetails.setNotificationType(notificationType);
notificationDetails.setNotification(message);
notificationDetails.setCloud(stack.cloudPlatform());
notificationDetails.setRegion(stack.getRegion());
notificationDetails.setAvailabiltyZone(stack.getAvailabilityZone());
notificationDetails.setStackId(stackId);
notificationDetails.setStackName(stack.getDisplayName());
notificationDetails.setStackStatus(stack.getStatus().name());
notificationDetails.setNodeCount(stack.getRunningInstanceMetaData().size());
notificationDetails.setInstanceGroup(instanceGroupName);
Cluster cluster = stack.getCluster();
if (cluster != null) {
notificationDetails.setClusterId(cluster.getId());
notificationDetails.setClusterName(cluster.getName());
notificationDetails.setClusterStatus(cluster.getStatus().name());
Blueprint blueprint = cluster.getBlueprint();
if (blueprint != null) {
notificationDetails.setBlueprintId(blueprint.getId());
notificationDetails.setBlueprintName(blueprint.getAmbariName());
}
}
return new StructuredNotificationEvent(operationDetails, notificationDetails);
}
Aggregations