if (osDisk.managedDisk() == null) { osDisk.withManagedDisk(new ManagedDiskParameters()); if (osDisk.managedDisk().storageAccountType() == null) { osDisk.managedDisk() .withStorageAccountType(StorageAccountTypes.STANDARD_LRS); osDisk.withVhd(null); if (osDisk.vhd() == null) { String osDiskVhdContainerName = "vhds"; String osDiskVhdName = this.vmName + "-os-disk-" + UUID.randomUUID().toString() + ".vhd"; withOSDiskVhdLocation(osDiskVhdContainerName, osDiskVhdName); osDisk.withManagedDisk(null); if (osDisk.name() == null) { withOSDiskName(this.vmName + "-os-disk"); if (osDisk.managedDisk() != null) { osDisk.managedDisk().withStorageAccountType(null); osDisk.withVhd(null); } else { osDisk.withManagedDisk(null); if (osDisk.name() == null) { withOSDiskName(this.vmName + "-os-disk"); if (osDisk.caching() == null) {
/** * 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; }
/** * Checks whether the OS disk is based on a stored image ('captured' or 'bring your own feature'). * <p> * A stored image is created by calling {@link VirtualMachine#capture(String, String, boolean)}. * * @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(StorageProfile storageProfile) { OSDisk osDisk = storageProfile.osDisk(); return isOSDiskFromImage(osDisk) && osDisk.image() != null && osDisk.image().uri() != null; }
/** * Checks whether the OS disk is directly attached to a managed disk. * * @param osDisk the osDisk value in the storage profile * @return true if the OS disk is attached to a managed disk, false otherwise */ private boolean isOSDiskAttachedManaged(OSDisk osDisk) { return osDisk.createOption() == DiskCreateOptionTypes.ATTACH && osDisk.managedDisk() != null && osDisk.managedDisk().id() != null; }
dockerVM.networkSecurityGroupName = (nicIPConfiguration.parent().networkSecurityGroupId() != null) ? ResourceUtils.nameFromResourceId(nicIPConfiguration.parent().networkSecurityGroupId()) : null; dockerVM.vmSize = vm.size().toString(); dockerVM.osDiskName = vm.storageProfile().osDisk().name(); if (vm.storageProfile().imageReference() != null) { dockerVM.osHost = new AzureOSHost(vm.storageProfile().imageReference()); if (vm.storageProfile().osDisk().managedDisk() != null) { dockerVM.storageAccountName = vm.storageProfile().osDisk().name(); dockerVM.storageAccountType = "Managed disk"; } else { dockerVM.storageAccountName = vm.storageProfile().osDisk().vhd().uri().split("[.]")[0].split("/")[2]; dockerVM.storageAccountType = AzureDockerUtils.getStorageTypeForVMSize(dockerVM.vmSize);
@Override public OperatingSystemTypes osType() { return this.inner().storageProfile().osDisk().osType(); }
@Override public String osDiskId() { if (this.storageProfile().osDisk().managedDisk() != null) { return this.storageProfile().osDisk().managedDisk().id(); } return null; }
@Override public VirtualMachineImpl withOSDiskStorageAccountType(StorageAccountTypes accountType) { if (this.inner().storageProfile().osDisk().managedDisk() == null) { this.inner() .storageProfile() .osDisk() .withManagedDisk(new ManagedDiskParameters()); } this.inner() .storageProfile() .osDisk() .managedDisk() .withStorageAccountType(accountType); return this; }
@Override public String osDiskName() { return this.inner().storageProfile().osDisk().name(); }
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(), throw new RuntimeException(ex); this.inner().storageProfile().osDisk().withVhd(osVhd);
@Override public int osDiskSizeInGB() { return Utils.toPrimitiveInt(this.inner().storageProfile().osDisk().diskSizeGB()); }
@Override public CachingTypes osDiskCachingType() { return inner().storageProfile().osDisk().caching(); }
/** * Checks whether the OS disk is based on an image (image from PIR or custom image [captured, bringYourOwnFeature]). * * @param osDisk the osDisk value in the storage profile * @return true if the OS disk is configured to use image from PIR or custom image */ private boolean isOSDiskFromImage(OSDisk osDisk) { return osDisk.createOption() == DiskCreateOptionTypes.FROM_IMAGE; }
@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 EncryptionStatus osDiskStatus() { if (!hasEncryptionDetails()) { return EncryptionStatus.NOT_ENCRYPTED; } if (encryptionExtension.provisioningState() == null) { return EncryptionStatus.NOT_ENCRYPTED; } if (!encryptionExtension.provisioningState().equalsIgnoreCase("Succeeded")) { return EncryptionStatus.NOT_ENCRYPTED; } if (this.virtualMachine.storageProfile() == null || virtualMachine.storageProfile().osDisk() == null || virtualMachine.storageProfile().osDisk().encryptionSettings() == null) { return EncryptionStatus.NOT_ENCRYPTED; } DiskEncryptionSettings encryptionSettings = virtualMachine .storageProfile() .osDisk() .encryptionSettings(); if (encryptionSettings.diskEncryptionKey() != null && encryptionSettings.diskEncryptionKey().secretUrl() != null && Utils.toPrimitiveBoolean(encryptionSettings.enabled())) { return EncryptionStatus.ENCRYPTED; } return EncryptionStatus.NOT_ENCRYPTED; }
@Override public OperatingSystemTypes osType() { return this.inner().storageProfile().osDisk().osType(); }
@Override public String osDiskId() { if (this.storageProfile().osDisk().managedDisk() != null) { return this.storageProfile().osDisk().managedDisk().id(); } return null; }
/** * Checks whether the OS disk is directly attached to a managed disk. * * @param osDisk the osDisk value in the storage profile * @return true if the OS disk is attached to a managed disk, false otherwise */ private boolean isOSDiskAttachedManaged(OSDisk osDisk) { return osDisk.createOption() == DiskCreateOptionTypes.ATTACH && osDisk.managedDisk() != null && osDisk.managedDisk().id() != null; }