use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters in project cloudbreak by hortonworks.
the class DefaultCcmV2ParameterSupplierTest method testGetCcmV2Parameter.
@Test
void testGetCcmV2Parameter() {
setupRegisterInvertingProxyDetails();
CcmV2Parameters resultParameters = underTest.getCcmV2Parameters(TEST_ACCOUNT_ID, Optional.of(TEST_ENVIRONMENT_CRN), TEST_GATEWAY_DOMAIN, Crn.fromString(TEST_CLUSTER_CRN).getResource());
assertResult(resultParameters);
verify(ccmV2Client).listInvertingProxyAgents(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)));
verify(ccmV2Client).registerInvertingProxyAgent(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)), eq(TEST_GATEWAY_DOMAIN), eq(TEST_RESOURCE_ID));
verify(ccmV2Client, never()).deregisterInvertingProxyAgent(any(), any());
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters in project cloudbreak by hortonworks.
the class CcmUserDataService method getCcmV2ConnectivityParameters.
private CcmConnectivityParameters getCcmV2ConnectivityParameters(Stack stack) {
String generatedGatewayFqdn = getGatewayFqdn(stack);
CcmV2Parameters ccmV2Parameters = ccmV2ParameterSupplier.getCcmV2Parameters(ThreadBasedUserCrnProvider.getAccountId(), Optional.empty(), generatedGatewayFqdn, CcmResourceUtil.getKeyId(stack.getResourceCrn()));
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmV2Parameters);
saveCcmV2Config(stack.getId(), ccmV2Parameters);
return ccmConnectivityParameters;
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters 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.CcmV2Parameters in project cloudbreak by hortonworks.
the class DefaultCcmV2ParameterSupplierTest method unregisterAgentIsCalledWhenExisted.
@Test
void unregisterAgentIsCalledWhenExisted() {
setupRegisterInvertingProxyDetails();
when(ccmV2Client.listInvertingProxyAgents(any(), any(), any())).thenReturn(List.of(InvertingProxyAgent.newBuilder().setAgentCrn(TEST_AGENT_CRN).build()));
CcmV2Parameters resultParameters = underTest.getCcmV2Parameters(TEST_ACCOUNT_ID, Optional.of(TEST_ENVIRONMENT_CRN), TEST_GATEWAY_DOMAIN, Crn.fromString(TEST_CLUSTER_CRN).getResource());
assertResult(resultParameters);
verify(ccmV2Client).listInvertingProxyAgents(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)));
verify(ccmV2Client).registerInvertingProxyAgent(anyString(), eq(TEST_ACCOUNT_ID), eq(Optional.of(TEST_ENVIRONMENT_CRN)), eq(TEST_GATEWAY_DOMAIN), eq(TEST_RESOURCE_ID));
verify(ccmV2Client).deregisterInvertingProxyAgent(any(), eq(TEST_AGENT_CRN));
}
use of com.sequenceiq.cloudbreak.ccm.cloudinit.CcmV2Parameters 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