Search in sources :

Example 1 with LinuxConfiguration

use of com.microsoft.azure.management.compute.LinuxConfiguration 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)

Example 2 with LinuxConfiguration

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

the class VirtualMachineImpl method setOSProfileDefaults.

private void setOSProfileDefaults() {
    if (isInUpdateMode()) {
        return;
    }
    StorageProfile storageProfile = this.inner().storageProfile();
    OSDisk osDisk = storageProfile.osDisk();
    if (isOSDiskFromImage(osDisk)) {
        //
        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) {
            //
            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);
    }
}
Also used : StorageProfile(com.microsoft.azure.management.compute.StorageProfile) OSDisk(com.microsoft.azure.management.compute.OSDisk) OSProfile(com.microsoft.azure.management.compute.OSProfile) LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration)

Example 3 with LinuxConfiguration

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

the class VirtualMachineScaleSetImpl method withLinuxCustomImage.

@Override
public VirtualMachineScaleSetImpl withLinuxCustomImage(String customImageId) {
    ImageReferenceInner imageReferenceInner = new ImageReferenceInner();
    imageReferenceInner.withId(customImageId);
    this.inner().virtualMachineProfile().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
    this.inner().virtualMachineProfile().storageProfile().withImageReference(imageReferenceInner);
    this.inner().virtualMachineProfile().osProfile().withLinuxConfiguration(new LinuxConfiguration());
    this.isMarketplaceLinuxImage = true;
    return this;
}
Also used : LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration)

Example 4 with LinuxConfiguration

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

the class VirtualMachineImpl method withLinuxCustomImage.

@Override
public VirtualMachineImpl withLinuxCustomImage(String customImageId) {
    ImageReferenceInner imageReferenceInner = new ImageReferenceInner();
    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;
}
Also used : LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration)

Example 5 with LinuxConfiguration

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

the class VirtualMachineScaleSetImpl method withSpecificLinuxImageVersion.

@Override
public VirtualMachineScaleSetImpl withSpecificLinuxImageVersion(ImageReference imageReference) {
    this.inner().virtualMachineProfile().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE);
    this.inner().virtualMachineProfile().storageProfile().withImageReference(imageReference.inner());
    this.inner().virtualMachineProfile().osProfile().withLinuxConfiguration(new LinuxConfiguration());
    this.isMarketplaceLinuxImage = true;
    return this;
}
Also used : LinuxConfiguration(com.microsoft.azure.management.compute.LinuxConfiguration)

Aggregations

LinuxConfiguration (com.microsoft.azure.management.compute.LinuxConfiguration)8 VirtualHardDisk (com.microsoft.azure.management.compute.VirtualHardDisk)2 OSDisk (com.microsoft.azure.management.compute.OSDisk)1 OSProfile (com.microsoft.azure.management.compute.OSProfile)1 StorageProfile (com.microsoft.azure.management.compute.StorageProfile)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