Search in sources :

Example 1 with DefaultCcmV2JumpgateParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters 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 2 with DefaultCcmV2JumpgateParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters in project cloudbreak by hortonworks.

the class SaltConfigProviderTest method testGetSaltConfig.

@Test
public void testGetSaltConfig() throws Exception {
    Stack stack = mock(Stack.class);
    when(stack.getCcmParameters()).thenReturn(new CcmConnectivityParameters(new DefaultCcmV2JumpgateParameters()));
    FreeIpaConfigView freeIpaConfigView = mock(FreeIpaConfigView.class);
    Map freeIpaConfigViewMap = mock(Map.class);
    when(freeIpaConfigService.createFreeIpaConfigs(any(), any())).thenReturn(freeIpaConfigView);
    when(stack.getCloudPlatform()).thenReturn(CLOUD_PLATFORM);
    when(freeIpaConfigView.toMap()).thenReturn(freeIpaConfigViewMap);
    when(telemetryConfigService.createTelemetryPillarConfig(any())).thenReturn(Map.of());
    when(proxyConfigService.createProxyPillarConfig(any())).thenReturn(Map.of());
    when(tagConfigService.createTagsPillarConfig(any())).thenReturn(Map.of());
    when(ccmParametersConfigService.createCcmParametersPillarConfig(any(), any())).thenReturn(Map.of(PILLAR, new SaltPillarProperties(PILLARPATH, Map.of(PILLARKEY, PILLARVALUE))));
    SaltConfig saltConfig = underTest.getSaltConfig(stack, Set.of());
    Map<String, SaltPillarProperties> servicePillarConfig = saltConfig.getServicePillarConfig();
    assertNotNull(servicePillarConfig);
    SaltPillarProperties freeIpaProperties = servicePillarConfig.get("freeipa");
    assertNotNull(freeIpaProperties);
    assertEquals("/freeipa/init.sls", freeIpaProperties.getPath());
    assertEquals(freeIpaConfigViewMap, freeIpaProperties.getProperties().get("freeipa"));
    SaltPillarProperties discoveryProperties = servicePillarConfig.get("discovery");
    assertNotNull(discoveryProperties);
    assertEquals("/discovery/init.sls", discoveryProperties.getPath());
    assertEquals(CLOUD_PLATFORM, discoveryProperties.getProperties().get("platform"));
    SaltPillarProperties pillarProperties = servicePillarConfig.get(PILLAR);
    assertNotNull(pillarProperties);
    assertEquals(PILLARPATH, pillarProperties.getPath());
    assertEquals(PILLARVALUE, pillarProperties.getProperties().get(PILLARKEY));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) FreeIpaConfigView(com.sequenceiq.freeipa.service.freeipa.config.FreeIpaConfigView) Map(java.util.Map) SaltPillarProperties(com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultCcmV2JumpgateParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataWithCCMV2JumpgateParams.

@ParameterizedTest(name = "Forced TLS mode = {0}, entitlement = {1}, filename = {2}")
@MethodSource("tlsCases")
@DisplayName("test if CCM V2 Jumpgate parameters are passed the user data contains them")
void testBuildUserDataWithCCMV2JumpgateParams(CcmV2TlsType ccmV2TlsType, boolean oneWayTlsEntitlementEnabled, String expectedContentFileName) throws IOException {
    CcmV2JumpgateParameters ccmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate", "environmentCrn", "agentMachineUserAccessKeyId", "agentMachineUserEncipheredAccessKey");
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
    PlatformParameters platformParameters = mock(PlatformParameters.class);
    ScriptParams scriptParams = mock(ScriptParams.class);
    when(scriptParams.getDiskPrefix()).thenReturn("sd");
    when(scriptParams.getStartLabel()).thenReturn(98);
    when(platformParameters.scriptParams()).thenReturn(scriptParams);
    lenient().when(entitlementService.ccmV2UseOneWayTls(ACCOUNT_ID)).thenReturn(oneWayTlsEntitlementEnabled);
    environment.setCcmV2TlsType(ccmV2TlsType);
    String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", ccmConnectivityParameters, null);
    String expectedUserData = FileReaderUtils.readFileFromClasspath(expectedContentFileName);
    assertEquals(expectedUserData, userData);
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) ScriptParams(com.sequenceiq.cloudbreak.cloud.model.ScriptParams) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with DefaultCcmV2JumpgateParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters in project cloudbreak by hortonworks.

the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2JumpgateIsEnabled.

@Test
void testFetchAndSaveCcmParametersWhenCcmV2JumpgateIsEnabled() {
    Stack stack = getAStack();
    stack.setTunnel(Tunnel.CCMV2_JUMPGATE);
    DefaultCcmV2JumpgateParameters defaultCcmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters();
    CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
    assertEquals(CcmConnectivityMode.CCMV2_JUMPGATE, ccmParameters.getConnectivityMode(), "CCM V2 Jumpgate should be enabled.");
    assertThat(ccmParameters.getCcmV2JumpgateParameters()).withFailMessage("CCM V2 Jumpgate Parameters should match.").isEqualToComparingFieldByField(defaultCcmV2JumpgateParameters);
    verifyNoInteractions(ccmParameterSupplier);
    verify(stackService, never()).setCcmV2AgentCrnByStackId(anyLong(), anyString());
    verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 5 with DefaultCcmV2JumpgateParameters

use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters in project cloudbreak by hortonworks.

the class UserDataBuilderTest method testBuildUserDataWithCCMV2Jumpgate.

@Test
public void testBuildUserDataWithCCMV2Jumpgate() throws IOException {
    CcmV2JumpgateParameters ccmV2JumpgateParameters = new DefaultCcmV2JumpgateParameters();
    CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2JumpgateParameters);
    Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
    String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
    String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-v2-jumpgate-init.sh");
    Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
    Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
}
Also used : CcmConnectivityParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) DefaultCcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters) CcmV2JumpgateParameters(com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters) Test(org.junit.Test)

Aggregations

DefaultCcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2JumpgateParameters)6 CcmConnectivityParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmConnectivityParameters)5 Test (org.junit.jupiter.api.Test)3 CcmV2JumpgateParameters (com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2JumpgateParameters)2 Stack (com.sequenceiq.freeipa.entity.Stack)2 InvertingProxy (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxy)1 InvertingProxyAgent (com.cloudera.thunderhead.service.clusterconnectivitymanagementv2.ClusterConnectivityManagementV2Proto.InvertingProxyAgent)1 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)1 ScriptParams (com.sequenceiq.cloudbreak.cloud.model.ScriptParams)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)1 SaltPillarProperties (com.sequenceiq.cloudbreak.orchestrator.model.SaltPillarProperties)1 InstanceGroupType (com.sequenceiq.common.api.type.InstanceGroupType)1 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)1 FreeIpaConfigView (com.sequenceiq.freeipa.service.freeipa.config.FreeIpaConfigView)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Test (org.junit.Test)1 DisplayName (org.junit.jupiter.api.DisplayName)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1