當前位置: 首頁>>代碼示例>>Java>>正文


Java StorageProfile.osDisk方法代碼示例

本文整理匯總了Java中com.microsoft.azure.management.compute.StorageProfile.osDisk方法的典型用法代碼示例。如果您正苦於以下問題:Java StorageProfile.osDisk方法的具體用法?Java StorageProfile.osDisk怎麽用?Java StorageProfile.osDisk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.microsoft.azure.management.compute.StorageProfile的用法示例。


在下文中一共展示了StorageProfile.osDisk方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setOSDiskDefaults

import com.microsoft.azure.management.compute.StorageProfile; //導入方法依賴的package包/類
private void setOSDiskDefaults() {
    if (isInUpdateMode()) {
        return;
    }
    StorageProfile storageProfile = this.inner().storageProfile();
    OSDisk osDisk = storageProfile.osDisk();
    if (isOSDiskFromImage(osDisk)) {
        // ODDisk CreateOption: FROM_IMAGE
        //
        if (isManagedDiskEnabled()) {
            // Note:
            // Managed disk
            //     Supported: PlatformImage and CustomImage
            //     UnSupported: StoredImage
            //
            if (osDisk.managedDisk() == null) {
                osDisk.withManagedDisk(new ManagedDiskParametersInner());
            }
            if (osDisk.managedDisk().storageAccountType() == null) {
                osDisk.managedDisk()
                        .withStorageAccountType(StorageAccountTypes.STANDARD_LRS);
            }
            osDisk.withVhd(null);
            // We won't set osDisk.name() explicitly for managed disk, if it is null CRP generates unique
            // name for the disk resource within the resource group.
        } else {
            // Note:
            // Native (un-managed) disk
            //     Supported: PlatformImage and StoredImage
            //     UnSupported: CustomImage
            //
            if (isOSDiskFromPlatformImage(storageProfile)
                    || isOSDiskFromStoredImage(storageProfile)) {
                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");
            }
        }
    } else {
        // ODDisk CreateOption: ATTACH
        //
        if (isManagedDiskEnabled()) {
            // In case of attach, it is not allowed to change the storage account type of the
            // managed 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) {
        withOSDiskCaching(CachingTypes.READ_WRITE);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:67,代碼來源:VirtualMachineImpl.java

示例2: setOSProfileDefaults

import com.microsoft.azure.management.compute.StorageProfile; //導入方法依賴的package包/類
private void setOSProfileDefaults() {
    if (isInUpdateMode()) {
        return;
    }
    StorageProfile storageProfile = this.inner().storageProfile();
    OSDisk osDisk = storageProfile.osDisk();
    if (isOSDiskFromImage(osDisk)) {
        // ODDisk CreateOption: FROM_IMAGE
        //
        if (osDisk.osType() == OperatingSystemTypes.LINUX || this.isMarketplaceLinuxImage) {
            // linux image: PlatformImage | CustomImage | StoredImage
            //
            OSProfile osProfile = this.inner().osProfile();
            if (osProfile.linuxConfiguration() == null) {
                osProfile.withLinuxConfiguration(new LinuxConfiguration());
            }
            this.inner().osProfile()
                    .linuxConfiguration()
                    .withDisablePasswordAuthentication(osProfile.adminPassword() == null);
        }
        if (this.inner().osProfile().computerName() == null) {
            // VM name cannot contain only numeric values and cannot exceed 15 chars
            //
            if (vmName.matches("[0-9]+")) {
                this.inner().osProfile()
                        .withComputerName(SdkContext.randomResourceName("vm", 15));
            } else if (vmName.length() <= 15) {
                this.inner().osProfile()
                        .withComputerName(vmName);
            } else {
                this.inner().osProfile()
                        .withComputerName(SdkContext.randomResourceName("vm", 15));
            }
        }
    } else {
        // ODDisk CreateOption: ATTACH
        //
        // OS Profile must be set to null when an VM's OS disk is ATTACH-ed to a managed disk or
        // Specialized VHD
        //
        this.inner().withOsProfile(null);
    }
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:44,代碼來源:VirtualMachineImpl.java

示例3: isOSDiskFromStoredImage

import com.microsoft.azure.management.compute.StorageProfile; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:15,代碼來源:VirtualMachineImpl.java


注:本文中的com.microsoft.azure.management.compute.StorageProfile.osDisk方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。