use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class UpdateAmbariRequestToUpdateClusterRequestConverter method convert.
@Override
public UpdateClusterJson convert(ReinstallRequestV2 source) {
UpdateClusterJson updateStackJson = new UpdateClusterJson();
updateStackJson.setValidateBlueprint(true);
updateStackJson.setKerberosPassword(source.getKerberosPassword());
updateStackJson.setKerberosPrincipal(source.getKerberosPrincipal());
Blueprint blueprint = blueprintRepository.findOneByName(source.getBlueprintName(), source.getAccount());
if (blueprint != null) {
updateStackJson.setBlueprintId(blueprint.getId());
updateStackJson.setAmbariStackDetails(source.getAmbariStackDetails());
Set<HostGroupRequest> hostgroups = new HashSet<>();
for (InstanceGroupV2Request instanceGroupV2Request : source.getInstanceGroups()) {
HostGroupRequest hostGroupRequest = new HostGroupRequest();
hostGroupRequest.setRecoveryMode(instanceGroupV2Request.getRecoveryMode());
hostGroupRequest.setRecipeNames(instanceGroupV2Request.getRecipeNames());
hostGroupRequest.setName(instanceGroupV2Request.getGroup());
ConstraintJson constraintJson = new ConstraintJson();
constraintJson.setHostCount(instanceGroupV2Request.getNodeCount());
constraintJson.setInstanceGroupName(instanceGroupV2Request.getGroup());
hostGroupRequest.setConstraint(constraintJson);
hostgroups.add(hostGroupRequest);
}
updateStackJson.setHostgroups(hostgroups);
} else {
throw new BadRequestException(String.format("Blueprint '%s' not available", source.getBlueprintName()));
}
return updateStackJson;
}
use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class MockClusterCreationWithSaltSuccessTest method convertHostGroups.
private Set<HostGroupRequest> convertHostGroups(Iterable<HostGroup> hostGroups, String runRecipesOnHosts) {
Set<Long> recipeIds = Collections.emptySet();
List<String> hostGroupsWithRecipe = Collections.emptyList();
if (!runRecipesOnHosts.isEmpty()) {
recipeIds = getItContext().getContextParam(CloudbreakITContextConstants.RECIPE_ID, Set.class);
Assert.assertFalse(recipeIds == null || recipeIds.isEmpty());
hostGroupsWithRecipe = Arrays.asList(runRecipesOnHosts.split(","));
}
Set<HostGroupRequest> hgMaps = new HashSet<>();
for (HostGroup hostgroup : hostGroups) {
HostGroupRequest hostGroupBase = new HostGroupRequest();
hostGroupBase.setName(hostgroup.getName());
ConstraintJson constraintJson = new ConstraintJson();
constraintJson.setInstanceGroupName(hostgroup.getInstanceGroupName());
constraintJson.setHostCount(hostgroup.getHostCount());
hostGroupBase.setConstraint(constraintJson);
if (hostGroupsWithRecipe.contains(hostgroup.getName())) {
hostGroupBase.setRecipeIds(recipeIds);
}
hgMaps.add(hostGroupBase);
}
return hgMaps;
}
use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class ClusterDecorator method convertHostGroupsFromJson.
private Set<HostGroup> convertHostGroupsFromJson(Stack stack, IdentityUser user, Cluster cluster, Iterable<HostGroupRequest> hostGroupsJsons) {
Set<HostGroup> hostGroups = new HashSet<>();
for (HostGroupRequest json : hostGroupsJsons) {
HostGroup hostGroup = conversionService.convert(json, HostGroup.class);
hostGroup.setCluster(cluster);
hostGroup = hostGroupDecorator.decorate(hostGroup, json, user, stack.getId(), true, stack.isPublicInAccount());
hostGroups.add(hostGroup);
}
return hostGroups;
}
Aggregations