use of com.google.cloud.compute.v1.Image in project openstack4j by ContainX.
the class ImageV2Tests method testGetImageWithLocations.
public void testGetImageWithLocations() throws IOException {
respondWith(IMAGE_WIHT_LOCATION_JSON);
String id = "c73056d6-c583-4d6c-9f70-04f3bfd8dff4";
Image image = osv3().imagesV2().get(id);
assertNotNull(image);
assertNotNull(image.getId());
assertEquals(image.getId(), id);
assertEquals(2, image.getLocations().size());
}
use of com.google.cloud.compute.v1.Image in project openstack4j by ContainX.
the class ImageServiceImpl method update.
/**
* {@inheritDoc}
*/
@Override
public Image update(Image image) {
checkNotNull(image);
ObjectMapper objectMapper = new ObjectMapper();
Image origImage = get(image.getId());
ObjectNode origJson;
ObjectNode newJson;
try {
String oImg = objectMapper.writeValueAsString(origImage);
origJson = (ObjectNode) objectMapper.readTree(oImg);
String img = objectMapper.writeValueAsString(image);
newJson = (ObjectNode) objectMapper.readTree(img);
JsonNode jsonDiff = JsonDiff.asJson(origJson, newJson);
GlanceImageUpdate giu = new GlanceImageUpdate(jsonDiff);
return update(image.getId(), giu);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
use of com.google.cloud.compute.v1.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ImageIT method setupBeforeEach.
@BeforeEach
public void setupBeforeEach() throws ClientException {
clientlibs = "core.wcm.components.image.v3";
imageTests = new ImageTests();
imageTests.setup(adminClient, contextPath, label, Commons.rtImage_v3, rootPage, defaultPageTemplate, clientlibs, new Image());
}
use of com.google.cloud.compute.v1.Image in project cloudbreak by hortonworks.
the class OpenStackImageVerifier method getStatus.
public ImageStatus getStatus(OSClient<?> osClient, String name) {
ImageStatus imageStatus;
List<? extends Image> images = osClient.imagesV2().list(Collections.singletonMap("name", name));
if (images == null || images.isEmpty()) {
imageStatus = null;
LOGGER.error("OpenStack image: {} not found", name);
List<? extends Image> allImages = osClient.imagesV2().list();
if (allImages != null) {
for (Image image : allImages) {
LOGGER.info("Available images: {}, entry: {}", image.getName(), image);
}
}
LOGGER.warn("OpenStack image: {} not found", name);
} else if (images.size() > 1) {
for (Image image : images) {
LOGGER.info("Multiple images found: {}, entry: {}", image.getName(), image);
}
List<String> imageIds = images.stream().map(Image::getId).collect(Collectors.toList());
throw new CloudConnectorException(String.format("Multiple OpenStack images found with ids: %s, image name: %s", String.join(", ", imageIds), name));
} else {
LOGGER.info("OpenStack Image found: {}, entry: {}", name, images);
imageStatus = images.get(0).getStatus();
}
return imageStatus;
}
use of com.google.cloud.compute.v1.Image in project cloudbreak by hortonworks.
the class OpenStackSetup method checkImageStatus.
@Override
public ImageStatusResult checkImageStatus(AuthenticatedContext authenticatedContext, CloudStack stack, com.sequenceiq.cloudbreak.cloud.model.Image image) {
String imageName = image.getImageName();
OSClient osClient = openStackClient.createOSClient(authenticatedContext);
Image.ImageStatus imageStatus = openStackImageVerifier.getStatus(osClient, imageName);
ImageStatusResult imageStatusResult;
switch(imageStatus) {
case ACTIVE:
imageStatusResult = new ImageStatusResult(ImageStatus.CREATE_FINISHED, ImageStatusResult.COMPLETED);
break;
case QUEUED:
case SAVING:
imageStatusResult = new ImageStatusResult(ImageStatus.IN_PROGRESS, ImageStatusResult.HALF);
break;
default:
imageStatusResult = new ImageStatusResult(ImageStatus.CREATE_FAILED, ImageStatusResult.COMPLETED);
break;
}
LOGGER.info("OpenStack image result. name: {}, imageStatus: {}, imageStatusResult: {}", imageName, imageStatus, imageStatusResult);
return imageStatusResult;
}
Aggregations