Search in sources :

Example 36 with Image

use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.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;
}
Also used : OSClient(org.openstack4j.api.OSClient) Image(org.openstack4j.model.image.v2.Image) ImageStatusResult(com.sequenceiq.cloudbreak.common.type.ImageStatusResult)

Example 37 with Image

use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.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;
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) GlanceImageUpdate(org.openstack4j.openstack.image.v2.domain.GlanceImageUpdate) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) GlanceImage(org.openstack4j.openstack.image.v2.domain.GlanceImage) CachedImage(org.openstack4j.model.image.v2.CachedImage) Image(org.openstack4j.model.image.v2.Image) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 38 with Image

use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.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());
}
Also used : Image(org.openstack4j.model.image.v2.Image)

Example 39 with Image

use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v1.Image in project openstack4j by ContainX.

the class ImageV2Tests method testCreateImage.

public void testCreateImage() throws IOException {
    respondWith(IMAGE_JSON);
    String id = "8a2ea42d-06b5-42c2-a54d-97105420f2bb";
    String name = "amphora-x64-haproxy";
    ContainerFormat cf = ContainerFormat.BARE;
    DiskFormat df = DiskFormat.QCOW2;
    Long mindisk = 0L;
    Long minram = 0L;
    Image.ImageVisibility vis = Image.ImageVisibility.PUBLIC;
    String key1 = "test-key1";
    String key2 = "test-key2";
    String key3 = "id";
    String value1 = "test-value1";
    String value2 = "test-value2";
    String value3 = "test-value3";
    Image im = Builders.imageV2().id(id).name(name).containerFormat(cf).diskFormat(df).minDisk(mindisk).minRam(minram).visibility(vis).additionalProperty(key1, value1).additionalProperty(key2, value2).additionalProperty(key3, value3).build();
    Image image = osv3().imagesV2().create(im);
    assertNotNull(image);
    assertEquals(image.getId(), id);
    assertEquals(image.getName(), name);
    assertEquals(image.getContainerFormat(), cf);
    assertEquals(image.getDiskFormat(), df);
    assertEquals(image.getVisibility(), vis);
    assertEquals(image.getMinDisk(), mindisk);
    assertEquals(image.getMinRam(), minram);
    assertEquals(image.getAdditionalPropertyValue(key1), value1);
    assertEquals(image.getAdditionalPropertyValue(key2), value2);
    assertNull(image.getAdditionalPropertyValue(key3));
}
Also used : ContainerFormat(org.openstack4j.model.image.v2.ContainerFormat) Image(org.openstack4j.model.image.v2.Image) DiskFormat(org.openstack4j.model.image.v2.DiskFormat)

Example 40 with Image

use of com.adobe.cq.wcm.core.components.it.seljup.util.components.image.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());
}
Also used : ImageTests(com.adobe.cq.wcm.core.components.it.seljup.tests.image.ImageTests) Image(com.adobe.cq.wcm.core.components.it.seljup.util.components.image.v2.Image) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)28 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)28 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)28 Feature (com.google.cloud.vision.v1.Feature)28 Image (com.google.cloud.vision.v1.Image)28 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)27 ArrayList (java.util.ArrayList)27 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)25 ByteString (com.google.protobuf.ByteString)17 EntityAnnotation (com.google.cloud.vision.v1.EntityAnnotation)16 ImageSource (com.google.cloud.vision.v1.ImageSource)15 FileInputStream (java.io.FileInputStream)14 WebPage (com.google.cloud.vision.v1.WebDetection.WebPage)8 Block (com.google.cloud.vision.v1.Block)6 ColorInfo (com.google.cloud.vision.v1.ColorInfo)6 CropHint (com.google.cloud.vision.v1.CropHint)6 CropHintsAnnotation (com.google.cloud.vision.v1.CropHintsAnnotation)6 DominantColorsAnnotation (com.google.cloud.vision.v1.DominantColorsAnnotation)6 FaceAnnotation (com.google.cloud.vision.v1.FaceAnnotation)6 LocationInfo (com.google.cloud.vision.v1.LocationInfo)6