Search in sources :

Example 1 with AuditEventV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses in project cloudbreak by hortonworks.

the class SdxTestDto method investigate.

@Override
public Clue investigate() {
    if (getResponse() == null || getResponse().getCrn() == null) {
        return null;
    }
    AuditEventV4Responses auditEvents = AuditUtil.getAuditEvents(getTestContext().getMicroserviceClient(CloudbreakClient.class), CloudbreakEventService.DATAHUB_RESOURCE_TYPE, null, getResponse().getCrn());
    boolean hasSpotTermination = (getResponse().getStackV4Response() == null) ? false : getResponse().getStackV4Response().getInstanceGroups().stream().flatMap(ig -> ig.getMetadata().stream()).anyMatch(metadata -> InstanceStatus.DELETED_BY_PROVIDER == metadata.getInstanceStatus());
    return new Clue("SDX", auditEvents, getResponse(), hasSpotTermination);
}
Also used : Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) InstanceMetaDataV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response) Prototype(com.sequenceiq.it.cloudbreak.Prototype) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Map(java.util.Map) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) SdxRecipe(com.sequenceiq.sdx.api.model.SdxRecipe) Purgable(com.sequenceiq.it.cloudbreak.context.Purgable) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) InstanceGroupV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.InstanceGroupV4Response) UUID(java.util.UUID) AuditUtil(com.sequenceiq.it.cloudbreak.util.AuditUtil) Collectors(java.util.stream.Collectors) SdxAwsSpotParameters(com.sequenceiq.sdx.api.model.SdxAwsSpotParameters) Objects(java.util.Objects) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) SdxRecoveryRequest(com.sequenceiq.sdx.api.model.SdxRecoveryRequest) List(java.util.List) AbstractSdxTestDto(com.sequenceiq.it.cloudbreak.dto.AbstractSdxTestDto) RunningParameter.emptyRunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter.emptyRunningParameter) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) SdxEndpoint(com.sequenceiq.sdx.api.endpoint.SdxEndpoint) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) SdxInstanceGroupRequest(com.sequenceiq.sdx.api.model.SdxInstanceGroupRequest) ResponseUtil(com.sequenceiq.it.cloudbreak.util.ResponseUtil) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) Investigable(com.sequenceiq.it.cloudbreak.context.Investigable) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) CollectionUtils(org.apache.commons.collections.CollectionUtils) DELETED(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse.DELETED) Logger(org.slf4j.Logger) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) Clue(com.sequenceiq.it.cloudbreak.context.Clue) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) CommonClusterManagerProperties(com.sequenceiq.it.cloudbreak.cloud.v4.CommonClusterManagerProperties) SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) RunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) Collections(java.util.Collections) SdxAwsRequest(com.sequenceiq.sdx.api.model.SdxAwsRequest) InstanceUtil(com.sequenceiq.it.cloudbreak.util.InstanceUtil) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) Clue(com.sequenceiq.it.cloudbreak.context.Clue)

Example 2 with AuditEventV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses in project cloudbreak by hortonworks.

the class AuditEventV4Controller method getAuditEventsZipResponse.

private Response getAuditEventsZipResponse(Collection<AuditEventV4Response> auditEventV4Responses, String resourceType) {
    StreamingOutput streamingOutput = output -> {
        try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
            zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
            zipOutputStream.write(JsonUtil.writeValueAsString(auditEventV4Responses).getBytes());
            zipOutputStream.closeEntry();
        }
    };
    String fileName = String.format("audit-%s.zip", resourceType);
    return Response.ok(streamingOutput).header("content-disposition", String.format("attachment; filename = %s", fileName)).build();
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) AuditEventV4Endpoint(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.AuditEventV4Endpoint) DisableCheckPermissions(com.sequenceiq.authorization.annotation.DisableCheckPermissions) Collection(java.util.Collection) StreamingOutput(javax.ws.rs.core.StreamingOutput) JsonUtil(com.sequenceiq.cloudbreak.common.json.JsonUtil) Controller(org.springframework.stereotype.Controller) AuditEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response) Inject(javax.inject.Inject) CloudbreakRestRequestThreadLocalService(com.sequenceiq.cloudbreak.structuredevent.CloudbreakRestRequestThreadLocalService) List(java.util.List) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) Response(javax.ws.rs.core.Response) AuditEventService(com.sequenceiq.cloudbreak.service.audit.AuditEventService) ZipEntry(java.util.zip.ZipEntry) ZipOutputStream(java.util.zip.ZipOutputStream) ZipEntry(java.util.zip.ZipEntry) StreamingOutput(javax.ws.rs.core.StreamingOutput)

Example 3 with AuditEventV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses in project cloudbreak by hortonworks.

