use of com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint in project cloudbreak by hortonworks.
the class DefaultCcmParameterSupplier method createServerParameters.
/**
* Creates server parameters based on the specified minasshd service.
*
* @param minaSshdService the minasshd service
* @return the server parameters
*/
private DefaultServerParameters createServerParameters(MinaSshdService minaSshdService) {
MinaSshdManagementProto.SshTunnelingConfiguration sshTunnelingConfiguration = minaSshdService.getSshTunnelingConfiguration();
MinaSshdManagementProto.NlbPort nlbPort = sshTunnelingConfiguration.getNlbPort();
String ccmHostAddressString = nlbPort.getNlbFqdn();
int ccmPort = nlbPort.getPort();
String ccmPublicKey = sshTunnelingConfiguration.getSshdPublicKey().toStringUtf8();
String minaSshdServiceId = minaSshdService.getMinaSshdServiceId();
return new DefaultServerParameters(new BaseServiceEndpoint(new HostEndpoint(ccmHostAddressString), ccmPort, null), "ssh-rsa " + ccmPublicKey + "\n", minaSshdServiceId);
}
use of com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataWithCCM.
@Test
public void testBuildUserDataWithCCM() throws IOException {
BaseServiceEndpoint serviceEndpoint = new BaseServiceEndpoint(new HostEndpoint("ccm.cloudera.com"));
DefaultServerParameters serverParameters = new DefaultServerParameters(serviceEndpoint, "pub-key", "mina-id");
DefaultInstanceParameters instanceParameters = new DefaultInstanceParameters("tunnel-id", "key-id", "private-key");
DefaultTunnelParameters nginxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.GATEWAY, 9443);
DefaultTunnelParameters knoxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.KNOX, 8443);
CcmParameters ccmParameters = new DefaultCcmParameters(serverParameters, instanceParameters, List.of(nginxTunnel, knoxTunnel));
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmParameters);
Map<InstanceGroupType, String> userdata = underTest.buildUserData(Platform.platform("AZURE"), "priv-key".getBytes(), "cloudbreak", getPlatformParameters(), "pass", "cert", ccmConnectivityParameters, null);
String expectedGwScript = FileReaderUtils.readFileFromClasspath("azure-gateway-ccm-init.sh");
String expectedCoreScript = FileReaderUtils.readFileFromClasspath("azure-core-ccm-init.sh");
Assert.assertEquals(expectedGwScript, userdata.get(InstanceGroupType.GATEWAY));
Assert.assertEquals(expectedCoreScript, userdata.get(InstanceGroupType.CORE));
}
use of com.sequenceiq.cloudbreak.ccm.endpoint.BaseServiceEndpoint in project cloudbreak by hortonworks.
the class UserDataBuilderTest method testBuildUserDataWithCCMParams.
@Test
@DisplayName("test if CCM parameters are passed the user data contains them")
void testBuildUserDataWithCCMParams() throws IOException {
BaseServiceEndpoint serviceEndpoint = new BaseServiceEndpoint(new HostEndpoint("ccm.cloudera.com"));
DefaultServerParameters serverParameters = new DefaultServerParameters(serviceEndpoint, "pub-key", "mina-id");
DefaultInstanceParameters instanceParameters = new DefaultInstanceParameters("tunnel-id", "key-id", "private-key");
DefaultTunnelParameters nginxTunnel = new DefaultTunnelParameters(KnownServiceIdentifier.GATEWAY, 9443);
CcmParameters ccmParameters = new DefaultCcmParameters(serverParameters, instanceParameters, List.of(nginxTunnel));
CcmConnectivityParameters ccmConnectivityParameters = new CcmConnectivityParameters(ccmParameters);
ProxyAuthentication proxyAuthentication = ProxyAuthentication.builder().withUserName("user").withPassword("pwd").build();
ProxyConfig proxyConfig = ProxyConfig.builder().withServerHost("proxy.host").withServerPort(1234).withProxyAuthentication(proxyAuthentication).withNoProxyHosts("noproxy.com").withProtocol("https").build();
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, proxyConfig);
String expectedUserData = FileReaderUtils.readFileFromClasspath("azure-ccm-init.sh");
assertEquals(expectedUserData, userData);
}
Aggregations