Search in sources :

Example 1 with ImageDataDisk

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

the class Utils method print.

/**
     * Prints information of a virtual machine custom image.
     *
     * @param image the image
     */
public static void print(VirtualMachineCustomImage image) {
    StringBuilder builder = new StringBuilder().append("Virtual machine custom image: ").append(image.id()).append("Name: ").append(image.name()).append("\n\tResource group: ").append(image.resourceGroupName()).append("\n\tCreated from virtual machine: ").append(image.sourceVirtualMachineId());
    builder.append("\n\tOS disk image: ").append("\n\t\tOperating system: ").append(image.osDiskImage().osType()).append("\n\t\tOperating system state: ").append(image.osDiskImage().osState()).append("\n\t\tCaching: ").append(image.osDiskImage().caching()).append("\n\t\tSize (GB): ").append(image.osDiskImage().diskSizeGB());
    if (image.isCreatedFromVirtualMachine()) {
        builder.append("\n\t\tSource virtual machine: ").append(image.sourceVirtualMachineId());
    }
    if (image.osDiskImage().managedDisk() != null) {
        builder.append("\n\t\tSource managed disk: ").append(image.osDiskImage().managedDisk().id());
    }
    if (image.osDiskImage().snapshot() != null) {
        builder.append("\n\t\tSource snapshot: ").append(image.osDiskImage().snapshot().id());
    }
    if (image.osDiskImage().blobUri() != null) {
        builder.append("\n\t\tSource un-managed vhd: ").append(image.osDiskImage().blobUri());
    }
    if (image.dataDiskImages() != null) {
        for (ImageDataDisk diskImage : image.dataDiskImages().values()) {
            builder.append("\n\tDisk Image (Lun) #: ").append(diskImage.lun()).append("\n\t\tCaching: ").append(diskImage.caching()).append("\n\t\tSize (GB): ").append(diskImage.diskSizeGB());
            if (image.isCreatedFromVirtualMachine()) {
                builder.append("\n\t\tSource virtual machine: ").append(image.sourceVirtualMachineId());
            }
            if (diskImage.managedDisk() != null) {
                builder.append("\n\t\tSource managed disk: ").append(diskImage.managedDisk().id());
            }
            if (diskImage.snapshot() != null) {
                builder.append("\n\t\tSource snapshot: ").append(diskImage.snapshot().id());
            }
            if (diskImage.blobUri() != null) {
                builder.append("\n\t\tSource un-managed vhd: ").append(diskImage.blobUri());
            }
        }
    }
    System.out.println(builder.toString());
}
Also used : ImageDataDisk(com.microsoft.azure.management.compute.ImageDataDisk)

Example 2 with ImageDataDisk

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

the class VirtualMachineCustomImageImpl method ensureDefaultLuns.

private void ensureDefaultLuns() {
    if (this.inner().storageProfile() != null && this.inner().storageProfile().dataDisks() != null) {
        List<ImageDataDisk> imageDisks = this.inner().storageProfile().dataDisks();
        List<Integer> usedLuns = new ArrayList<>();
        for (ImageDataDisk imageDisk : imageDisks) {
            if (imageDisk.lun() != -1) {
                usedLuns.add(imageDisk.lun());
            }
        }
        if (usedLuns.size() == imageDisks.size()) {
            return;
        }
        for (ImageDataDisk imageDisk : imageDisks) {
            if (imageDisk.lun() != -1) {
                continue;
            }
            Integer i = 0;
            while (usedLuns.contains(i)) {
                i++;
            }
            imageDisk.withLun(i);
            usedLuns.add(i);
        }
    }
}
Also used : ImageDataDisk(com.microsoft.azure.management.compute.ImageDataDisk) ArrayList(java.util.ArrayList)

Aggregations

ImageDataDisk (com.microsoft.azure.management.compute.ImageDataDisk)2 ArrayList (java.util.ArrayList)1