@Override public String vhdUri() { return this.inner().vhd().uri(); }
@Override public UnmanagedDataDiskImpl withExistingVhd(String storageAccountName, String containerName, String vhdName) { this.inner() .withCreateOption(DiskCreateOptionTypes.ATTACH) .withVhd(new VirtualHardDisk() .withUri(blobUrl(storageAccountName, containerName, vhdName))); return this; }
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"); } } } } }
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"); } } } } }
@Override public String vhdUri() { return this.inner().vhd().uri(); }
@Override public UnmanagedDataDiskImpl withExistingVhd(String storageAccountName, String containerName, String vhdName) { this.inner() .withCreateOption(DiskCreateOptionTypes.ATTACH) .withVhd(new VirtualHardDisk() .withUri(blobUrl(storageAccountName, containerName, vhdName))); return this; }
VirtualHardDisk osVhd = new VirtualHardDisk(); osVhd.withUri(temporaryBlobUrl(containerName, vhdName)); this.inner().storageProfile().osDisk().withVhd(osVhd); return this; VirtualHardDisk osVhd = new VirtualHardDisk(); try { URL sourceCustomImageUrl = new URL(osDisk.image().uri()); URL destinationVhdUrl = new URL(sourceCustomImageUrl.getProtocol(), sourceCustomImageUrl.getHost(), "/" + containerName + "/" + vhdName); osVhd.withUri(destinationVhdUrl.toString()); } catch (MalformedURLException ex) { throw new RuntimeException(ex);
/** * Checks whether the OS disk is directly attached to a unmanaged VHD. * * @param osDisk the osDisk value in the storage profile * @return true if the OS disk is attached to a unmanaged VHD, false otherwise */ private boolean isOSDiskAttachedUnmanaged(OSDisk osDisk) { return osDisk.createOption() == DiskCreateOptionTypes.ATTACH && osDisk.vhd() != null && osDisk.vhd().uri() != null; }
@Override public UnmanagedDataDiskImpl storeAt(String storageAccountName, String containerName, String vhdName) { this.inner().withVhd(new VirtualHardDisk()); // URL points to where the underlying vhd needs to be stored this.inner().vhd().withUri(blobUrl(storageAccountName, containerName, vhdName)); return this; }
VirtualHardDisk osVhd = new VirtualHardDisk(); osVhd.withUri(temporaryBlobUrl(containerName, vhdName)); this.inner().storageProfile().osDisk().withVhd(osVhd); return this; VirtualHardDisk osVhd = new VirtualHardDisk(); try { URL sourceCustomImageUrl = new URL(osDisk.image().uri()); URL destinationVhdUrl = new URL(sourceCustomImageUrl.getProtocol(), sourceCustomImageUrl.getHost(), "/" + containerName + "/" + vhdName); osVhd.withUri(destinationVhdUrl.toString()); } catch (MalformedURLException ex) { throw new RuntimeException(ex);
/** * Checks whether the OS disk is directly attached to a unmanaged VHD. * * @param osDisk the osDisk value in the storage profile * @return true if the OS disk is attached to a unmanaged VHD, false otherwise */ private boolean isOSDiskAttachedUnmanaged(OSDisk osDisk) { return osDisk.createOption() == DiskCreateOptionTypes.ATTACH && osDisk.vhd() != null && osDisk.vhd().uri() != null; }
@Override public UnmanagedDataDiskImpl storeAt(String storageAccountName, String containerName, String vhdName) { this.inner().withVhd(new VirtualHardDisk()); // URL points to where the underlying vhd needs to be stored this.inner().vhd().withUri(blobUrl(storageAccountName, containerName, vhdName)); return this; }
@Override public String sourceImageUri() { if (this.inner().image() != null) { return this.inner().image().uri(); } return null; }
protected static void ensureDisksVhdUri(List<VirtualMachineUnmanagedDataDisk> dataDisks, StorageAccount storageAccount, String namePrefix) { for (VirtualMachineUnmanagedDataDisk dataDisk : dataDisks) { if (dataDisk.creationMethod() == DiskCreateOptionTypes.EMPTY || dataDisk.creationMethod() == DiskCreateOptionTypes.FROM_IMAGE) { //New empty and from image data disk requires Vhd Uri to be set if (dataDisk.inner().vhd() == null) { dataDisk.inner().withVhd(new VirtualHardDisk()); dataDisk.inner().vhd().withUri(storageAccount.endPoints().primary().blob() + "vhds/" + namePrefix + "-data-disk-" + dataDisk.lun() + "-" + UUID.randomUUID().toString() + ".vhd"); } } } }
/** * Checks whether the OS disk is based on a stored image ('captured' or 'bring your own feature'). * * @param storageProfile the storage profile * @return true if the OS disk is configured to use custom image ('captured' or 'bring your own feature') */ private boolean isOSDiskFromStoredImage(VirtualMachineScaleSetStorageProfile storageProfile) { VirtualMachineScaleSetOSDisk osDisk = storageProfile.osDisk(); return isOSDiskFromImage(osDisk) && osDisk.image() != null && osDisk.image().uri() != null; }
protected static void ensureDisksVhdUri(List<VirtualMachineUnmanagedDataDisk> dataDisks, StorageAccount storageAccount, String namePrefix) { for (VirtualMachineUnmanagedDataDisk dataDisk : dataDisks) { if (dataDisk.creationMethod() == DiskCreateOptionTypes.EMPTY || dataDisk.creationMethod() == DiskCreateOptionTypes.FROM_IMAGE) { //New empty and from image data disk requires Vhd Uri to be set if (dataDisk.inner().vhd() == null) { dataDisk.inner().withVhd(new VirtualHardDisk()); dataDisk.inner().vhd().withUri(storageAccount.endPoints().primary().blob() + "vhds/" + namePrefix + "-data-disk-" + dataDisk.lun() + "-" + UUID.randomUUID().toString() + ".vhd"); } } } }
/** * Checks whether the OS disk is based on a stored image ('captured' or 'bring your own feature'). * * @param storageProfile the storage profile * @return true if the OS disk is configured to use custom image ('captured' or 'bring your own feature') */ private boolean isOSDiskFromStoredImage(VirtualMachineScaleSetStorageProfile storageProfile) { VirtualMachineScaleSetOSDisk osDisk = storageProfile.osDisk(); return isOSDiskFromImage(osDisk) && osDisk.image() != null && osDisk.image().uri() != null; }
@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; }