Search in sources :

Example 1 with EnvironmentDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails in project cloudbreak by hortonworks.

the class CDPStructuredFlowEventToCDPEnvironmentStatusChangedConverter method convert.

public UsageProto.CDPEnvironmentStatusChanged convert(CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent, UsageProto.CDPEnvironmentStatus.Value status) {
    UsageProto.CDPEnvironmentStatusChanged.Builder cdpEnvironmentStatusChangedBuilder = UsageProto.CDPEnvironmentStatusChanged.newBuilder();
    cdpEnvironmentStatusChangedBuilder.setOperationDetails(operationDetailsConverter.convert(cdpStructuredFlowEvent));
    cdpEnvironmentStatusChangedBuilder.setNewStatus(status);
    if (cdpStructuredFlowEvent != null) {
        cdpEnvironmentStatusChangedBuilder.setFailureReason(defaultIfEmpty(cdpStructuredFlowEvent.getStatusReason(), ""));
        EnvironmentDetails environmentDetails = cdpStructuredFlowEvent.getPayload();
        cdpEnvironmentStatusChangedBuilder.setEnvironmentDetails(environmentDetailsConverter.convert(environmentDetails));
        cdpEnvironmentStatusChangedBuilder.setTelemetryFeatureDetails(telemetryFeatureDetailsConverter.convert(environmentDetails));
        cdpEnvironmentStatusChangedBuilder.setFreeIPA(freeIPADetailsConverter.convert(environmentDetails));
    }
    UsageProto.CDPEnvironmentStatusChanged ret = cdpEnvironmentStatusChangedBuilder.build();
    LOGGER.debug("Converted CDPEnvironmentStatusChanged event: {}", ret);
    return ret;
}
Also used : EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Example 2 with EnvironmentDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails in project cloudbreak by hortonworks.

the class CDPEnvironmentStructuredFlowEventToCDPEnvironmentStatusChangedConverter method convert.

public UsageProto.CDPEnvironmentStatusChanged convert(CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent, UsageProto.CDPEnvironmentStatus.Value status) {
    UsageProto.CDPEnvironmentStatusChanged.Builder cdpEnvironmentStatusChangedBuilder = UsageProto.CDPEnvironmentStatusChanged.newBuilder();
    cdpEnvironmentStatusChangedBuilder.setNewStatus(status);
    if (cdpStructuredFlowEvent != null) {
        String cloudProvider = cdpStructuredFlowEvent.getPayload() != null ? cdpStructuredFlowEvent.getPayload().getCloudPlatform() : null;
        cdpEnvironmentStatusChangedBuilder.setOperationDetails(operationDetailsConverter.convert(cdpStructuredFlowEvent, cloudProvider));
        cdpEnvironmentStatusChangedBuilder.setFailureReason(defaultIfEmpty(cdpStructuredFlowEvent.getStatusReason(), ""));
        EnvironmentDetails environmentDetails = cdpStructuredFlowEvent.getPayload();
        cdpEnvironmentStatusChangedBuilder.setEnvironmentDetails(environmentDetailsConverter.convert(environmentDetails));
        cdpEnvironmentStatusChangedBuilder.setTelemetryFeatureDetails(telemetryFeatureDetailsConverter.convert(environmentDetails));
        cdpEnvironmentStatusChangedBuilder.setFreeIPA(freeIPADetailsConverter.convert(environmentDetails));
    }
    UsageProto.CDPEnvironmentStatusChanged ret = cdpEnvironmentStatusChangedBuilder.build();
    LOGGER.debug("Converted CDPEnvironmentStatusChanged event: {}", ret);
    return ret;
}
Also used : EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Example 3 with EnvironmentDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails in project cloudbreak by hortonworks.

the class EnvironmentStructuredFlowEventFactory method createStructuredFlowEvent.

@Override
public CDPStructuredFlowEvent createStructuredFlowEvent(Long resourceId, FlowDetails flowDetails, Exception exception) {
    Environment environment = environmentService.findEnvironmentByIdOrThrow(resourceId);
    String resourceType = CloudbreakEventService.ENVIRONMENT_RESOURCE_TYPE;
    CDPOperationDetails operationDetails = new CDPOperationDetails(clock.getCurrentTimeMillis(), FLOW, resourceType, environment.getId(), environment.getName(), nodeConfig.getId(), serviceVersion, environment.getAccountId(), environment.getResourceCrn(), environment.getCreator(), environment.getResourceCrn(), null);
    EnvironmentDetails environmentDetails = environmentDtoConverter.environmentToDto(environment);
    CDPEnvironmentStructuredFlowEvent event = new CDPEnvironmentStructuredFlowEvent(operationDetails, flowDetails, environmentDetails, environment.getStatus().name(), getReason(environment));
    if (exception != null) {
        event.setException(ExceptionUtils.getStackTrace(exception));
    }
    return event;
}
Also used : CDPEnvironmentStructuredFlowEvent(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent) EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) Environment(com.sequenceiq.environment.environment.domain.Environment) CDPOperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)

Example 4 with EnvironmentDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails in project cloudbreak by hortonworks.

the class EnvironmentDetailsToCDPNetworkDetailsConverter method convert.

