Search in sources :

Example 1 with UpgradePolicy

use of com.microsoft.azure.management.compute.UpgradePolicy in project azure-sdk-for-java by Azure.

the class VirtualMachineScaleSetImpl method setOSProfileDefaults.

private void setOSProfileDefaults() {
    if (isInUpdateMode()) {
        return;
    }
    if (this.inner().sku().capacity() == null) {
        this.withCapacity(2);
    }
    if (this.inner().upgradePolicy() == null || this.inner().upgradePolicy().mode() == null) {
        this.inner().withUpgradePolicy(new UpgradePolicy().withMode(UpgradeMode.AUTOMATIC));
    }
    VirtualMachineScaleSetOSProfile osProfile = this.inner().virtualMachineProfile().osProfile();
    VirtualMachineScaleSetOSDisk osDisk = this.inner().virtualMachineProfile().storageProfile().osDisk();
    if (isOSDiskFromImage(osDisk)) {
        //
        if (this.osType() == OperatingSystemTypes.LINUX || this.isMarketplaceLinuxImage) {
            if (osProfile.linuxConfiguration() == null) {
                osProfile.withLinuxConfiguration(new LinuxConfiguration());
            }
            osProfile.linuxConfiguration().withDisablePasswordAuthentication(osProfile.adminPassword() == null);
        }
        if (this.computerNamePrefix() == null) {
            // VM name cannot contain only numeric values and cannot exceed 15 chars
            if (this.name().matches("[0-9]+")) {
                withComputerNamePrefix(this.namer.randomName("vmss-vm", 12));
            } else if (this.name().length() <= 12) {
                withComputerNamePrefix(this.name() + "-vm");
            } else {
                withComputerNamePrefix(this.namer.randomName("vmss-vm", 12));
            }
        }
    } else {
        // NOP [ODDisk CreateOption: ATTACH, ATTACH is not supported for VMSS]
        this.inner().virtualMachineProfile().withOsProfile(null);
    }
}
Also used : VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) UpgradePolicy(com.microsoft.azure.management.compute.UpgradePolicy) LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration) VirtualMachineScaleSetOSProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)

Aggregations

LinuxConfiguration (com.microsoft.azure.management.compute.LinuxConfiguration)1 UpgradePolicy (com.microsoft.azure.management.compute.UpgradePolicy)1 VirtualMachineScaleSetOSDisk (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk)1 VirtualMachineScaleSetOSProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)1