Search in sources :

Example 1 with VirtualMachineScaleSetOSDisk

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

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

the class VirtualMachineScaleSetImpl method setOSDiskDefault.

private void setOSDiskDefault() {
    if (isInUpdateMode()) {
        return;
    }
    VirtualMachineScaleSetStorageProfile storageProfile = this.inner().virtualMachineProfile().storageProfile();
    VirtualMachineScaleSetOSDisk osDisk = storageProfile.osDisk();
    if (isOSDiskFromImage(osDisk)) {
        //
        if (isManagedDiskEnabled()) {
            //
            if (osDisk.managedDisk() == null) {
                osDisk.withManagedDisk(new VirtualMachineScaleSetManagedDiskParameters());
            }
            if (osDisk.managedDisk().storageAccountType() == null) {
                osDisk.managedDisk().withStorageAccountType(StorageAccountTypes.STANDARD_LRS);
            }
            osDisk.withVhdContainers(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
            //
            osDisk.withManagedDisk(null);
            if (osDisk.name() == null) {
                withOSDiskName(this.name() + "-os-disk");
            }
        }
    } else {
    // NOP [ODDisk CreateOption: ATTACH, ATTACH is not supported for VMSS]
    }
    if (this.osDiskCachingType() == null) {
        withOSDiskCaching(CachingTypes.READ_WRITE);
    }
}
Also used : VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) VirtualMachineScaleSetStorageProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile) VirtualMachineScaleSetManagedDiskParameters(com.microsoft.azure.management.compute.VirtualMachineScaleSetManagedDiskParameters)

Example 3 with VirtualMachineScaleSetOSDisk

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

the class VirtualMachineScaleSetsImpl method wrapModel.

@Override
protected VirtualMachineScaleSetImpl wrapModel(String name) {
    VirtualMachineScaleSetInner inner = new VirtualMachineScaleSetInner();
    inner.withVirtualMachineProfile(new VirtualMachineScaleSetVMProfile());
    inner.virtualMachineProfile().withStorageProfile(new VirtualMachineScaleSetStorageProfile().withOsDisk(new VirtualMachineScaleSetOSDisk().withVhdContainers(new ArrayList<String>())));
    inner.virtualMachineProfile().withOsProfile(new VirtualMachineScaleSetOSProfile());
    inner.virtualMachineProfile().withNetworkProfile(new VirtualMachineScaleSetNetworkProfile());
    inner.virtualMachineProfile().networkProfile().withNetworkInterfaceConfigurations(new ArrayList<VirtualMachineScaleSetNetworkConfigurationInner>());
    VirtualMachineScaleSetNetworkConfigurationInner primaryNetworkInterfaceConfiguration = new VirtualMachineScaleSetNetworkConfigurationInner().withPrimary(true).withName("primary-nic-cfg").withIpConfigurations(new ArrayList<VirtualMachineScaleSetIPConfigurationInner>());
    primaryNetworkInterfaceConfiguration.ipConfigurations().add(new VirtualMachineScaleSetIPConfigurationInner().withName("primary-nic-ip-cfg"));
    inner.virtualMachineProfile().networkProfile().networkInterfaceConfigurations().add(primaryNetworkInterfaceConfiguration);
    return new VirtualMachineScaleSetImpl(name, inner, this.manager(), this.storageManager, this.networkManager);
}
Also used : VirtualMachineScaleSetNetworkProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile) VirtualMachineScaleSetVMProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetVMProfile) VirtualMachineScaleSetOSProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile) VirtualMachineScaleSetOSDisk(com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk) VirtualMachineScaleSetStorageProfile(com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)

Aggregations

VirtualMachineScaleSetOSDisk (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSDisk)3 VirtualMachineScaleSetOSProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetOSProfile)2 VirtualMachineScaleSetStorageProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetStorageProfile)2 LinuxConfiguration (com.microsoft.azure.management.compute.LinuxConfiguration)1 UpgradePolicy (com.microsoft.azure.management.compute.UpgradePolicy)1 VirtualMachineScaleSetManagedDiskParameters (com.microsoft.azure.management.compute.VirtualMachineScaleSetManagedDiskParameters)1 VirtualMachineScaleSetNetworkProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetNetworkProfile)1 VirtualMachineScaleSetVMProfile (com.microsoft.azure.management.compute.VirtualMachineScaleSetVMProfile)1