use of com.microsoft.azure.management.compute.VirtualHardDisk in project azure-sdk-for-java by Azure.
the class VirtualMachineScaleSetImpl method withStoredLinuxImage.
@Override
public VirtualMachineScaleSetImpl withStoredLinuxImage(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.LINUX);
this.inner().virtualMachineProfile().osProfile().withLinuxConfiguration(new LinuxConfiguration());
return this;
}
use of com.microsoft.azure.management.compute.VirtualHardDisk in project azure-sdk-for-java by Azure.
the class VirtualMachineImpl method withOSDiskVhdLocation.
@Override
public VirtualMachineImpl withOSDiskVhdLocation(String containerName, String vhdName) {
//
if (isManagedDiskEnabled()) {
return this;
}
StorageProfile storageProfile = this.inner().storageProfile();
OSDisk osDisk = storageProfile.osDisk();
//
if (!this.isOSDiskFromImage(osDisk)) {
return this;
}
//
if (this.isOsDiskFromCustomImage(storageProfile)) {
return this;
}
//
if (this.isOSDiskFromPlatformImage(storageProfile)) {
VirtualHardDisk osVhd = new VirtualHardDisk();
osVhd.withUri(temporaryBlobUrl(containerName, vhdName));
this.inner().storageProfile().osDisk().withVhd(osVhd);
return this;
}
// as the image.
if (this.isOSDiskFromStoredImage(storageProfile)) {
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);
}
this.inner().storageProfile().osDisk().withVhd(osVhd);
}
return this;
}
use of com.microsoft.azure.management.compute.VirtualHardDisk in project azure-sdk-for-java by Azure.
the class VirtualMachineImpl method withStoredLinuxImage.
@Override
public VirtualMachineImpl withStoredLinuxImage(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 | custom image osType will be null, azure will pick it from the image metadata.
// But for stored image, osType needs to be specified explicitly
//
this.inner().storageProfile().osDisk().withOsType(OperatingSystemTypes.LINUX);
this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration());
return this;
}
use of com.microsoft.azure.management.compute.VirtualHardDisk in project azure-sdk-for-java by Azure.
the class UnmanagedDataDiskImpl method storeAt.
@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;
}
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, 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");
}
}
}
}
Aggregations