Search in sources :

Example 1 with VirtualHardDisk

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

the class VirtualMachineScaleSetImpl method withStoredWindowsImage.

@Override
public VirtualMachineScaleSetImpl withStoredWindowsImage(String imageUrl) {
    VirtualHardDisk userImageVhd = new VirtualHardDisk();
    userImageVhd.withUri(imageUrl);
    this.inner().virtualMachineProfile().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
    this.inner().virtualMachineProfile().storageProfile().osDisk().withImage(userImageVhd);
    // For platform image osType will be null, azure will pick it from the image metadata.
    this.inner().virtualMachineProfile().storageProfile().osDisk().withOsType(OperatingSystemTypes.WINDOWS);
    this.inner().virtualMachineProfile().osProfile().withWindowsConfiguration(new WindowsConfiguration());
    // sets defaults for "Stored(Custom)Image" or "VM(Platform)Image"
    this.inner().virtualMachineProfile().osProfile().windowsConfiguration().withProvisionVMAgent(true);
    this.inner().virtualMachineProfile().osProfile().windowsConfiguration().withEnableAutomaticUpdates(true);
    return this;
}
Also used : VirtualHardDisk(com.microsoft.azure.management.compute.VirtualHardDisk) WindowsConfiguration(com.microsoft.azure.management.compute.WindowsConfiguration)

Example 2 with VirtualHardDisk

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

the class VirtualMachineImpl method withSpecializedOSUnmanagedDisk.

@Override
public VirtualMachineImpl withSpecializedOSUnmanagedDisk(String osDiskUrl, OperatingSystemTypes osType) {
    VirtualHardDisk osVhd = new VirtualHardDisk();
    osVhd.withUri(osDiskUrl);
    this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.ATTACH);
    this.inner().storageProfile().osDisk().withVhd(osVhd);
    this.inner().storageProfile().osDisk().withOsType(osType);
    this.inner().storageProfile().osDisk().withManagedDisk(null);
    return this;
}
Also used : VirtualHardDisk(com.microsoft.azure.management.compute.VirtualHardDisk)

Example 3 with VirtualHardDisk

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

the class VirtualMachineImpl method withStoredWindowsImage.

// Virtual machine image specific fluent methods
//
@Override
public VirtualMachineImpl withStoredWindowsImage(String imageUrl) {
    VirtualHardDisk userImageVhd = new VirtualHardDisk();
    userImageVhd.withUri(imageUrl);
    this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
    this.inner().storageProfile().osDisk().withImage(userImageVhd);
    // For platform image osType will be null, azure will pick it from the image metadata.
    this.inner().storageProfile().osDisk().withOsType(OperatingSystemTypes.WINDOWS);
    this.inner().osProfile().withWindowsConfiguration(new WindowsConfiguration());
    // sets defaults for "Stored(User)Image" or "VM(Platform)Image"
    this.inner().osProfile().windowsConfiguration().withProvisionVMAgent(true);
    this.inner().osProfile().windowsConfiguration().withEnableAutomaticUpdates(true);
    return this;
}
Also used : VirtualHardDisk(com.microsoft.azure.management.compute.VirtualHardDisk) WindowsConfiguration(com.microsoft.azure.management.compute.WindowsConfiguration)

Example 4 with VirtualHardDisk

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

the class UnmanagedDataDiskImpl method ensureDisksVhdUri.

protected static void ensureDisksVhdUri(List<VirtualMachineUnmanagedDataDisk> dataDisks, String namePrefix) {
    String containerUrl = null;
    for (VirtualMachineUnmanagedDataDisk dataDisk : dataDisks) {
        if (dataDisk.creationMethod() == DiskCreateOptionTypes.EMPTY && dataDisk.inner().vhd() != null) {
            int idx = dataDisk.inner().vhd().uri().lastIndexOf('/');
            containerUrl = dataDisk.inner().vhd().uri().substring(0, idx);
            break;
        }
    }
    if (containerUrl != null) {
        for (VirtualMachineUnmanagedDataDisk dataDisk : dataDisks) {
            if (dataDisk.creationMethod() == DiskCreateOptionTypes.EMPTY) {
                //New data disk requires Vhd Uri to be set
                if (dataDisk.inner().vhd() == null) {
                    dataDisk.inner().withVhd(new VirtualHardDisk());
                    dataDisk.inner().vhd().withUri(containerUrl + namePrefix + "-data-disk-" + dataDisk.lun() + "-" + UUID.randomUUID().toString() + ".vhd");
                }
            }
        }
    }
}
Also used : VirtualHardDisk(com.microsoft.azure.management.compute.VirtualHardDisk) VirtualMachineUnmanagedDataDisk(com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk)

Example 5 with VirtualHardDisk

use of com.microsoft.azure.management.compute.VirtualHardDisk in project cloudbreak by hortonworks.

the class AzureResourceConnector method collectRemovableDisks.

private void collectRemovableDisks(Map<String, Object> resourcesToRemove, VirtualMachine virtualMachine) {
    StorageProfile storageProfile = virtualMachine.storageProfile();
    List<DataDisk> dataDisks = storageProfile.dataDisks();
    Collection<String> storageProfileDiskNames = new ArrayList<>();
    Collection<String> managedDiskIds = new ArrayList<>();
    for (DataDisk datadisk : dataDisks) {
        VirtualHardDisk vhd = datadisk.vhd();
        if (datadisk.vhd() != null) {
            storageProfileDiskNames.add(getNameFromConnectionString(vhd.uri()));
        } else {
            managedDiskIds.add(datadisk.managedDisk().id());
        }
    }
    OSDisk osDisk = storageProfile.osDisk();
    if (osDisk.vhd() != null) {
        VirtualHardDisk vhd = osDisk.vhd();
        storageProfileDiskNames.add(getNameFromConnectionString(vhd.uri()));
    } else {
        managedDiskIds.add(osDisk.managedDisk().id());
    }
    resourcesToRemove.put(STORAGE_PROFILE_DISK_NAMES, storageProfileDiskNames);
    resourcesToRemove.put(MANAGED_DISK_IDS, managedDiskIds);
}
Also used : StorageProfile(com.microsoft.azure.management.compute.StorageProfile) OSDisk(com.microsoft.azure.management.compute.OSDisk) DataDisk(com.microsoft.azure.management.compute.DataDisk) ArrayList(java.util.ArrayList) VirtualHardDisk(com.microsoft.azure.management.compute.VirtualHardDisk)

Aggregations

VirtualHardDisk (com.microsoft.azure.management.compute.VirtualHardDisk)10 LinuxConfiguration (com.microsoft.azure.management.compute.LinuxConfiguration)2 OSDisk (com.microsoft.azure.management.compute.OSDisk)2 StorageProfile (com.microsoft.azure.management.compute.StorageProfile)2 VirtualMachineUnmanagedDataDisk (com.microsoft.azure.management.compute.VirtualMachineUnmanagedDataDisk)2 WindowsConfiguration (com.microsoft.azure.management.compute.WindowsConfiguration)2 DataDisk (com.microsoft.azure.management.compute.DataDisk)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1