use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogService method delete.
public void delete(String name) {
if (isEnvDefault(name)) {
throw new BadRequestException(String.format("%s cannot be deleted because it is an environment default image catalog.", name));
}
ImageCatalog imageCatalog = get(name);
authorizationService.hasWritePermission(imageCatalog);
imageCatalog.setArchived(true);
setImageCatalogAsDefault(null);
imageCatalog.setImageCatalogName(generateArchiveName(name));
imageCatalogRepository.save(imageCatalog);
LOGGER.info("Image catalog has been archived: {}", imageCatalog);
}
use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogService method removeDefaultFlag.
private void removeDefaultFlag() {
ImageCatalog imageCatalog = getDefaultImageCatalog();
if (imageCatalog != null) {
setImageCatalogAsDefault(null);
imageCatalogRepository.save(imageCatalog);
}
}
use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogService method setAsDefault.
public ImageCatalog setAsDefault(String name) {
removeDefaultFlag();
if (!isEnvDefault(name)) {
ImageCatalog imageCatalog = get(name);
checkImageCatalog(imageCatalog, name);
authorizationService.hasWritePermission(imageCatalog);
setImageCatalogAsDefault(imageCatalog);
return imageCatalog;
}
return getCloudbreakDefaultImageCatalog();
}
use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogService method getImages.
public StatedImages getImages(String imageCatalogUrl, String imageCatalogName, Set<String> platforms, String cbVersion) throws CloudbreakImageCatalogException {
LOGGER.info("Determine images for imageCatalogUrl: '{}', platforms: '{}' and Cloudbreak version: '{}'.", imageCatalogUrl, platforms, cbVersion);
StatedImages images;
CloudbreakImageCatalogV2 imageCatalog = imageCatalogProvider.getImageCatalogV2(imageCatalogUrl);
if (imageCatalog != null) {
Set<String> vMImageUUIDs = new HashSet<>();
List<CloudbreakVersion> cloudbreakVersions = imageCatalog.getVersions().getCloudbreakVersions();
String cbv = UNSPECIFIED_VERSION.equals(cbVersion) ? latestCloudbreakVersion(cloudbreakVersions) : cbVersion;
List<CloudbreakVersion> exactMatchedImgs = cloudbreakVersions.stream().filter(cloudbreakVersion -> cloudbreakVersion.getVersions().contains(cbv)).collect(Collectors.toList());
if (!exactMatchedImgs.isEmpty()) {
exactMatchedImgs.forEach(cloudbreakVersion -> vMImageUUIDs.addAll(cloudbreakVersion.getImageIds()));
} else {
vMImageUUIDs.addAll(prefixMatchForCBVersion(cbVersion, cloudbreakVersions));
}
List<Image> baseImages = filterImagesByPlatforms(platforms, imageCatalog.getImages().getBaseImages(), vMImageUUIDs);
List<Image> hdpImages = filterImagesByPlatforms(platforms, imageCatalog.getImages().getHdpImages(), vMImageUUIDs);
List<Image> hdfImages = filterImagesByPlatforms(platforms, imageCatalog.getImages().getHdfImages(), vMImageUUIDs);
images = statedImages(new Images(baseImages, hdpImages, hdfImages), imageCatalogUrl, imageCatalogName);
} else {
images = statedImages(emptyImages(), imageCatalogUrl, imageCatalogName);
}
return images;
}
use of com.sequenceiq.cloudbreak.domain.ImageCatalog in project cloudbreak by hortonworks.
the class ImageCatalogService method get.
public ImageCatalog get(String name) {
ImageCatalog imageCatalog;
if (isEnvDefault(name)) {
imageCatalog = getCloudbreakDefaultImageCatalog();
} else {
IdentityUser user = authenticatedUserService.getCbUser();
imageCatalog = imageCatalogRepository.findByName(name, user.getUserId(), user.getAccount());
}
return imageCatalog;
}
Aggregations