use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters 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());
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.
the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.
@Test
public void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
Stack stack = getAStack();
stack.setTunnel(Tunnel.CCMV2);
DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
verifyNoInteractions(ccmParameterSupplier);
verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
verify(stackService, never()).setMinaSshdServiceIdByStackId(any(), any());
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.
the class CcmUserDataServiceTest method testFetchAndSaveCcmParametersWhenCcmV2IsEnabled.
@Test
void testFetchAndSaveCcmParametersWhenCcmV2IsEnabled() {
Stack stack = getAStack();
stack.setTunnel(Tunnel.CCMV2);
DefaultCcmV2Parameters defaultCcmV2Parameters = mock(DefaultCcmV2Parameters.class);
FreeIpa freeIpa = mock(FreeIpa.class);
when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
when(freeIpa.getDomain()).thenReturn("cldr.work.site");
when(ccmV2ParameterSupplier.getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString())).thenReturn(defaultCcmV2Parameters);
when(defaultCcmV2Parameters.getAgentCrn()).thenReturn("testAgentCrn");
when(hostDiscoveryService.determineGatewayFqdn(any(), any())).thenReturn("datahub.master0.cldr.work.site");
CcmConnectivityParameters ccmParameters = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.fetchAndSaveCcmParameters(stack));
assertEquals(CcmConnectivityMode.CCMV2, ccmParameters.getConnectivityMode(), "CCM V2 should be enabled.");
assertEquals(defaultCcmV2Parameters, ccmParameters.getCcmV2Parameters(), "CCM V2 Parameters should match.");
verify(ccmV2ParameterSupplier, times(1)).getCcmV2Parameters(anyString(), any(Optional.class), anyString(), anyString());
verifyNoInteractions(ccmParameterSupplier);
verify(stackService, times(1)).setCcmV2AgentCrnByStackId(100L, "testAgentCrn");
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataWithCCMV2.
@Test
public void testBuildUserDataWithCCMV2() throws IOException {
CcmV2Parameters ccmV2Parameters = new DefaultCcmV2Parameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate");
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
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-init.sh");
Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.DefaultCcmV2Parameters in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataWithCCMV2Params.
@Test
@DisplayName("test if CCM V2 parameters are passed the user data contains them")
void testBuildUserDataWithCCMV2Params() throws IOException {
CcmV2Parameters ccmV2Parameters = new DefaultCcmV2Parameters("invertingProxyHost", "invertingProxyCertificate", "agentCrn", "agentKeyId", "agentEncipheredPrivateKey", "agentCertificate");
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
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);
String userData = underTest.buildUserData(ACCOUNT_ID, environment, Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", platformParameters, "pass", "cert", ccmConnectivityParameters, null);
String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-ccm-v2-init.sh");
assertEquals(expectedUserData, userData);
}
Aggregations