private StorageProfile createStorageProfile(Image image, List<DataDisk> dataDisks) { return StorageProfile.create(createImageReference(image), createOSDisk(image), dataDisks); }
public boolean cleanupManagedDisks(VirtualMachine virtualMachine) { Map<String, URI> deleteJobs = new HashMap<String, URI>(); OSDisk osDisk = virtualMachine.properties().storageProfile().osDisk(); deleteManagedDisk(osDisk.managedDiskParameters(), deleteJobs); for (DataDisk dataDisk : virtualMachine.properties().storageProfile().dataDisks()) { deleteManagedDisk(dataDisk.managedDiskParameters(), deleteJobs); } Set<String> nonDeletedDisks = filterValues(deleteJobs, not(resourceDeleted)).keySet(); if (!nonDeletedDisks.isEmpty()) { logger.warn(">> could not delete disks: %s", Joiner.on(',').join(nonDeletedDisks)); } return nonDeletedDisks.isEmpty(); }
@SerializedNames({"imageReference", "osDisk", "dataDisks"}) public static StorageProfile create(final ImageReference imageReference, final OSDisk osDisk, final List<DataDisk> dataDisks) { StorageProfile.Builder builder = StorageProfile.builder() .imageReference(imageReference) .osDisk(osDisk) .dataDisks(dataDisks != null ? ImmutableList.copyOf(dataDisks) : null); return builder.build(); }
@Test(dependsOnMethods = "testStart") public void testUpdate() { VirtualMachine vm = api().get(vmName); VirtualMachineProperties oldProperties = vm.properties(); StorageProfile oldStorageProfile = oldProperties.storageProfile(); DataDisk newDataDisk = DataDisk.builder() .name(vmName + "new-data-disk") .diskSizeGB("1") .lun(1) .createOption(DataDisk.DiskCreateOptionTypes.EMPTY) .build(); List<DataDisk> oldDataDisks = oldStorageProfile.dataDisks(); assertEquals(oldDataDisks.size(), 1); ImmutableList<DataDisk> newDataDisks = ImmutableList.<DataDisk> builder().addAll(oldDataDisks).add(newDataDisk).build(); StorageProfile newStorageProfile = oldStorageProfile.toBuilder().dataDisks(newDataDisks).build(); VirtualMachineProperties newProperties = oldProperties.toBuilder().storageProfile(newStorageProfile).build(); VirtualMachine newVm = vm.toBuilder().properties(newProperties).build(); vm = api().createOrUpdate(vmName, newVm.location(), newVm.properties(), newVm.tags(), newVm.plan()); assertEquals(vm.properties().storageProfile().dataDisks().size(), oldDataDisks.size() + 1); }
@Override public VMImage apply(Image input) { return VMImage.customImage().resourceGroup(extractResourceGroup(input.id())).customImageId(input.id()).location(input.location()).name(input.name()) .offer(input.properties().storageProfile().osDisk().osType()).build(); } }
protected Optional<? extends Image> findImage(final StorageProfile storageProfile, String locatioName) { if (storageProfile.imageReference() != null) { String imageId = storageProfile.imageReference().customImageId() != null ? storageProfile.imageReference().encodeFieldsToUniqueIdCustom(locatioName) : storageProfile.imageReference().encodeFieldsToUniqueId(locatioName); return imageCache.get(imageId); } else { logger.warn("could not find image for storage profile %s", storageProfile); return Optional.absent(); } }
@Override public VMImage apply(Image input) { return VMImage.customImage().resourceGroup(extractResourceGroup(input.id())).customImageId(input.id()).location(input.location()).name(input.name()) .offer(input.properties().storageProfile().osDisk().osType()).build(); } }
protected Optional<? extends Image> findImage(final StorageProfile storageProfile, String locatioName) { if (storageProfile.imageReference() != null) { String imageId = storageProfile.imageReference().customImageId() != null ? storageProfile.imageReference().encodeFieldsToUniqueIdCustom(locatioName) : storageProfile.imageReference().encodeFieldsToUniqueId(locatioName); return imageCache.get(imageId); } else { logger.warn("could not find image for storage profile %s", storageProfile); return Optional.absent(); } }
private StorageProfile createStorageProfile(Image image, List<DataDisk> dataDisks) { return StorageProfile.create(createImageReference(image), createOSDisk(image), dataDisks); }
public boolean cleanupManagedDisks(VirtualMachine virtualMachine) { Map<String, URI> deleteJobs = new HashMap<String, URI>(); OSDisk osDisk = virtualMachine.properties().storageProfile().osDisk(); deleteManagedDisk(osDisk.managedDiskParameters(), deleteJobs); for (DataDisk dataDisk : virtualMachine.properties().storageProfile().dataDisks()) { deleteManagedDisk(dataDisk.managedDiskParameters(), deleteJobs); } Set<String> nonDeletedDisks = filterValues(deleteJobs, not(resourceDeleted)).keySet(); if (!nonDeletedDisks.isEmpty()) { logger.warn(">> could not delete disks: %s", Joiner.on(',').join(nonDeletedDisks)); } return nonDeletedDisks.isEmpty(); }
@SerializedNames({"imageReference", "osDisk", "dataDisks"}) public static StorageProfile create(final ImageReference imageReference, final OSDisk osDisk, final List<DataDisk> dataDisks) { StorageProfile.Builder builder = StorageProfile.builder() .imageReference(imageReference) .osDisk(osDisk) .dataDisks(dataDisks != null ? ImmutableList.copyOf(dataDisks) : null); return builder.build(); }
private StorageProfile getLinuxStorageProfile_Default() { return StorageProfile.create(getLinuxImageReference(), getLinuxOSDisk(), null); }
private Image newVirtualMachineImage() { return Image .builder() .name(imageName) .location(location) .properties( ImageProperties .builder() .sourceVirtualMachine(IdReference.create("vmId")) .storageProfile( StorageProfile.create(null, OSDisk.builder().osType("Linux").name("Ubuntu").build(), ImmutableList.<DataDisk> of())).provisioningState("Succeeded").build()).build(); } }
"Standard_LRS"); OSDisk osDisk = OSDisk.create("Windows", "windowsmachine", vhd, "ReadWrite", "FromImage", null, managedDiskParameters, null); StorageProfile storageProfile = StorageProfile.create(imgRef, osDisk, dataDisks); LinuxConfiguration linuxConfig = null; OSProfile.WindowsConfiguration.WinRM winrm = OSProfile.WindowsConfiguration.WinRM.create(
null, VirtualMachineScaleSetVirtualMachineProfile.create( StorageProfile.create( ImageReference.create( null,
DataDisk.builder().name("mydatadisk1").diskSizeGB("1").lun(0).managedDiskParameters(managedDiskParameters).createOption(DataDisk.DiskCreateOptionTypes.EMPTY).caching(DataDisk.CachingTypes.READ_WRITE).build()); OSDisk osDisk = OSDisk.builder().osType("Windows").name("windowsmachine").caching("ReadWrite").createOption("FromImage").managedDiskParameters(managedDiskParameters).build(); StorageProfile storageProfile = StorageProfile.create(imgRef, osDisk, dataDisks); LinuxConfiguration linuxConfig = null; OSProfile.WindowsConfiguration.WinRM winrm = OSProfile.WindowsConfiguration.WinRM.create(
StorageProfile storageProfile = StorageProfile.create(imgRef, osDisk.build(), ImmutableList.of(dataDisk.build()));