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;
}
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;
}
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());
}
}
}
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));
}
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());
}
}
Aggregations