use of com.google.api.services.compute.Compute.Images.Get in project cloudbreak by hortonworks.
the class GcpProvisionSetup method checkImageStatus.
@Override
public ImageStatusResult checkImageStatus(AuthenticatedContext authenticatedContext, CloudStack stack, com.sequenceiq.cloudbreak.cloud.model.Image image) {
CloudCredential credential = authenticatedContext.getCloudCredential();
String projectId = getProjectId(credential);
String imageName = image.getImageName();
try {
Image gcpApiImage = new Image();
gcpApiImage.setName(getImageName(imageName));
Compute compute = buildCompute(credential);
Get getImages = compute.images().get(projectId, gcpApiImage.getName());
String status = getImages.execute().getStatus();
LOGGER.info("Status of image {} copy: {}", gcpApiImage.getName(), status);
if (READY.equals(status)) {
return new ImageStatusResult(ImageStatus.CREATE_FINISHED, ImageStatusResult.COMPLETED);
}
} catch (IOException e) {
LOGGER.warn("Failed to retrieve image copy status", e);
return new ImageStatusResult(ImageStatus.CREATE_FAILED, 0);
}
return new ImageStatusResult(ImageStatus.IN_PROGRESS, ImageStatusResult.HALF);
}
Aggregations