use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.
the class StructuredFlowEventFactory method createStucturedFlowEvent.
public StructuredFlowEvent createStucturedFlowEvent(Long stackId, FlowDetails flowDetails, Boolean detailed, Exception exception) {
Stack stack = stackService.getById(stackId);
UserProfile userProfile = userProfileService.get(stack.getAccount(), stack.getOwner());
OperationDetails operationDetails = new OperationDetails("FLOW", "STACK", stackId, stack.getAccount(), stack.getOwner(), userProfile.getUserName(), cloudbreakNodeConfig.getId(), cbVersion);
StackDetails stackDetails = null;
ClusterDetails clusterDetails = null;
BlueprintDetails blueprintDetails = null;
if (detailed) {
stackDetails = conversionService.convert(stack, StackDetails.class);
Cluster cluster = stack.getCluster();
if (cluster != null) {
clusterDetails = conversionService.convert(cluster, ClusterDetails.class);
blueprintDetails = conversionService.convert(cluster.getBlueprint(), BlueprintDetails.class);
}
}
return exception != null ? new StructuredFlowErrorEvent(operationDetails, flowDetails, stackDetails, clusterDetails, blueprintDetails, ExceptionUtils.getStackTrace(exception)) : new StructuredFlowEvent(operationDetails, flowDetails, stackDetails, clusterDetails, blueprintDetails);
}
use of com.sequenceiq.cloudbreak.domain.UserProfile 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