public UsageProto.CDPNetworkDetails convert(EnvironmentDetails environmentDetails) {
    UsageProto.CDPNetworkDetails.Builder cdpNetworkDetails = UsageProto.CDPNetworkDetails.newBuilder();
    cdpNetworkDetails.setNumberPublicSubnets(DEFAULT_INTEGER_VALUE);
    cdpNetworkDetails.setNumberPrivateSubnets(DEFAULT_INTEGER_VALUE);
    Tunnel tunnel = environmentDetails.getTunnel();
    if (tunnel != null) {
        cdpNetworkDetails.setConnectivity(tunnel.name());
    }
    CcmV2TlsType tlsType = environmentDetails.getTlsType();
    if (tlsType != null) {
        cdpNetworkDetails.setControlPlaneAndCCMAgentConnectionSecurity(tlsType.name());
    }
    NetworkDto network = environmentDetails.getNetwork();
    if (network != null) {
        cdpNetworkDetails.setNetworkType(network.getRegistrationType().name());
        cdpNetworkDetails.setServiceEndpointCreation(network.getServiceEndpointCreation().name());
        if (network.getSubnetMetas() != null) {
            if (network.getSubnetMetas().isEmpty()) {
                cdpNetworkDetails.setNumberPrivateSubnets(0);
                cdpNetworkDetails.setNumberPublicSubnets(0);
            } else {
                List<SubnetType> types = network.getSubnetMetas().values().stream().map(CloudSubnet::getType).filter(Objects::nonNull).sorted().collect(Collectors.toUnmodifiableList());
                if (!types.isEmpty()) {
                    cdpNetworkDetails.setNumberPrivateSubnets(types.stream().filter(e -> e.equals(SubnetType.PRIVATE) || e.equals(SubnetType.MLX) || e.equals(SubnetType.DWX)).collect(Collectors.toList()).size());
                    cdpNetworkDetails.setNumberPublicSubnets(types.stream().filter(e -> e.equals(SubnetType.PUBLIC)).collect(Collectors.toList()).size());
                }
            }
        }
        cdpNetworkDetails.setPublicEndpointAccessGateway(network.getPublicEndpointAccessGateway() != null ? network.getPublicEndpointAccessGateway().name() : PublicEndpointAccessGateway.DISABLED.name());
    }
    cdpNetworkDetails.setSecurityAccessType(defaultIfEmpty(environmentDetails.getSecurityAccessType(), ""));
    cdpNetworkDetails.setProxyDetails(convertProxy(environmentDetails.getProxyDetails()));
    cdpNetworkDetails.setDomain(defaultIfEmpty(environmentDetails.getDomain(), ""));
    cdpNetworkDetails.setOwnDnsZones(convertOwnDnsZones(network, environmentDetails.getCloudPlatform()));
    UsageProto.CDPNetworkDetails ret = cdpNetworkDetails.build();
    LOGGER.debug("Converted CDPNetworkDetails: {}", ret);
    return ret;
}
Also used : StringUtils.defaultIfEmpty(org.apache.commons.lang3.StringUtils.defaultIfEmpty) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) ProxyDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.proxy.ProxyDetails) Objects(java.util.Objects) List(java.util.List) Component(org.springframework.stereotype.Component) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) SubnetType(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) Optional(java.util.Optional) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) CcmV2TlsType(com.sequenceiq.common.api.type.CcmV2TlsType) EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) Tunnel(com.sequenceiq.common.api.type.Tunnel) NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) Tunnel(com.sequenceiq.common.api.type.Tunnel) Objects(java.util.Objects) CcmV2TlsType(com.sequenceiq.common.api.type.CcmV2TlsType) SubnetType(com.sequenceiq.cloudbreak.cloud.model.network.SubnetType) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Example 5 with EnvironmentDetails

use of com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails in project cloudbreak by hortonworks.

the class CDPEnvironmentStructuredFlowEventToCDPEnvironmentRequestedConverter method convert.

public UsageProto.CDPEnvironmentRequested convert(CDPEnvironmentStructuredFlowEvent cdpStructuredFlowEvent) {
    UsageProto.CDPEnvironmentRequested.Builder cdpEnvironmentRequestedBuilder = UsageProto.CDPEnvironmentRequested.newBuilder();
    if (cdpStructuredFlowEvent != null) {
        String cloudProvider = cdpStructuredFlowEvent.getPayload() != null ? cdpStructuredFlowEvent.getPayload().getCloudPlatform() : null;
        cdpEnvironmentRequestedBuilder.setOperationDetails(operationDetailsConverter.convert(cdpStructuredFlowEvent, cloudProvider));
        EnvironmentDetails environmentDetails = cdpStructuredFlowEvent.getPayload();
        cdpEnvironmentRequestedBuilder.setEnvironmentDetails(environmentDetailsConverter.convert(environmentDetails));
        cdpEnvironmentRequestedBuilder.setTelemetryFeatureDetails(telemetryFeatureDetailsConverter.convert(environmentDetails));
        cdpEnvironmentRequestedBuilder.setFreeIPA(freeIPADetailsConverter.convert(environmentDetails));
    }
    UsageProto.CDPEnvironmentRequested ret = cdpEnvironmentRequestedBuilder.build();
    LOGGER.debug("Converted CDPEnvironmentRequested event: {}", ret);
    return ret;
}
Also used : EnvironmentDetails(com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto)

Aggregations

EnvironmentDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.EnvironmentDetails)8 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)5 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)3 CDPEnvironmentStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.CDPEnvironmentStructuredFlowEvent)2 Environment (com.sequenceiq.environment.environment.domain.Environment)2 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 SubnetType (com.sequenceiq.cloudbreak.cloud.model.network.SubnetType)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 FlowDetails (com.sequenceiq.cloudbreak.structuredevent.event.FlowDetails)1 ProxyDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.environment.proxy.ProxyDetails)1 CcmV2TlsType (com.sequenceiq.common.api.type.CcmV2TlsType)1 PublicEndpointAccessGateway (com.sequenceiq.common.api.type.PublicEndpointAccessGateway)1 Tunnel (com.sequenceiq.common.api.type.Tunnel)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1