/** * Checks whether the OS disk is based on a CustomImage. * <p> * A custom image is represented by {@link com.microsoft.azure.management.compute.VirtualMachineCustomImage}. * * @param storageProfile the storage profile * @return true if the OS disk is configured to be based on custom image. */ private boolean isOsDiskFromCustomImage(StorageProfile storageProfile) { ImageReference imageReference = storageProfile.imageReference(); return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.id() != null; }
@Override public VirtualMachineImpl withoutUnmanagedDataDisk(String name) { // Its ok not to throw here, since in general 'withoutXX' can be NOP int idx = -1; for (VirtualMachineUnmanagedDataDisk dataDisk : this.unmanagedDataDisks) { idx++; if (dataDisk.name().equalsIgnoreCase(name)) { this.unmanagedDataDisks.remove(idx); this.inner().storageProfile().dataDisks().remove(idx); break; } } return this; }
private void initializeDataDisks() { if (this.inner().storageProfile().dataDisks() == null) { this.inner() .storageProfile() .withDataDisks(new ArrayList<DataDisk>()); } this.isUnmanagedDiskSelected = false; this.managedDataDisks.clear(); this.unmanagedDataDisks = new ArrayList<>(); if (!isManagedDiskEnabled()) { for (DataDisk dataDiskInner : this.storageProfile().dataDisks()) { this.unmanagedDataDisks.add(new UnmanagedDataDiskImpl(dataDiskInner, this)); } } }
@Override public VirtualMachineImpl withSpecificLinuxImageVersion(ImageReference imageReference) { this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE); this.inner().storageProfile().withImageReference(imageReference); this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration()); this.isMarketplaceLinuxImage = true; return this; }
@Override public boolean isOSBasedOnCustomImage() { ImageReference imageReference = this.inner().storageProfile().imageReference(); if (imageReference != null && imageReference.id() != null) { return true; } return false; }
@Override protected VirtualMachineImpl wrapModel(String name) { VirtualMachineInner inner = new VirtualMachineInner(); inner.withStorageProfile(new StorageProfile() .withOsDisk(new OSDisk()) .withDataDisks(new ArrayList<DataDisk>())); inner.withOsProfile(new OSProfile()); inner.withHardwareProfile(new HardwareProfile()); inner.withNetworkProfile(new NetworkProfile() .withNetworkInterfaces(new ArrayList<NetworkInterfaceReference>())); return new VirtualMachineImpl(name, inner, this.manager(), this.storageManager, this.networkManager, this.rbacManager); }
@Override public VirtualMachineImpl withSpecificLinuxImageVersion(ImageReference imageReference) { this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE); this.inner().storageProfile().withImageReference(imageReference); this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration()); this.isMarketplaceLinuxImage = true; return this; }
@Override public ImageReference platformImageReference() { if (isOSBasedOnPlatformImage()) { return this.inner().storageProfile().imageReference(); } return null; }
@Override protected VirtualMachineImpl wrapModel(String name) { VirtualMachineInner inner = new VirtualMachineInner(); inner.withStorageProfile(new StorageProfile() .withOsDisk(new OSDisk()) .withDataDisks(new ArrayList<DataDisk>())); inner.withOsProfile(new OSProfile()); inner.withHardwareProfile(new HardwareProfile()); inner.withNetworkProfile(new NetworkProfile() .withNetworkInterfaces(new ArrayList<NetworkInterfaceReference>())); return new VirtualMachineImpl(name, inner, this.manager(), this.storageManager, this.networkManager, this.rbacManager); }
private void initializeDataDisks() { if (this.inner().storageProfile().dataDisks() == null) { this.inner() .storageProfile() .withDataDisks(new ArrayList<DataDisk>()); } this.isUnmanagedDiskSelected = false; this.managedDataDisks.clear(); this.unmanagedDataDisks = new ArrayList<>(); if (!isManagedDiskEnabled()) { for (DataDisk dataDiskInner : this.storageProfile().dataDisks()) { this.unmanagedDataDisks.add(new UnmanagedDataDiskImpl(dataDiskInner, this)); } } }
@Override public VirtualMachineImpl withLinuxCustomImage(String customImageId) { ImageReference imageReferenceInner = new ImageReference(); imageReferenceInner.withId(customImageId); this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE); this.inner().storageProfile().withImageReference(imageReferenceInner); this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration()); this.isMarketplaceLinuxImage = true; return this; }
/** * Checks whether the OS disk is based on a CustomImage. * <p> * A custom image is represented by {@link com.microsoft.azure.management.compute.VirtualMachineCustomImage}. * * @param storageProfile the storage profile * @return true if the OS disk is configured to be based on custom image. */ private boolean isOsDiskFromCustomImage(StorageProfile storageProfile) { ImageReference imageReference = storageProfile.imageReference(); return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.id() != null; }
@Override public boolean isOSBasedOnCustomImage() { ImageReference imageReference = this.inner().storageProfile().imageReference(); if (imageReference != null && imageReference.id() != null) { return true; } return false; }
VirtualMachineImpl withUnmanagedDataDisk(UnmanagedDataDiskImpl dataDisk) { this.inner() .storageProfile() .dataDisks() .add(dataDisk.inner()); this.unmanagedDataDisks .add(dataDisk); return this; }
void setDataDisksDefaults() { VirtualMachineInner vmInner = this.vm.inner(); if (isPending()) { if (vmInner.storageProfile().dataDisks() == null) { vmInner.storageProfile().withDataDisks(new ArrayList<DataDisk>()); List<DataDisk> dataDisks = vmInner.storageProfile().dataDisks(); final List<Integer> usedLuns = new ArrayList<>(); removeDataDisks(); if (vmInner.storageProfile().dataDisks() != null && vmInner.storageProfile().dataDisks().size() == 0) { if (vm.isInCreateMode()) { vmInner.storageProfile().withDataDisks(null);
@Override public VirtualMachineImpl withOSDiskSizeInGB(Integer size) { this.inner().storageProfile().osDisk().withDiskSizeGB(size); return this; }
@Override public VirtualMachineImpl withLinuxCustomImage(String customImageId) { ImageReference imageReferenceInner = new ImageReference(); imageReferenceInner.withId(customImageId); this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE); this.inner().storageProfile().withImageReference(imageReferenceInner); this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration()); this.isMarketplaceLinuxImage = true; return this; }
/** * Checks whether the OS disk is based on an platform image (image in PIR). * * @param storageProfile the storage profile * @return true if the OS disk is configured to be based on platform image. */ private boolean isOSDiskFromPlatformImage(StorageProfile storageProfile) { ImageReference imageReference = storageProfile.imageReference(); return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.publisher() != null && imageReference.offer() != null && imageReference.sku() != null && imageReference.version() != null; }