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());
}
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));
}
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);
}
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());
}
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));
}
Aggregations