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;
}
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;
}
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;
}
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");
}
}
}
}
}
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);
}
Aggregations