Search in sources :

Example 1 with ImageReferenceInner

use of com.microsoft.azure.management.compute.implementation.ImageReferenceInner in project azure-sdk-for-java by Azure.

the class ImageReference method inner.

@Override
public ImageReferenceInner inner() {
    if (super.inner() != null) {
        return super.inner();
    }
    ImageReferenceInner imageReferenceInner = new ImageReferenceInner();
    imageReferenceInner.withPublisher(this.publisher()).withOffer(this.offer()).withVersion(this.version()).withSku(this.sku()).withId(this.id());
    return imageReferenceInner;
}
Also used : ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner)

Example 2 with ImageReferenceInner

use of com.microsoft.azure.management.compute.implementation.ImageReferenceInner in project photon-model by vmware.

the class AzureInstanceService method resolveLatestVirtualMachineImage.

/**
 * Get the LATEST VirtualMachineImage using publisher, offer and SKU.
 */
private DeferredResult<AzureInstanceContext> resolveLatestVirtualMachineImage(AzureInstanceContext ctx) {
    ImageReferenceInner imageReference = ctx.imageSource.asImageReferenceInner();
    if (AzureConstants.AZURE_URN_VERSION_LATEST.equalsIgnoreCase(imageReference.version())) {
        String msg = String.format("Getting latest Azure image by %s:%s:%s", imageReference.publisher(), imageReference.offer(), imageReference.sku());
        AzureDeferredResultServiceCallback<List<VirtualMachineImageResourceInner>> callback = new Default<>(ctx.service, msg);
        getComputeManagementClientImpl(ctx).virtualMachineImages().listAsync(ctx.resourceGroup.location(), imageReference.publisher(), imageReference.offer(), imageReference.sku(), null, 1, AzureConstants.ORDER_BY_VM_IMAGE_RESOURCE_NAME_DESC, callback);
        return callback.toDeferredResult().thenApply(imageResources -> {
            if (imageResources == null || imageResources.isEmpty() || imageResources.get(0) == null) {
                throw new IllegalStateException(String.format("No latest Azure image found by %s:%s:%s", imageReference.publisher(), imageReference.offer(), imageReference.sku()));
            }
            // Update 'latest'-version with actual version
            imageReference.withVersion(imageResources.get(0).name());
            return ctx;
        });
    }
    return DeferredResult.completed(ctx);
}
Also used : ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner) ArrayList(java.util.ArrayList) List(java.util.List) Default(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default)

Example 3 with ImageReferenceInner

use of com.microsoft.azure.management.compute.implementation.ImageReferenceInner in project photon-model by vmware.

the class AzureComputeEnumerationAdapterService method updateDiskCustomProperties.

private void updateDiskCustomProperties(VirtualMachineInner vm, EnumerationContext ctx, DiskState diskToUpdate) {
    ImageReferenceInner imageReference = vm.storageProfile().imageReference();
    diskToUpdate.sourceImageReference = URI.create(imageReferenceToImageId(imageReference));
    diskToUpdate.regionId = vm.location();
    diskToUpdate.bootOrder = 1;
    if (diskToUpdate.customProperties == null) {
        diskToUpdate.customProperties = new HashMap<>();
    }
    if (vm.storageProfile().osDisk() != null && vm.storageProfile().osDisk().caching() != null) {
        diskToUpdate.customProperties.put(AZURE_OSDISK_CACHING, vm.storageProfile().osDisk().caching().name());
    }
    diskToUpdate.computeHostLink = ctx.parentCompute.documentSelfLink;
    if (StringUtils.isEmpty(diskToUpdate.endpointLink)) {
        diskToUpdate.endpointLink = ctx.request.endpointLink;
    }
    AdapterUtils.addToEndpointLinks(diskToUpdate, ctx.request.endpointLink);
}
Also used : ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner)

Aggregations

ImageReferenceInner (com.microsoft.azure.management.compute.implementation.ImageReferenceInner)3 Default (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1