Search in sources :

Example 1 with InvertingProxyAgent

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent in project cloudbreak by hortonworks.

the class GrpcCcmV2Client method registerAgent.

public InvertingProxyAgent registerAgent(String requestId, String accountId, Optional<String> environmentCrnOpt, String domainName, String keyId, String actorCrn) {
    try (ManagedChannelWrapper channelWrapper = makeWrapper()) {
        ClusterConnectivityManagementV2BlockingStub client = makeClient(channelWrapper.getChannel(), requestId, actorCrn);
        RegisterAgentRequest.Builder registerAgentRequestBuilder = RegisterAgentRequest.newBuilder().setAccountId(accountId).setDomainName(domainName).setKeyId(keyId);
        environmentCrnOpt.ifPresent(registerAgentRequestBuilder::setEnvironmentCrn);
        RegisterAgentRequest registerAgentRequest = registerAgentRequestBuilder.build();
        LOGGER.debug("Calling registerAgent with params accountId: '{}', environmentCrnOpt: '{}', domainName: '{}', keyId:'{}' ", accountId, environmentCrnOpt, domainName, keyId);
        RegisterAgentResponse registerAgentResponse = client.registerAgent(registerAgentRequest);
        return registerAgentResponse.getInvertingProxyAgent();
    }
}
Also used : RegisterAgentResponse(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentResponse) RegisterAgentRequest(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentRequest) ManagedChannelWrapper(com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper) ClusterConnectivityManagementV2BlockingStub(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)

Example 2 with InvertingProxyAgent

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent in project cloudbreak by hortonworks.

the class DefaultCcmV2JumpgateParameterSupplier method getCcmV2JumpgateParameters.

