use of org.platformlayer.PlatformLayerClientException in project platformlayer by platformlayer.
the class ImageFactory method getOrCreateImage.
public DiskImage getOrCreateImage(DiskImage template) throws OpsException {
DiskImage best = null;
try {
for (DiskImage candidate : platformLayer.listItems(DiskImage.class)) {
if (isMatch(candidate, template)) {
best = candidate;
break;
}
}
if (best == null) {
// We should be owned by the recipe
PlatformLayerKey recipeKey = template.getRecipeId();
if (recipeKey != null) {
template.getTags().add(Tag.buildParentTag(recipeKey));
}
best = platformLayer.putItem(template);
}
} catch (PlatformLayerClientException e) {
throw new OpsException("Error fetching or building image", e);
}
return best;
}
Aggregations