Search in sources :

Example 11 with HostGroupRequest

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;
}
Also used : InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) HashSet(java.util.HashSet)

Example 12 with HostGroupRequest

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;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.it.cloudbreak.HostGroup) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) HashSet(java.util.HashSet)

Example 13 with HostGroupRequest

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;
}
Also used : HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HashSet(java.util.HashSet)

Aggregations

HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)13 HashSet (java.util.HashSet)7 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)5 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)4 HostGroup (com.sequenceiq.it.cloudbreak.HostGroup)4 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)3 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)3 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 Set (java.util.Set)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1