@Override
public CcmV2JumpgateParameters getCcmV2JumpgateParameters(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    InvertingProxyAndAgent invertingProxyAndAgent = getInvertingProxyAndAgent(accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    InvertingProxy invertingProxy = invertingProxyAndAgent.getInvertingProxy();
    InvertingProxyAgent invertingProxyAgent = invertingProxyAndAgent.getInvertingProxyAgent();
    LOGGER.debug("CcmV2JumpgateConfig successfully retrieved InvertingProxyHost: '{}', InvertingProxyStatus: '{}', InvertingProxyAgentCrn: '{}', " + "EnvironmentCrnOpt: '{}'", invertingProxy.getHostname(), invertingProxy.getStatus(), invertingProxyAgent.getAgentCrn(), invertingProxyAgent.getEnvironmentCrn());
    return new DefaultCcmV2JumpgateParameters(invertingProxy.getHostname(), invertingProxy.getCertificate(), invertingProxyAgent.getAgentCrn(), agentKeyId, invertingProxyAgent.getEncipheredPrivateKey(), invertingProxyAgent.getCertificate(), invertingProxyAgent.getEnvironmentCrn(), invertingProxyAgent.getAccessKeyId(), invertingProxyAgent.getEncipheredAccessKey());
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)

Example 3 with InvertingProxyAgent

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent in project cloudbreak by hortonworks.

the class DefaultCcmV2ParameterSupplier method getCcmV2Parameters.

public CcmV2Parameters getCcmV2Parameters(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    InvertingProxyAndAgent invertingProxyAndAgent = getInvertingProxyAndAgent(accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    InvertingProxy invertingProxy = invertingProxyAndAgent.getInvertingProxy();
    InvertingProxyAgent invertingProxyAgent = invertingProxyAndAgent.getInvertingProxyAgent();
    LOGGER.debug("CcmV2Config successfully retrieved InvertingProxyHost: '{}', InvertingProxyStatus: '{}', InvertingProxyAgentCrn: '{}', " + "EnvironmentCrnOpt: '{}'", invertingProxy.getHostname(), invertingProxy.getStatus(), invertingProxyAgent.getAgentCrn(), Optional.of(invertingProxyAgent.getEnvironmentCrn()));
    return new DefaultCcmV2Parameters(invertingProxy.getHostname(), invertingProxy.getCertificate(), invertingProxyAgent.getAgentCrn(), agentKeyId, invertingProxyAgent.getEncipheredPrivateKey(), invertingProxyAgent.getCertificate());
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)

Example 4 with InvertingProxyAgent

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent in project cloudbreak by hortonworks.

the class DefaultCcmV2ParameterSupplier method getInvertingProxyAndAgent.

protected InvertingProxyAndAgent getInvertingProxyAndAgent(@Nonnull String accountId, @Nonnull Optional<String> environmentCrnOpt, @Nonnull String clusterGatewayDomain, @Nonnull String agentKeyId) {
    String requestId = MDCBuilder.getOrGenerateRequestId();
    InvertingProxy invertingProxy = ccmV2Client.awaitReadyInvertingProxyForAccount(requestId, accountId);
    unregisterExistingAgent(requestId, accountId, environmentCrnOpt, agentKeyId);
    InvertingProxyAgent invertingProxyAgent = ccmV2Client.registerInvertingProxyAgent(requestId, accountId, environmentCrnOpt, clusterGatewayDomain, agentKeyId);
    validateCcmV2ConfigResponse(invertingProxy, invertingProxyAgent);
    return new InvertingProxyAndAgent(invertingProxy, invertingProxyAgent);
}
Also used : InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)

Example 5 with InvertingProxyAgent

use of com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent in project cloudbreak by hortonworks.

the class DefaultCcmV2ParameterSupplier method unregisterExistingAgent.

private void unregisterExistingAgent(String requestId, String accountId, Optional<String> environmentCrnOpt, String agentKeyId) {
    try {
        List<InvertingProxyAgent> invertingProxyAgents = ccmV2Client.listInvertingProxyAgents(requestId, accountId, environmentCrnOpt);
        Optional<InvertingProxyAgent> registeredAgentWithSameKey = invertingProxyAgents.stream().filter(agent -> agentKeyId.equals(CcmResourceUtil.getKeyId(agent.getAgentCrn()))).findFirst();
        registeredAgentWithSameKey.ifPresent(agent -> ccmV2Client.deregisterInvertingProxyAgent(requestId, agent.getAgentCrn()));
    } catch (CcmV2Exception e) {
        throw new CcmV2Exception("Error in trying to deregister possibly existing CCM Agent", e);
    }
}
Also used : Logger(org.slf4j.Logger) CcmV2ManagementClient(com.sequenceiq.cloudbreak.ccmimpl.ccmv2.CcmV2ManagementClient) LoggerFactory(org.slf4j.LoggerFactory) CcmResourceUtil(com.sequenceiq.cloudbreak.ccm.key.CcmResourceUtil) MDCBuilder(com.sequenceiq.cloudbreak.logger.MDCBuilder) StringUtils(org.apache.commons.lang3.StringUtils) CcmV2ParameterSupplier(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2ParameterSupplier) Inject(javax.inject.Inject) InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) List(java.util.List) Component(org.springframework.stereotype.Component) CcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters) CcmV2Exception(com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception) Optional(java.util.Optional) InvertingProxy(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy) DefaultCcmV2Parameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters) Nonnull(javax.annotation.Nonnull) InvertingProxyAgent(com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent) CcmV2Exception(com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception)

Aggregations

InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)10 InvertingProxy (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)7 Optional (java.util.Optional)4 ClusterConnectivityManagementV2BlockingStub (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Grpc.ClusterConnectivityManagementV2BlockingStub)2 DefaultCcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters)2 CcmV2Exception (com.sequenceiq.cloudbreak.ccm.exception.CcmV2Exception)2 ManagedChannelWrapper (com.sequenceiq.cloudbreak.grpc.ManagedChannelWrapper)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ListAgentsRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest)1 Builder (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsRequest.Builder)1 ListAgentsResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.ListAgentsResponse)1 RegisterAgentRequest (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentRequest)1 RegisterAgentResponse (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.RegisterAgentResponse)1 PageToken (com.cloudera.thunderhead.service.common.paging.PagingProto.PageToken)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 CcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)1 CcmV2ParameterSupplier (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2ParameterSupplier)1 CcmV2Parameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters)1