the class AuditEventService method getAuditEventsByWorkspaceId.

public List<AuditEventV4Response> getAuditEventsByWorkspaceId(Long workspaceId, String resourceType, Long resourceId, String resourceCrn) {
    User user = userService.getOrCreate(legacyRestRequestThreadLocalService.getCloudbreakUser());
    Workspace workspace = getWorkspaceService().get(workspaceId, user);
    List<AuditEventV4Response> auditEventV4Responses = getEventsForUserWithTypeAndResourceIdByWorkspace(workspace, resourceType, resourceId, resourceCrn);
    auditEventV4Responses.sort(new AuditEventComparator().reversed());
    return auditEventV4Responses;
}
Also used : User(com.sequenceiq.cloudbreak.workspace.model.User) AuditEventComparator(com.sequenceiq.cloudbreak.comparator.audit.AuditEventComparator) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) AuditEventV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Response)

Example 4 with AuditEventV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses in project cloudbreak by hortonworks.

the class SdxCustomTestDto method investigate.

@Override
public Clue investigate() {
    if (getResponse() == null || getResponse().getCrn() == null) {
        return null;
    }
    AuditEventV4Responses auditEvents = AuditUtil.getAuditEvents(getTestContext().getMicroserviceClient(CloudbreakClient.class), CloudbreakEventService.DATAHUB_RESOURCE_TYPE, null, getResponse().getCrn());
    boolean hasSpotTermination = (getResponse().getStackV4Response() == null) ? false : getResponse().getStackV4Response().getInstanceGroups().stream().flatMap(ig -> ig.getMetadata().stream()).anyMatch(metadata -> InstanceStatus.DELETED_BY_PROVIDER == metadata.getInstanceStatus());
    return new Clue("SDX", auditEvents, getResponse(), hasSpotTermination);
}
Also used : ResponseUtil(com.sequenceiq.it.cloudbreak.util.ResponseUtil) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) Investigable(com.sequenceiq.it.cloudbreak.context.Investigable) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Prototype(com.sequenceiq.it.cloudbreak.Prototype) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Searchable(com.sequenceiq.it.cloudbreak.search.Searchable) Map(java.util.Map) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) CommonCloudProperties(com.sequenceiq.it.cloudbreak.cloud.v4.CommonCloudProperties) ResourcePropertyProvider(com.sequenceiq.it.cloudbreak.ResourcePropertyProvider) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) DELETED(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse.DELETED) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Purgable(com.sequenceiq.it.cloudbreak.context.Purgable) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) SdxCustomClusterRequest(com.sequenceiq.sdx.api.model.SdxCustomClusterRequest) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UUID(java.util.UUID) AuditUtil(com.sequenceiq.it.cloudbreak.util.AuditUtil) Collectors(java.util.stream.Collectors) Clue(com.sequenceiq.it.cloudbreak.context.Clue) List(java.util.List) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) AbstractSdxTestDto(com.sequenceiq.it.cloudbreak.dto.AbstractSdxTestDto) CommonClusterManagerProperties(com.sequenceiq.it.cloudbreak.cloud.v4.CommonClusterManagerProperties) SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) RunningParameter.emptyRunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter.emptyRunningParameter) RunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) SdxEndpoint(com.sequenceiq.sdx.api.endpoint.SdxEndpoint) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) SdxInstanceGroupRequest(com.sequenceiq.sdx.api.model.SdxInstanceGroupRequest) ImageSettingsTestDto(com.sequenceiq.it.cloudbreak.dto.ImageSettingsTestDto) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) Clue(com.sequenceiq.it.cloudbreak.context.Clue)

Example 5 with AuditEventV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses in project cloudbreak by hortonworks.

the class SdxInternalTestDto method investigate.

