use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.
the class StackToStackV2RequestConverter method prepareImage.
private void prepareImage(Stack source, StackV2Request stackV2Request) {
try {
Image image = componentConfigProvider.getImage(source.getId());
ImageSettings is = new ImageSettings();
is.setImageId(Strings.isNullOrEmpty(image.getImageId()) ? "" : image.getImageId());
is.setImageCatalog(Strings.isNullOrEmpty(image.getImageCatalogName()) ? "" : image.getImageCatalogName());
stackV2Request.setImageSettings(is);
} catch (CloudbreakImageNotFoundException e) {
LOGGER.error(e.toString());
}
}
use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.
the class StackToCloudStackConverter method convert.
public CloudStack convert(Stack stack, Collection<String> deleteRequestedInstances) {
Image image = null;
List<Group> instanceGroups = buildInstanceGroups(stack.getInstanceGroupsAsList(), stack.getStackAuthentication(), deleteRequestedInstances);
try {
image = imageService.getImage(stack.getId());
} catch (CloudbreakImageNotFoundException e) {
LOGGER.info(e.getMessage());
}
Network network = buildNetwork(stack);
StackTemplate stackTemplate = componentConfigProvider.getStackTemplate(stack.getId());
InstanceAuthentication instanceAuthentication = buildInstanceAuthentication(stack.getStackAuthentication());
String template = null;
if (stackTemplate != null) {
template = stackTemplate.getTemplate();
}
return new CloudStack(instanceGroups, network, image, stack.getParameters(), getUserDefinedTags(stack), template, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey());
}
use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.
the class ImageCatalogService method getImage.
public StatedImage getImage(String catalogUrl, String catalogName, String imageId) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Images images = imageCatalogProvider.getImageCatalogV2(catalogUrl).getImages();
Optional<? extends Image> image = getImage(imageId, images);
if (!image.isPresent()) {
images = imageCatalogProvider.getImageCatalogV2(catalogUrl, true).getImages();
image = getImage(imageId, images);
}
if (!image.isPresent()) {
throw new CloudbreakImageNotFoundException(String.format("Could not find any image with id: '%s'.", imageId));
}
return statedImage(image.get(), catalogUrl, catalogName);
}
use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.
the class ImageCatalogService method getImageByCatalogName.
public StatedImage getImageByCatalogName(String imageId, String catalogName) throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
StatedImage image;
if (StringUtils.isEmpty(catalogName)) {
image = getImage(imageId);
} else {
ImageCatalog imageCatalog = get(catalogName);
if (imageCatalog != null) {
image = getImage(imageCatalog.getImageCatalogUrl(), imageCatalog.getImageCatalogName(), imageId);
} else {
String msg = String.format("The specified image catalog '%s' could not be found.", catalogName);
LOGGER.error(msg);
throw new CloudbreakImageNotFoundException(msg);
}
}
return image;
}
use of com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException in project cloudbreak by hortonworks.
the class StackToStackResponseConverter method convert.
@Override
public StackResponse convert(Stack source) {
StackResponse stackJson = new StackResponse();
try {
Image image = imageService.getImage(source.getId());
stackJson.setImage(getConversionService().convert(image, ImageJson.class));
} catch (CloudbreakImageNotFoundException exc) {
LOGGER.info(exc.getMessage());
}
stackJson.setName(source.getName());
stackJson.setOwner(source.getOwner());
stackJson.setAccount(source.getAccount());
stackJson.setPublicInAccount(source.isPublicInAccount());
stackJson.setStackAuthentication(conversionService.convert(source.getStackAuthentication(), StackAuthenticationResponse.class));
stackJson.setId(source.getId());
if (source.getCredential() == null) {
stackJson.setCloudPlatform(null);
stackJson.setCredentialId(null);
} else {
stackJson.setCloudPlatform(source.cloudPlatform());
stackJson.setCredentialId(source.getCredential().getId());
stackJson.setCredential(getConversionService().convert(source.getCredential(), CredentialResponse.class));
}
stackJson.setStatus(source.getStatus());
stackJson.setStatusReason(source.getStatusReason());
stackJson.setRegion(source.getRegion());
stackJson.setAvailabilityZone(source.getAvailabilityZone());
stackJson.setOnFailureAction(source.getOnFailureActionAction());
List<InstanceGroupResponse> templateGroups = new ArrayList<>(convertInstanceGroups(source.getInstanceGroups()));
stackJson.setInstanceGroups(templateGroups);
if (source.getCluster() != null) {
stackJson.setCluster(getConversionService().convert(source.getCluster(), ClusterResponse.class));
} else {
stackJson.setCluster(new ClusterResponse());
}
if (source.getFailurePolicy() != null) {
stackJson.setFailurePolicy(getConversionService().convert(source.getFailurePolicy(), FailurePolicyResponse.class));
}
if (source.getNetwork() == null) {
stackJson.setNetworkId(null);
} else {
stackJson.setNetworkId(source.getNetwork().getId());
stackJson.setNetwork(getConversionService().convert(source.getNetwork(), NetworkResponse.class));
}
stackJson.setParameters(Maps.newHashMap(source.getParameters()));
stackJson.setPlatformVariant(source.getPlatformVariant());
if (source.getOrchestrator() != null) {
stackJson.setOrchestrator(getConversionService().convert(source.getOrchestrator(), OrchestratorResponse.class));
}
stackJson.setCreated(source.getCreated());
stackJson.setGatewayPort(source.getGatewayPort());
stackJson.setCustomDomain(source.getCustomDomain());
stackJson.setCustomHostname(source.getCustomHostname());
stackJson.setClusterNameAsSubdomain(source.isClusterNameAsSubdomain());
stackJson.setHostgroupNameAsHostname(source.isHostgroupNameAsHostname());
addNodeCount(source, stackJson);
putSubnetIdIntoResponse(source, stackJson);
putVpcIdIntoResponse(source, stackJson);
putS3RoleIntoResponse(source, stackJson);
convertComponentConfig(stackJson, source);
convertTags(stackJson, source.getTags());
addFlexSubscription(stackJson, source);
return stackJson;
}
Aggregations