Search in sources :

Example 16 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class AltusMachineUserService method storeDataBusCredential.

/**
 * Store databus access / secret keypair and machine user name in the cluster if altus credential exists
 * @param altusCredential dto for databus access/private key
 * @param stack component will be attached to this stack
 * @return domain object that holds databus credential
 */
public DataBusCredential storeDataBusCredential(Optional<AltusCredential> altusCredential, Stack stack) {
    if (altusCredential.isPresent()) {
        DataBusCredential dataBusCredential = new DataBusCredential();
        dataBusCredential.setMachineUserName(getFluentDatabusMachineUserName(stack));
        dataBusCredential.setAccessKey(altusCredential.get().getAccessKey());
        dataBusCredential.setPrivateKey(altusCredential.get().getPrivateKey() != null ? new String(altusCredential.get().getPrivateKey()) : null);
        String databusCredentialJsonString = new Json(dataBusCredential).getValue();
        Cluster cluster = stack.getCluster();
        if (cluster != null) {
            cluster.setDatabusCredential(databusCredentialJsonString);
            clusterService.updateCluster(cluster);
        }
        return dataBusCredential;
    }
    return null;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) DataBusCredential(com.sequenceiq.common.api.telemetry.model.DataBusCredential)

Example 17 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class InstanceMetadataUpdater method updateInstanceMetaDataIfVersionQueryFailed.

private List<String> updateInstanceMetaDataIfVersionQueryFailed(Map<String, Map<String, String>> packageVersionsByNameByHost, Stack stack) throws IOException {
    Set<InstanceMetaData> instanceMetaDataSet = stack.getNotDeletedAndNotZombieInstanceMetaDataSet();
    List<String> failedVersionQueriesByHost = Lists.newArrayList();
    for (InstanceMetaData im : instanceMetaDataSet) {
        Map<String, String> packageVersionsOnHost = packageVersionsByNameByHost.get(im.getDiscoveryFQDN());
        if (CollectionUtils.isEmpty(packageVersionsOnHost)) {
            failedVersionQueriesByHost.add(im.getDiscoveryFQDN());
            Image image = im.getImage().get(Image.class);
            image.getPackageVersions().clear();
            im.setImage(new Json(image));
            im.setInstanceStatus(InstanceStatus.SERVICES_UNHEALTHY);
            im.setStatusReason("Version query is failed on host");
            instanceMetaDataService.save(im);
        }
    }
    return failedVersionQueriesByHost;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 18 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class StackDecorator method updateInstanceGroupParameters.

private void updateInstanceGroupParameters(Map<String, InstanceGroupParameterResponse> instanceGroupParameterResponses, InstanceGroup instanceGroup) {
    InstanceGroupParameterResponse instanceGroupParameterResponse = instanceGroupParameterResponses.get(instanceGroup.getGroupName());
    if (instanceGroupParameterResponse != null) {
        try {
            Json jsonProperties = new Json(instanceGroupParameterResponse.getParameters());
            instanceGroup.setAttributes(jsonProperties);
        } catch (IllegalArgumentException e) {
            LOGGER.info("Could not update '{}' instancegroup parameters with defaults.", instanceGroupParameterResponse.getGroupName());
        }
    }
}
Also used : InstanceGroupParameterResponse(com.sequenceiq.cloudbreak.cloud.model.InstanceGroupParameterResponse) Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 19 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class ImageService method addImage.

private void addImage(Stack stack, Map<InstanceGroupType, String> userData, StatedImage statedImage, String imageName, com.sequenceiq.cloudbreak.cloud.model.catalog.Image catalogBasedImage, Set<Component> components) {
    Image image = new Image(imageName, userData, catalogBasedImage.getOs(), catalogBasedImage.getOsType(), statedImage.getImageCatalogUrl(), statedImage.getImageCatalogName(), catalogBasedImage.getUuid(), catalogBasedImage.getPackageVersions());
    components.add(new Component(IMAGE, IMAGE.name(), new Json(image), stack));
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Component(com.sequenceiq.cloudbreak.domain.stack.Component)

Example 20 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class ImageService method addCmRepo.

private void addCmRepo(Stack stack, Set<Component> components, com.sequenceiq.cloudbreak.cloud.model.catalog.Image catalogBasedImage) throws CloudbreakImageCatalogException {
    if (catalogBasedImage.getStackDetails() != null) {
        ImageStackDetails stackDetails = catalogBasedImage.getStackDetails();
        StackType stackType = determineStackType(stackDetails);
        ClouderaManagerRepo clouderaManagerRepo = getClouderaManagerRepo(catalogBasedImage, stackType);
        components.add(new Component(CM_REPO_DETAILS, CM_REPO_DETAILS.name(), new Json(clouderaManagerRepo), stack));
    } else {
        LOGGER.debug("There are no stackDetails for stack {}, cannot determine CM repo version.", stack.getName());
    }
}
Also used : StackType(com.sequenceiq.cloudbreak.cloud.model.component.StackType) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) ImageStackDetails(com.sequenceiq.cloudbreak.cloud.model.catalog.ImageStackDetails) Json(com.sequenceiq.cloudbreak.common.json.Json) Component(com.sequenceiq.cloudbreak.domain.stack.Component)

Aggregations

Json (com.sequenceiq.cloudbreak.common.json.Json)266 Test (org.junit.jupiter.api.Test)95 HashMap (java.util.HashMap)49 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)31 Template (com.sequenceiq.freeipa.entity.Template)26 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)25 List (java.util.List)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)23 Map (java.util.Map)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)21 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)21 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)21 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)20 IOException (java.io.IOException)20 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)16 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)14