use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class ClusterCreationSetupService method prepare.
public Cluster prepare(ClusterRequest request, Stack stack, Blueprint blueprint, IdentityUser user) throws Exception {
String stackName = stack.getName();
long start = System.currentTimeMillis();
Cluster cluster = conversionService.convert(request, Cluster.class);
cluster.setStack(stack);
LOGGER.info("Cluster conversion took {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
cluster = clusterDecorator.decorate(cluster, request, blueprint, user, stack);
LOGGER.info("Cluster object decorated in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
List<ClusterComponent> components = new ArrayList<>();
Set<Component> allComponent = componentConfigProvider.getAllComponentsByStackIdAndType(stack.getId(), Sets.newHashSet(ComponentType.AMBARI_REPO_DETAILS, ComponentType.HDP_REPO_DETAILS, ComponentType.IMAGE));
Optional<Component> stackAmbariRepoConfig = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.AMBARI_REPO_DETAILS) && c.getName().equalsIgnoreCase(ComponentType.AMBARI_REPO_DETAILS.name())).findAny();
Optional<Component> stackHdpRepoConfig = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.HDP_REPO_DETAILS) && c.getName().equalsIgnoreCase(ComponentType.HDP_REPO_DETAILS.name())).findAny();
Optional<Component> stackImageComponent = allComponent.stream().filter(c -> c.getComponentType().equals(ComponentType.IMAGE) && c.getName().equalsIgnoreCase(ComponentType.IMAGE.name())).findAny();
ClusterComponent ambariRepoConfig = determineAmbariRepoConfig(stackAmbariRepoConfig, request.getAmbariRepoDetailsJson(), stackImageComponent, cluster);
components.add(ambariRepoConfig);
ClusterComponent hdpRepoConfig = determineHDPRepoConfig(blueprint, stack.getId(), stackHdpRepoConfig, request, cluster, user, stackImageComponent);
components.add(hdpRepoConfig);
checkVDFFile(ambariRepoConfig, hdpRepoConfig, stackName);
LOGGER.info("Cluster components saved in {} ms for stack {}", System.currentTimeMillis() - start, stackName);
start = System.currentTimeMillis();
Cluster savedCluster = clusterService.create(user, stack, cluster, components);
LOGGER.info("Cluster object creation took {} ms for stack {}", System.currentTimeMillis() - start, stackName);
return savedCluster;
}
use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class MockClusterCreationWithSaltFailTest method testClusterCreation.
@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
// GIVEN
IntegrationTestContext itContext = getItContext();
String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
Integer stackId = Integer.valueOf(stackIdStr);
Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
// WHEN
ClusterRequest clusterRequest = new ClusterRequest();
clusterRequest.setName(clusterName);
clusterRequest.setDescription("Cluster for integration test");
clusterRequest.setEnableSecurity(enableSecurity);
clusterRequest.setPassword(ambariPassword);
clusterRequest.setUserName(ambariUser);
clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
clusterRequest.setHostGroups(hostGroupJsons1);
KerberosRequest kerberosRequest = new KerberosRequest();
kerberosRequest.setAdmin(kerberosAdmin);
kerberosRequest.setPassword(kerberosPassword);
kerberosRequest.setMasterKey(kerberosMasterKey);
clusterRequest.setKerberos(kerberosRequest);
initSpark();
Map<String, CloudVmMetaDataStatus> instanceMap = itContext.getContextParam(CloudbreakITContextConstants.MOCK_INSTANCE_MAP, Map.class);
addSaltMappings(instanceMap);
addAmbariMappings(instanceMap);
ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
// THEN
Assert.assertNotNull(clusterId);
CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
String failMessage = "Source file salt://ambari/scripts/ambari-server-initttt.sh not found | " + "Service ambari-server is already enabled, and is dead | " + "Package haveged is already installed.";
CloudbreakUtil.checkClusterFailed(getCloudbreakClient().stackV1Endpoint(), stackIdStr, failMessage);
}
use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class MockClusterCreationWithSaltSuccessTest method testClusterCreation.
@Test
@Parameters({ "clusterName", "ambariPort", "ambariUser", "ambariPassword", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "mockPort" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("8080") String ambariPort, @Optional("admin") String ambariUser, @Optional("admin123!@#") String ambariPassword, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("9443") int mockPort) throws Exception {
// GIVEN
IntegrationTestContext itContext = getItContext();
String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
Integer stackId = Integer.valueOf(stackIdStr);
Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts);
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_USER_ID, ambariUser);
itContext.putContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID, ambariPassword);
// WHEN
ClusterRequest clusterRequest = new ClusterRequest();
clusterRequest.setName(clusterName);
clusterRequest.setDescription("Cluster for integration test");
clusterRequest.setEmailNeeded(emailNeeded);
clusterRequest.setEnableSecurity(enableSecurity);
clusterRequest.setPassword(ambariPassword);
clusterRequest.setUserName(ambariUser);
clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
clusterRequest.setHostGroups(hostGroupJsons1);
if (enableSecurity) {
KerberosRequest kerberosRequest = new KerberosRequest();
kerberosRequest.setAdmin(kerberosAdmin);
kerberosRequest.setPassword(kerberosPassword);
kerberosRequest.setMasterKey(kerberosMasterKey);
clusterRequest.setKerberos(kerberosRequest);
}
GatewayJson gatewayJson = new GatewayJson();
gatewayJson.setEnableGateway(Boolean.TRUE);
gatewayJson.setExposedServices(ImmutableList.of("ALL"));
clusterRequest.setGateway(gatewayJson);
ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
// THEN
Assert.assertNotNull(clusterId);
CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
StackCreationMock stackCreationMock = getItContext().getContextParam(CloudbreakV2Constants.MOCK_SERVER, StackCreationMock.class);
stackCreationMock.verifyCalls(clusterName);
}
use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class ClusterCreationTest method testClusterCreation.
@Test
@Parameters({ "clusterName", "emailNeeded", "enableSecurity", "kerberosMasterKey", "kerberosAdmin", "kerberosPassword", "runRecipesOnHosts", "checkAmbari", "withRDSConfig", "autoRecoveryMode", "withFs" })
public void testClusterCreation(@Optional("it-cluster") String clusterName, @Optional("false") boolean emailNeeded, @Optional("false") boolean enableSecurity, @Optional String kerberosMasterKey, @Optional String kerberosAdmin, @Optional String kerberosPassword, @Optional("") String runRecipesOnHosts, @Optional("true") boolean checkAmbari, @Optional("false") boolean withRDSConfig, @Optional("false") boolean autoRecoveryMode, @Optional("false") boolean withFs) throws Exception {
// GIVEN
IntegrationTestContext itContext = getItContext();
String stackIdStr = itContext.getContextParam(CloudbreakITContextConstants.STACK_ID);
Integer stackId = Integer.valueOf(stackIdStr);
Integer blueprintId = Integer.valueOf(itContext.getContextParam(CloudbreakITContextConstants.BLUEPRINT_ID));
List<HostGroup> hostgroups = itContext.getContextParam(CloudbreakITContextConstants.HOSTGROUP_ID, List.class);
Set<HostGroupRequest> hostGroupJsons1 = convertHostGroups(hostgroups, runRecipesOnHosts, autoRecoveryMode);
String ambariUser = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_USER_ID);
String ambariPassword = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PASSWORD_ID);
String ambariPort = itContext.getContextParam(CloudbreakITContextConstants.AMBARI_PORT_ID);
// WHEN
ClusterRequest clusterRequest = new ClusterRequest();
clusterRequest.setName(clusterName);
clusterRequest.setDescription("Cluster for integration test");
clusterRequest.setEnableSecurity(enableSecurity);
clusterRequest.setPassword(ambariPassword);
clusterRequest.setUserName(ambariUser);
clusterRequest.setBlueprintId(Long.valueOf(blueprintId));
clusterRequest.setHostGroups(hostGroupJsons1);
if (withRDSConfig) {
clusterRequest = setRDSConfiguration(itContext, clusterRequest);
}
if (withFs) {
clusterRequest = setFileSystem(itContext, clusterRequest);
}
if (enableSecurity) {
KerberosRequest kerberosRequest = new KerberosRequest();
kerberosRequest.setAdmin(kerberosAdmin);
kerberosRequest.setPassword(kerberosPassword);
kerberosRequest.setMasterKey(kerberosMasterKey);
clusterRequest.setKerberos(kerberosRequest);
}
ClusterV1Endpoint clusterV1Endpoint = getCloudbreakClient().clusterEndpoint();
Long clusterId = clusterV1Endpoint.post(Long.valueOf(stackId), clusterRequest).getId();
// THEN
Assert.assertNotNull(clusterId);
CloudbreakUtil.waitAndCheckStackStatus(getCloudbreakClient(), stackIdStr, "AVAILABLE");
CloudbreakUtil.checkClusterAvailability(getCloudbreakClient().stackV1Endpoint(), ambariPort, stackIdStr, ambariUser, ambariPassword, checkAmbari);
if (Boolean.TRUE.equals(withRDSConfig)) {
checkRDSConfigWithCluster(itContext, clusterName);
}
}
use of com.sequenceiq.cloudbreak.api.model.ClusterRequest in project cloudbreak by hortonworks.
the class ClusterV2RequestToClusterRequestConverter method convert.
@Override
public ClusterRequest convert(ClusterV2Request source) {
ClusterRequest cluster = new ClusterRequest();
cluster.setExecutorType(source.getExecutorType());
cluster.setEmailNeeded(source.getEmailNeeded());
cluster.setEmailTo(source.getEmailTo());
cluster.setFileSystem(source.getFileSystem());
cluster.setName(source.getName());
if (source.getRdsConfigNames() != null && !source.getRdsConfigNames().isEmpty()) {
cluster.setRdsConfigNames(source.getRdsConfigNames());
}
cluster.setProxyName(source.getProxyName());
cluster.setLdapConfigName(source.getLdapConfigName());
AmbariV2Request ambariRequest = source.getAmbari();
if (ambariRequest != null) {
cluster.setAmbariDatabaseDetails(ambariRequest.getAmbariDatabaseDetails());
cluster.setAmbariRepoDetailsJson(ambariRequest.getAmbariRepoDetailsJson());
cluster.setAmbariStackDetails(ambariRequest.getAmbariStackDetails());
cluster.setBlueprintCustomPropertiesAsString(ambariRequest.getBlueprintCustomProperties());
cluster.setBlueprintId(ambariRequest.getBlueprintId());
cluster.setBlueprintName(ambariRequest.getBlueprintName());
cluster.setBlueprintInputs(ambariRequest.getBlueprintInputs());
cluster.setConfigStrategy(ambariRequest.getConfigStrategy());
cluster.setConnectedCluster(ambariRequest.getConnectedCluster());
cluster.setEnableSecurity(ambariRequest.getEnableSecurity());
cluster.setGateway(ambariRequest.getGateway());
cluster.setKerberos(ambariRequest.getKerberos());
cluster.setPassword(ambariRequest.getPassword());
cluster.setUserName(ambariRequest.getUserName());
cluster.setValidateBlueprint(ambariRequest.getValidateBlueprint());
cluster.setAmbariSecurityMasterKey(ambariRequest.getAmbariSecurityMasterKey());
}
cluster.setHostGroups(new HashSet<>());
return cluster;
}
Aggregations