@Override
public Clue investigate() {
    if (getResponse() == null || getResponse().getCrn() == null) {
        return null;
    }
    AuditEventV4Responses auditEvents = AuditUtil.getAuditEvents(getTestContext().getMicroserviceClient(CloudbreakClient.class), CloudbreakEventService.DATAHUB_RESOURCE_TYPE, null, getResponse().getCrn());
    boolean hasSpotTermination = (getResponse().getStackV4Response() == null) ? false : getResponse().getStackV4Response().getInstanceGroups().stream().flatMap(ig -> ig.getMetadata().stream()).anyMatch(metadata -> InstanceStatus.DELETED_BY_PROVIDER == metadata.getInstanceStatus());
    return new Clue("SDX", auditEvents, getResponse(), hasSpotTermination);
}
Also used : ClusterTestDto(com.sequenceiq.it.cloudbreak.dto.ClusterTestDto) SdxDatabaseAvailabilityType(com.sequenceiq.sdx.api.model.SdxDatabaseAvailabilityType) Arrays(java.util.Arrays) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) SdxDatabaseRequest(com.sequenceiq.sdx.api.model.SdxDatabaseRequest) InstanceMetaDataV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.instancegroup.instancemetadata.InstanceMetaDataV4Response) Prototype(com.sequenceiq.it.cloudbreak.Prototype) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) InstanceGroupTestDto(com.sequenceiq.it.cloudbreak.dto.InstanceGroupTestDto) Map(java.util.Map) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) CommonCloudProperties(com.sequenceiq.it.cloudbreak.cloud.v4.CommonCloudProperties) StackTestDto(com.sequenceiq.it.cloudbreak.dto.stack.StackTestDto) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) SdxInternalClusterRequest(com.sequenceiq.sdx.api.model.SdxInternalClusterRequest) PlacementSettingsTestDto(com.sequenceiq.it.cloudbreak.dto.PlacementSettingsTestDto) Purgable(com.sequenceiq.it.cloudbreak.context.Purgable) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) UUID(java.util.UUID) AuditUtil(com.sequenceiq.it.cloudbreak.util.AuditUtil) Collectors(java.util.stream.Collectors) List(java.util.List) AbstractSdxTestDto(com.sequenceiq.it.cloudbreak.dto.AbstractSdxTestDto) RunningParameter.emptyRunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter.emptyRunningParameter) SdxUpgradeRequest(com.sequenceiq.sdx.api.model.SdxUpgradeRequest) Optional(java.util.Optional) SdxEndpoint(com.sequenceiq.sdx.api.endpoint.SdxEndpoint) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) SdxClusterResizeRequest(com.sequenceiq.sdx.api.model.SdxClusterResizeRequest) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) ResponseUtil(com.sequenceiq.it.cloudbreak.util.ResponseUtil) SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) Investigable(com.sequenceiq.it.cloudbreak.context.Investigable) Supplier(java.util.function.Supplier) Inject(javax.inject.Inject) StackAuthenticationTestDto(com.sequenceiq.it.cloudbreak.dto.StackAuthenticationTestDto) Searchable(com.sequenceiq.it.cloudbreak.search.Searchable) CustomDomainSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.customdomain.CustomDomainSettingsV4Request) DELETED(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse.DELETED) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) CloudbreakTestDto(com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) IDBROKER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) Clue(com.sequenceiq.it.cloudbreak.context.Clue) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) CommonClusterManagerProperties(com.sequenceiq.it.cloudbreak.cloud.v4.CommonClusterManagerProperties) SdxRepairRequest(com.sequenceiq.sdx.api.model.SdxRepairRequest) RunningParameter(com.sequenceiq.it.cloudbreak.context.RunningParameter) SdxClient(com.sequenceiq.it.cloudbreak.SdxClient) Collections(java.util.Collections) ImageSettingsTestDto(com.sequenceiq.it.cloudbreak.dto.ImageSettingsTestDto) InstanceUtil(com.sequenceiq.it.cloudbreak.util.InstanceUtil) CloudbreakClient(com.sequenceiq.it.cloudbreak.CloudbreakClient) AuditEventV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses) Clue(com.sequenceiq.it.cloudbreak.context.Clue)

Aggregations

AuditEventV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.audits.responses.AuditEventV4Responses)6 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)5 CloudbreakEventService (com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService)5 CloudbreakClient (com.sequenceiq.it.cloudbreak.CloudbreakClient)5 Prototype (com.sequenceiq.it.cloudbreak.Prototype)5 Clue (com.sequenceiq.it.cloudbreak.context.Clue)5 Investigable (com.sequenceiq.it.cloudbreak.context.Investigable)5 Purgable (com.sequenceiq.it.cloudbreak.context.Purgable)5 RunningParameter (com.sequenceiq.it.cloudbreak.context.RunningParameter)5 RunningParameter.key (com.sequenceiq.it.cloudbreak.context.RunningParameter.key)5 TestContext (com.sequenceiq.it.cloudbreak.context.TestContext)5 EnvironmentTestDto (com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto)5 AuditUtil (com.sequenceiq.it.cloudbreak.util.AuditUtil)5 ResponseUtil (com.sequenceiq.it.cloudbreak.util.ResponseUtil)5 List (java.util.List)5 Inject (javax.inject.Inject)5 RunningParameter.emptyRunningParameter (com.sequenceiq.it.cloudbreak.context.RunningParameter.emptyRunningParameter)4 CloudbreakTestDto (com.sequenceiq.it.cloudbreak.dto.CloudbreakTestDto)4 Searchable (com.sequenceiq.it.cloudbreak.search.Searchable)4 Map (java.util.Map)4